authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-19 22:36:24-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-06-19 22:36:24-07:00
loga72d634b731952ee227d026c27e83c5702dcea4a
tree8bfc4c9afa75a27ebb1108924589a8e7d5cc89ed
parentc6e2e1ae4b85fc36acc89c9a5e2673834146d628
parenta4d1edac8d65e1aa4b565f6fb11ab78541d97efa
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #16046 from BratishkaErik/issue-6128

Renaming `@xtoy` to `@YfromX`

682 files changed, 8613 insertions(+), 8278 deletions(-)

CMakeLists.txt+2-2
......@@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
376376 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig"
377377 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig"
378378 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig"
379 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig"
379 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_from_float.zig"
380380 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig"
381381 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig"
382382 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig"
......@@ -417,7 +417,7 @@ set(ZIG_STAGE2_SOURCES
417417 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig"
418418 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig"
419419 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig"
420 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig"
420 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_from_int.zig"
421421 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig"
422422 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig"
423423 "${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig"
build.zig+1-1
......@@ -487,7 +487,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
487487 .cpu_arch = .wasm32,
488488 .os_tag = .wasi,
489489 };
490 target.cpu_features_add.addFeature(@enumToInt(std.Target.wasm.Feature.bulk_memory));
490 target.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory));
491491
492492 const exe = addCompilerStep(b, .ReleaseSmall, target);
493493
doc/langref.html.in+75-75
......@@ -2763,14 +2763,14 @@ test "comptime pointers" {
27632763 }
27642764}
27652765 {#code_end#}
2766 <p>To convert an integer address into a pointer, use {#syntax#}@intToPtr{#endsyntax#}.
2767 To convert a pointer to an integer, use {#syntax#}@ptrToInt{#endsyntax#}:</p>
2766 <p>To convert an integer address into a pointer, use {#syntax#}@ptrFromInt{#endsyntax#}.
2767 To convert a pointer to an integer, use {#syntax#}@intFromPtr{#endsyntax#}:</p>
27682768 {#code_begin|test|test_integer_pointer_conversion#}
27692769const expect = @import("std").testing.expect;
27702770
2771test "@ptrToInt and @intToPtr" {
2772 const ptr = @intToPtr(*i32, 0xdeadbee0);
2773 const addr = @ptrToInt(ptr);
2771test "@intFromPtr and @ptrFromInt" {
2772 const ptr = @ptrFromInt(*i32, 0xdeadbee0);
2773 const addr = @intFromPtr(ptr);
27742774 try expect(@TypeOf(addr) == usize);
27752775 try expect(addr == 0xdeadbee0);
27762776}
......@@ -2780,18 +2780,18 @@ test "@ptrToInt and @intToPtr" {
27802780 {#code_begin|test|test_comptime_pointer_conversion#}
27812781const expect = @import("std").testing.expect;
27822782
2783test "comptime @intToPtr" {
2783test "comptime @ptrFromInt" {
27842784 comptime {
27852785 // Zig is able to do this at compile-time, as long as
27862786 // ptr is never dereferenced.
2787 const ptr = @intToPtr(*i32, 0xdeadbee0);
2788 const addr = @ptrToInt(ptr);
2787 const ptr = @ptrFromInt(*i32, 0xdeadbee0);
2788 const addr = @intFromPtr(ptr);
27892789 try expect(@TypeOf(addr) == usize);
27902790 try expect(addr == 0xdeadbee0);
27912791 }
27922792}
27932793 {#code_end#}
2794 {#see_also|Optional Pointers|@intToPtr|@ptrToInt|C Pointers#}
2794 {#see_also|Optional Pointers|@ptrFromInt|@intFromPtr|C Pointers#}
27952795 {#header_open|volatile#}
27962796 <p>Loads and stores are assumed to not have side effects. If a given load or store
27972797 should have side effects, such as Memory Mapped Input/Output (MMIO), use {#syntax#}volatile{#endsyntax#}.
......@@ -2801,7 +2801,7 @@ test "comptime @intToPtr" {
28012801const expect = @import("std").testing.expect;
28022802
28032803test "volatile" {
2804 const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);
2804 const mmio_ptr = @ptrFromInt(*volatile u8, 0x12345678);
28052805 try expect(@TypeOf(mmio_ptr) == *volatile u8);
28062806}
28072807 {#code_end#}
......@@ -2942,8 +2942,8 @@ const expect = std.testing.expect;
29422942
29432943test "allowzero" {
29442944 var zero: usize = 0;
2945 var ptr = @intToPtr(*allowzero i32, zero);
2946 try expect(@ptrToInt(ptr) == 0);
2945 var ptr = @ptrFromInt(*allowzero i32, zero);
2946 try expect(@intFromPtr(ptr) == 0);
29472947}
29482948 {#code_end#}
29492949 {#header_close#}
......@@ -3006,7 +3006,7 @@ test "basic slices" {
30063006 // while using the `ptr` field gives a many-item pointer.
30073007 try expect(@TypeOf(slice.ptr) == [*]i32);
30083008 try expect(@TypeOf(&slice[0]) == *i32);
3009 try expect(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));
3009 try expect(@intFromPtr(slice.ptr) == @intFromPtr(&slice[0]));
30103010
30113011 // Slices have array bounds checking. If you try to access something out
30123012 // of bounds, you'll get a safety check failure:
......@@ -3448,8 +3448,8 @@ var bit_field = BitField{
34483448};
34493449
34503450test "pointers of sub-byte-aligned fields share addresses" {
3451 try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.b));
3452 try expect(@ptrToInt(&bit_field.a) == @ptrToInt(&bit_field.c));
3451 try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.b));
3452 try expect(@intFromPtr(&bit_field.a) == @intFromPtr(&bit_field.c));
34533453}
34543454 {#code_end#}
34553455 <p>
......@@ -3664,9 +3664,9 @@ const Value = enum(u2) {
36643664// Now you can cast between u2 and Value.
36653665// The ordinal value starts from 0, counting up by 1 from the previous member.
36663666test "enum ordinal value" {
3667 try expect(@enumToInt(Value.zero) == 0);
3668 try expect(@enumToInt(Value.one) == 1);
3669 try expect(@enumToInt(Value.two) == 2);
3667 try expect(@intFromEnum(Value.zero) == 0);
3668 try expect(@intFromEnum(Value.one) == 1);
3669 try expect(@intFromEnum(Value.two) == 2);
36703670}
36713671
36723672// You can override the ordinal value for an enum.
......@@ -3676,9 +3676,9 @@ const Value2 = enum(u32) {
36763676 million = 1000000,
36773677};
36783678test "set enum ordinal value" {
3679 try expect(@enumToInt(Value2.hundred) == 100);
3680 try expect(@enumToInt(Value2.thousand) == 1000);
3681 try expect(@enumToInt(Value2.million) == 1000000);
3679 try expect(@intFromEnum(Value2.hundred) == 100);
3680 try expect(@intFromEnum(Value2.thousand) == 1000);
3681 try expect(@intFromEnum(Value2.million) == 1000000);
36823682}
36833683
36843684// You can also override only some values.
......@@ -3690,11 +3690,11 @@ const Value3 = enum(u4) {
36903690 e,
36913691};
36923692test "enum implicit ordinal values and overridden values" {
3693 try expect(@enumToInt(Value3.a) == 0);
3694 try expect(@enumToInt(Value3.b) == 8);
3695 try expect(@enumToInt(Value3.c) == 9);
3696 try expect(@enumToInt(Value3.d) == 4);
3697 try expect(@enumToInt(Value3.e) == 5);
3693 try expect(@intFromEnum(Value3.a) == 0);
3694 try expect(@intFromEnum(Value3.b) == 8);
3695 try expect(@intFromEnum(Value3.c) == 9);
3696 try expect(@intFromEnum(Value3.d) == 4);
3697 try expect(@intFromEnum(Value3.e) == 5);
36983698}
36993699
37003700// Enums can have methods, the same as structs and unions.
......@@ -3811,7 +3811,7 @@ test "switch using enum literals" {
38113811 It must specify a tag type and cannot consume every enumeration value.
38123812 </p>
38133813 <p>
3814 {#link|@intToEnum#} on a non-exhaustive enum involves the safety semantics
3814 {#link|@enumFromInt#} on a non-exhaustive enum involves the safety semantics
38153815 of {#link|@intCast#} to the integer tag type, but beyond that always results in
38163816 a well-defined enum value.
38173817 </p>
......@@ -4385,7 +4385,7 @@ fn withFor(any: AnySlice) usize {
43854385 // With `inline for` the function gets generated as
43864386 // a series of `if` statements relying on the optimizer
43874387 // to convert it to a switch.
4388 if (field.value == @enumToInt(any)) {
4388 if (field.value == @intFromEnum(any)) {
43894389 return @field(any, field.name).len;
43904390 }
43914391 }
......@@ -4428,7 +4428,7 @@ fn getNum(u: U) u32 {
44284428 // `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value.
44294429 inline else => |num, tag| {
44304430 if (tag == .b) {
4431 return @floatToInt(u32, num);
4431 return @intFromFloat(u32, num);
44324432 }
44334433 return num;
44344434 }
......@@ -6625,19 +6625,19 @@ test "coercion from homogenous tuple to array" {
66256625 <ul>
66266626 <li>{#link|@bitCast#} - change type but maintain bit representation</li>
66276627 <li>{#link|@alignCast#} - make a pointer have more alignment</li>
6628 <li>{#link|@boolToInt#} - convert true to 1 and false to 0</li>
6629 <li>{#link|@enumToInt#} - obtain the integer tag value of an enum or tagged union</li>
6628 <li>{#link|@intFromBool#} - convert true to 1 and false to 0</li>
6629 <li>{#link|@intFromEnum#} - obtain the integer tag value of an enum or tagged union</li>
66306630 <li>{#link|@errSetCast#} - convert to a smaller error set</li>
6631 <li>{#link|@errorToInt#} - obtain the integer value of an error code</li>
6631 <li>{#link|@intFromError#} - obtain the integer value of an error code</li>
66326632 <li>{#link|@floatCast#} - convert a larger float to a smaller float</li>
6633 <li>{#link|@floatToInt#} - obtain the integer part of a float value</li>
6633 <li>{#link|@intFromFloat#} - obtain the integer part of a float value</li>
66346634 <li>{#link|@intCast#} - convert between integer types</li>
6635 <li>{#link|@intToEnum#} - obtain an enum value based on its integer tag value</li>
6636 <li>{#link|@intToError#} - obtain an error code based on its integer value</li>
6637 <li>{#link|@intToFloat#} - convert an integer to a float value</li>
6638 <li>{#link|@intToPtr#} - convert an address to a pointer</li>
6635 <li>{#link|@enumFromInt#} - obtain an enum value based on its integer tag value</li>
6636 <li>{#link|@errorFromInt#} - obtain an error code based on its integer value</li>
6637 <li>{#link|@floatFromInt#} - convert an integer to a float value</li>
6638 <li>{#link|@ptrFromInt#} - convert an address to a pointer</li>
66396639 <li>{#link|@ptrCast#} - convert between pointer types</li>
6640 <li>{#link|@ptrToInt#} - obtain the address of a pointer</li>
6640 <li>{#link|@intFromPtr#} - obtain the address of a pointer</li>
66416641 <li>{#link|@truncate#} - convert between integer types, chopping off bits</li>
66426642 </ul>
66436643 {#header_close#}
......@@ -6744,8 +6744,8 @@ fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
67446744}
67456745
67466746test "peer type resolution: *const T and ?*T" {
6747 const a = @intToPtr(*const usize, 0x123456780);
6748 const b = @intToPtr(?*usize, 0x123456780);
6747 const a = @ptrFromInt(*const usize, 0x123456780);
6748 const b = @ptrFromInt(?*usize, 0x123456780);
67496749 try expect(a == b);
67506750 try expect(b == a);
67516751}
......@@ -7542,7 +7542,7 @@ pub fn main() void {
75427542 {#target_linux_x86_64#}
75437543pub fn main() noreturn {
75447544 const msg = "hello world\n";
7545 _ = syscall3(SYS_write, STDOUT_FILENO, @ptrToInt(msg), msg.len);
7545 _ = syscall3(SYS_write, STDOUT_FILENO, @intFromPtr(msg), msg.len);
75467546 _ = syscall1(SYS_exit, 0);
75477547 unreachable;
75487548}
......@@ -7857,7 +7857,7 @@ comptime {
78577857 Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
78587858 </p>
78597859 <p>
7860 Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
7860 Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
78617861 </p>
78627862 <p>
78637863 Can be used for these things for example:
......@@ -7884,8 +7884,8 @@ comptime {
78847884 {#see_also|@offsetOf#}
78857885 {#header_close#}
78867886
7887 {#header_open|@boolToInt#}
7888 <pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre>
7887 {#header_open|@intFromBool#}
7888 <pre>{#syntax#}@intFromBool(value: bool) u1{#endsyntax#}</pre>
78897889 <p>
78907890 Converts {#syntax#}true{#endsyntax#} to {#syntax#}@as(u1, 1){#endsyntax#} and {#syntax#}false{#endsyntax#} to
78917891 {#syntax#}@as(u1, 0){#endsyntax#}.
......@@ -8348,8 +8348,8 @@ test "main" {
83488348 {#see_also|@import#}
83498349 {#header_close#}
83508350
8351 {#header_open|@enumToInt#}
8352 <pre>{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
8351 {#header_open|@intFromEnum#}
8352 <pre>{#syntax#}@intFromEnum(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
83538353 <p>
83548354 Converts an enumeration value into its integer tag type. When a tagged union is passed,
83558355 the tag value is used as the enumeration value.
......@@ -8358,7 +8358,7 @@ test "main" {
83588358 If there is only one possible enum value, the result is a {#syntax#}comptime_int{#endsyntax#}
83598359 known at {#link|comptime#}.
83608360 </p>
8361 {#see_also|@intToEnum#}
8361 {#see_also|@enumFromInt#}
83628362 {#header_close#}
83638363
83648364 {#header_open|@errorName#}
......@@ -8383,8 +8383,8 @@ test "main" {
83838383 </p>
83848384 {#header_close#}
83858385
8386 {#header_open|@errorToInt#}
8387 <pre>{#syntax#}@errorToInt(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
8386 {#header_open|@intFromError#}
8387 <pre>{#syntax#}@intFromError(err: anytype) std.meta.Int(.unsigned, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
83888388 <p>
83898389 Supports the following types:
83908390 </p>
......@@ -8400,7 +8400,7 @@ test "main" {
84008400 It is generally recommended to avoid this
84018401 cast, as the integer representation of an error is not stable across source code changes.
84028402 </p>
8403 {#see_also|@intToError#}
8403 {#see_also|@errorFromInt#}
84048404 {#header_close#}
84058405
84068406 {#header_open|@errSetCast#}
......@@ -8526,8 +8526,8 @@ test "decl access by string" {
85268526 </p>
85278527 {#header_close#}
85288528
8529 {#header_open|@floatToInt#}
8530 <pre>{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
8529 {#header_open|@intFromFloat#}
8530 <pre>{#syntax#}@intFromFloat(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
85318531 <p>
85328532 Converts the integer part of a floating point number to the destination type.
85338533 </p>
......@@ -8535,7 +8535,7 @@ test "decl access by string" {
85358535 If the integer part of the floating point number cannot fit in the destination type,
85368536 it invokes safety-checked {#link|Undefined Behavior#}.
85378537 </p>
8538 {#see_also|@intToFloat#}
8538 {#see_also|@floatFromInt#}
85398539 {#header_close#}
85408540
85418541 {#header_open|@frameAddress#}
......@@ -8666,8 +8666,8 @@ test "integer cast panic" {
86668666 </p>
86678667 {#header_close#}
86688668
8669 {#header_open|@intToEnum#}
8670 <pre>{#syntax#}@intToEnum(comptime DestType: type, integer: anytype) DestType{#endsyntax#}</pre>
8669 {#header_open|@enumFromInt#}
8670 <pre>{#syntax#}@enumFromInt(comptime DestType: type, integer: anytype) DestType{#endsyntax#}</pre>
86718671 <p>
86728672 Converts an integer into an {#link|enum#} value.
86738673 </p>
......@@ -8675,11 +8675,11 @@ test "integer cast panic" {
86758675 Attempting to convert an integer which represents no value in the chosen enum type invokes
86768676 safety-checked {#link|Undefined Behavior#}.
86778677 </p>
8678 {#see_also|@enumToInt#}
8678 {#see_also|@intFromEnum#}
86798679 {#header_close#}
86808680
8681 {#header_open|@intToError#}
8682 <pre>{#syntax#}@intToError(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
8681 {#header_open|@errorFromInt#}
8682 <pre>{#syntax#}@errorFromInt(value: std.meta.Int(.unsigned, @sizeOf(anyerror) * 8)) anyerror{#endsyntax#}</pre>
86838683 <p>
86848684 Converts from the integer representation of an error into {#link|The Global Error Set#} type.
86858685 </p>
......@@ -8691,20 +8691,20 @@ test "integer cast panic" {
86918691 Attempting to convert an integer that does not correspond to any error results in
86928692 safety-protected {#link|Undefined Behavior#}.
86938693 </p>
8694 {#see_also|@errorToInt#}
8694 {#see_also|@intFromError#}
86958695 {#header_close#}
86968696
8697 {#header_open|@intToFloat#}
8698 <pre>{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
8697 {#header_open|@floatFromInt#}
8698 <pre>{#syntax#}@floatFromInt(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
86998699 <p>
8700 Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe.
8700 Converts an integer to the closest floating point representation. To convert the other way, use {#link|@intFromFloat#}. This cast is always safe.
87018701 </p>
87028702 {#header_close#}
87038703
8704 {#header_open|@intToPtr#}
8705 <pre>{#syntax#}@intToPtr(comptime DestType: type, address: usize) DestType{#endsyntax#}</pre>
8704 {#header_open|@ptrFromInt#}
8705 <pre>{#syntax#}@ptrFromInt(comptime DestType: type, address: usize) DestType{#endsyntax#}</pre>
87068706 <p>
8707 Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@ptrToInt#}. Casting an address of 0 to a destination type
8707 Converts an integer to a {#link|pointer|Pointers#}. To convert the other way, use {#link|@intFromPtr#}. Casting an address of 0 to a destination type
87088708 which in not {#link|optional|Optional Pointers#} and does not have the {#syntax#}allowzero{#endsyntax#} attribute will result in a
87098709 {#link|Pointer Cast Invalid Null#} panic when runtime safety checks are enabled.
87108710 </p>
......@@ -8928,13 +8928,13 @@ pub const PrefetchOptions = struct {
89288928 </ul>
89298929 {#header_close#}
89308930
8931 {#header_open|@ptrToInt#}
8932 <pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre>
8931 {#header_open|@intFromPtr#}
8932 <pre>{#syntax#}@intFromPtr(value: anytype) usize{#endsyntax#}</pre>
89338933 <p>
89348934 Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer.
89358935 {#syntax#}value{#endsyntax#} can be {#syntax#}*T{#endsyntax#} or {#syntax#}?*T{#endsyntax#}.
89368936 </p>
8937 <p>To convert the other way, use {#link|@intToPtr#}</p>
8937 <p>To convert the other way, use {#link|@ptrFromInt#}</p>
89388938
89398939 {#header_close#}
89408940
......@@ -10165,8 +10165,8 @@ fn getNumberOrFail() !i32 {
1016510165 {#code_begin|test_err|test_comptime_invalid_error_code|integer value '11' represents no error#}
1016610166comptime {
1016710167 const err = error.AnError;
10168 const number = @errorToInt(err) + 10;
10169 const invalid_err = @intToError(number);
10168 const number = @intFromError(err) + 10;
10169 const invalid_err = @errorFromInt(number);
1017010170 _ = invalid_err;
1017110171}
1017210172 {#code_end#}
......@@ -10176,8 +10176,8 @@ const std = @import("std");
1017610176
1017710177pub fn main() void {
1017810178 var err = error.AnError;
10179 var number = @errorToInt(err) + 500;
10180 var invalid_err = @intToError(number);
10179 var number = @intFromError(err) + 500;
10180 var invalid_err = @errorFromInt(number);
1018110181 std.debug.print("value: {}\n", .{invalid_err});
1018210182}
1018310183 {#code_end#}
......@@ -10192,7 +10192,7 @@ const Foo = enum {
1019210192};
1019310193comptime {
1019410194 const a: u2 = 3;
10195 const b = @intToEnum(Foo, a);
10195 const b = @enumFromInt(Foo, a);
1019610196 _ = b;
1019710197}
1019810198 {#code_end#}
......@@ -10208,7 +10208,7 @@ const Foo = enum {
1020810208
1020910209pub fn main() void {
1021010210 var a: u2 = 3;
10211 var b = @intToEnum(Foo, a);
10211 var b = @enumFromInt(Foo, a);
1021210212 std.debug.print("value: {s}\n", .{@tagName(b)});
1021310213}
1021410214 {#code_end#}
......@@ -10255,7 +10255,7 @@ fn foo(set1: Set1) void {
1025510255 <p>At compile-time:</p>
1025610256 {#code_begin|test_err|test_comptime_incorrect_pointer_alignment|pointer address 0x1 is not aligned to 4 bytes#}
1025710257comptime {
10258 const ptr = @intToPtr(*align(1) i32, 0x1);
10258 const ptr = @ptrFromInt(*align(1) i32, 0x1);
1025910259 const aligned = @alignCast(4, ptr);
1026010260 _ = aligned;
1026110261}
lib/compiler_rt.zig+2-2
......@@ -55,7 +55,7 @@ comptime {
5555 _ = @import("compiler_rt/trunctfdf2.zig");
5656 _ = @import("compiler_rt/trunctfxf2.zig");
5757
58 _ = @import("compiler_rt/float_to_int.zig");
58 _ = @import("compiler_rt/int_from_float.zig");
5959 _ = @import("compiler_rt/fixhfsi.zig");
6060 _ = @import("compiler_rt/fixhfdi.zig");
6161 _ = @import("compiler_rt/fixhfti.zig");
......@@ -87,7 +87,7 @@ comptime {
8787 _ = @import("compiler_rt/fixunsxfdi.zig");
8888 _ = @import("compiler_rt/fixunsxfti.zig");
8989
90 _ = @import("compiler_rt/int_to_float.zig");
90 _ = @import("compiler_rt/float_from_int.zig");
9191 _ = @import("compiler_rt/floatsihf.zig");
9292 _ = @import("compiler_rt/floatsisf.zig");
9393 _ = @import("compiler_rt/floatsidf.zig");
lib/compiler_rt/aarch64_outline_atomics.zig+1-1
......@@ -8,7 +8,7 @@ const always_has_lse = std.Target.aarch64.featureSetHas(builtin.cpu.features, .l
88/// It is intentionally not exported in order to make the machine code that
99/// uses it a statically predicted direct branch rather than using the PLT,
1010/// which ARM is concerned would have too much overhead.
11var __aarch64_have_lse_atomics: u8 = @boolToInt(always_has_lse);
11var __aarch64_have_lse_atomics: u8 = @intFromBool(always_has_lse);
1212
1313fn __aarch64_cas1_relax() align(16) callconv(.Naked) void {
1414 @setRuntimeSafety(false);
lib/compiler_rt/atomics.zig+11-11
......@@ -119,21 +119,21 @@ var spinlocks: SpinlockTable = SpinlockTable{};
119119
120120fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
121121 _ = model;
122 var sl = spinlocks.get(@ptrToInt(src));
122 var sl = spinlocks.get(@intFromPtr(src));
123123 defer sl.release();
124124 @memcpy(dest[0..size], src);
125125}
126126
127127fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
128128 _ = model;
129 var sl = spinlocks.get(@ptrToInt(dest));
129 var sl = spinlocks.get(@intFromPtr(dest));
130130 defer sl.release();
131131 @memcpy(dest[0..size], src);
132132}
133133
134134fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
135135 _ = model;
136 var sl = spinlocks.get(@ptrToInt(ptr));
136 var sl = spinlocks.get(@intFromPtr(ptr));
137137 defer sl.release();
138138 @memcpy(old[0..size], ptr);
139139 @memcpy(ptr[0..size], val);
......@@ -149,7 +149,7 @@ fn __atomic_compare_exchange(
149149) callconv(.C) i32 {
150150 _ = success;
151151 _ = failure;
152 var sl = spinlocks.get(@ptrToInt(ptr));
152 var sl = spinlocks.get(@intFromPtr(ptr));
153153 defer sl.release();
154154 for (ptr[0..size], 0..) |b, i| {
155155 if (expected[i] != b) break;
......@@ -168,7 +168,7 @@ fn __atomic_compare_exchange(
168168inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
169169 _ = model;
170170 if (@sizeOf(T) > largest_atomic_size) {
171 var sl = spinlocks.get(@ptrToInt(src));
171 var sl = spinlocks.get(@intFromPtr(src));
172172 defer sl.release();
173173 return src.*;
174174 } else {
......@@ -199,7 +199,7 @@ fn __atomic_load_16(src: *u128, model: i32) callconv(.C) u128 {
199199inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
200200 _ = model;
201201 if (@sizeOf(T) > largest_atomic_size) {
202 var sl = spinlocks.get(@ptrToInt(dst));
202 var sl = spinlocks.get(@intFromPtr(dst));
203203 defer sl.release();
204204 dst.* = value;
205205 } else {
......@@ -230,9 +230,9 @@ fn __atomic_store_16(dst: *u128, value: u128, model: i32) callconv(.C) void {
230230fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
231231 const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8);
232232
233 const addr = @ptrToInt(ptr);
233 const addr = @intFromPtr(ptr);
234234 const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1);
235 const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @intToPtr(*WideAtomic, wide_addr));
235 const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @ptrFromInt(*WideAtomic, wide_addr));
236236
237237 const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1);
238238 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 {
255255inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
256256 _ = model;
257257 if (@sizeOf(T) > largest_atomic_size) {
258 var sl = spinlocks.get(@ptrToInt(ptr));
258 var sl = spinlocks.get(@intFromPtr(ptr));
259259 defer sl.release();
260260 const value = ptr.*;
261261 ptr.* = val;
......@@ -305,7 +305,7 @@ inline fn atomic_compare_exchange_N(
305305 _ = success;
306306 _ = failure;
307307 if (@sizeOf(T) > largest_atomic_size) {
308 var sl = spinlocks.get(@ptrToInt(ptr));
308 var sl = spinlocks.get(@intFromPtr(ptr));
309309 defer sl.release();
310310 const value = ptr.*;
311311 if (value == expected.*) {
......@@ -362,7 +362,7 @@ inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr
362362 };
363363
364364 if (@sizeOf(T) > largest_atomic_size) {
365 var sl = spinlocks.get(@ptrToInt(ptr));
365 var sl = spinlocks.get(@intFromPtr(ptr));
366366 defer sl.release();
367367
368368 const value = ptr.*;
lib/compiler_rt/clear_cache.zig+1-1
......@@ -63,7 +63,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
6363 .addr = start,
6464 .len = end - start,
6565 };
66 const result = sysarch(ARM_SYNC_ICACHE, @ptrToInt(&arg));
66 const result = sysarch(ARM_SYNC_ICACHE, @intFromPtr(&arg));
6767 std.debug.assert(result == 0);
6868 exportIt();
6969 },
lib/compiler_rt/cmpdf2.zig+4-4
......@@ -26,7 +26,7 @@ comptime {
2626/// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`,
2727/// and `__ltdf2`.
2828fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 {
29 return @enumToInt(comparef.cmpf2(f64, comparef.LE, a, b));
29 return @intFromEnum(comparef.cmpf2(f64, comparef.LE, a, b));
3030}
3131
3232/// "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 {
5656}
5757
5858fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 {
59 return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
59 return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
6060}
6161
6262fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 {
63 return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
63 return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
6464}
6565
6666fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 {
67 return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
67 return @intFromBool(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
6868}
lib/compiler_rt/cmphf2.zig+1-1
......@@ -20,7 +20,7 @@ comptime {
2020/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
2121/// and `__lthf2`.
2222fn __cmphf2(a: f16, b: f16) callconv(.C) i32 {
23 return @enumToInt(comparef.cmpf2(f16, comparef.LE, a, b));
23 return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b));
2424}
2525
2626/// "These functions return a value less than or equal to zero if neither argument is NaN,
lib/compiler_rt/cmpsf2.zig+4-4
......@@ -26,7 +26,7 @@ comptime {
2626/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
2727/// and `__ltsf2`.
2828fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 {
29 return @enumToInt(comparef.cmpf2(f32, comparef.LE, a, b));
29 return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b));
3030}
3131
3232/// "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 {
5656}
5757
5858fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 {
59 return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
59 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
6060}
6161
6262fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 {
63 return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
63 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
6464}
6565
6666fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 {
67 return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
67 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
6868}
lib/compiler_rt/cmptf2.zig+8-8
......@@ -34,7 +34,7 @@ comptime {
3434/// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`,
3535/// and `__lttf2`.
3636fn __cmptf2(a: f128, b: f128) callconv(.C) i32 {
37 return @enumToInt(comparef.cmpf2(f128, comparef.LE, a, b));
37 return @intFromEnum(comparef.cmpf2(f128, comparef.LE, a, b));
3838}
3939
4040/// "These functions return a value less than or equal to zero if neither argument is NaN,
......@@ -71,34 +71,34 @@ const SparcFCMP = enum(i32) {
7171};
7272
7373fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 {
74 return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
74 return @intFromEnum(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
7575}
7676
7777fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool {
78 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
78 return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
7979}
8080
8181fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool {
82 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
82 return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
8383}
8484
8585fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool {
86 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less;
86 return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Less;
8787}
8888
8989fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool {
90 return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
90 return @enumFromInt(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
9191}
9292
9393fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool {
94 return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
94 return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) {
9595 .Equal, .Greater => true,
9696 .Less, .Unordered => false,
9797 };
9898}
9999
100100fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool {
101 return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
101 return switch (@enumFromInt(SparcFCMP, _Qp_cmp(a, b))) {
102102 .Equal, .Less => true,
103103 .Greater, .Unordered => false,
104104 };
lib/compiler_rt/cmpxf2.zig+1-1
......@@ -20,7 +20,7 @@ comptime {
2020/// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`,
2121/// and `__ltxf2`.
2222fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 {
23 return @enumToInt(comparef.cmp_f80(comparef.LE, a, b));
23 return @intFromEnum(comparef.cmp_f80(comparef.LE, a, b));
2424}
2525
2626/// "These functions return a value less than or equal to zero if neither argument is NaN,
lib/compiler_rt/comparef.zig+2-2
......@@ -77,7 +77,7 @@ pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT {
7777 if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0)
7878 return .Equal;
7979
80 if (@boolToInt(a_rep.exp == b_rep.exp) & @boolToInt(a_rep.fraction == b_rep.fraction) != 0) {
80 if (@intFromBool(a_rep.exp == b_rep.exp) & @intFromBool(a_rep.fraction == b_rep.fraction) != 0) {
8181 return .Equal;
8282 } else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) {
8383 // signs are different
......@@ -109,7 +109,7 @@ pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
109109 const aAbs: rep_t = @bitCast(rep_t, a) & absMask;
110110 const bAbs: rep_t = @bitCast(rep_t, b) & absMask;
111111
112 return @boolToInt(aAbs > infRep or bAbs > infRep);
112 return @intFromBool(aAbs > infRep or bAbs > infRep);
113113}
114114
115115test {
lib/compiler_rt/divdf3.zig+2-2
......@@ -199,7 +199,7 @@ inline fn div(a: f64, b: f64) f64 {
199199 } else if (writtenExponent < 1) {
200200 if (writtenExponent == 0) {
201201 // Check whether the rounded result is normal.
202 const round = @boolToInt((residual << 1) > bSignificand);
202 const round = @intFromBool((residual << 1) > bSignificand);
203203 // Clear the implicit bit.
204204 var absResult = quotient & significandMask;
205205 // Round.
......@@ -213,7 +213,7 @@ inline fn div(a: f64, b: f64) f64 {
213213 // code to round them correctly.
214214 return @bitCast(f64, quotientSign);
215215 } else {
216 const round = @boolToInt((residual << 1) > bSignificand);
216 const round = @intFromBool((residual << 1) > bSignificand);
217217 // Clear the implicit bit
218218 var absResult = quotient & significandMask;
219219 // Insert the exponent
lib/compiler_rt/divsf3.zig+2-2
......@@ -179,7 +179,7 @@ inline fn div(a: f32, b: f32) f32 {
179179 } else if (writtenExponent < 1) {
180180 if (writtenExponent == 0) {
181181 // Check whether the rounded result is normal.
182 const round = @boolToInt((residual << 1) > bSignificand);
182 const round = @intFromBool((residual << 1) > bSignificand);
183183 // Clear the implicit bit.
184184 var absResult = quotient & significandMask;
185185 // Round.
......@@ -193,7 +193,7 @@ inline fn div(a: f32, b: f32) f32 {
193193 // code to round them correctly.
194194 return @bitCast(f32, quotientSign);
195195 } else {
196 const round = @boolToInt((residual << 1) > bSignificand);
196 const round = @intFromBool((residual << 1) > bSignificand);
197197 // Clear the implicit bit
198198 var absResult = quotient & significandMask;
199199 // Insert the exponent
lib/compiler_rt/divtf3.zig+2-2
......@@ -214,7 +214,7 @@ inline fn div(a: f128, b: f128) f128 {
214214 } else if (writtenExponent < 1) {
215215 if (writtenExponent == 0) {
216216 // Check whether the rounded result is normal.
217 const round = @boolToInt((residual << 1) > bSignificand);
217 const round = @intFromBool((residual << 1) > bSignificand);
218218 // Clear the implicit bit.
219219 var absResult = quotient & significandMask;
220220 // Round.
......@@ -228,7 +228,7 @@ inline fn div(a: f128, b: f128) f128 {
228228 // code to round them correctly.
229229 return @bitCast(f128, quotientSign);
230230 } else {
231 const round = @boolToInt((residual << 1) >= bSignificand);
231 const round = @intFromBool((residual << 1) >= bSignificand);
232232 // Clear the implicit bit
233233 var absResult = quotient & significandMask;
234234 // Insert the exponent
lib/compiler_rt/divxf3.zig+1-1
......@@ -195,7 +195,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
195195 // code to round them correctly.
196196 return @bitCast(T, quotientSign);
197197 } else {
198 const round = @boolToInt(residual > (bSignificand >> 1));
198 const round = @intFromBool(residual > (bSignificand >> 1));
199199 // Insert the exponent
200200 var absResult = quotient | (@intCast(Z, writtenExponent) << significandBits);
201201 // Round
lib/compiler_rt/exp.zig+4-4
......@@ -74,12 +74,12 @@ pub fn expf(x_: f32) callconv(.C) f32 {
7474 if (hx > 0x3EB17218) {
7575 // |x| > 1.5 * ln2
7676 if (hx > 0x3F851592) {
77 k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]);
77 k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]);
7878 } else {
7979 k = 1 - sign - sign;
8080 }
8181
82 const fk = @intToFloat(f32, k);
82 const fk = @floatFromInt(f32, k);
8383 hi = x - fk * ln2hi;
8484 lo = fk * ln2lo;
8585 x = hi - lo;
......@@ -157,12 +157,12 @@ pub fn exp(x_: f64) callconv(.C) f64 {
157157 if (hx > 0x3FD62E42) {
158158 // |x| >= 1.5 * ln2
159159 if (hx > 0x3FF0A2B2) {
160 k = @floatToInt(i32, invln2 * x + half[@intCast(usize, sign)]);
160 k = @intFromFloat(i32, invln2 * x + half[@intCast(usize, sign)]);
161161 } else {
162162 k = 1 - sign - sign;
163163 }
164164
165 const dk = @intToFloat(f64, k);
165 const dk = @floatFromInt(f64, k);
166166 hi = x - dk * ln2hi;
167167 lo = dk * ln2lo;
168168 x = hi - lo;
lib/compiler_rt/exp2.zig+2-2
......@@ -32,7 +32,7 @@ pub fn __exp2h(x: f16) callconv(.C) f16 {
3232
3333pub fn exp2f(x: f32) callconv(.C) f32 {
3434 const tblsiz = @intCast(u32, exp2ft.len);
35 const redux: f32 = 0x1.8p23 / @intToFloat(f32, tblsiz);
35 const redux: f32 = 0x1.8p23 / @floatFromInt(f32, tblsiz);
3636 const P1: f32 = 0x1.62e430p-1;
3737 const P2: f32 = 0x1.ebfbe0p-3;
3838 const P3: f32 = 0x1.c6b348p-5;
......@@ -89,7 +89,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 {
8989
9090pub fn exp2(x: f64) callconv(.C) f64 {
9191 const tblsiz: u32 = @intCast(u32, exp2dt.len / 2);
92 const redux: f64 = 0x1.8p52 / @intToFloat(f64, tblsiz);
92 const redux: f64 = 0x1.8p52 / @floatFromInt(f64, tblsiz);
9393 const P1: f64 = 0x1.62e42fefa39efp-1;
9494 const P2: f64 = 0x1.ebfbdff82c575p-3;
9595 const P3: f64 = 0x1.c6b08d704a0a6p-5;
lib/compiler_rt/fixdfdi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixdfdi(a: f64) callconv(.C) i64 {
15 return floatToInt(i64, a);
15 return intFromFloat(i64, a);
1616}
1717
1818fn __aeabi_d2lz(a: f64) callconv(.AAPCS) i64 {
19 return floatToInt(i64, a);
19 return intFromFloat(i64, a);
2020}
lib/compiler_rt/fixdfsi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixdfsi(a: f64) callconv(.C) i32 {
15 return floatToInt(i32, a);
15 return intFromFloat(i32, a);
1616}
1717
1818fn __aeabi_d2iz(a: f64) callconv(.AAPCS) i32 {
19 return floatToInt(i32, a);
19 return intFromFloat(i32, a);
2020}
lib/compiler_rt/fixdfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixdfti(a: f64) callconv(.C) i128 {
16 return floatToInt(i128, a);
16 return intFromFloat(i128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(i128, a));
22 return @bitCast(v2u64, intFromFloat(i128, a));
2323}
lib/compiler_rt/fixhfdi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixhfdi(a: f16) callconv(.C) i64 {
11 return floatToInt(i64, a);
11 return intFromFloat(i64, a);
1212}
lib/compiler_rt/fixhfsi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixhfsi(a: f16) callconv(.C) i32 {
11 return floatToInt(i32, a);
11 return intFromFloat(i32, a);
1212}
lib/compiler_rt/fixhfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixhfti(a: f16) callconv(.C) i128 {
16 return floatToInt(i128, a);
16 return intFromFloat(i128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixhfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(i128, a));
22 return @bitCast(v2u64, intFromFloat(i128, a));
2323}
lib/compiler_rt/fixsfdi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixsfdi(a: f32) callconv(.C) i64 {
15 return floatToInt(i64, a);
15 return intFromFloat(i64, a);
1616}
1717
1818fn __aeabi_f2lz(a: f32) callconv(.AAPCS) i64 {
19 return floatToInt(i64, a);
19 return intFromFloat(i64, a);
2020}
lib/compiler_rt/fixsfsi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixsfsi(a: f32) callconv(.C) i32 {
15 return floatToInt(i32, a);
15 return intFromFloat(i32, a);
1616}
1717
1818fn __aeabi_f2iz(a: f32) callconv(.AAPCS) i32 {
19 return floatToInt(i32, a);
19 return intFromFloat(i32, a);
2020}
lib/compiler_rt/fixsfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixsfti(a: f32) callconv(.C) i128 {
16 return floatToInt(i128, a);
16 return intFromFloat(i128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixsfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(i128, a));
22 return @bitCast(v2u64, intFromFloat(i128, a));
2323}
lib/compiler_rt/fixtfdi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __fixtfdi(a: f128) callconv(.C) i64 {
16 return floatToInt(i64, a);
16 return intFromFloat(i64, a);
1717}
1818
1919fn _Qp_qtox(a: *const f128) callconv(.C) i64 {
20 return floatToInt(i64, a.*);
20 return intFromFloat(i64, a.*);
2121}
lib/compiler_rt/fixtfsi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __fixtfsi(a: f128) callconv(.C) i32 {
16 return floatToInt(i32, a);
16 return intFromFloat(i32, a);
1717}
1818
1919fn _Qp_qtoi(a: *const f128) callconv(.C) i32 {
20 return floatToInt(i32, a.*);
20 return intFromFloat(i32, a.*);
2121}
lib/compiler_rt/fixtfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -15,11 +15,11 @@ comptime {
1515}
1616
1717pub fn __fixtfti(a: f128) callconv(.C) i128 {
18 return floatToInt(i128, a);
18 return intFromFloat(i128, a);
1919}
2020
2121const v2u64 = @Vector(2, u64);
2222
2323fn __fixtfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
24 return @bitCast(v2u64, floatToInt(i128, a));
24 return @bitCast(v2u64, intFromFloat(i128, a));
2525}
lib/compiler_rt/fixunsdfdi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixunsdfdi(a: f64) callconv(.C) u64 {
15 return floatToInt(u64, a);
15 return intFromFloat(u64, a);
1616}
1717
1818fn __aeabi_d2ulz(a: f64) callconv(.AAPCS) u64 {
19 return floatToInt(u64, a);
19 return intFromFloat(u64, a);
2020}
lib/compiler_rt/fixunsdfsi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixunsdfsi(a: f64) callconv(.C) u32 {
15 return floatToInt(u32, a);
15 return intFromFloat(u32, a);
1616}
1717
1818fn __aeabi_d2uiz(a: f64) callconv(.AAPCS) u32 {
19 return floatToInt(u32, a);
19 return intFromFloat(u32, a);
2020}
lib/compiler_rt/fixunsdfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixunsdfti(a: f64) callconv(.C) u128 {
16 return floatToInt(u128, a);
16 return intFromFloat(u128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixunsdfti_windows_x86_64(a: f64) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(u128, a));
22 return @bitCast(v2u64, intFromFloat(u128, a));
2323}
lib/compiler_rt/fixunshfdi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixunshfdi(a: f16) callconv(.C) u64 {
11 return floatToInt(u64, a);
11 return intFromFloat(u64, a);
1212}
lib/compiler_rt/fixunshfsi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixunshfsi(a: f16) callconv(.C) u32 {
11 return floatToInt(u32, a);
11 return intFromFloat(u32, a);
1212}
lib/compiler_rt/fixunshfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixunshfti(a: f16) callconv(.C) u128 {
16 return floatToInt(u128, a);
16 return intFromFloat(u128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(u128, a));
22 return @bitCast(v2u64, intFromFloat(u128, a));
2323}
lib/compiler_rt/fixunssfdi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixunssfdi(a: f32) callconv(.C) u64 {
15 return floatToInt(u64, a);
15 return intFromFloat(u64, a);
1616}
1717
1818fn __aeabi_f2ulz(a: f32) callconv(.AAPCS) u64 {
19 return floatToInt(u64, a);
19 return intFromFloat(u64, a);
2020}
lib/compiler_rt/fixunssfsi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __fixunssfsi(a: f32) callconv(.C) u32 {
15 return floatToInt(u32, a);
15 return intFromFloat(u32, a);
1616}
1717
1818fn __aeabi_f2uiz(a: f32) callconv(.AAPCS) u32 {
19 return floatToInt(u32, a);
19 return intFromFloat(u32, a);
2020}
lib/compiler_rt/fixunssfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixunssfti(a: f32) callconv(.C) u128 {
16 return floatToInt(u128, a);
16 return intFromFloat(u128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixunssfti_windows_x86_64(a: f32) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(u128, a));
22 return @bitCast(v2u64, intFromFloat(u128, a));
2323}
lib/compiler_rt/fixunstfdi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
16 return floatToInt(u64, a);
16 return intFromFloat(u64, a);
1717}
1818
1919fn _Qp_qtoux(a: *const f128) callconv(.C) u64 {
20 return floatToInt(u64, a.*);
20 return intFromFloat(u64, a.*);
2121}
lib/compiler_rt/fixunstfsi.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
16 return floatToInt(u32, a);
16 return intFromFloat(u32, a);
1717}
1818
1919fn _Qp_qtoui(a: *const f128) callconv(.C) u32 {
20 return floatToInt(u32, a.*);
20 return intFromFloat(u32, a.*);
2121}
lib/compiler_rt/fixunstfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -15,11 +15,11 @@ comptime {
1515}
1616
1717pub fn __fixunstfti(a: f128) callconv(.C) u128 {
18 return floatToInt(u128, a);
18 return intFromFloat(u128, a);
1919}
2020
2121const v2u64 = @Vector(2, u64);
2222
2323fn __fixunstfti_windows_x86_64(a: f128) callconv(.C) v2u64 {
24 return @bitCast(v2u64, floatToInt(u128, a));
24 return @bitCast(v2u64, intFromFloat(u128, a));
2525}
lib/compiler_rt/fixunsxfdi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixunsxfdi(a: f80) callconv(.C) u64 {
11 return floatToInt(u64, a);
11 return intFromFloat(u64, a);
1212}
lib/compiler_rt/fixunsxfsi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixunsxfsi(a: f80) callconv(.C) u32 {
11 return floatToInt(u32, a);
11 return intFromFloat(u32, a);
1212}
lib/compiler_rt/fixunsxfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixunsxfti(a: f80) callconv(.C) u128 {
16 return floatToInt(u128, a);
16 return intFromFloat(u128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixunsxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(u128, a));
22 return @bitCast(v2u64, intFromFloat(u128, a));
2323}
lib/compiler_rt/fixxfdi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixxfdi(a: f80) callconv(.C) i64 {
11 return floatToInt(i64, a);
11 return intFromFloat(i64, a);
1212}
lib/compiler_rt/fixxfsi.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const floatToInt = @import("./float_to_int.zig").floatToInt;
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __fixxfsi(a: f80) callconv(.C) i32 {
11 return floatToInt(i32, a);
11 return intFromFloat(i32, a);
1212}
lib/compiler_rt/fixxfti.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const floatToInt = @import("./float_to_int.zig").floatToInt;
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55pub const panic = common.panic;
66
......@@ -13,11 +13,11 @@ comptime {
1313}
1414
1515pub fn __fixxfti(a: f80) callconv(.C) i128 {
16 return floatToInt(i128, a);
16 return intFromFloat(i128, a);
1717}
1818
1919const v2u64 = @Vector(2, u64);
2020
2121fn __fixxfti_windows_x86_64(a: f80) callconv(.C) v2u64 {
22 return @bitCast(v2u64, floatToInt(i128, a));
22 return @bitCast(v2u64, intFromFloat(i128, a));
2323}
lib/compiler_rt/float_from_int.zig created+58
......@@ -0,0 +1,58 @@
1const Int = @import("std").meta.Int;
2const math = @import("std").math;
3
4pub fn floatFromInt(comptime T: type, x: anytype) T {
5 if (x == 0) return 0;
6
7 // Various constants whose values follow from the type parameters.
8 // Any reasonable optimizer will fold and propagate all of these.
9 const Z = Int(.unsigned, @bitSizeOf(@TypeOf(x)));
10 const uT = Int(.unsigned, @bitSizeOf(T));
11 const inf = math.inf(T);
12 const float_bits = @bitSizeOf(T);
13 const int_bits = @bitSizeOf(@TypeOf(x));
14 const exp_bits = math.floatExponentBits(T);
15 const fractional_bits = math.floatFractionalBits(T);
16 const exp_bias = math.maxInt(Int(.unsigned, exp_bits - 1));
17 const implicit_bit = if (T != f80) @as(uT, 1) << fractional_bits else 0;
18 const max_exp = exp_bias;
19
20 // Sign
21 var abs_val = math.absCast(x);
22 const sign_bit = if (x < 0) @as(uT, 1) << (float_bits - 1) else 0;
23 var result: uT = sign_bit;
24
25 // Compute significand
26 var exp = int_bits - @clz(abs_val) - 1;
27 if (int_bits <= fractional_bits or exp <= fractional_bits) {
28 const shift_amt = fractional_bits - @intCast(math.Log2Int(uT), exp);
29
30 // Shift up result to line up with the significand - no rounding required
31 result = (@intCast(uT, abs_val) << shift_amt);
32 result ^= implicit_bit; // Remove implicit integer bit
33 } else {
34 var shift_amt = @intCast(math.Log2Int(Z), exp - fractional_bits);
35 const exact_tie: bool = @ctz(abs_val) == shift_amt - 1;
36
37 // Shift down result and remove implicit integer bit
38 result = @intCast(uT, (abs_val >> (shift_amt - 1))) ^ (implicit_bit << 1);
39
40 // Round result, including round-to-even for exact ties
41 result = ((result + 1) >> 1) & ~@as(uT, @intFromBool(exact_tie));
42 }
43
44 // Compute exponent
45 if ((int_bits > max_exp) and (exp > max_exp)) // If exponent too large, overflow to infinity
46 return @bitCast(T, sign_bit | @bitCast(uT, inf));
47
48 result += (@as(uT, exp) + exp_bias) << math.floatMantissaBits(T);
49
50 // If the result included a carry, we need to restore the explicit integer bit
51 if (T == f80) result |= 1 << fractional_bits;
52
53 return @bitCast(T, sign_bit | result);
54}
55
56test {
57 _ = @import("float_from_int_test.zig");
58}
lib/compiler_rt/float_from_int_test.zig created+836
......@@ -0,0 +1,836 @@
1const std = @import("std");
2const testing = std.testing;
3const math = std.math;
4
5const __floatunsihf = @import("floatunsihf.zig").__floatunsihf;
6
7// Conversion to f32
8const __floatsisf = @import("floatsisf.zig").__floatsisf;
9const __floatunsisf = @import("floatunsisf.zig").__floatunsisf;
10const __floatdisf = @import("floatdisf.zig").__floatdisf;
11const __floatundisf = @import("floatundisf.zig").__floatundisf;
12const __floattisf = @import("floattisf.zig").__floattisf;
13const __floatuntisf = @import("floatuntisf.zig").__floatuntisf;
14
15// Conversion to f64
16const __floatsidf = @import("floatsidf.zig").__floatsidf;
17const __floatunsidf = @import("floatunsidf.zig").__floatunsidf;
18const __floatdidf = @import("floatdidf.zig").__floatdidf;
19const __floatundidf = @import("floatundidf.zig").__floatundidf;
20const __floattidf = @import("floattidf.zig").__floattidf;
21const __floatuntidf = @import("floatuntidf.zig").__floatuntidf;
22
23// Conversion to f128
24const __floatsitf = @import("floatsitf.zig").__floatsitf;
25const __floatunsitf = @import("floatunsitf.zig").__floatunsitf;
26const __floatditf = @import("floatditf.zig").__floatditf;
27const __floatunditf = @import("floatunditf.zig").__floatunditf;
28const __floattitf = @import("floattitf.zig").__floattitf;
29const __floatuntitf = @import("floatuntitf.zig").__floatuntitf;
30
31fn test__floatsisf(a: i32, expected: u32) !void {
32 const r = __floatsisf(a);
33 try std.testing.expect(@bitCast(u32, r) == expected);
34}
35
36fn test_one_floatunsisf(a: u32, expected: u32) !void {
37 const r = __floatunsisf(a);
38 try std.testing.expect(@bitCast(u32, r) == expected);
39}
40
41test "floatsisf" {
42 try test__floatsisf(0, 0x00000000);
43 try test__floatsisf(1, 0x3f800000);
44 try test__floatsisf(-1, 0xbf800000);
45 try test__floatsisf(0x7FFFFFFF, 0x4f000000);
46 try test__floatsisf(@bitCast(i32, @intCast(u32, 0x80000000)), 0xcf000000);
47}
48
49test "floatunsisf" {
50 // Test the produced bit pattern
51 try test_one_floatunsisf(0, 0);
52 try test_one_floatunsisf(1, 0x3f800000);
53 try test_one_floatunsisf(0x7FFFFFFF, 0x4f000000);
54 try test_one_floatunsisf(0x80000000, 0x4f000000);
55 try test_one_floatunsisf(0xFFFFFFFF, 0x4f800000);
56}
57
58fn test__floatdisf(a: i64, expected: f32) !void {
59 const x = __floatdisf(a);
60 try testing.expect(x == expected);
61}
62
63fn test__floatundisf(a: u64, expected: f32) !void {
64 try std.testing.expectEqual(expected, __floatundisf(a));
65}
66
67test "floatdisf" {
68 try test__floatdisf(0, 0.0);
69 try test__floatdisf(1, 1.0);
70 try test__floatdisf(2, 2.0);
71 try test__floatdisf(-1, -1.0);
72 try test__floatdisf(-2, -2.0);
73 try test__floatdisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
74 try test__floatdisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
75 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000008000000000)), -0x1.FFFFFEp+62);
76 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000010000000000)), -0x1.FFFFFCp+62);
77 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000000000000000)), -0x1.000000p+63);
78 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000000000000001)), -0x1.000000p+63);
79 try test__floatdisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
80 try test__floatdisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
81 try test__floatdisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
82 try test__floatdisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
83 try test__floatdisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
84 try test__floatdisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
85 try test__floatdisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
86 try test__floatdisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
87 try test__floatdisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
88 try test__floatdisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
89 try test__floatdisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
90}
91
92test "floatundisf" {
93 try test__floatundisf(0, 0.0);
94 try test__floatundisf(1, 1.0);
95 try test__floatundisf(2, 2.0);
96 try test__floatundisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
97 try test__floatundisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
98 try test__floatundisf(0x8000008000000000, 0x1p+63);
99 try test__floatundisf(0x8000010000000000, 0x1.000002p+63);
100 try test__floatundisf(0x8000000000000000, 0x1p+63);
101 try test__floatundisf(0x8000000000000001, 0x1p+63);
102 try test__floatundisf(0xFFFFFFFFFFFFFFFE, 0x1p+64);
103 try test__floatundisf(0xFFFFFFFFFFFFFFFF, 0x1p+64);
104 try test__floatundisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
105 try test__floatundisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
106 try test__floatundisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
107 try test__floatundisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
108 try test__floatundisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
109 try test__floatundisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
110 try test__floatundisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
111 try test__floatundisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
112 try test__floatundisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
113 try test__floatundisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
114 try test__floatundisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
115}
116
117fn test__floattisf(a: i128, expected: f32) !void {
118 const x = __floattisf(a);
119 try testing.expect(x == expected);
120}
121
122fn test__floatuntisf(a: u128, expected: f32) !void {
123 const x = __floatuntisf(a);
124 try testing.expect(x == expected);
125}
126
127test "floattisf" {
128 try test__floattisf(0, 0.0);
129
130 try test__floattisf(1, 1.0);
131 try test__floattisf(2, 2.0);
132 try test__floattisf(-1, -1.0);
133 try test__floattisf(-2, -2.0);
134
135 try test__floattisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
136 try test__floattisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
137
138 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000008000000000), -0x1.FFFFFEp+62);
139 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000010000000000), -0x1.FFFFFCp+62);
140
141 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000000000000000), -0x1.000000p+63);
142 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000000000000001), -0x1.000000p+63);
143
144 try test__floattisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
145
146 try test__floattisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
147 try test__floattisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
148 try test__floattisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
149 try test__floattisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
150 try test__floattisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
151
152 try test__floattisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
153 try test__floattisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
154 try test__floattisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
155 try test__floattisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
156 try test__floattisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
157
158 try test__floattisf(make_ti(0x0007FB72E8000000, 0), 0x1.FEDCBAp+114);
159
160 try test__floattisf(make_ti(0x0007FB72EA000000, 0), 0x1.FEDCBAp+114);
161 try test__floattisf(make_ti(0x0007FB72EB000000, 0), 0x1.FEDCBAp+114);
162 try test__floattisf(make_ti(0x0007FB72EBFFFFFF, 0), 0x1.FEDCBAp+114);
163 try test__floattisf(make_ti(0x0007FB72EC000000, 0), 0x1.FEDCBCp+114);
164 try test__floattisf(make_ti(0x0007FB72E8000001, 0), 0x1.FEDCBAp+114);
165
166 try test__floattisf(make_ti(0x0007FB72E6000000, 0), 0x1.FEDCBAp+114);
167 try test__floattisf(make_ti(0x0007FB72E7000000, 0), 0x1.FEDCBAp+114);
168 try test__floattisf(make_ti(0x0007FB72E7FFFFFF, 0), 0x1.FEDCBAp+114);
169 try test__floattisf(make_ti(0x0007FB72E4000001, 0), 0x1.FEDCBAp+114);
170 try test__floattisf(make_ti(0x0007FB72E4000000, 0), 0x1.FEDCB8p+114);
171}
172
173test "floatuntisf" {
174 try test__floatuntisf(0, 0.0);
175
176 try test__floatuntisf(1, 1.0);
177 try test__floatuntisf(2, 2.0);
178 try test__floatuntisf(20, 20.0);
179
180 try test__floatuntisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
181 try test__floatuntisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
182
183 try test__floatuntisf(make_uti(0x8000008000000000, 0), 0x1.000001p+127);
184 try test__floatuntisf(make_uti(0x8000000000000800, 0), 0x1.0p+127);
185 try test__floatuntisf(make_uti(0x8000010000000000, 0), 0x1.000002p+127);
186
187 try test__floatuntisf(make_uti(0x8000000000000000, 0), 0x1.000000p+127);
188
189 try test__floatuntisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
190
191 try test__floatuntisf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
192 try test__floatuntisf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
193
194 try test__floatuntisf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
195
196 try test__floatuntisf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
197 try test__floatuntisf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
198 try test__floatuntisf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
199
200 try test__floatuntisf(0xFFFFFFFFFFFFFFFE, 0x1p+64);
201 try test__floatuntisf(0xFFFFFFFFFFFFFFFF, 0x1p+64);
202
203 try test__floatuntisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
204
205 try test__floatuntisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
206 try test__floatuntisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
207 try test__floatuntisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
208 try test__floatuntisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
209 try test__floatuntisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
210
211 try test__floatuntisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
212 try test__floatuntisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
213 try test__floatuntisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
214 try test__floatuntisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
215 try test__floatuntisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
216
217 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCB90000000000001), 0x1.FEDCBAp+76);
218 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBA0000000000000), 0x1.FEDCBAp+76);
219 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBAFFFFFFFFFFFFF), 0x1.FEDCBAp+76);
220 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBB0000000000000), 0x1.FEDCBCp+76);
221 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBB0000000000001), 0x1.FEDCBCp+76);
222 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBBFFFFFFFFFFFFF), 0x1.FEDCBCp+76);
223 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBC0000000000000), 0x1.FEDCBCp+76);
224 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBC0000000000001), 0x1.FEDCBCp+76);
225 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBD0000000000000), 0x1.FEDCBCp+76);
226 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBD0000000000001), 0x1.FEDCBEp+76);
227 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBDFFFFFFFFFFFFF), 0x1.FEDCBEp+76);
228 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBE0000000000000), 0x1.FEDCBEp+76);
229
230 // Test overflow to infinity
231 try test__floatuntisf(@as(u128, math.maxInt(u128)), @bitCast(f32, math.inf(f32)));
232}
233
234fn test_one_floatsidf(a: i32, expected: u64) !void {
235 const r = __floatsidf(a);
236 try std.testing.expect(@bitCast(u64, r) == expected);
237}
238
239fn test_one_floatunsidf(a: u32, expected: u64) !void {
240 const r = __floatunsidf(a);
241 try std.testing.expect(@bitCast(u64, r) == expected);
242}
243
244test "floatsidf" {
245 try test_one_floatsidf(0, 0x0000000000000000);
246 try test_one_floatsidf(1, 0x3ff0000000000000);
247 try test_one_floatsidf(-1, 0xbff0000000000000);
248 try test_one_floatsidf(0x7FFFFFFF, 0x41dfffffffc00000);
249 try test_one_floatsidf(@bitCast(i32, @intCast(u32, 0x80000000)), 0xc1e0000000000000);
250}
251
252test "floatunsidf" {
253 try test_one_floatunsidf(0, 0x0000000000000000);
254 try test_one_floatunsidf(1, 0x3ff0000000000000);
255 try test_one_floatunsidf(0x7FFFFFFF, 0x41dfffffffc00000);
256 try test_one_floatunsidf(@intCast(u32, 0x80000000), 0x41e0000000000000);
257 try test_one_floatunsidf(@intCast(u32, 0xFFFFFFFF), 0x41efffffffe00000);
258}
259
260fn test__floatdidf(a: i64, expected: f64) !void {
261 const r = __floatdidf(a);
262 try testing.expect(r == expected);
263}
264
265fn test__floatundidf(a: u64, expected: f64) !void {
266 const r = __floatundidf(a);
267 try testing.expect(r == expected);
268}
269
270test "floatdidf" {
271 try test__floatdidf(0, 0.0);
272 try test__floatdidf(1, 1.0);
273 try test__floatdidf(2, 2.0);
274 try test__floatdidf(20, 20.0);
275 try test__floatdidf(-1, -1.0);
276 try test__floatdidf(-2, -2.0);
277 try test__floatdidf(-20, -20.0);
278 try test__floatdidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
279 try test__floatdidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
280 try test__floatdidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
281 try test__floatdidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
282 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000008000000000)), -0x1.FFFFFEp+62);
283 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000800)), -0x1.FFFFFFFFFFFFEp+62);
284 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000010000000000)), -0x1.FFFFFCp+62);
285 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000001000)), -0x1.FFFFFFFFFFFFCp+62);
286 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000000)), -0x1.000000p+63);
287 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000001)), -0x1.000000p+63); // 0x8000000000000001
288 try test__floatdidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
289 try test__floatdidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
290 try test__floatdidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
291 try test__floatdidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
292 try test__floatdidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
293 try test__floatdidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
294 try test__floatdidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
295 try test__floatdidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
296 try test__floatdidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
297 try test__floatdidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
298 try test__floatdidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
299 try test__floatdidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
300 try test__floatdidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
301 try test__floatdidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
302 try test__floatdidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
303 try test__floatdidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
304 try test__floatdidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
305 try test__floatdidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
306 try test__floatdidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
307 try test__floatdidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
308 try test__floatdidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
309 try test__floatdidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
310 try test__floatdidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
311 try test__floatdidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
312 try test__floatdidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
313 try test__floatdidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
314}
315
316test "floatundidf" {
317 try test__floatundidf(0, 0.0);
318 try test__floatundidf(1, 1.0);
319 try test__floatundidf(2, 2.0);
320 try test__floatundidf(20, 20.0);
321 try test__floatundidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
322 try test__floatundidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
323 try test__floatundidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
324 try test__floatundidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
325 try test__floatundidf(0x8000008000000000, 0x1.000001p+63);
326 try test__floatundidf(0x8000000000000800, 0x1.0000000000001p+63);
327 try test__floatundidf(0x8000010000000000, 0x1.000002p+63);
328 try test__floatundidf(0x8000000000001000, 0x1.0000000000002p+63);
329 try test__floatundidf(0x8000000000000000, 0x1p+63);
330 try test__floatundidf(0x8000000000000001, 0x1p+63);
331 try test__floatundidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
332 try test__floatundidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
333 try test__floatundidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
334 try test__floatundidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
335 try test__floatundidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
336 try test__floatundidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
337 try test__floatundidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
338 try test__floatundidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
339 try test__floatundidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
340 try test__floatundidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
341 try test__floatundidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
342 try test__floatundidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
343 try test__floatundidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
344 try test__floatundidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
345 try test__floatundidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
346 try test__floatundidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
347 try test__floatundidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
348 try test__floatundidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
349 try test__floatundidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
350 try test__floatundidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
351 try test__floatundidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
352 try test__floatundidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
353 try test__floatundidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
354 try test__floatundidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
355 try test__floatundidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
356 try test__floatundidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
357}
358
359fn test__floattidf(a: i128, expected: f64) !void {
360 const x = __floattidf(a);
361 try testing.expect(x == expected);
362}
363
364fn test__floatuntidf(a: u128, expected: f64) !void {
365 const x = __floatuntidf(a);
366 try testing.expect(x == expected);
367}
368
369test "floattidf" {
370 try test__floattidf(0, 0.0);
371
372 try test__floattidf(1, 1.0);
373 try test__floattidf(2, 2.0);
374 try test__floattidf(20, 20.0);
375 try test__floattidf(-1, -1.0);
376 try test__floattidf(-2, -2.0);
377 try test__floattidf(-20, -20.0);
378
379 try test__floattidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
380 try test__floattidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
381 try test__floattidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
382 try test__floattidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
383
384 try test__floattidf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126);
385 try test__floattidf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126);
386 try test__floattidf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126);
387 try test__floattidf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126);
388
389 try test__floattidf(make_ti(0x8000000000000000, 0), -0x1.000000p+127);
390 try test__floattidf(make_ti(0x8000000000000001, 0), -0x1.000000p+127);
391
392 try test__floattidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
393
394 try test__floattidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
395 try test__floattidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
396 try test__floattidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
397 try test__floattidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
398 try test__floattidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
399
400 try test__floattidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
401 try test__floattidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
402 try test__floattidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
403 try test__floattidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
404 try test__floattidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
405
406 try test__floattidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
407 try test__floattidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
408 try test__floattidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
409 try test__floattidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
410 try test__floattidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
411 try test__floattidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
412 try test__floattidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
413 try test__floattidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
414 try test__floattidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
415 try test__floattidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
416 try test__floattidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
417 try test__floattidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
418 try test__floattidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
419 try test__floattidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
420 try test__floattidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
421
422 try test__floattidf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
423 try test__floattidf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121);
424 try test__floattidf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121);
425 try test__floattidf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121);
426 try test__floattidf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121);
427 try test__floattidf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121);
428 try test__floattidf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121);
429 try test__floattidf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121);
430 try test__floattidf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121);
431 try test__floattidf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121);
432 try test__floattidf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121);
433 try test__floattidf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121);
434 try test__floattidf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121);
435 try test__floattidf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121);
436 try test__floattidf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
437}
438
439test "floatuntidf" {
440 try test__floatuntidf(0, 0.0);
441
442 try test__floatuntidf(1, 1.0);
443 try test__floatuntidf(2, 2.0);
444 try test__floatuntidf(20, 20.0);
445
446 try test__floatuntidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
447 try test__floatuntidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
448 try test__floatuntidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
449 try test__floatuntidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
450
451 try test__floatuntidf(make_uti(0x8000008000000000, 0), 0x1.000001p+127);
452 try test__floatuntidf(make_uti(0x8000000000000800, 0), 0x1.0000000000001p+127);
453 try test__floatuntidf(make_uti(0x8000010000000000, 0), 0x1.000002p+127);
454 try test__floatuntidf(make_uti(0x8000000000001000, 0), 0x1.0000000000002p+127);
455
456 try test__floatuntidf(make_uti(0x8000000000000000, 0), 0x1.000000p+127);
457 try test__floatuntidf(make_uti(0x8000000000000001, 0), 0x1.0000000000000002p+127);
458
459 try test__floatuntidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
460
461 try test__floatuntidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
462 try test__floatuntidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
463 try test__floatuntidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
464 try test__floatuntidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
465 try test__floatuntidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
466
467 try test__floatuntidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
468 try test__floatuntidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
469 try test__floatuntidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
470 try test__floatuntidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
471 try test__floatuntidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
472
473 try test__floatuntidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
474 try test__floatuntidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
475 try test__floatuntidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
476 try test__floatuntidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
477 try test__floatuntidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
478 try test__floatuntidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
479 try test__floatuntidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
480 try test__floatuntidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
481 try test__floatuntidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
482 try test__floatuntidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
483 try test__floatuntidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
484 try test__floatuntidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
485 try test__floatuntidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
486 try test__floatuntidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
487 try test__floatuntidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
488
489 try test__floatuntidf(make_uti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
490 try test__floatuntidf(make_uti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121);
491 try test__floatuntidf(make_uti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121);
492 try test__floatuntidf(make_uti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121);
493 try test__floatuntidf(make_uti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121);
494 try test__floatuntidf(make_uti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121);
495 try test__floatuntidf(make_uti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121);
496 try test__floatuntidf(make_uti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121);
497 try test__floatuntidf(make_uti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121);
498 try test__floatuntidf(make_uti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121);
499 try test__floatuntidf(make_uti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121);
500 try test__floatuntidf(make_uti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121);
501 try test__floatuntidf(make_uti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121);
502 try test__floatuntidf(make_uti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121);
503 try test__floatuntidf(make_uti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
504}
505
506fn test__floatsitf(a: i32, expected: u128) !void {
507 const r = __floatsitf(a);
508 try std.testing.expect(@bitCast(u128, r) == expected);
509}
510
511test "floatsitf" {
512 try test__floatsitf(0, 0);
513 try test__floatsitf(0x7FFFFFFF, 0x401dfffffffc00000000000000000000);
514 try test__floatsitf(0x12345678, 0x401b2345678000000000000000000000);
515 try test__floatsitf(-0x12345678, 0xc01b2345678000000000000000000000);
516 try test__floatsitf(@bitCast(i32, @intCast(u32, 0xffffffff)), 0xbfff0000000000000000000000000000);
517 try test__floatsitf(@bitCast(i32, @intCast(u32, 0x80000000)), 0xc01e0000000000000000000000000000);
518}
519
520fn test__floatunsitf(a: u32, expected_hi: u64, expected_lo: u64) !void {
521 const x = __floatunsitf(a);
522
523 const x_repr = @bitCast(u128, x);
524 const x_hi = @intCast(u64, x_repr >> 64);
525 const x_lo = @truncate(u64, x_repr);
526
527 if (x_hi == expected_hi and x_lo == expected_lo) {
528 return;
529 }
530 // nan repr
531 else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
532 if ((x_hi & 0x7fff000000000000) == 0x7fff000000000000 and ((x_hi & 0xffffffffffff) > 0 or x_lo > 0)) {
533 return;
534 }
535 }
536
537 @panic("__floatunsitf test failure");
538}
539
540test "floatunsitf" {
541 try test__floatunsitf(0x7fffffff, 0x401dfffffffc0000, 0x0);
542 try test__floatunsitf(0, 0x0, 0x0);
543 try test__floatunsitf(0xffffffff, 0x401efffffffe0000, 0x0);
544 try test__floatunsitf(0x12345678, 0x401b234567800000, 0x0);
545}
546
547fn test__floatditf(a: i64, expected: f128) !void {
548 const x = __floatditf(a);
549 try testing.expect(x == expected);
550}
551
552fn test__floatunditf(a: u64, expected_hi: u64, expected_lo: u64) !void {
553 const x = __floatunditf(a);
554
555 const x_repr = @bitCast(u128, x);
556 const x_hi = @intCast(u64, x_repr >> 64);
557 const x_lo = @truncate(u64, x_repr);
558
559 if (x_hi == expected_hi and x_lo == expected_lo) {
560 return;
561 }
562 // nan repr
563 else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
564 if ((x_hi & 0x7fff000000000000) == 0x7fff000000000000 and ((x_hi & 0xffffffffffff) > 0 or x_lo > 0)) {
565 return;
566 }
567 }
568
569 @panic("__floatunditf test failure");
570}
571
572test "floatditf" {
573 try test__floatditf(0x7fffffffffffffff, make_tf(0x403dffffffffffff, 0xfffc000000000000));
574 try test__floatditf(0x123456789abcdef1, make_tf(0x403b23456789abcd, 0xef10000000000000));
575 try test__floatditf(0x2, make_tf(0x4000000000000000, 0x0));
576 try test__floatditf(0x1, make_tf(0x3fff000000000000, 0x0));
577 try test__floatditf(0x0, make_tf(0x0, 0x0));
578 try test__floatditf(@bitCast(i64, @as(u64, 0xffffffffffffffff)), make_tf(0xbfff000000000000, 0x0));
579 try test__floatditf(@bitCast(i64, @as(u64, 0xfffffffffffffffe)), make_tf(0xc000000000000000, 0x0));
580 try test__floatditf(-0x123456789abcdef1, make_tf(0xc03b23456789abcd, 0xef10000000000000));
581 try test__floatditf(@bitCast(i64, @as(u64, 0x8000000000000000)), make_tf(0xc03e000000000000, 0x0));
582}
583
584test "floatunditf" {
585 try test__floatunditf(0xffffffffffffffff, 0x403effffffffffff, 0xfffe000000000000);
586 try test__floatunditf(0xfffffffffffffffe, 0x403effffffffffff, 0xfffc000000000000);
587 try test__floatunditf(0x8000000000000000, 0x403e000000000000, 0x0);
588 try test__floatunditf(0x7fffffffffffffff, 0x403dffffffffffff, 0xfffc000000000000);
589 try test__floatunditf(0x123456789abcdef1, 0x403b23456789abcd, 0xef10000000000000);
590 try test__floatunditf(0x2, 0x4000000000000000, 0x0);
591 try test__floatunditf(0x1, 0x3fff000000000000, 0x0);
592 try test__floatunditf(0x0, 0x0, 0x0);
593}
594
595fn test__floattitf(a: i128, expected: f128) !void {
596 const x = __floattitf(a);
597 try testing.expect(x == expected);
598}
599
600fn test__floatuntitf(a: u128, expected: f128) !void {
601 const x = __floatuntitf(a);
602 try testing.expect(x == expected);
603}
604
605test "floattitf" {
606 try test__floattitf(0, 0.0);
607
608 try test__floattitf(1, 1.0);
609 try test__floattitf(2, 2.0);
610 try test__floattitf(20, 20.0);
611 try test__floattitf(-1, -1.0);
612 try test__floattitf(-2, -2.0);
613 try test__floattitf(-20, -20.0);
614
615 try test__floattitf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
616 try test__floattitf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
617 try test__floattitf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
618 try test__floattitf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
619
620 try test__floattitf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126);
621 try test__floattitf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126);
622 try test__floattitf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126);
623 try test__floattitf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126);
624
625 try test__floattitf(make_ti(0x8000000000000000, 0), -0x1.000000p+127);
626 try test__floattitf(make_ti(0x8000000000000001, 0), -0x1.FFFFFFFFFFFFFFFCp+126);
627
628 try test__floattitf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
629
630 try test__floattitf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
631 try test__floattitf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
632 try test__floattitf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
633 try test__floattitf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
634 try test__floattitf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
635
636 try test__floattitf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
637 try test__floattitf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
638 try test__floattitf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
639 try test__floattitf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
640 try test__floattitf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
641
642 try test__floattitf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
643 try test__floattitf(0x023479FD0E092DA1, 0x1.1A3CFE870496D08p+57);
644 try test__floattitf(0x023479FD0E092DB0, 0x1.1A3CFE870496D8p+57);
645 try test__floattitf(0x023479FD0E092DB8, 0x1.1A3CFE870496DCp+57);
646 try test__floattitf(0x023479FD0E092DB6, 0x1.1A3CFE870496DBp+57);
647 try test__floattitf(0x023479FD0E092DBF, 0x1.1A3CFE870496DF8p+57);
648 try test__floattitf(0x023479FD0E092DC1, 0x1.1A3CFE870496E08p+57);
649 try test__floattitf(0x023479FD0E092DC7, 0x1.1A3CFE870496E38p+57);
650 try test__floattitf(0x023479FD0E092DC8, 0x1.1A3CFE870496E4p+57);
651 try test__floattitf(0x023479FD0E092DCF, 0x1.1A3CFE870496E78p+57);
652 try test__floattitf(0x023479FD0E092DD0, 0x1.1A3CFE870496E8p+57);
653 try test__floattitf(0x023479FD0E092DD1, 0x1.1A3CFE870496E88p+57);
654 try test__floattitf(0x023479FD0E092DD8, 0x1.1A3CFE870496ECp+57);
655 try test__floattitf(0x023479FD0E092DDF, 0x1.1A3CFE870496EF8p+57);
656 try test__floattitf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
657
658 try test__floattitf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
659 try test__floattitf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496D08p+121);
660 try test__floattitf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496D8p+121);
661 try test__floattitf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496DCp+121);
662 try test__floattitf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496DBp+121);
663 try test__floattitf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496DF8p+121);
664 try test__floattitf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496E08p+121);
665 try test__floattitf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496E38p+121);
666 try test__floattitf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496E4p+121);
667 try test__floattitf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496E78p+121);
668 try test__floattitf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496E8p+121);
669 try test__floattitf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496E88p+121);
670 try test__floattitf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496ECp+121);
671 try test__floattitf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496EF8p+121);
672 try test__floattitf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
673
674 try test__floattitf(make_ti(0, 0xFFFFFFFFFFFFFFFF), 0x1.FFFFFFFFFFFFFFFEp+63);
675
676 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC2801), 0x1.23456789ABCDEF0123456789ABC3p+124);
677 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3000), 0x1.23456789ABCDEF0123456789ABC3p+124);
678 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC37FF), 0x1.23456789ABCDEF0123456789ABC3p+124);
679 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3800), 0x1.23456789ABCDEF0123456789ABC4p+124);
680 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4000), 0x1.23456789ABCDEF0123456789ABC4p+124);
681 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC47FF), 0x1.23456789ABCDEF0123456789ABC4p+124);
682 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4800), 0x1.23456789ABCDEF0123456789ABC4p+124);
683 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4801), 0x1.23456789ABCDEF0123456789ABC5p+124);
684 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC57FF), 0x1.23456789ABCDEF0123456789ABC5p+124);
685}
686
687test "floatuntitf" {
688 try test__floatuntitf(0, 0.0);
689
690 try test__floatuntitf(1, 1.0);
691 try test__floatuntitf(2, 2.0);
692 try test__floatuntitf(20, 20.0);
693
694 try test__floatuntitf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
695 try test__floatuntitf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
696 try test__floatuntitf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
697 try test__floatuntitf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
698 try test__floatuntitf(0x7FFFFFFFFFFFFFFF, 0xF.FFFFFFFFFFFFFFEp+59);
699 try test__floatuntitf(0xFFFFFFFFFFFFFFFE, 0xF.FFFFFFFFFFFFFFEp+60);
700 try test__floatuntitf(0xFFFFFFFFFFFFFFFF, 0xF.FFFFFFFFFFFFFFFp+60);
701
702 try test__floatuntitf(0x8000008000000000, 0x8.000008p+60);
703 try test__floatuntitf(0x8000000000000800, 0x8.0000000000008p+60);
704 try test__floatuntitf(0x8000010000000000, 0x8.00001p+60);
705 try test__floatuntitf(0x8000000000001000, 0x8.000000000001p+60);
706
707 try test__floatuntitf(0x8000000000000000, 0x8p+60);
708 try test__floatuntitf(0x8000000000000001, 0x8.000000000000001p+60);
709
710 try test__floatuntitf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
711
712 try test__floatuntitf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
713 try test__floatuntitf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
714 try test__floatuntitf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
715 try test__floatuntitf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
716 try test__floatuntitf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
717
718 try test__floatuntitf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
719 try test__floatuntitf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
720 try test__floatuntitf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
721 try test__floatuntitf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
722 try test__floatuntitf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
723
724 try test__floatuntitf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
725 try test__floatuntitf(0x023479FD0E092DA1, 0x1.1A3CFE870496D08p+57);
726 try test__floatuntitf(0x023479FD0E092DB0, 0x1.1A3CFE870496D8p+57);
727 try test__floatuntitf(0x023479FD0E092DB8, 0x1.1A3CFE870496DCp+57);
728 try test__floatuntitf(0x023479FD0E092DB6, 0x1.1A3CFE870496DBp+57);
729 try test__floatuntitf(0x023479FD0E092DBF, 0x1.1A3CFE870496DF8p+57);
730 try test__floatuntitf(0x023479FD0E092DC1, 0x1.1A3CFE870496E08p+57);
731 try test__floatuntitf(0x023479FD0E092DC7, 0x1.1A3CFE870496E38p+57);
732 try test__floatuntitf(0x023479FD0E092DC8, 0x1.1A3CFE870496E4p+57);
733 try test__floatuntitf(0x023479FD0E092DCF, 0x1.1A3CFE870496E78p+57);
734 try test__floatuntitf(0x023479FD0E092DD0, 0x1.1A3CFE870496E8p+57);
735 try test__floatuntitf(0x023479FD0E092DD1, 0x1.1A3CFE870496E88p+57);
736 try test__floatuntitf(0x023479FD0E092DD8, 0x1.1A3CFE870496ECp+57);
737 try test__floatuntitf(0x023479FD0E092DDF, 0x1.1A3CFE870496EF8p+57);
738 try test__floatuntitf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
739
740 try test__floatuntitf(make_uti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
741 try test__floatuntitf(make_uti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496D08p+121);
742 try test__floatuntitf(make_uti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496D8p+121);
743 try test__floatuntitf(make_uti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496DCp+121);
744 try test__floatuntitf(make_uti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496DBp+121);
745 try test__floatuntitf(make_uti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496DF8p+121);
746 try test__floatuntitf(make_uti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496E08p+121);
747 try test__floatuntitf(make_uti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496E38p+121);
748 try test__floatuntitf(make_uti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496E4p+121);
749 try test__floatuntitf(make_uti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496E78p+121);
750 try test__floatuntitf(make_uti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496E8p+121);
751 try test__floatuntitf(make_uti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496E88p+121);
752 try test__floatuntitf(make_uti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496ECp+121);
753 try test__floatuntitf(make_uti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496EF8p+121);
754 try test__floatuntitf(make_uti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
755
756 try test__floatuntitf(make_uti(0, 0xFFFFFFFFFFFFFFFF), 0x1.FFFFFFFFFFFFFFFEp+63);
757
758 try test__floatuntitf(make_uti(0xFFFFFFFFFFFFFFFF, 0x0000000000000000), 0x1.FFFFFFFFFFFFFFFEp+127);
759 try test__floatuntitf(make_uti(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF), 0x1.0000000000000000p+128);
760
761 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC2801), 0x1.23456789ABCDEF0123456789ABC3p+124);
762 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC3000), 0x1.23456789ABCDEF0123456789ABC3p+124);
763 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC37FF), 0x1.23456789ABCDEF0123456789ABC3p+124);
764 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC3800), 0x1.23456789ABCDEF0123456789ABC4p+124);
765 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC4000), 0x1.23456789ABCDEF0123456789ABC4p+124);
766 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC47FF), 0x1.23456789ABCDEF0123456789ABC4p+124);
767 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC4800), 0x1.23456789ABCDEF0123456789ABC4p+124);
768 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC4801), 0x1.23456789ABCDEF0123456789ABC5p+124);
769 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC57FF), 0x1.23456789ABCDEF0123456789ABC5p+124);
770}
771
772fn make_ti(high: u64, low: u64) i128 {
773 var result: u128 = high;
774 result <<= 64;
775 result |= low;
776 return @bitCast(i128, result);
777}
778
779fn make_uti(high: u64, low: u64) u128 {
780 var result: u128 = high;
781 result <<= 64;
782 result |= low;
783 return result;
784}
785
786fn make_tf(high: u64, low: u64) f128 {
787 var result: u128 = high;
788 result <<= 64;
789 result |= low;
790 return @bitCast(f128, result);
791}
792
793test "conversion to f16" {
794 try testing.expect(__floatunsihf(@as(u32, 0)) == 0.0);
795 try testing.expect(__floatunsihf(@as(u32, 1)) == 1.0);
796 try testing.expect(__floatunsihf(@as(u32, 65504)) == 65504);
797 try testing.expect(__floatunsihf(@as(u32, 65504 + (1 << 4))) == math.inf(f16));
798}
799
800test "conversion to f32" {
801 try testing.expect(__floatunsisf(@as(u32, 0)) == 0.0);
802 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u32))) != 1.0);
803 try testing.expect(__floatsisf(@as(i32, math.minInt(i32))) != 1.0);
804 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24))) == math.maxInt(u24));
805 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 1) == math.maxInt(u24) + 1); // 0x100_0000 - Exact
806 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 2) == math.maxInt(u24) + 1); // 0x100_0001 - Tie: Rounds down to even
807 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 3) == math.maxInt(u24) + 3); // 0x100_0002 - Exact
808 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 4) == math.maxInt(u24) + 5); // 0x100_0003 - Tie: Rounds up to even
809 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 5) == math.maxInt(u24) + 5); // 0x100_0004 - Exact
810}
811
812test "conversion to f80" {
813 if (std.debug.runtime_safety) return error.SkipZigTest;
814
815 const floatFromInt = @import("./float_from_int.zig").floatFromInt;
816
817 try testing.expect(floatFromInt(f80, @as(i80, -12)) == -12);
818 try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0);
819 try testing.expect(@intFromFloat(u80, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1);
820
821 try testing.expect(floatFromInt(f80, @as(u32, 0)) == 0.0);
822 try testing.expect(floatFromInt(f80, @as(u32, 1)) == 1.0);
823 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24));
824 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64));
825 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact
826 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down
827 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact
828 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up
829
830 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up
831 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact
832 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down
833 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down
834 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up
835 try testing.expect(@intFromFloat(u128, floatFromInt(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact
836}
lib/compiler_rt/float_to_int.zig deleted-55
......@@ -1,55 +0,0 @@
1const Int = @import("std").meta.Int;
2const math = @import("std").math;
3const Log2Int = math.Log2Int;
4
5pub inline fn floatToInt(comptime I: type, a: anytype) I {
6 const F = @TypeOf(a);
7 const float_bits = @typeInfo(F).Float.bits;
8 const int_bits = @typeInfo(I).Int.bits;
9 const rep_t = Int(.unsigned, float_bits);
10 const sig_bits = math.floatMantissaBits(F);
11 const exp_bits = math.floatExponentBits(F);
12 const fractional_bits = math.floatFractionalBits(F);
13
14 const implicit_bit = if (F != f80) (@as(rep_t, 1) << sig_bits) else 0;
15 const max_exp = (1 << (exp_bits - 1));
16 const exp_bias = max_exp - 1;
17 const sig_mask = (@as(rep_t, 1) << sig_bits) - 1;
18
19 // Break a into sign, exponent, significand
20 const a_rep: rep_t = @bitCast(rep_t, a);
21 const negative = (a_rep >> (float_bits - 1)) != 0;
22 const exponent = @intCast(i32, (a_rep << 1) >> (sig_bits + 1)) - exp_bias;
23 const significand: rep_t = (a_rep & sig_mask) | implicit_bit;
24
25 // If the exponent is negative, the result rounds to zero.
26 if (exponent < 0) return 0;
27
28 // If the value is too large for the integer type, saturate.
29 switch (@typeInfo(I).Int.signedness) {
30 .unsigned => {
31 if (negative) return 0;
32 if (@intCast(c_uint, exponent) >= @min(int_bits, max_exp)) return math.maxInt(I);
33 },
34 .signed => if (@intCast(c_uint, exponent) >= @min(int_bits - 1, max_exp)) {
35 return if (negative) math.minInt(I) else math.maxInt(I);
36 },
37 }
38
39 // If 0 <= exponent < sig_bits, right shift to get the result.
40 // Otherwise, shift left.
41 var result: I = undefined;
42 if (exponent < fractional_bits) {
43 result = @intCast(I, significand >> @intCast(Log2Int(rep_t), fractional_bits - exponent));
44 } else {
45 result = @intCast(I, significand) << @intCast(Log2Int(I), exponent - fractional_bits);
46 }
47
48 if ((@typeInfo(I).Int.signedness == .signed) and negative)
49 return ~result +% 1;
50 return result;
51}
52
53test {
54 _ = @import("float_to_int_test.zig");
55}
lib/compiler_rt/float_to_int_test.zig deleted-950
......@@ -1,950 +0,0 @@
1const std = @import("std");
2const testing = std.testing;
3const math = std.math;
4
5const __fixunshfti = @import("fixunshfti.zig").__fixunshfti;
6const __fixunsxfti = @import("fixunsxfti.zig").__fixunsxfti;
7
8// Conversion from f32
9const __fixsfsi = @import("fixsfsi.zig").__fixsfsi;
10const __fixunssfsi = @import("fixunssfsi.zig").__fixunssfsi;
11const __fixsfdi = @import("fixsfdi.zig").__fixsfdi;
12const __fixunssfdi = @import("fixunssfdi.zig").__fixunssfdi;
13const __fixsfti = @import("fixsfti.zig").__fixsfti;
14const __fixunssfti = @import("fixunssfti.zig").__fixunssfti;
15
16// Conversion from f64
17const __fixdfsi = @import("fixdfsi.zig").__fixdfsi;
18const __fixunsdfsi = @import("fixunsdfsi.zig").__fixunsdfsi;
19const __fixdfdi = @import("fixdfdi.zig").__fixdfdi;
20const __fixunsdfdi = @import("fixunsdfdi.zig").__fixunsdfdi;
21const __fixdfti = @import("fixdfti.zig").__fixdfti;
22const __fixunsdfti = @import("fixunsdfti.zig").__fixunsdfti;
23
24// Conversion from f128
25const __fixtfsi = @import("fixtfsi.zig").__fixtfsi;
26const __fixunstfsi = @import("fixunstfsi.zig").__fixunstfsi;
27const __fixtfdi = @import("fixtfdi.zig").__fixtfdi;
28const __fixunstfdi = @import("fixunstfdi.zig").__fixunstfdi;
29const __fixtfti = @import("fixtfti.zig").__fixtfti;
30const __fixunstfti = @import("fixunstfti.zig").__fixunstfti;
31
32fn test__fixsfsi(a: f32, expected: i32) !void {
33 const x = __fixsfsi(a);
34 try testing.expect(x == expected);
35}
36
37fn test__fixunssfsi(a: f32, expected: u32) !void {
38 const x = __fixunssfsi(a);
39 try testing.expect(x == expected);
40}
41
42test "fixsfsi" {
43 try test__fixsfsi(-math.floatMax(f32), math.minInt(i32));
44
45 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
46 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000);
47
48 try test__fixsfsi(-0x1.0000000000000p+127, -0x80000000);
49 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
50 try test__fixsfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
51
52 try test__fixsfsi(-0x1.0000000000001p+63, -0x80000000);
53 try test__fixsfsi(-0x1.0000000000000p+63, -0x80000000);
54 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
55 try test__fixsfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
56
57 try test__fixsfsi(-0x1.FFFFFEp+62, -0x80000000);
58 try test__fixsfsi(-0x1.FFFFFCp+62, -0x80000000);
59
60 try test__fixsfsi(-0x1.000000p+31, -0x80000000);
61 try test__fixsfsi(-0x1.FFFFFFp+30, -0x80000000);
62 try test__fixsfsi(-0x1.FFFFFEp+30, -0x7FFFFF80);
63 try test__fixsfsi(-0x1.FFFFFCp+30, -0x7FFFFF00);
64
65 try test__fixsfsi(-2.01, -2);
66 try test__fixsfsi(-2.0, -2);
67 try test__fixsfsi(-1.99, -1);
68 try test__fixsfsi(-1.0, -1);
69 try test__fixsfsi(-0.99, 0);
70 try test__fixsfsi(-0.5, 0);
71 try test__fixsfsi(-math.floatMin(f32), 0);
72 try test__fixsfsi(0.0, 0);
73 try test__fixsfsi(math.floatMin(f32), 0);
74 try test__fixsfsi(0.5, 0);
75 try test__fixsfsi(0.99, 0);
76 try test__fixsfsi(1.0, 1);
77 try test__fixsfsi(1.5, 1);
78 try test__fixsfsi(1.99, 1);
79 try test__fixsfsi(2.0, 2);
80 try test__fixsfsi(2.01, 2);
81
82 try test__fixsfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
83 try test__fixsfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
84 try test__fixsfsi(0x1.FFFFFFp+30, 0x7FFFFFFF);
85 try test__fixsfsi(0x1.000000p+31, 0x7FFFFFFF);
86
87 try test__fixsfsi(0x1.FFFFFCp+62, 0x7FFFFFFF);
88 try test__fixsfsi(0x1.FFFFFEp+62, 0x7FFFFFFF);
89
90 try test__fixsfsi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFF);
91 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFF);
92 try test__fixsfsi(0x1.0000000000000p+63, 0x7FFFFFFF);
93 try test__fixsfsi(0x1.0000000000001p+63, 0x7FFFFFFF);
94
95 try test__fixsfsi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFF);
96 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFF);
97 try test__fixsfsi(0x1.0000000000000p+127, 0x7FFFFFFF);
98
99 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF);
100 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32));
101
102 try test__fixsfsi(math.floatMax(f32), math.maxInt(i32));
103}
104
105test "fixunssfsi" {
106 try test__fixunssfsi(0.0, 0);
107
108 try test__fixunssfsi(0.5, 0);
109 try test__fixunssfsi(0.99, 0);
110 try test__fixunssfsi(1.0, 1);
111 try test__fixunssfsi(1.5, 1);
112 try test__fixunssfsi(1.99, 1);
113 try test__fixunssfsi(2.0, 2);
114 try test__fixunssfsi(2.01, 2);
115 try test__fixunssfsi(-0.5, 0);
116 try test__fixunssfsi(-0.99, 0);
117
118 try test__fixunssfsi(-1.0, 0);
119 try test__fixunssfsi(-1.5, 0);
120 try test__fixunssfsi(-1.99, 0);
121 try test__fixunssfsi(-2.0, 0);
122 try test__fixunssfsi(-2.01, 0);
123
124 try test__fixunssfsi(0x1.000000p+31, 0x80000000);
125 try test__fixunssfsi(0x1.000000p+32, 0xFFFFFFFF);
126 try test__fixunssfsi(0x1.FFFFFEp+31, 0xFFFFFF00);
127 try test__fixunssfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
128 try test__fixunssfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
129
130 try test__fixunssfsi(-0x1.FFFFFEp+30, 0);
131 try test__fixunssfsi(-0x1.FFFFFCp+30, 0);
132}
133
134fn test__fixsfdi(a: f32, expected: i64) !void {
135 const x = __fixsfdi(a);
136 try testing.expect(x == expected);
137}
138
139fn test__fixunssfdi(a: f32, expected: u64) !void {
140 const x = __fixunssfdi(a);
141 try testing.expect(x == expected);
142}
143
144test "fixsfdi" {
145 try test__fixsfdi(-math.floatMax(f32), math.minInt(i64));
146
147 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
148 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000);
149
150 try test__fixsfdi(-0x1.0000000000000p+127, -0x8000000000000000);
151 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
152 try test__fixsfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
153
154 try test__fixsfdi(-0x1.0000000000001p+63, -0x8000000000000000);
155 try test__fixsfdi(-0x1.0000000000000p+63, -0x8000000000000000);
156 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+62, -0x8000000000000000);
157 try test__fixsfdi(-0x1.FFFFFFFFFFFFEp+62, -0x8000000000000000);
158
159 try test__fixsfdi(-0x1.FFFFFFp+62, -0x8000000000000000);
160 try test__fixsfdi(-0x1.FFFFFEp+62, -0x7fffff8000000000);
161 try test__fixsfdi(-0x1.FFFFFCp+62, -0x7fffff0000000000);
162
163 try test__fixsfdi(-2.01, -2);
164 try test__fixsfdi(-2.0, -2);
165 try test__fixsfdi(-1.99, -1);
166 try test__fixsfdi(-1.0, -1);
167 try test__fixsfdi(-0.99, 0);
168 try test__fixsfdi(-0.5, 0);
169 try test__fixsfdi(-math.floatMin(f32), 0);
170 try test__fixsfdi(0.0, 0);
171 try test__fixsfdi(math.floatMin(f32), 0);
172 try test__fixsfdi(0.5, 0);
173 try test__fixsfdi(0.99, 0);
174 try test__fixsfdi(1.0, 1);
175 try test__fixsfdi(1.5, 1);
176 try test__fixsfdi(1.99, 1);
177 try test__fixsfdi(2.0, 2);
178 try test__fixsfdi(2.01, 2);
179
180 try test__fixsfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
181 try test__fixsfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
182 try test__fixsfdi(0x1.FFFFFFp+62, 0x7FFFFFFFFFFFFFFF);
183
184 try test__fixsfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFFFFF);
185 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFFFF);
186 try test__fixsfdi(0x1.0000000000000p+63, 0x7FFFFFFFFFFFFFFF);
187 try test__fixsfdi(0x1.0000000000001p+63, 0x7FFFFFFFFFFFFFFF);
188
189 try test__fixsfdi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFF);
190 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFF);
191 try test__fixsfdi(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFF);
192
193 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF);
194 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64));
195
196 try test__fixsfdi(math.floatMax(f32), math.maxInt(i64));
197}
198
199test "fixunssfdi" {
200 try test__fixunssfdi(0.0, 0);
201
202 try test__fixunssfdi(0.5, 0);
203 try test__fixunssfdi(0.99, 0);
204 try test__fixunssfdi(1.0, 1);
205 try test__fixunssfdi(1.5, 1);
206 try test__fixunssfdi(1.99, 1);
207 try test__fixunssfdi(2.0, 2);
208 try test__fixunssfdi(2.01, 2);
209 try test__fixunssfdi(-0.5, 0);
210 try test__fixunssfdi(-0.99, 0);
211
212 try test__fixunssfdi(-1.0, 0);
213 try test__fixunssfdi(-1.5, 0);
214 try test__fixunssfdi(-1.99, 0);
215 try test__fixunssfdi(-2.0, 0);
216 try test__fixunssfdi(-2.01, 0);
217
218 try test__fixunssfdi(0x1.FFFFFEp+63, 0xFFFFFF0000000000);
219 try test__fixunssfdi(0x1.000000p+63, 0x8000000000000000);
220 try test__fixunssfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
221 try test__fixunssfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
222
223 try test__fixunssfdi(-0x1.FFFFFEp+62, 0x0000000000000000);
224 try test__fixunssfdi(-0x1.FFFFFCp+62, 0x0000000000000000);
225}
226
227fn test__fixsfti(a: f32, expected: i128) !void {
228 const x = __fixsfti(a);
229 try testing.expect(x == expected);
230}
231
232fn test__fixunssfti(a: f32, expected: u128) !void {
233 const x = __fixunssfti(a);
234 try testing.expect(x == expected);
235}
236
237test "fixsfti" {
238 try test__fixsfti(-math.floatMax(f32), math.minInt(i128));
239
240 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
241 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000);
242
243 try test__fixsfti(-0x1.0000000000000p+127, -0x80000000000000000000000000000000);
244 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+126, -0x80000000000000000000000000000000);
245 try test__fixsfti(-0x1.FFFFFFFFFFFFEp+126, -0x80000000000000000000000000000000);
246 try test__fixsfti(-0x1.FFFFFF0000000p+126, -0x80000000000000000000000000000000);
247 try test__fixsfti(-0x1.FFFFFE0000000p+126, -0x7FFFFF80000000000000000000000000);
248 try test__fixsfti(-0x1.FFFFFC0000000p+126, -0x7FFFFF00000000000000000000000000);
249
250 try test__fixsfti(-0x1.0000000000001p+63, -0x8000000000000000);
251 try test__fixsfti(-0x1.0000000000000p+63, -0x8000000000000000);
252 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+62, -0x8000000000000000);
253 try test__fixsfti(-0x1.FFFFFFFFFFFFEp+62, -0x8000000000000000);
254
255 try test__fixsfti(-0x1.FFFFFFp+62, -0x8000000000000000);
256 try test__fixsfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
257 try test__fixsfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
258
259 try test__fixsfti(-0x1.000000p+31, -0x80000000);
260 try test__fixsfti(-0x1.FFFFFFp+30, -0x80000000);
261 try test__fixsfti(-0x1.FFFFFEp+30, -0x7FFFFF80);
262 try test__fixsfti(-0x1.FFFFFCp+30, -0x7FFFFF00);
263
264 try test__fixsfti(-2.01, -2);
265 try test__fixsfti(-2.0, -2);
266 try test__fixsfti(-1.99, -1);
267 try test__fixsfti(-1.0, -1);
268 try test__fixsfti(-0.99, 0);
269 try test__fixsfti(-0.5, 0);
270 try test__fixsfti(-math.floatMin(f32), 0);
271 try test__fixsfti(0.0, 0);
272 try test__fixsfti(math.floatMin(f32), 0);
273 try test__fixsfti(0.5, 0);
274 try test__fixsfti(0.99, 0);
275 try test__fixsfti(1.0, 1);
276 try test__fixsfti(1.5, 1);
277 try test__fixsfti(1.99, 1);
278 try test__fixsfti(2.0, 2);
279 try test__fixsfti(2.01, 2);
280
281 try test__fixsfti(0x1.FFFFFCp+30, 0x7FFFFF00);
282 try test__fixsfti(0x1.FFFFFEp+30, 0x7FFFFF80);
283 try test__fixsfti(0x1.FFFFFFp+30, 0x80000000);
284 try test__fixsfti(0x1.000000p+31, 0x80000000);
285
286 try test__fixsfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
287 try test__fixsfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
288 try test__fixsfti(0x1.FFFFFFp+62, 0x8000000000000000);
289
290 try test__fixsfti(0x1.FFFFFFFFFFFFEp+62, 0x8000000000000000);
291 try test__fixsfti(0x1.FFFFFFFFFFFFFp+62, 0x8000000000000000);
292 try test__fixsfti(0x1.0000000000000p+63, 0x8000000000000000);
293 try test__fixsfti(0x1.0000000000001p+63, 0x8000000000000000);
294
295 try test__fixsfti(0x1.FFFFFC0000000p+126, 0x7FFFFF00000000000000000000000000);
296 try test__fixsfti(0x1.FFFFFE0000000p+126, 0x7FFFFF80000000000000000000000000);
297 try test__fixsfti(0x1.FFFFFF0000000p+126, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
298 try test__fixsfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
299 try test__fixsfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
300 try test__fixsfti(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
301
302 try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
303 try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128));
304
305 try test__fixsfti(math.floatMax(f32), math.maxInt(i128));
306}
307
308test "fixunssfti" {
309 try test__fixunssfti(0.0, 0);
310
311 try test__fixunssfti(0.5, 0);
312 try test__fixunssfti(0.99, 0);
313 try test__fixunssfti(1.0, 1);
314 try test__fixunssfti(1.5, 1);
315 try test__fixunssfti(1.99, 1);
316 try test__fixunssfti(2.0, 2);
317 try test__fixunssfti(2.01, 2);
318 try test__fixunssfti(-0.5, 0);
319 try test__fixunssfti(-0.99, 0);
320
321 try test__fixunssfti(-1.0, 0);
322 try test__fixunssfti(-1.5, 0);
323 try test__fixunssfti(-1.99, 0);
324 try test__fixunssfti(-2.0, 0);
325 try test__fixunssfti(-2.01, 0);
326
327 try test__fixunssfti(0x1.FFFFFEp+63, 0xFFFFFF0000000000);
328 try test__fixunssfti(0x1.000000p+63, 0x8000000000000000);
329 try test__fixunssfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
330 try test__fixunssfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
331 try test__fixunssfti(0x1.FFFFFEp+127, 0xFFFFFF00000000000000000000000000);
332 try test__fixunssfti(0x1.000000p+127, 0x80000000000000000000000000000000);
333 try test__fixunssfti(0x1.FFFFFEp+126, 0x7FFFFF80000000000000000000000000);
334 try test__fixunssfti(0x1.FFFFFCp+126, 0x7FFFFF00000000000000000000000000);
335
336 try test__fixunssfti(-0x1.FFFFFEp+62, 0x0000000000000000);
337 try test__fixunssfti(-0x1.FFFFFCp+62, 0x0000000000000000);
338 try test__fixunssfti(-0x1.FFFFFEp+126, 0x0000000000000000);
339 try test__fixunssfti(-0x1.FFFFFCp+126, 0x0000000000000000);
340 try test__fixunssfti(math.floatMax(f32), 0xffffff00000000000000000000000000);
341 try test__fixunssfti(math.inf(f32), math.maxInt(u128));
342}
343
344fn test__fixdfsi(a: f64, expected: i32) !void {
345 const x = __fixdfsi(a);
346 try testing.expect(x == expected);
347}
348
349fn test__fixunsdfsi(a: f64, expected: u32) !void {
350 const x = __fixunsdfsi(a);
351 try testing.expect(x == expected);
352}
353
354test "fixdfsi" {
355 try test__fixdfsi(-math.floatMax(f64), math.minInt(i32));
356
357 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
358 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000);
359
360 try test__fixdfsi(-0x1.0000000000000p+127, -0x80000000);
361 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
362 try test__fixdfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
363
364 try test__fixdfsi(-0x1.0000000000001p+63, -0x80000000);
365 try test__fixdfsi(-0x1.0000000000000p+63, -0x80000000);
366 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
367 try test__fixdfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
368
369 try test__fixdfsi(-0x1.FFFFFEp+62, -0x80000000);
370 try test__fixdfsi(-0x1.FFFFFCp+62, -0x80000000);
371
372 try test__fixdfsi(-0x1.000000p+31, -0x80000000);
373 try test__fixdfsi(-0x1.FFFFFFp+30, -0x7FFFFFC0);
374 try test__fixdfsi(-0x1.FFFFFEp+30, -0x7FFFFF80);
375
376 try test__fixdfsi(-2.01, -2);
377 try test__fixdfsi(-2.0, -2);
378 try test__fixdfsi(-1.99, -1);
379 try test__fixdfsi(-1.0, -1);
380 try test__fixdfsi(-0.99, 0);
381 try test__fixdfsi(-0.5, 0);
382 try test__fixdfsi(-math.floatMin(f64), 0);
383 try test__fixdfsi(0.0, 0);
384 try test__fixdfsi(math.floatMin(f64), 0);
385 try test__fixdfsi(0.5, 0);
386 try test__fixdfsi(0.99, 0);
387 try test__fixdfsi(1.0, 1);
388 try test__fixdfsi(1.5, 1);
389 try test__fixdfsi(1.99, 1);
390 try test__fixdfsi(2.0, 2);
391 try test__fixdfsi(2.01, 2);
392
393 try test__fixdfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
394 try test__fixdfsi(0x1.FFFFFFp+30, 0x7FFFFFC0);
395 try test__fixdfsi(0x1.000000p+31, 0x7FFFFFFF);
396
397 try test__fixdfsi(0x1.FFFFFCp+62, 0x7FFFFFFF);
398 try test__fixdfsi(0x1.FFFFFEp+62, 0x7FFFFFFF);
399
400 try test__fixdfsi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFF);
401 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFF);
402 try test__fixdfsi(0x1.0000000000000p+63, 0x7FFFFFFF);
403 try test__fixdfsi(0x1.0000000000001p+63, 0x7FFFFFFF);
404
405 try test__fixdfsi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFF);
406 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFF);
407 try test__fixdfsi(0x1.0000000000000p+127, 0x7FFFFFFF);
408
409 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF);
410 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32));
411
412 try test__fixdfsi(math.floatMax(f64), math.maxInt(i32));
413}
414
415test "fixunsdfsi" {
416 try test__fixunsdfsi(0.0, 0);
417
418 try test__fixunsdfsi(0.5, 0);
419 try test__fixunsdfsi(0.99, 0);
420 try test__fixunsdfsi(1.0, 1);
421 try test__fixunsdfsi(1.5, 1);
422 try test__fixunsdfsi(1.99, 1);
423 try test__fixunsdfsi(2.0, 2);
424 try test__fixunsdfsi(2.01, 2);
425 try test__fixunsdfsi(-0.5, 0);
426 try test__fixunsdfsi(-0.99, 0);
427 try test__fixunsdfsi(-1.0, 0);
428 try test__fixunsdfsi(-1.5, 0);
429 try test__fixunsdfsi(-1.99, 0);
430 try test__fixunsdfsi(-2.0, 0);
431 try test__fixunsdfsi(-2.01, 0);
432
433 try test__fixunsdfsi(0x1.000000p+31, 0x80000000);
434 try test__fixunsdfsi(0x1.000000p+32, 0xFFFFFFFF);
435 try test__fixunsdfsi(0x1.FFFFFEp+31, 0xFFFFFF00);
436 try test__fixunsdfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
437 try test__fixunsdfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
438
439 try test__fixunsdfsi(-0x1.FFFFFEp+30, 0);
440 try test__fixunsdfsi(-0x1.FFFFFCp+30, 0);
441
442 try test__fixunsdfsi(0x1.FFFFFFFEp+31, 0xFFFFFFFF);
443 try test__fixunsdfsi(0x1.FFFFFFFC00000p+30, 0x7FFFFFFF);
444 try test__fixunsdfsi(0x1.FFFFFFF800000p+30, 0x7FFFFFFE);
445}
446
447fn test__fixdfdi(a: f64, expected: i64) !void {
448 const x = __fixdfdi(a);
449 try testing.expect(x == expected);
450}
451
452fn test__fixunsdfdi(a: f64, expected: u64) !void {
453 const x = __fixunsdfdi(a);
454 try testing.expect(x == expected);
455}
456
457test "fixdfdi" {
458 try test__fixdfdi(-math.floatMax(f64), math.minInt(i64));
459
460 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
461 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000);
462
463 try test__fixdfdi(-0x1.0000000000000p+127, -0x8000000000000000);
464 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
465 try test__fixdfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
466
467 try test__fixdfdi(-0x1.0000000000001p+63, -0x8000000000000000);
468 try test__fixdfdi(-0x1.0000000000000p+63, -0x8000000000000000);
469 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
470 try test__fixdfdi(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
471
472 try test__fixdfdi(-0x1.FFFFFEp+62, -0x7fffff8000000000);
473 try test__fixdfdi(-0x1.FFFFFCp+62, -0x7fffff0000000000);
474
475 try test__fixdfdi(-2.01, -2);
476 try test__fixdfdi(-2.0, -2);
477 try test__fixdfdi(-1.99, -1);
478 try test__fixdfdi(-1.0, -1);
479 try test__fixdfdi(-0.99, 0);
480 try test__fixdfdi(-0.5, 0);
481 try test__fixdfdi(-math.floatMin(f64), 0);
482 try test__fixdfdi(0.0, 0);
483 try test__fixdfdi(math.floatMin(f64), 0);
484 try test__fixdfdi(0.5, 0);
485 try test__fixdfdi(0.99, 0);
486 try test__fixdfdi(1.0, 1);
487 try test__fixdfdi(1.5, 1);
488 try test__fixdfdi(1.99, 1);
489 try test__fixdfdi(2.0, 2);
490 try test__fixdfdi(2.01, 2);
491
492 try test__fixdfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
493 try test__fixdfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
494
495 try test__fixdfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
496 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
497 try test__fixdfdi(0x1.0000000000000p+63, 0x7FFFFFFFFFFFFFFF);
498 try test__fixdfdi(0x1.0000000000001p+63, 0x7FFFFFFFFFFFFFFF);
499
500 try test__fixdfdi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFF);
501 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFF);
502 try test__fixdfdi(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFF);
503
504 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF);
505 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64));
506
507 try test__fixdfdi(math.floatMax(f64), math.maxInt(i64));
508}
509
510test "fixunsdfdi" {
511 try test__fixunsdfdi(0.0, 0);
512 try test__fixunsdfdi(0.5, 0);
513 try test__fixunsdfdi(0.99, 0);
514 try test__fixunsdfdi(1.0, 1);
515 try test__fixunsdfdi(1.5, 1);
516 try test__fixunsdfdi(1.99, 1);
517 try test__fixunsdfdi(2.0, 2);
518 try test__fixunsdfdi(2.01, 2);
519 try test__fixunsdfdi(-0.5, 0);
520 try test__fixunsdfdi(-0.99, 0);
521 try test__fixunsdfdi(-1.0, 0);
522 try test__fixunsdfdi(-1.5, 0);
523 try test__fixunsdfdi(-1.99, 0);
524 try test__fixunsdfdi(-2.0, 0);
525 try test__fixunsdfdi(-2.01, 0);
526
527 try test__fixunsdfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
528 try test__fixunsdfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
529
530 try test__fixunsdfdi(-0x1.FFFFFEp+62, 0);
531 try test__fixunsdfdi(-0x1.FFFFFCp+62, 0);
532
533 try test__fixunsdfdi(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800);
534 try test__fixunsdfdi(0x1.0000000000000p+63, 0x8000000000000000);
535 try test__fixunsdfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
536 try test__fixunsdfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
537
538 try test__fixunsdfdi(-0x1.FFFFFFFFFFFFFp+62, 0);
539 try test__fixunsdfdi(-0x1.FFFFFFFFFFFFEp+62, 0);
540}
541
542fn test__fixdfti(a: f64, expected: i128) !void {
543 const x = __fixdfti(a);
544 try testing.expect(x == expected);
545}
546
547fn test__fixunsdfti(a: f64, expected: u128) !void {
548 const x = __fixunsdfti(a);
549 try testing.expect(x == expected);
550}
551
552test "fixdfti" {
553 try test__fixdfti(-math.floatMax(f64), math.minInt(i128));
554
555 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
556 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000);
557
558 try test__fixdfti(-0x1.0000000000000p+127, -0x80000000000000000000000000000000);
559 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+126, -0x7FFFFFFFFFFFFC000000000000000000);
560 try test__fixdfti(-0x1.FFFFFFFFFFFFEp+126, -0x7FFFFFFFFFFFF8000000000000000000);
561
562 try test__fixdfti(-0x1.0000000000001p+63, -0x8000000000000800);
563 try test__fixdfti(-0x1.0000000000000p+63, -0x8000000000000000);
564 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
565 try test__fixdfti(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
566
567 try test__fixdfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
568 try test__fixdfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
569
570 try test__fixdfti(-2.01, -2);
571 try test__fixdfti(-2.0, -2);
572 try test__fixdfti(-1.99, -1);
573 try test__fixdfti(-1.0, -1);
574 try test__fixdfti(-0.99, 0);
575 try test__fixdfti(-0.5, 0);
576 try test__fixdfti(-math.floatMin(f64), 0);
577 try test__fixdfti(0.0, 0);
578 try test__fixdfti(math.floatMin(f64), 0);
579 try test__fixdfti(0.5, 0);
580 try test__fixdfti(0.99, 0);
581 try test__fixdfti(1.0, 1);
582 try test__fixdfti(1.5, 1);
583 try test__fixdfti(1.99, 1);
584 try test__fixdfti(2.0, 2);
585 try test__fixdfti(2.01, 2);
586
587 try test__fixdfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
588 try test__fixdfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
589
590 try test__fixdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
591 try test__fixdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
592 try test__fixdfti(0x1.0000000000000p+63, 0x8000000000000000);
593 try test__fixdfti(0x1.0000000000001p+63, 0x8000000000000800);
594
595 try test__fixdfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFF8000000000000000000);
596 try test__fixdfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFC000000000000000000);
597 try test__fixdfti(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
598
599 try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
600 try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128));
601
602 try test__fixdfti(math.floatMax(f64), math.maxInt(i128));
603}
604
605test "fixunsdfti" {
606 try test__fixunsdfti(0.0, 0);
607
608 try test__fixunsdfti(0.5, 0);
609 try test__fixunsdfti(0.99, 0);
610 try test__fixunsdfti(1.0, 1);
611 try test__fixunsdfti(1.5, 1);
612 try test__fixunsdfti(1.99, 1);
613 try test__fixunsdfti(2.0, 2);
614 try test__fixunsdfti(2.01, 2);
615 try test__fixunsdfti(-0.5, 0);
616 try test__fixunsdfti(-0.99, 0);
617 try test__fixunsdfti(-1.0, 0);
618 try test__fixunsdfti(-1.5, 0);
619 try test__fixunsdfti(-1.99, 0);
620 try test__fixunsdfti(-2.0, 0);
621 try test__fixunsdfti(-2.01, 0);
622
623 try test__fixunsdfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
624 try test__fixunsdfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
625
626 try test__fixunsdfti(-0x1.FFFFFEp+62, 0);
627 try test__fixunsdfti(-0x1.FFFFFCp+62, 0);
628
629 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800);
630 try test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000);
631 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
632 try test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
633
634 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+127, 0xFFFFFFFFFFFFF8000000000000000000);
635 try test__fixunsdfti(0x1.0000000000000p+127, 0x80000000000000000000000000000000);
636 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFC000000000000000000);
637 try test__fixunsdfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFF8000000000000000000);
638 try test__fixunsdfti(0x1.0000000000000p+128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
639
640 try test__fixunsdfti(-0x1.FFFFFFFFFFFFFp+62, 0);
641 try test__fixunsdfti(-0x1.FFFFFFFFFFFFEp+62, 0);
642}
643
644fn test__fixtfsi(a: f128, expected: i32) !void {
645 const x = __fixtfsi(a);
646 try testing.expect(x == expected);
647}
648
649fn test__fixunstfsi(a: f128, expected: u32) !void {
650 const x = __fixunstfsi(a);
651 try testing.expect(x == expected);
652}
653
654test "fixtfsi" {
655 try test__fixtfsi(-math.floatMax(f128), math.minInt(i32));
656
657 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
658 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000);
659
660 try test__fixtfsi(-0x1.0000000000000p+127, -0x80000000);
661 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
662 try test__fixtfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
663
664 try test__fixtfsi(-0x1.0000000000001p+63, -0x80000000);
665 try test__fixtfsi(-0x1.0000000000000p+63, -0x80000000);
666 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
667 try test__fixtfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
668
669 try test__fixtfsi(-0x1.FFFFFEp+62, -0x80000000);
670 try test__fixtfsi(-0x1.FFFFFCp+62, -0x80000000);
671
672 try test__fixtfsi(-0x1.000000p+31, -0x80000000);
673 try test__fixtfsi(-0x1.FFFFFFp+30, -0x7FFFFFC0);
674 try test__fixtfsi(-0x1.FFFFFEp+30, -0x7FFFFF80);
675 try test__fixtfsi(-0x1.FFFFFCp+30, -0x7FFFFF00);
676
677 try test__fixtfsi(-2.01, -2);
678 try test__fixtfsi(-2.0, -2);
679 try test__fixtfsi(-1.99, -1);
680 try test__fixtfsi(-1.0, -1);
681 try test__fixtfsi(-0.99, 0);
682 try test__fixtfsi(-0.5, 0);
683 try test__fixtfsi(-math.floatMin(f32), 0);
684 try test__fixtfsi(0.0, 0);
685 try test__fixtfsi(math.floatMin(f32), 0);
686 try test__fixtfsi(0.5, 0);
687 try test__fixtfsi(0.99, 0);
688 try test__fixtfsi(1.0, 1);
689 try test__fixtfsi(1.5, 1);
690 try test__fixtfsi(1.99, 1);
691 try test__fixtfsi(2.0, 2);
692 try test__fixtfsi(2.01, 2);
693
694 try test__fixtfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
695 try test__fixtfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
696 try test__fixtfsi(0x1.FFFFFFp+30, 0x7FFFFFC0);
697 try test__fixtfsi(0x1.000000p+31, 0x7FFFFFFF);
698
699 try test__fixtfsi(0x1.FFFFFCp+62, 0x7FFFFFFF);
700 try test__fixtfsi(0x1.FFFFFEp+62, 0x7FFFFFFF);
701
702 try test__fixtfsi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFF);
703 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFF);
704 try test__fixtfsi(0x1.0000000000000p+63, 0x7FFFFFFF);
705 try test__fixtfsi(0x1.0000000000001p+63, 0x7FFFFFFF);
706
707 try test__fixtfsi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFF);
708 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFF);
709 try test__fixtfsi(0x1.0000000000000p+127, 0x7FFFFFFF);
710
711 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF);
712 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32));
713
714 try test__fixtfsi(math.floatMax(f128), math.maxInt(i32));
715}
716
717test "fixunstfsi" {
718 try test__fixunstfsi(math.inf(f128), 0xffffffff);
719 try test__fixunstfsi(0, 0x0);
720 try test__fixunstfsi(0x1.23456789abcdefp+5, 0x24);
721 try test__fixunstfsi(0x1.23456789abcdefp-3, 0x0);
722 try test__fixunstfsi(0x1.23456789abcdefp+20, 0x123456);
723 try test__fixunstfsi(0x1.23456789abcdefp+40, 0xffffffff);
724 try test__fixunstfsi(0x1.23456789abcdefp+256, 0xffffffff);
725 try test__fixunstfsi(-0x1.23456789abcdefp+3, 0x0);
726
727 try test__fixunstfsi(0x1p+32, 0xFFFFFFFF);
728}
729
730fn test__fixtfdi(a: f128, expected: i64) !void {
731 const x = __fixtfdi(a);
732 try testing.expect(x == expected);
733}
734
735fn test__fixunstfdi(a: f128, expected: u64) !void {
736 const x = __fixunstfdi(a);
737 try testing.expect(x == expected);
738}
739
740test "fixtfdi" {
741 try test__fixtfdi(-math.floatMax(f128), math.minInt(i64));
742
743 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
744 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000);
745
746 try test__fixtfdi(-0x1.0000000000000p+127, -0x8000000000000000);
747 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
748 try test__fixtfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
749
750 try test__fixtfdi(-0x1.0000000000001p+63, -0x8000000000000000);
751 try test__fixtfdi(-0x1.0000000000000p+63, -0x8000000000000000);
752 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
753 try test__fixtfdi(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
754
755 try test__fixtfdi(-0x1.FFFFFEp+62, -0x7FFFFF8000000000);
756 try test__fixtfdi(-0x1.FFFFFCp+62, -0x7FFFFF0000000000);
757
758 try test__fixtfdi(-0x1.000000p+31, -0x80000000);
759 try test__fixtfdi(-0x1.FFFFFFp+30, -0x7FFFFFC0);
760 try test__fixtfdi(-0x1.FFFFFEp+30, -0x7FFFFF80);
761 try test__fixtfdi(-0x1.FFFFFCp+30, -0x7FFFFF00);
762
763 try test__fixtfdi(-2.01, -2);
764 try test__fixtfdi(-2.0, -2);
765 try test__fixtfdi(-1.99, -1);
766 try test__fixtfdi(-1.0, -1);
767 try test__fixtfdi(-0.99, 0);
768 try test__fixtfdi(-0.5, 0);
769 try test__fixtfdi(-math.floatMin(f64), 0);
770 try test__fixtfdi(0.0, 0);
771 try test__fixtfdi(math.floatMin(f64), 0);
772 try test__fixtfdi(0.5, 0);
773 try test__fixtfdi(0.99, 0);
774 try test__fixtfdi(1.0, 1);
775 try test__fixtfdi(1.5, 1);
776 try test__fixtfdi(1.99, 1);
777 try test__fixtfdi(2.0, 2);
778 try test__fixtfdi(2.01, 2);
779
780 try test__fixtfdi(0x1.FFFFFCp+30, 0x7FFFFF00);
781 try test__fixtfdi(0x1.FFFFFEp+30, 0x7FFFFF80);
782 try test__fixtfdi(0x1.FFFFFFp+30, 0x7FFFFFC0);
783 try test__fixtfdi(0x1.000000p+31, 0x80000000);
784
785 try test__fixtfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
786 try test__fixtfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
787
788 try test__fixtfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
789 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
790 try test__fixtfdi(0x1.0000000000000p+63, 0x7FFFFFFFFFFFFFFF);
791 try test__fixtfdi(0x1.0000000000001p+63, 0x7FFFFFFFFFFFFFFF);
792
793 try test__fixtfdi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFF);
794 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFF);
795 try test__fixtfdi(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFF);
796
797 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF);
798 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64));
799
800 try test__fixtfdi(math.floatMax(f128), math.maxInt(i64));
801}
802
803test "fixunstfdi" {
804 try test__fixunstfdi(0.0, 0);
805
806 try test__fixunstfdi(0.5, 0);
807 try test__fixunstfdi(0.99, 0);
808 try test__fixunstfdi(1.0, 1);
809 try test__fixunstfdi(1.5, 1);
810 try test__fixunstfdi(1.99, 1);
811 try test__fixunstfdi(2.0, 2);
812 try test__fixunstfdi(2.01, 2);
813 try test__fixunstfdi(-0.5, 0);
814 try test__fixunstfdi(-0.99, 0);
815 try test__fixunstfdi(-1.0, 0);
816 try test__fixunstfdi(-1.5, 0);
817 try test__fixunstfdi(-1.99, 0);
818 try test__fixunstfdi(-2.0, 0);
819 try test__fixunstfdi(-2.01, 0);
820
821 try test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
822 try test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
823
824 try test__fixunstfdi(-0x1.FFFFFEp+62, 0);
825 try test__fixunstfdi(-0x1.FFFFFCp+62, 0);
826
827 try test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
828 try test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
829
830 try test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0);
831 try test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0);
832
833 try test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63, 0xFFFFFFFFFFFFFFFF);
834 try test__fixunstfdi(0x1.0000000000000002p+63, 0x8000000000000001);
835 try test__fixunstfdi(0x1.0000000000000000p+63, 0x8000000000000000);
836 try test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62, 0x7FFFFFFFFFFFFFFF);
837 try test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62, 0x7FFFFFFFFFFFFFFE);
838 try test__fixunstfdi(0x1p+64, 0xFFFFFFFFFFFFFFFF);
839
840 try test__fixunstfdi(-0x1.0000000000000000p+63, 0);
841 try test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62, 0);
842 try test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62, 0);
843}
844
845fn test__fixtfti(a: f128, expected: i128) !void {
846 const x = __fixtfti(a);
847 try testing.expect(x == expected);
848}
849
850fn test__fixunstfti(a: f128, expected: u128) !void {
851 const x = __fixunstfti(a);
852 try testing.expect(x == expected);
853}
854
855test "fixtfti" {
856 try test__fixtfti(-math.floatMax(f128), math.minInt(i128));
857
858 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
859 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000);
860
861 try test__fixtfti(-0x1.0000000000000p+127, -0x80000000000000000000000000000000);
862 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+126, -0x7FFFFFFFFFFFFC000000000000000000);
863 try test__fixtfti(-0x1.FFFFFFFFFFFFEp+126, -0x7FFFFFFFFFFFF8000000000000000000);
864
865 try test__fixtfti(-0x1.0000000000001p+63, -0x8000000000000800);
866 try test__fixtfti(-0x1.0000000000000p+63, -0x8000000000000000);
867 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
868 try test__fixtfti(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
869
870 try test__fixtfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
871 try test__fixtfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
872
873 try test__fixtfti(-2.01, -2);
874 try test__fixtfti(-2.0, -2);
875 try test__fixtfti(-1.99, -1);
876 try test__fixtfti(-1.0, -1);
877 try test__fixtfti(-0.99, 0);
878 try test__fixtfti(-0.5, 0);
879 try test__fixtfti(-math.floatMin(f128), 0);
880 try test__fixtfti(0.0, 0);
881 try test__fixtfti(math.floatMin(f128), 0);
882 try test__fixtfti(0.5, 0);
883 try test__fixtfti(0.99, 0);
884 try test__fixtfti(1.0, 1);
885 try test__fixtfti(1.5, 1);
886 try test__fixtfti(1.99, 1);
887 try test__fixtfti(2.0, 2);
888 try test__fixtfti(2.01, 2);
889
890 try test__fixtfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
891 try test__fixtfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
892
893 try test__fixtfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
894 try test__fixtfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
895 try test__fixtfti(0x1.0000000000000p+63, 0x8000000000000000);
896 try test__fixtfti(0x1.0000000000001p+63, 0x8000000000000800);
897
898 try test__fixtfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFF8000000000000000000);
899 try test__fixtfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFC000000000000000000);
900 try test__fixtfti(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
901
902 try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
903 try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128));
904
905 try test__fixtfti(math.floatMax(f128), math.maxInt(i128));
906}
907
908test "fixunstfti" {
909 try test__fixunstfti(math.inf(f128), 0xffffffffffffffffffffffffffffffff);
910
911 try test__fixunstfti(0.0, 0);
912
913 try test__fixunstfti(0.5, 0);
914 try test__fixunstfti(0.99, 0);
915 try test__fixunstfti(1.0, 1);
916 try test__fixunstfti(1.5, 1);
917 try test__fixunstfti(1.99, 1);
918 try test__fixunstfti(2.0, 2);
919 try test__fixunstfti(2.01, 2);
920 try test__fixunstfti(-0.01, 0);
921 try test__fixunstfti(-0.99, 0);
922
923 try test__fixunstfti(0x1p+128, 0xffffffffffffffffffffffffffffffff);
924
925 try test__fixunstfti(0x1.FFFFFEp+126, 0x7fffff80000000000000000000000000);
926 try test__fixunstfti(0x1.FFFFFEp+127, 0xffffff00000000000000000000000000);
927 try test__fixunstfti(0x1.FFFFFEp+128, 0xffffffffffffffffffffffffffffffff);
928 try test__fixunstfti(0x1.FFFFFEp+129, 0xffffffffffffffffffffffffffffffff);
929}
930
931fn test__fixunshfti(a: f16, expected: u128) !void {
932 const x = __fixunshfti(a);
933 try testing.expect(x == expected);
934}
935
936test "fixunshfti for f16" {
937 try test__fixunshfti(math.inf(f16), math.maxInt(u128));
938 try test__fixunshfti(math.floatMax(f16), 65504);
939}
940
941fn test__fixunsxfti(a: f80, expected: u128) !void {
942 const x = __fixunsxfti(a);
943 try testing.expect(x == expected);
944}
945
946test "fixunsxfti for f80" {
947 try test__fixunsxfti(math.inf(f80), math.maxInt(u128));
948 try test__fixunsxfti(math.floatMax(f80), math.maxInt(u128));
949 try test__fixunsxfti(math.maxInt(u64), math.maxInt(u64));
950}
lib/compiler_rt/floatdidf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatdidf(a: i64) callconv(.C) f64 {
15 return intToFloat(f64, a);
15 return floatFromInt(f64, a);
1616}
1717
1818fn __aeabi_l2d(a: i64) callconv(.AAPCS) f64 {
19 return intToFloat(f64, a);
19 return floatFromInt(f64, a);
2020}
lib/compiler_rt/floatdihf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatdihf(a: i64) callconv(.C) f16 {
11 return intToFloat(f16, a);
11 return floatFromInt(f16, a);
1212}
lib/compiler_rt/floatdisf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatdisf(a: i64) callconv(.C) f32 {
15 return intToFloat(f32, a);
15 return floatFromInt(f32, a);
1616}
1717
1818fn __aeabi_l2f(a: i64) callconv(.AAPCS) f32 {
19 return intToFloat(f32, a);
19 return floatFromInt(f32, a);
2020}
lib/compiler_rt/floatditf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatditf(a: i64) callconv(.C) f128 {
16 return intToFloat(f128, a);
16 return floatFromInt(f128, a);
1717}
1818
1919fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
20 c.* = intToFloat(f128, a);
20 c.* = floatFromInt(f128, a);
2121}
lib/compiler_rt/floatdixf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatdixf(a: i64) callconv(.C) f80 {
11 return intToFloat(f80, a);
11 return floatFromInt(f80, a);
1212}
lib/compiler_rt/floatsidf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatsidf(a: i32) callconv(.C) f64 {
15 return intToFloat(f64, a);
15 return floatFromInt(f64, a);
1616}
1717
1818fn __aeabi_i2d(a: i32) callconv(.AAPCS) f64 {
19 return intToFloat(f64, a);
19 return floatFromInt(f64, a);
2020}
lib/compiler_rt/floatsihf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatsihf(a: i32) callconv(.C) f16 {
11 return intToFloat(f16, a);
11 return floatFromInt(f16, a);
1212}
lib/compiler_rt/floatsisf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatsisf(a: i32) callconv(.C) f32 {
15 return intToFloat(f32, a);
15 return floatFromInt(f32, a);
1616}
1717
1818fn __aeabi_i2f(a: i32) callconv(.AAPCS) f32 {
19 return intToFloat(f32, a);
19 return floatFromInt(f32, a);
2020}
lib/compiler_rt/floatsitf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatsitf(a: i32) callconv(.C) f128 {
16 return intToFloat(f128, a);
16 return floatFromInt(f128, a);
1717}
1818
1919fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
20 c.* = intToFloat(f128, a);
20 c.* = floatFromInt(f128, a);
2121}
lib/compiler_rt/floatsixf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatsixf(a: i32) callconv(.C) f80 {
11 return intToFloat(f80, a);
11 return floatFromInt(f80, a);
1212}
lib/compiler_rt/floattidf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floattidf(a: i128) callconv(.C) f64 {
16 return intToFloat(f64, a);
16 return floatFromInt(f64, a);
1717}
1818
1919fn __floattidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 {
20 return intToFloat(f64, @bitCast(i128, a));
20 return floatFromInt(f64, @bitCast(i128, a));
2121}
lib/compiler_rt/floattihf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floattihf(a: i128) callconv(.C) f16 {
16 return intToFloat(f16, a);
16 return floatFromInt(f16, a);
1717}
1818
1919fn __floattihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 {
20 return intToFloat(f16, @bitCast(i128, a));
20 return floatFromInt(f16, @bitCast(i128, a));
2121}
lib/compiler_rt/floattisf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floattisf(a: i128) callconv(.C) f32 {
16 return intToFloat(f32, a);
16 return floatFromInt(f32, a);
1717}
1818
1919fn __floattisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 {
20 return intToFloat(f32, @bitCast(i128, a));
20 return floatFromInt(f32, @bitCast(i128, a));
2121}
lib/compiler_rt/floattitf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -15,9 +15,9 @@ comptime {
1515}
1616
1717pub fn __floattitf(a: i128) callconv(.C) f128 {
18 return intToFloat(f128, a);
18 return floatFromInt(f128, a);
1919}
2020
2121fn __floattitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 {
22 return intToFloat(f128, @bitCast(i128, a));
22 return floatFromInt(f128, @bitCast(i128, a));
2323}
lib/compiler_rt/floattixf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floattixf(a: i128) callconv(.C) f80 {
16 return intToFloat(f80, a);
16 return floatFromInt(f80, a);
1717}
1818
1919fn __floattixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 {
20 return intToFloat(f80, @bitCast(i128, a));
20 return floatFromInt(f80, @bitCast(i128, a));
2121}
lib/compiler_rt/floatundidf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatundidf(a: u64) callconv(.C) f64 {
15 return intToFloat(f64, a);
15 return floatFromInt(f64, a);
1616}
1717
1818fn __aeabi_ul2d(a: u64) callconv(.AAPCS) f64 {
19 return intToFloat(f64, a);
19 return floatFromInt(f64, a);
2020}
lib/compiler_rt/floatundihf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatundihf(a: u64) callconv(.C) f16 {
11 return intToFloat(f16, a);
11 return floatFromInt(f16, a);
1212}
lib/compiler_rt/floatundisf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatundisf(a: u64) callconv(.C) f32 {
15 return intToFloat(f32, a);
15 return floatFromInt(f32, a);
1616}
1717
1818fn __aeabi_ul2f(a: u64) callconv(.AAPCS) f32 {
19 return intToFloat(f32, a);
19 return floatFromInt(f32, a);
2020}
lib/compiler_rt/floatunditf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatunditf(a: u64) callconv(.C) f128 {
16 return intToFloat(f128, a);
16 return floatFromInt(f128, a);
1717}
1818
1919fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
20 c.* = intToFloat(f128, a);
20 c.* = floatFromInt(f128, a);
2121}
lib/compiler_rt/floatundixf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatundixf(a: u64) callconv(.C) f80 {
11 return intToFloat(f80, a);
11 return floatFromInt(f80, a);
1212}
lib/compiler_rt/floatunsidf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatunsidf(a: u32) callconv(.C) f64 {
15 return intToFloat(f64, a);
15 return floatFromInt(f64, a);
1616}
1717
1818fn __aeabi_ui2d(a: u32) callconv(.AAPCS) f64 {
19 return intToFloat(f64, a);
19 return floatFromInt(f64, a);
2020}
lib/compiler_rt/floatunsihf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010pub fn __floatunsihf(a: u32) callconv(.C) f16 {
11 return intToFloat(f16, a);
11 return floatFromInt(f16, a);
1212}
lib/compiler_rt/floatunsisf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -12,9 +12,9 @@ comptime {
1212}
1313
1414pub fn __floatunsisf(a: u32) callconv(.C) f32 {
15 return intToFloat(f32, a);
15 return floatFromInt(f32, a);
1616}
1717
1818fn __aeabi_ui2f(a: u32) callconv(.AAPCS) f32 {
19 return intToFloat(f32, a);
19 return floatFromInt(f32, a);
2020}
lib/compiler_rt/floatunsitf.zig+3-3
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatunsitf(a: u32) callconv(.C) f128 {
16 return intToFloat(f128, a);
16 return floatFromInt(f128, a);
1717}
1818
1919fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
20 c.* = intToFloat(f128, a);
20 c.* = floatFromInt(f128, a);
2121}
lib/compiler_rt/floatunsixf.zig+2-2
......@@ -1,5 +1,5 @@
11const common = @import("./common.zig");
2const intToFloat = @import("./int_to_float.zig").intToFloat;
2const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33
44pub const panic = common.panic;
55
......@@ -8,5 +8,5 @@ comptime {
88}
99
1010fn __floatunsixf(a: u32) callconv(.C) f80 {
11 return intToFloat(f80, a);
11 return floatFromInt(f80, a);
1212}
lib/compiler_rt/floatuntidf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatuntidf(a: u128) callconv(.C) f64 {
16 return intToFloat(f64, a);
16 return floatFromInt(f64, a);
1717}
1818
1919fn __floatuntidf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f64 {
20 return intToFloat(f64, @bitCast(u128, a));
20 return floatFromInt(f64, @bitCast(u128, a));
2121}
lib/compiler_rt/floatuntihf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatuntihf(a: u128) callconv(.C) f16 {
16 return intToFloat(f16, a);
16 return floatFromInt(f16, a);
1717}
1818
1919fn __floatuntihf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f16 {
20 return intToFloat(f16, @bitCast(u128, a));
20 return floatFromInt(f16, @bitCast(u128, a));
2121}
lib/compiler_rt/floatuntisf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatuntisf(a: u128) callconv(.C) f32 {
16 return intToFloat(f32, a);
16 return floatFromInt(f32, a);
1717}
1818
1919fn __floatuntisf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f32 {
20 return intToFloat(f32, @bitCast(u128, a));
20 return floatFromInt(f32, @bitCast(u128, a));
2121}
lib/compiler_rt/floatuntitf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -15,9 +15,9 @@ comptime {
1515}
1616
1717pub fn __floatuntitf(a: u128) callconv(.C) f128 {
18 return intToFloat(f128, a);
18 return floatFromInt(f128, a);
1919}
2020
2121fn __floatuntitf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f128 {
22 return intToFloat(f128, @bitCast(u128, a));
22 return floatFromInt(f128, @bitCast(u128, a));
2323}
lib/compiler_rt/floatuntixf.zig+3-3
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const common = @import("./common.zig");
3const intToFloat = @import("./int_to_float.zig").intToFloat;
3const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55pub const panic = common.panic;
66
......@@ -13,9 +13,9 @@ comptime {
1313}
1414
1515pub fn __floatuntixf(a: u128) callconv(.C) f80 {
16 return intToFloat(f80, a);
16 return floatFromInt(f80, a);
1717}
1818
1919fn __floatuntixf_windows_x86_64(a: @Vector(2, u64)) callconv(.C) f80 {
20 return intToFloat(f80, @bitCast(u128, a));
20 return floatFromInt(f80, @bitCast(u128, a));
2121}
lib/compiler_rt/gedf2.zig+3-3
......@@ -18,7 +18,7 @@ comptime {
1818/// "These functions return a value greater than or equal to zero if neither
1919/// argument is NaN, and a is greater than or equal to b."
2020pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 {
21 return @enumToInt(comparef.cmpf2(f64, comparef.GE, a, b));
21 return @intFromEnum(comparef.cmpf2(f64, comparef.GE, a, b));
2222}
2323
2424/// "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 {
2828}
2929
3030fn __aeabi_dcmpge(a: f64, b: f64) callconv(.AAPCS) i32 {
31 return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) != .Less);
31 return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) != .Less);
3232}
3333
3434fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.AAPCS) i32 {
35 return @boolToInt(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater);
35 return @intFromBool(comparef.cmpf2(f64, comparef.GE, a, b) == .Greater);
3636}
lib/compiler_rt/gehf2.zig+1-1
......@@ -13,7 +13,7 @@ comptime {
1313/// "These functions return a value greater than or equal to zero if neither
1414/// argument is NaN, and a is greater than or equal to b."
1515pub fn __gehf2(a: f16, b: f16) callconv(.C) i32 {
16 return @enumToInt(comparef.cmpf2(f16, comparef.GE, a, b));
16 return @intFromEnum(comparef.cmpf2(f16, comparef.GE, a, b));
1717}
1818
1919/// "These functions return a value greater than zero if neither argument is NaN,
lib/compiler_rt/gesf2.zig+3-3
......@@ -18,7 +18,7 @@ comptime {
1818/// "These functions return a value greater than or equal to zero if neither
1919/// argument is NaN, and a is greater than or equal to b."
2020pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 {
21 return @enumToInt(comparef.cmpf2(f32, comparef.GE, a, b));
21 return @intFromEnum(comparef.cmpf2(f32, comparef.GE, a, b));
2222}
2323
2424/// "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 {
2828}
2929
3030fn __aeabi_fcmpge(a: f32, b: f32) callconv(.AAPCS) i32 {
31 return @boolToInt(comparef.cmpf2(f32, comparef.GE, a, b) != .Less);
31 return @intFromBool(comparef.cmpf2(f32, comparef.GE, a, b) != .Less);
3232}
3333
3434fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.AAPCS) i32 {
35 return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater);
35 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Greater);
3636}
lib/compiler_rt/getf2.zig+1-1
......@@ -20,7 +20,7 @@ comptime {
2020/// "These functions return a value greater than or equal to zero if neither
2121/// argument is NaN, and a is greater than or equal to b."
2222fn __getf2(a: f128, b: f128) callconv(.C) i32 {
23 return @enumToInt(comparef.cmpf2(f128, comparef.GE, a, b));
23 return @intFromEnum(comparef.cmpf2(f128, comparef.GE, a, b));
2424}
2525
2626/// "These functions return a value greater than zero if neither argument is NaN,
lib/compiler_rt/gexf2.zig+1-1
......@@ -9,7 +9,7 @@ comptime {
99}
1010
1111fn __gexf2(a: f80, b: f80) callconv(.C) i32 {
12 return @enumToInt(comparef.cmp_f80(comparef.GE, a, b));
12 return @intFromEnum(comparef.cmp_f80(comparef.GE, a, b));
1313}
1414
1515fn __gtxf2(a: f80, b: f80) callconv(.C) i32 {
lib/compiler_rt/int_from_float.zig created+55
......@@ -0,0 +1,55 @@
1const Int = @import("std").meta.Int;
2const math = @import("std").math;
3const Log2Int = math.Log2Int;
4
5pub inline fn intFromFloat(comptime I: type, a: anytype) I {
6 const F = @TypeOf(a);
7 const float_bits = @typeInfo(F).Float.bits;
8 const int_bits = @typeInfo(I).Int.bits;
9 const rep_t = Int(.unsigned, float_bits);
10 const sig_bits = math.floatMantissaBits(F);
11 const exp_bits = math.floatExponentBits(F);
12 const fractional_bits = math.floatFractionalBits(F);
13
14 const implicit_bit = if (F != f80) (@as(rep_t, 1) << sig_bits) else 0;
15 const max_exp = (1 << (exp_bits - 1));
16 const exp_bias = max_exp - 1;
17 const sig_mask = (@as(rep_t, 1) << sig_bits) - 1;
18
19 // Break a into sign, exponent, significand
20 const a_rep: rep_t = @bitCast(rep_t, a);
21 const negative = (a_rep >> (float_bits - 1)) != 0;
22 const exponent = @intCast(i32, (a_rep << 1) >> (sig_bits + 1)) - exp_bias;
23 const significand: rep_t = (a_rep & sig_mask) | implicit_bit;
24
25 // If the exponent is negative, the result rounds to zero.
26 if (exponent < 0) return 0;
27
28 // If the value is too large for the integer type, saturate.
29 switch (@typeInfo(I).Int.signedness) {
30 .unsigned => {
31 if (negative) return 0;
32 if (@intCast(c_uint, exponent) >= @min(int_bits, max_exp)) return math.maxInt(I);
33 },
34 .signed => if (@intCast(c_uint, exponent) >= @min(int_bits - 1, max_exp)) {
35 return if (negative) math.minInt(I) else math.maxInt(I);
36 },
37 }
38
39 // If 0 <= exponent < sig_bits, right shift to get the result.
40 // Otherwise, shift left.
41 var result: I = undefined;
42 if (exponent < fractional_bits) {
43 result = @intCast(I, significand >> @intCast(Log2Int(rep_t), fractional_bits - exponent));
44 } else {
45 result = @intCast(I, significand) << @intCast(Log2Int(I), exponent - fractional_bits);
46 }
47
48 if ((@typeInfo(I).Int.signedness == .signed) and negative)
49 return ~result +% 1;
50 return result;
51}
52
53test {
54 _ = @import("int_from_float_test.zig");
55}
lib/compiler_rt/int_from_float_test.zig created+950
......@@ -0,0 +1,950 @@
1const std = @import("std");
2const testing = std.testing;
3const math = std.math;
4
5const __fixunshfti = @import("fixunshfti.zig").__fixunshfti;
6const __fixunsxfti = @import("fixunsxfti.zig").__fixunsxfti;
7
8// Conversion from f32
9const __fixsfsi = @import("fixsfsi.zig").__fixsfsi;
10const __fixunssfsi = @import("fixunssfsi.zig").__fixunssfsi;
11const __fixsfdi = @import("fixsfdi.zig").__fixsfdi;
12const __fixunssfdi = @import("fixunssfdi.zig").__fixunssfdi;
13const __fixsfti = @import("fixsfti.zig").__fixsfti;
14const __fixunssfti = @import("fixunssfti.zig").__fixunssfti;
15
16// Conversion from f64
17const __fixdfsi = @import("fixdfsi.zig").__fixdfsi;
18const __fixunsdfsi = @import("fixunsdfsi.zig").__fixunsdfsi;
19const __fixdfdi = @import("fixdfdi.zig").__fixdfdi;
20const __fixunsdfdi = @import("fixunsdfdi.zig").__fixunsdfdi;
21const __fixdfti = @import("fixdfti.zig").__fixdfti;
22const __fixunsdfti = @import("fixunsdfti.zig").__fixunsdfti;
23
24// Conversion from f128
25const __fixtfsi = @import("fixtfsi.zig").__fixtfsi;
26const __fixunstfsi = @import("fixunstfsi.zig").__fixunstfsi;
27const __fixtfdi = @import("fixtfdi.zig").__fixtfdi;
28const __fixunstfdi = @import("fixunstfdi.zig").__fixunstfdi;
29const __fixtfti = @import("fixtfti.zig").__fixtfti;
30const __fixunstfti = @import("fixunstfti.zig").__fixunstfti;
31
32fn test__fixsfsi(a: f32, expected: i32) !void {
33 const x = __fixsfsi(a);
34 try testing.expect(x == expected);
35}
36
37fn test__fixunssfsi(a: f32, expected: u32) !void {
38 const x = __fixunssfsi(a);
39 try testing.expect(x == expected);
40}
41
42test "fixsfsi" {
43 try test__fixsfsi(-math.floatMax(f32), math.minInt(i32));
44
45 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
46 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000);
47
48 try test__fixsfsi(-0x1.0000000000000p+127, -0x80000000);
49 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
50 try test__fixsfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
51
52 try test__fixsfsi(-0x1.0000000000001p+63, -0x80000000);
53 try test__fixsfsi(-0x1.0000000000000p+63, -0x80000000);
54 try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
55 try test__fixsfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
56
57 try test__fixsfsi(-0x1.FFFFFEp+62, -0x80000000);
58 try test__fixsfsi(-0x1.FFFFFCp+62, -0x80000000);
59
60 try test__fixsfsi(-0x1.000000p+31, -0x80000000);
61 try test__fixsfsi(-0x1.FFFFFFp+30, -0x80000000);
62 try test__fixsfsi(-0x1.FFFFFEp+30, -0x7FFFFF80);
63 try test__fixsfsi(-0x1.FFFFFCp+30, -0x7FFFFF00);
64
65 try test__fixsfsi(-2.01, -2);
66 try test__fixsfsi(-2.0, -2);
67 try test__fixsfsi(-1.99, -1);
68 try test__fixsfsi(-1.0, -1);
69 try test__fixsfsi(-0.99, 0);
70 try test__fixsfsi(-0.5, 0);
71 try test__fixsfsi(-math.floatMin(f32), 0);
72 try test__fixsfsi(0.0, 0);
73 try test__fixsfsi(math.floatMin(f32), 0);
74 try test__fixsfsi(0.5, 0);
75 try test__fixsfsi(0.99, 0);
76 try test__fixsfsi(1.0, 1);
77 try test__fixsfsi(1.5, 1);
78 try test__fixsfsi(1.99, 1);
79 try test__fixsfsi(2.0, 2);
80 try test__fixsfsi(2.01, 2);
81
82 try test__fixsfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
83 try test__fixsfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
84 try test__fixsfsi(0x1.FFFFFFp+30, 0x7FFFFFFF);
85 try test__fixsfsi(0x1.000000p+31, 0x7FFFFFFF);
86
87 try test__fixsfsi(0x1.FFFFFCp+62, 0x7FFFFFFF);
88 try test__fixsfsi(0x1.FFFFFEp+62, 0x7FFFFFFF);
89
90 try test__fixsfsi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFF);
91 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFF);
92 try test__fixsfsi(0x1.0000000000000p+63, 0x7FFFFFFF);
93 try test__fixsfsi(0x1.0000000000001p+63, 0x7FFFFFFF);
94
95 try test__fixsfsi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFF);
96 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFF);
97 try test__fixsfsi(0x1.0000000000000p+127, 0x7FFFFFFF);
98
99 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF);
100 try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32));
101
102 try test__fixsfsi(math.floatMax(f32), math.maxInt(i32));
103}
104
105test "fixunssfsi" {
106 try test__fixunssfsi(0.0, 0);
107
108 try test__fixunssfsi(0.5, 0);
109 try test__fixunssfsi(0.99, 0);
110 try test__fixunssfsi(1.0, 1);
111 try test__fixunssfsi(1.5, 1);
112 try test__fixunssfsi(1.99, 1);
113 try test__fixunssfsi(2.0, 2);
114 try test__fixunssfsi(2.01, 2);
115 try test__fixunssfsi(-0.5, 0);
116 try test__fixunssfsi(-0.99, 0);
117
118 try test__fixunssfsi(-1.0, 0);
119 try test__fixunssfsi(-1.5, 0);
120 try test__fixunssfsi(-1.99, 0);
121 try test__fixunssfsi(-2.0, 0);
122 try test__fixunssfsi(-2.01, 0);
123
124 try test__fixunssfsi(0x1.000000p+31, 0x80000000);
125 try test__fixunssfsi(0x1.000000p+32, 0xFFFFFFFF);
126 try test__fixunssfsi(0x1.FFFFFEp+31, 0xFFFFFF00);
127 try test__fixunssfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
128 try test__fixunssfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
129
130 try test__fixunssfsi(-0x1.FFFFFEp+30, 0);
131 try test__fixunssfsi(-0x1.FFFFFCp+30, 0);
132}
133
134fn test__fixsfdi(a: f32, expected: i64) !void {
135 const x = __fixsfdi(a);
136 try testing.expect(x == expected);
137}
138
139fn test__fixunssfdi(a: f32, expected: u64) !void {
140 const x = __fixunssfdi(a);
141 try testing.expect(x == expected);
142}
143
144test "fixsfdi" {
145 try test__fixsfdi(-math.floatMax(f32), math.minInt(i64));
146
147 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
148 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000);
149
150 try test__fixsfdi(-0x1.0000000000000p+127, -0x8000000000000000);
151 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
152 try test__fixsfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
153
154 try test__fixsfdi(-0x1.0000000000001p+63, -0x8000000000000000);
155 try test__fixsfdi(-0x1.0000000000000p+63, -0x8000000000000000);
156 try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+62, -0x8000000000000000);
157 try test__fixsfdi(-0x1.FFFFFFFFFFFFEp+62, -0x8000000000000000);
158
159 try test__fixsfdi(-0x1.FFFFFFp+62, -0x8000000000000000);
160 try test__fixsfdi(-0x1.FFFFFEp+62, -0x7fffff8000000000);
161 try test__fixsfdi(-0x1.FFFFFCp+62, -0x7fffff0000000000);
162
163 try test__fixsfdi(-2.01, -2);
164 try test__fixsfdi(-2.0, -2);
165 try test__fixsfdi(-1.99, -1);
166 try test__fixsfdi(-1.0, -1);
167 try test__fixsfdi(-0.99, 0);
168 try test__fixsfdi(-0.5, 0);
169 try test__fixsfdi(-math.floatMin(f32), 0);
170 try test__fixsfdi(0.0, 0);
171 try test__fixsfdi(math.floatMin(f32), 0);
172 try test__fixsfdi(0.5, 0);
173 try test__fixsfdi(0.99, 0);
174 try test__fixsfdi(1.0, 1);
175 try test__fixsfdi(1.5, 1);
176 try test__fixsfdi(1.99, 1);
177 try test__fixsfdi(2.0, 2);
178 try test__fixsfdi(2.01, 2);
179
180 try test__fixsfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
181 try test__fixsfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
182 try test__fixsfdi(0x1.FFFFFFp+62, 0x7FFFFFFFFFFFFFFF);
183
184 try test__fixsfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFFFFF);
185 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFFFF);
186 try test__fixsfdi(0x1.0000000000000p+63, 0x7FFFFFFFFFFFFFFF);
187 try test__fixsfdi(0x1.0000000000001p+63, 0x7FFFFFFFFFFFFFFF);
188
189 try test__fixsfdi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFF);
190 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFF);
191 try test__fixsfdi(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFF);
192
193 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF);
194 try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64));
195
196 try test__fixsfdi(math.floatMax(f32), math.maxInt(i64));
197}
198
199test "fixunssfdi" {
200 try test__fixunssfdi(0.0, 0);
201
202 try test__fixunssfdi(0.5, 0);
203 try test__fixunssfdi(0.99, 0);
204 try test__fixunssfdi(1.0, 1);
205 try test__fixunssfdi(1.5, 1);
206 try test__fixunssfdi(1.99, 1);
207 try test__fixunssfdi(2.0, 2);
208 try test__fixunssfdi(2.01, 2);
209 try test__fixunssfdi(-0.5, 0);
210 try test__fixunssfdi(-0.99, 0);
211
212 try test__fixunssfdi(-1.0, 0);
213 try test__fixunssfdi(-1.5, 0);
214 try test__fixunssfdi(-1.99, 0);
215 try test__fixunssfdi(-2.0, 0);
216 try test__fixunssfdi(-2.01, 0);
217
218 try test__fixunssfdi(0x1.FFFFFEp+63, 0xFFFFFF0000000000);
219 try test__fixunssfdi(0x1.000000p+63, 0x8000000000000000);
220 try test__fixunssfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
221 try test__fixunssfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
222
223 try test__fixunssfdi(-0x1.FFFFFEp+62, 0x0000000000000000);
224 try test__fixunssfdi(-0x1.FFFFFCp+62, 0x0000000000000000);
225}
226
227fn test__fixsfti(a: f32, expected: i128) !void {
228 const x = __fixsfti(a);
229 try testing.expect(x == expected);
230}
231
232fn test__fixunssfti(a: f32, expected: u128) !void {
233 const x = __fixunssfti(a);
234 try testing.expect(x == expected);
235}
236
237test "fixsfti" {
238 try test__fixsfti(-math.floatMax(f32), math.minInt(i128));
239
240 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
241 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000);
242
243 try test__fixsfti(-0x1.0000000000000p+127, -0x80000000000000000000000000000000);
244 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+126, -0x80000000000000000000000000000000);
245 try test__fixsfti(-0x1.FFFFFFFFFFFFEp+126, -0x80000000000000000000000000000000);
246 try test__fixsfti(-0x1.FFFFFF0000000p+126, -0x80000000000000000000000000000000);
247 try test__fixsfti(-0x1.FFFFFE0000000p+126, -0x7FFFFF80000000000000000000000000);
248 try test__fixsfti(-0x1.FFFFFC0000000p+126, -0x7FFFFF00000000000000000000000000);
249
250 try test__fixsfti(-0x1.0000000000001p+63, -0x8000000000000000);
251 try test__fixsfti(-0x1.0000000000000p+63, -0x8000000000000000);
252 try test__fixsfti(-0x1.FFFFFFFFFFFFFp+62, -0x8000000000000000);
253 try test__fixsfti(-0x1.FFFFFFFFFFFFEp+62, -0x8000000000000000);
254
255 try test__fixsfti(-0x1.FFFFFFp+62, -0x8000000000000000);
256 try test__fixsfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
257 try test__fixsfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
258
259 try test__fixsfti(-0x1.000000p+31, -0x80000000);
260 try test__fixsfti(-0x1.FFFFFFp+30, -0x80000000);
261 try test__fixsfti(-0x1.FFFFFEp+30, -0x7FFFFF80);
262 try test__fixsfti(-0x1.FFFFFCp+30, -0x7FFFFF00);
263
264 try test__fixsfti(-2.01, -2);
265 try test__fixsfti(-2.0, -2);
266 try test__fixsfti(-1.99, -1);
267 try test__fixsfti(-1.0, -1);
268 try test__fixsfti(-0.99, 0);
269 try test__fixsfti(-0.5, 0);
270 try test__fixsfti(-math.floatMin(f32), 0);
271 try test__fixsfti(0.0, 0);
272 try test__fixsfti(math.floatMin(f32), 0);
273 try test__fixsfti(0.5, 0);
274 try test__fixsfti(0.99, 0);
275 try test__fixsfti(1.0, 1);
276 try test__fixsfti(1.5, 1);
277 try test__fixsfti(1.99, 1);
278 try test__fixsfti(2.0, 2);
279 try test__fixsfti(2.01, 2);
280
281 try test__fixsfti(0x1.FFFFFCp+30, 0x7FFFFF00);
282 try test__fixsfti(0x1.FFFFFEp+30, 0x7FFFFF80);
283 try test__fixsfti(0x1.FFFFFFp+30, 0x80000000);
284 try test__fixsfti(0x1.000000p+31, 0x80000000);
285
286 try test__fixsfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
287 try test__fixsfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
288 try test__fixsfti(0x1.FFFFFFp+62, 0x8000000000000000);
289
290 try test__fixsfti(0x1.FFFFFFFFFFFFEp+62, 0x8000000000000000);
291 try test__fixsfti(0x1.FFFFFFFFFFFFFp+62, 0x8000000000000000);
292 try test__fixsfti(0x1.0000000000000p+63, 0x8000000000000000);
293 try test__fixsfti(0x1.0000000000001p+63, 0x8000000000000000);
294
295 try test__fixsfti(0x1.FFFFFC0000000p+126, 0x7FFFFF00000000000000000000000000);
296 try test__fixsfti(0x1.FFFFFE0000000p+126, 0x7FFFFF80000000000000000000000000);
297 try test__fixsfti(0x1.FFFFFF0000000p+126, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
298 try test__fixsfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
299 try test__fixsfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
300 try test__fixsfti(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
301
302 try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
303 try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128));
304
305 try test__fixsfti(math.floatMax(f32), math.maxInt(i128));
306}
307
308test "fixunssfti" {
309 try test__fixunssfti(0.0, 0);
310
311 try test__fixunssfti(0.5, 0);
312 try test__fixunssfti(0.99, 0);
313 try test__fixunssfti(1.0, 1);
314 try test__fixunssfti(1.5, 1);
315 try test__fixunssfti(1.99, 1);
316 try test__fixunssfti(2.0, 2);
317 try test__fixunssfti(2.01, 2);
318 try test__fixunssfti(-0.5, 0);
319 try test__fixunssfti(-0.99, 0);
320
321 try test__fixunssfti(-1.0, 0);
322 try test__fixunssfti(-1.5, 0);
323 try test__fixunssfti(-1.99, 0);
324 try test__fixunssfti(-2.0, 0);
325 try test__fixunssfti(-2.01, 0);
326
327 try test__fixunssfti(0x1.FFFFFEp+63, 0xFFFFFF0000000000);
328 try test__fixunssfti(0x1.000000p+63, 0x8000000000000000);
329 try test__fixunssfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
330 try test__fixunssfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
331 try test__fixunssfti(0x1.FFFFFEp+127, 0xFFFFFF00000000000000000000000000);
332 try test__fixunssfti(0x1.000000p+127, 0x80000000000000000000000000000000);
333 try test__fixunssfti(0x1.FFFFFEp+126, 0x7FFFFF80000000000000000000000000);
334 try test__fixunssfti(0x1.FFFFFCp+126, 0x7FFFFF00000000000000000000000000);
335
336 try test__fixunssfti(-0x1.FFFFFEp+62, 0x0000000000000000);
337 try test__fixunssfti(-0x1.FFFFFCp+62, 0x0000000000000000);
338 try test__fixunssfti(-0x1.FFFFFEp+126, 0x0000000000000000);
339 try test__fixunssfti(-0x1.FFFFFCp+126, 0x0000000000000000);
340 try test__fixunssfti(math.floatMax(f32), 0xffffff00000000000000000000000000);
341 try test__fixunssfti(math.inf(f32), math.maxInt(u128));
342}
343
344fn test__fixdfsi(a: f64, expected: i32) !void {
345 const x = __fixdfsi(a);
346 try testing.expect(x == expected);
347}
348
349fn test__fixunsdfsi(a: f64, expected: u32) !void {
350 const x = __fixunsdfsi(a);
351 try testing.expect(x == expected);
352}
353
354test "fixdfsi" {
355 try test__fixdfsi(-math.floatMax(f64), math.minInt(i32));
356
357 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
358 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000);
359
360 try test__fixdfsi(-0x1.0000000000000p+127, -0x80000000);
361 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
362 try test__fixdfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
363
364 try test__fixdfsi(-0x1.0000000000001p+63, -0x80000000);
365 try test__fixdfsi(-0x1.0000000000000p+63, -0x80000000);
366 try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
367 try test__fixdfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
368
369 try test__fixdfsi(-0x1.FFFFFEp+62, -0x80000000);
370 try test__fixdfsi(-0x1.FFFFFCp+62, -0x80000000);
371
372 try test__fixdfsi(-0x1.000000p+31, -0x80000000);
373 try test__fixdfsi(-0x1.FFFFFFp+30, -0x7FFFFFC0);
374 try test__fixdfsi(-0x1.FFFFFEp+30, -0x7FFFFF80);
375
376 try test__fixdfsi(-2.01, -2);
377 try test__fixdfsi(-2.0, -2);
378 try test__fixdfsi(-1.99, -1);
379 try test__fixdfsi(-1.0, -1);
380 try test__fixdfsi(-0.99, 0);
381 try test__fixdfsi(-0.5, 0);
382 try test__fixdfsi(-math.floatMin(f64), 0);
383 try test__fixdfsi(0.0, 0);
384 try test__fixdfsi(math.floatMin(f64), 0);
385 try test__fixdfsi(0.5, 0);
386 try test__fixdfsi(0.99, 0);
387 try test__fixdfsi(1.0, 1);
388 try test__fixdfsi(1.5, 1);
389 try test__fixdfsi(1.99, 1);
390 try test__fixdfsi(2.0, 2);
391 try test__fixdfsi(2.01, 2);
392
393 try test__fixdfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
394 try test__fixdfsi(0x1.FFFFFFp+30, 0x7FFFFFC0);
395 try test__fixdfsi(0x1.000000p+31, 0x7FFFFFFF);
396
397 try test__fixdfsi(0x1.FFFFFCp+62, 0x7FFFFFFF);
398 try test__fixdfsi(0x1.FFFFFEp+62, 0x7FFFFFFF);
399
400 try test__fixdfsi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFF);
401 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFF);
402 try test__fixdfsi(0x1.0000000000000p+63, 0x7FFFFFFF);
403 try test__fixdfsi(0x1.0000000000001p+63, 0x7FFFFFFF);
404
405 try test__fixdfsi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFF);
406 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFF);
407 try test__fixdfsi(0x1.0000000000000p+127, 0x7FFFFFFF);
408
409 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF);
410 try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32));
411
412 try test__fixdfsi(math.floatMax(f64), math.maxInt(i32));
413}
414
415test "fixunsdfsi" {
416 try test__fixunsdfsi(0.0, 0);
417
418 try test__fixunsdfsi(0.5, 0);
419 try test__fixunsdfsi(0.99, 0);
420 try test__fixunsdfsi(1.0, 1);
421 try test__fixunsdfsi(1.5, 1);
422 try test__fixunsdfsi(1.99, 1);
423 try test__fixunsdfsi(2.0, 2);
424 try test__fixunsdfsi(2.01, 2);
425 try test__fixunsdfsi(-0.5, 0);
426 try test__fixunsdfsi(-0.99, 0);
427 try test__fixunsdfsi(-1.0, 0);
428 try test__fixunsdfsi(-1.5, 0);
429 try test__fixunsdfsi(-1.99, 0);
430 try test__fixunsdfsi(-2.0, 0);
431 try test__fixunsdfsi(-2.01, 0);
432
433 try test__fixunsdfsi(0x1.000000p+31, 0x80000000);
434 try test__fixunsdfsi(0x1.000000p+32, 0xFFFFFFFF);
435 try test__fixunsdfsi(0x1.FFFFFEp+31, 0xFFFFFF00);
436 try test__fixunsdfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
437 try test__fixunsdfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
438
439 try test__fixunsdfsi(-0x1.FFFFFEp+30, 0);
440 try test__fixunsdfsi(-0x1.FFFFFCp+30, 0);
441
442 try test__fixunsdfsi(0x1.FFFFFFFEp+31, 0xFFFFFFFF);
443 try test__fixunsdfsi(0x1.FFFFFFFC00000p+30, 0x7FFFFFFF);
444 try test__fixunsdfsi(0x1.FFFFFFF800000p+30, 0x7FFFFFFE);
445}
446
447fn test__fixdfdi(a: f64, expected: i64) !void {
448 const x = __fixdfdi(a);
449 try testing.expect(x == expected);
450}
451
452fn test__fixunsdfdi(a: f64, expected: u64) !void {
453 const x = __fixunsdfdi(a);
454 try testing.expect(x == expected);
455}
456
457test "fixdfdi" {
458 try test__fixdfdi(-math.floatMax(f64), math.minInt(i64));
459
460 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
461 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000);
462
463 try test__fixdfdi(-0x1.0000000000000p+127, -0x8000000000000000);
464 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
465 try test__fixdfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
466
467 try test__fixdfdi(-0x1.0000000000001p+63, -0x8000000000000000);
468 try test__fixdfdi(-0x1.0000000000000p+63, -0x8000000000000000);
469 try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
470 try test__fixdfdi(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
471
472 try test__fixdfdi(-0x1.FFFFFEp+62, -0x7fffff8000000000);
473 try test__fixdfdi(-0x1.FFFFFCp+62, -0x7fffff0000000000);
474
475 try test__fixdfdi(-2.01, -2);
476 try test__fixdfdi(-2.0, -2);
477 try test__fixdfdi(-1.99, -1);
478 try test__fixdfdi(-1.0, -1);
479 try test__fixdfdi(-0.99, 0);
480 try test__fixdfdi(-0.5, 0);
481 try test__fixdfdi(-math.floatMin(f64), 0);
482 try test__fixdfdi(0.0, 0);
483 try test__fixdfdi(math.floatMin(f64), 0);
484 try test__fixdfdi(0.5, 0);
485 try test__fixdfdi(0.99, 0);
486 try test__fixdfdi(1.0, 1);
487 try test__fixdfdi(1.5, 1);
488 try test__fixdfdi(1.99, 1);
489 try test__fixdfdi(2.0, 2);
490 try test__fixdfdi(2.01, 2);
491
492 try test__fixdfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
493 try test__fixdfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
494
495 try test__fixdfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
496 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
497 try test__fixdfdi(0x1.0000000000000p+63, 0x7FFFFFFFFFFFFFFF);
498 try test__fixdfdi(0x1.0000000000001p+63, 0x7FFFFFFFFFFFFFFF);
499
500 try test__fixdfdi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFF);
501 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFF);
502 try test__fixdfdi(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFF);
503
504 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF);
505 try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64));
506
507 try test__fixdfdi(math.floatMax(f64), math.maxInt(i64));
508}
509
510test "fixunsdfdi" {
511 try test__fixunsdfdi(0.0, 0);
512 try test__fixunsdfdi(0.5, 0);
513 try test__fixunsdfdi(0.99, 0);
514 try test__fixunsdfdi(1.0, 1);
515 try test__fixunsdfdi(1.5, 1);
516 try test__fixunsdfdi(1.99, 1);
517 try test__fixunsdfdi(2.0, 2);
518 try test__fixunsdfdi(2.01, 2);
519 try test__fixunsdfdi(-0.5, 0);
520 try test__fixunsdfdi(-0.99, 0);
521 try test__fixunsdfdi(-1.0, 0);
522 try test__fixunsdfdi(-1.5, 0);
523 try test__fixunsdfdi(-1.99, 0);
524 try test__fixunsdfdi(-2.0, 0);
525 try test__fixunsdfdi(-2.01, 0);
526
527 try test__fixunsdfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
528 try test__fixunsdfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
529
530 try test__fixunsdfdi(-0x1.FFFFFEp+62, 0);
531 try test__fixunsdfdi(-0x1.FFFFFCp+62, 0);
532
533 try test__fixunsdfdi(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800);
534 try test__fixunsdfdi(0x1.0000000000000p+63, 0x8000000000000000);
535 try test__fixunsdfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
536 try test__fixunsdfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
537
538 try test__fixunsdfdi(-0x1.FFFFFFFFFFFFFp+62, 0);
539 try test__fixunsdfdi(-0x1.FFFFFFFFFFFFEp+62, 0);
540}
541
542fn test__fixdfti(a: f64, expected: i128) !void {
543 const x = __fixdfti(a);
544 try testing.expect(x == expected);
545}
546
547fn test__fixunsdfti(a: f64, expected: u128) !void {
548 const x = __fixunsdfti(a);
549 try testing.expect(x == expected);
550}
551
552test "fixdfti" {
553 try test__fixdfti(-math.floatMax(f64), math.minInt(i128));
554
555 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
556 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000);
557
558 try test__fixdfti(-0x1.0000000000000p+127, -0x80000000000000000000000000000000);
559 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+126, -0x7FFFFFFFFFFFFC000000000000000000);
560 try test__fixdfti(-0x1.FFFFFFFFFFFFEp+126, -0x7FFFFFFFFFFFF8000000000000000000);
561
562 try test__fixdfti(-0x1.0000000000001p+63, -0x8000000000000800);
563 try test__fixdfti(-0x1.0000000000000p+63, -0x8000000000000000);
564 try test__fixdfti(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
565 try test__fixdfti(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
566
567 try test__fixdfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
568 try test__fixdfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
569
570 try test__fixdfti(-2.01, -2);
571 try test__fixdfti(-2.0, -2);
572 try test__fixdfti(-1.99, -1);
573 try test__fixdfti(-1.0, -1);
574 try test__fixdfti(-0.99, 0);
575 try test__fixdfti(-0.5, 0);
576 try test__fixdfti(-math.floatMin(f64), 0);
577 try test__fixdfti(0.0, 0);
578 try test__fixdfti(math.floatMin(f64), 0);
579 try test__fixdfti(0.5, 0);
580 try test__fixdfti(0.99, 0);
581 try test__fixdfti(1.0, 1);
582 try test__fixdfti(1.5, 1);
583 try test__fixdfti(1.99, 1);
584 try test__fixdfti(2.0, 2);
585 try test__fixdfti(2.01, 2);
586
587 try test__fixdfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
588 try test__fixdfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
589
590 try test__fixdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
591 try test__fixdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
592 try test__fixdfti(0x1.0000000000000p+63, 0x8000000000000000);
593 try test__fixdfti(0x1.0000000000001p+63, 0x8000000000000800);
594
595 try test__fixdfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFF8000000000000000000);
596 try test__fixdfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFC000000000000000000);
597 try test__fixdfti(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
598
599 try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
600 try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128));
601
602 try test__fixdfti(math.floatMax(f64), math.maxInt(i128));
603}
604
605test "fixunsdfti" {
606 try test__fixunsdfti(0.0, 0);
607
608 try test__fixunsdfti(0.5, 0);
609 try test__fixunsdfti(0.99, 0);
610 try test__fixunsdfti(1.0, 1);
611 try test__fixunsdfti(1.5, 1);
612 try test__fixunsdfti(1.99, 1);
613 try test__fixunsdfti(2.0, 2);
614 try test__fixunsdfti(2.01, 2);
615 try test__fixunsdfti(-0.5, 0);
616 try test__fixunsdfti(-0.99, 0);
617 try test__fixunsdfti(-1.0, 0);
618 try test__fixunsdfti(-1.5, 0);
619 try test__fixunsdfti(-1.99, 0);
620 try test__fixunsdfti(-2.0, 0);
621 try test__fixunsdfti(-2.01, 0);
622
623 try test__fixunsdfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
624 try test__fixunsdfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
625
626 try test__fixunsdfti(-0x1.FFFFFEp+62, 0);
627 try test__fixunsdfti(-0x1.FFFFFCp+62, 0);
628
629 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800);
630 try test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000);
631 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
632 try test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
633
634 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+127, 0xFFFFFFFFFFFFF8000000000000000000);
635 try test__fixunsdfti(0x1.0000000000000p+127, 0x80000000000000000000000000000000);
636 try test__fixunsdfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFC000000000000000000);
637 try test__fixunsdfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFF8000000000000000000);
638 try test__fixunsdfti(0x1.0000000000000p+128, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
639
640 try test__fixunsdfti(-0x1.FFFFFFFFFFFFFp+62, 0);
641 try test__fixunsdfti(-0x1.FFFFFFFFFFFFEp+62, 0);
642}
643
644fn test__fixtfsi(a: f128, expected: i32) !void {
645 const x = __fixtfsi(a);
646 try testing.expect(x == expected);
647}
648
649fn test__fixunstfsi(a: f128, expected: u32) !void {
650 const x = __fixunstfsi(a);
651 try testing.expect(x == expected);
652}
653
654test "fixtfsi" {
655 try test__fixtfsi(-math.floatMax(f128), math.minInt(i32));
656
657 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
658 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000);
659
660 try test__fixtfsi(-0x1.0000000000000p+127, -0x80000000);
661 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+126, -0x80000000);
662 try test__fixtfsi(-0x1.FFFFFFFFFFFFEp+126, -0x80000000);
663
664 try test__fixtfsi(-0x1.0000000000001p+63, -0x80000000);
665 try test__fixtfsi(-0x1.0000000000000p+63, -0x80000000);
666 try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+62, -0x80000000);
667 try test__fixtfsi(-0x1.FFFFFFFFFFFFEp+62, -0x80000000);
668
669 try test__fixtfsi(-0x1.FFFFFEp+62, -0x80000000);
670 try test__fixtfsi(-0x1.FFFFFCp+62, -0x80000000);
671
672 try test__fixtfsi(-0x1.000000p+31, -0x80000000);
673 try test__fixtfsi(-0x1.FFFFFFp+30, -0x7FFFFFC0);
674 try test__fixtfsi(-0x1.FFFFFEp+30, -0x7FFFFF80);
675 try test__fixtfsi(-0x1.FFFFFCp+30, -0x7FFFFF00);
676
677 try test__fixtfsi(-2.01, -2);
678 try test__fixtfsi(-2.0, -2);
679 try test__fixtfsi(-1.99, -1);
680 try test__fixtfsi(-1.0, -1);
681 try test__fixtfsi(-0.99, 0);
682 try test__fixtfsi(-0.5, 0);
683 try test__fixtfsi(-math.floatMin(f32), 0);
684 try test__fixtfsi(0.0, 0);
685 try test__fixtfsi(math.floatMin(f32), 0);
686 try test__fixtfsi(0.5, 0);
687 try test__fixtfsi(0.99, 0);
688 try test__fixtfsi(1.0, 1);
689 try test__fixtfsi(1.5, 1);
690 try test__fixtfsi(1.99, 1);
691 try test__fixtfsi(2.0, 2);
692 try test__fixtfsi(2.01, 2);
693
694 try test__fixtfsi(0x1.FFFFFCp+30, 0x7FFFFF00);
695 try test__fixtfsi(0x1.FFFFFEp+30, 0x7FFFFF80);
696 try test__fixtfsi(0x1.FFFFFFp+30, 0x7FFFFFC0);
697 try test__fixtfsi(0x1.000000p+31, 0x7FFFFFFF);
698
699 try test__fixtfsi(0x1.FFFFFCp+62, 0x7FFFFFFF);
700 try test__fixtfsi(0x1.FFFFFEp+62, 0x7FFFFFFF);
701
702 try test__fixtfsi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFF);
703 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFF);
704 try test__fixtfsi(0x1.0000000000000p+63, 0x7FFFFFFF);
705 try test__fixtfsi(0x1.0000000000001p+63, 0x7FFFFFFF);
706
707 try test__fixtfsi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFF);
708 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFF);
709 try test__fixtfsi(0x1.0000000000000p+127, 0x7FFFFFFF);
710
711 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF);
712 try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32));
713
714 try test__fixtfsi(math.floatMax(f128), math.maxInt(i32));
715}
716
717test "fixunstfsi" {
718 try test__fixunstfsi(math.inf(f128), 0xffffffff);
719 try test__fixunstfsi(0, 0x0);
720 try test__fixunstfsi(0x1.23456789abcdefp+5, 0x24);
721 try test__fixunstfsi(0x1.23456789abcdefp-3, 0x0);
722 try test__fixunstfsi(0x1.23456789abcdefp+20, 0x123456);
723 try test__fixunstfsi(0x1.23456789abcdefp+40, 0xffffffff);
724 try test__fixunstfsi(0x1.23456789abcdefp+256, 0xffffffff);
725 try test__fixunstfsi(-0x1.23456789abcdefp+3, 0x0);
726
727 try test__fixunstfsi(0x1p+32, 0xFFFFFFFF);
728}
729
730fn test__fixtfdi(a: f128, expected: i64) !void {
731 const x = __fixtfdi(a);
732 try testing.expect(x == expected);
733}
734
735fn test__fixunstfdi(a: f128, expected: u64) !void {
736 const x = __fixunstfdi(a);
737 try testing.expect(x == expected);
738}
739
740test "fixtfdi" {
741 try test__fixtfdi(-math.floatMax(f128), math.minInt(i64));
742
743 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
744 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000);
745
746 try test__fixtfdi(-0x1.0000000000000p+127, -0x8000000000000000);
747 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+126, -0x8000000000000000);
748 try test__fixtfdi(-0x1.FFFFFFFFFFFFEp+126, -0x8000000000000000);
749
750 try test__fixtfdi(-0x1.0000000000001p+63, -0x8000000000000000);
751 try test__fixtfdi(-0x1.0000000000000p+63, -0x8000000000000000);
752 try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
753 try test__fixtfdi(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
754
755 try test__fixtfdi(-0x1.FFFFFEp+62, -0x7FFFFF8000000000);
756 try test__fixtfdi(-0x1.FFFFFCp+62, -0x7FFFFF0000000000);
757
758 try test__fixtfdi(-0x1.000000p+31, -0x80000000);
759 try test__fixtfdi(-0x1.FFFFFFp+30, -0x7FFFFFC0);
760 try test__fixtfdi(-0x1.FFFFFEp+30, -0x7FFFFF80);
761 try test__fixtfdi(-0x1.FFFFFCp+30, -0x7FFFFF00);
762
763 try test__fixtfdi(-2.01, -2);
764 try test__fixtfdi(-2.0, -2);
765 try test__fixtfdi(-1.99, -1);
766 try test__fixtfdi(-1.0, -1);
767 try test__fixtfdi(-0.99, 0);
768 try test__fixtfdi(-0.5, 0);
769 try test__fixtfdi(-math.floatMin(f64), 0);
770 try test__fixtfdi(0.0, 0);
771 try test__fixtfdi(math.floatMin(f64), 0);
772 try test__fixtfdi(0.5, 0);
773 try test__fixtfdi(0.99, 0);
774 try test__fixtfdi(1.0, 1);
775 try test__fixtfdi(1.5, 1);
776 try test__fixtfdi(1.99, 1);
777 try test__fixtfdi(2.0, 2);
778 try test__fixtfdi(2.01, 2);
779
780 try test__fixtfdi(0x1.FFFFFCp+30, 0x7FFFFF00);
781 try test__fixtfdi(0x1.FFFFFEp+30, 0x7FFFFF80);
782 try test__fixtfdi(0x1.FFFFFFp+30, 0x7FFFFFC0);
783 try test__fixtfdi(0x1.000000p+31, 0x80000000);
784
785 try test__fixtfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
786 try test__fixtfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
787
788 try test__fixtfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
789 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
790 try test__fixtfdi(0x1.0000000000000p+63, 0x7FFFFFFFFFFFFFFF);
791 try test__fixtfdi(0x1.0000000000001p+63, 0x7FFFFFFFFFFFFFFF);
792
793 try test__fixtfdi(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFFFFF);
794 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFFFF);
795 try test__fixtfdi(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFF);
796
797 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF);
798 try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64));
799
800 try test__fixtfdi(math.floatMax(f128), math.maxInt(i64));
801}
802
803test "fixunstfdi" {
804 try test__fixunstfdi(0.0, 0);
805
806 try test__fixunstfdi(0.5, 0);
807 try test__fixunstfdi(0.99, 0);
808 try test__fixunstfdi(1.0, 1);
809 try test__fixunstfdi(1.5, 1);
810 try test__fixunstfdi(1.99, 1);
811 try test__fixunstfdi(2.0, 2);
812 try test__fixunstfdi(2.01, 2);
813 try test__fixunstfdi(-0.5, 0);
814 try test__fixunstfdi(-0.99, 0);
815 try test__fixunstfdi(-1.0, 0);
816 try test__fixunstfdi(-1.5, 0);
817 try test__fixunstfdi(-1.99, 0);
818 try test__fixunstfdi(-2.0, 0);
819 try test__fixunstfdi(-2.01, 0);
820
821 try test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
822 try test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
823
824 try test__fixunstfdi(-0x1.FFFFFEp+62, 0);
825 try test__fixunstfdi(-0x1.FFFFFCp+62, 0);
826
827 try test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
828 try test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
829
830 try test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0);
831 try test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0);
832
833 try test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63, 0xFFFFFFFFFFFFFFFF);
834 try test__fixunstfdi(0x1.0000000000000002p+63, 0x8000000000000001);
835 try test__fixunstfdi(0x1.0000000000000000p+63, 0x8000000000000000);
836 try test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62, 0x7FFFFFFFFFFFFFFF);
837 try test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62, 0x7FFFFFFFFFFFFFFE);
838 try test__fixunstfdi(0x1p+64, 0xFFFFFFFFFFFFFFFF);
839
840 try test__fixunstfdi(-0x1.0000000000000000p+63, 0);
841 try test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62, 0);
842 try test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62, 0);
843}
844
845fn test__fixtfti(a: f128, expected: i128) !void {
846 const x = __fixtfti(a);
847 try testing.expect(x == expected);
848}
849
850fn test__fixunstfti(a: f128, expected: u128) !void {
851 const x = __fixunstfti(a);
852 try testing.expect(x == expected);
853}
854
855test "fixtfti" {
856 try test__fixtfti(-math.floatMax(f128), math.minInt(i128));
857
858 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
859 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000);
860
861 try test__fixtfti(-0x1.0000000000000p+127, -0x80000000000000000000000000000000);
862 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+126, -0x7FFFFFFFFFFFFC000000000000000000);
863 try test__fixtfti(-0x1.FFFFFFFFFFFFEp+126, -0x7FFFFFFFFFFFF8000000000000000000);
864
865 try test__fixtfti(-0x1.0000000000001p+63, -0x8000000000000800);
866 try test__fixtfti(-0x1.0000000000000p+63, -0x8000000000000000);
867 try test__fixtfti(-0x1.FFFFFFFFFFFFFp+62, -0x7FFFFFFFFFFFFC00);
868 try test__fixtfti(-0x1.FFFFFFFFFFFFEp+62, -0x7FFFFFFFFFFFF800);
869
870 try test__fixtfti(-0x1.FFFFFEp+62, -0x7fffff8000000000);
871 try test__fixtfti(-0x1.FFFFFCp+62, -0x7fffff0000000000);
872
873 try test__fixtfti(-2.01, -2);
874 try test__fixtfti(-2.0, -2);
875 try test__fixtfti(-1.99, -1);
876 try test__fixtfti(-1.0, -1);
877 try test__fixtfti(-0.99, 0);
878 try test__fixtfti(-0.5, 0);
879 try test__fixtfti(-math.floatMin(f128), 0);
880 try test__fixtfti(0.0, 0);
881 try test__fixtfti(math.floatMin(f128), 0);
882 try test__fixtfti(0.5, 0);
883 try test__fixtfti(0.99, 0);
884 try test__fixtfti(1.0, 1);
885 try test__fixtfti(1.5, 1);
886 try test__fixtfti(1.99, 1);
887 try test__fixtfti(2.0, 2);
888 try test__fixtfti(2.01, 2);
889
890 try test__fixtfti(0x1.FFFFFCp+62, 0x7FFFFF0000000000);
891 try test__fixtfti(0x1.FFFFFEp+62, 0x7FFFFF8000000000);
892
893 try test__fixtfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800);
894 try test__fixtfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00);
895 try test__fixtfti(0x1.0000000000000p+63, 0x8000000000000000);
896 try test__fixtfti(0x1.0000000000001p+63, 0x8000000000000800);
897
898 try test__fixtfti(0x1.FFFFFFFFFFFFEp+126, 0x7FFFFFFFFFFFF8000000000000000000);
899 try test__fixtfti(0x1.FFFFFFFFFFFFFp+126, 0x7FFFFFFFFFFFFC000000000000000000);
900 try test__fixtfti(0x1.0000000000000p+127, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
901
902 try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
903 try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128));
904
905 try test__fixtfti(math.floatMax(f128), math.maxInt(i128));
906}
907
908test "fixunstfti" {
909 try test__fixunstfti(math.inf(f128), 0xffffffffffffffffffffffffffffffff);
910
911 try test__fixunstfti(0.0, 0);
912
913 try test__fixunstfti(0.5, 0);
914 try test__fixunstfti(0.99, 0);
915 try test__fixunstfti(1.0, 1);
916 try test__fixunstfti(1.5, 1);
917 try test__fixunstfti(1.99, 1);
918 try test__fixunstfti(2.0, 2);
919 try test__fixunstfti(2.01, 2);
920 try test__fixunstfti(-0.01, 0);
921 try test__fixunstfti(-0.99, 0);
922
923 try test__fixunstfti(0x1p+128, 0xffffffffffffffffffffffffffffffff);
924
925 try test__fixunstfti(0x1.FFFFFEp+126, 0x7fffff80000000000000000000000000);
926 try test__fixunstfti(0x1.FFFFFEp+127, 0xffffff00000000000000000000000000);
927 try test__fixunstfti(0x1.FFFFFEp+128, 0xffffffffffffffffffffffffffffffff);
928 try test__fixunstfti(0x1.FFFFFEp+129, 0xffffffffffffffffffffffffffffffff);
929}
930
931fn test__fixunshfti(a: f16, expected: u128) !void {
932 const x = __fixunshfti(a);
933 try testing.expect(x == expected);
934}
935
936test "fixunshfti for f16" {
937 try test__fixunshfti(math.inf(f16), math.maxInt(u128));
938 try test__fixunshfti(math.floatMax(f16), 65504);
939}
940
941fn test__fixunsxfti(a: f80, expected: u128) !void {
942 const x = __fixunsxfti(a);
943 try testing.expect(x == expected);
944}
945
946test "fixunsxfti for f80" {
947 try test__fixunsxfti(math.inf(f80), math.maxInt(u128));
948 try test__fixunsxfti(math.floatMax(f80), math.maxInt(u128));
949 try test__fixunsxfti(math.maxInt(u64), math.maxInt(u64));
950}
lib/compiler_rt/int_to_float.zig deleted-58
......@@ -1,58 +0,0 @@
1const Int = @import("std").meta.Int;
2const math = @import("std").math;
3
4pub fn intToFloat(comptime T: type, x: anytype) T {
5 if (x == 0) return 0;
6
7 // Various constants whose values follow from the type parameters.
8 // Any reasonable optimizer will fold and propagate all of these.
9 const Z = Int(.unsigned, @bitSizeOf(@TypeOf(x)));
10 const uT = Int(.unsigned, @bitSizeOf(T));
11 const inf = math.inf(T);
12 const float_bits = @bitSizeOf(T);
13 const int_bits = @bitSizeOf(@TypeOf(x));
14 const exp_bits = math.floatExponentBits(T);
15 const fractional_bits = math.floatFractionalBits(T);
16 const exp_bias = math.maxInt(Int(.unsigned, exp_bits - 1));
17 const implicit_bit = if (T != f80) @as(uT, 1) << fractional_bits else 0;
18 const max_exp = exp_bias;
19
20 // Sign
21 var abs_val = math.absCast(x);
22 const sign_bit = if (x < 0) @as(uT, 1) << (float_bits - 1) else 0;
23 var result: uT = sign_bit;
24
25 // Compute significand
26 var exp = int_bits - @clz(abs_val) - 1;
27 if (int_bits <= fractional_bits or exp <= fractional_bits) {
28 const shift_amt = fractional_bits - @intCast(math.Log2Int(uT), exp);
29
30 // Shift up result to line up with the significand - no rounding required
31 result = (@intCast(uT, abs_val) << shift_amt);
32 result ^= implicit_bit; // Remove implicit integer bit
33 } else {
34 var shift_amt = @intCast(math.Log2Int(Z), exp - fractional_bits);
35 const exact_tie: bool = @ctz(abs_val) == shift_amt - 1;
36
37 // Shift down result and remove implicit integer bit
38 result = @intCast(uT, (abs_val >> (shift_amt - 1))) ^ (implicit_bit << 1);
39
40 // Round result, including round-to-even for exact ties
41 result = ((result + 1) >> 1) & ~@as(uT, @boolToInt(exact_tie));
42 }
43
44 // Compute exponent
45 if ((int_bits > max_exp) and (exp > max_exp)) // If exponent too large, overflow to infinity
46 return @bitCast(T, sign_bit | @bitCast(uT, inf));
47
48 result += (@as(uT, exp) + exp_bias) << math.floatMantissaBits(T);
49
50 // If the result included a carry, we need to restore the explicit integer bit
51 if (T == f80) result |= 1 << fractional_bits;
52
53 return @bitCast(T, sign_bit | result);
54}
55
56test {
57 _ = @import("int_to_float_test.zig");
58}
lib/compiler_rt/int_to_float_test.zig deleted-836
......@@ -1,836 +0,0 @@
1const std = @import("std");
2const testing = std.testing;
3const math = std.math;
4
5const __floatunsihf = @import("floatunsihf.zig").__floatunsihf;
6
7// Conversion to f32
8const __floatsisf = @import("floatsisf.zig").__floatsisf;
9const __floatunsisf = @import("floatunsisf.zig").__floatunsisf;
10const __floatdisf = @import("floatdisf.zig").__floatdisf;
11const __floatundisf = @import("floatundisf.zig").__floatundisf;
12const __floattisf = @import("floattisf.zig").__floattisf;
13const __floatuntisf = @import("floatuntisf.zig").__floatuntisf;
14
15// Conversion to f64
16const __floatsidf = @import("floatsidf.zig").__floatsidf;
17const __floatunsidf = @import("floatunsidf.zig").__floatunsidf;
18const __floatdidf = @import("floatdidf.zig").__floatdidf;
19const __floatundidf = @import("floatundidf.zig").__floatundidf;
20const __floattidf = @import("floattidf.zig").__floattidf;
21const __floatuntidf = @import("floatuntidf.zig").__floatuntidf;
22
23// Conversion to f128
24const __floatsitf = @import("floatsitf.zig").__floatsitf;
25const __floatunsitf = @import("floatunsitf.zig").__floatunsitf;
26const __floatditf = @import("floatditf.zig").__floatditf;
27const __floatunditf = @import("floatunditf.zig").__floatunditf;
28const __floattitf = @import("floattitf.zig").__floattitf;
29const __floatuntitf = @import("floatuntitf.zig").__floatuntitf;
30
31fn test__floatsisf(a: i32, expected: u32) !void {
32 const r = __floatsisf(a);
33 try std.testing.expect(@bitCast(u32, r) == expected);
34}
35
36fn test_one_floatunsisf(a: u32, expected: u32) !void {
37 const r = __floatunsisf(a);
38 try std.testing.expect(@bitCast(u32, r) == expected);
39}
40
41test "floatsisf" {
42 try test__floatsisf(0, 0x00000000);
43 try test__floatsisf(1, 0x3f800000);
44 try test__floatsisf(-1, 0xbf800000);
45 try test__floatsisf(0x7FFFFFFF, 0x4f000000);
46 try test__floatsisf(@bitCast(i32, @intCast(u32, 0x80000000)), 0xcf000000);
47}
48
49test "floatunsisf" {
50 // Test the produced bit pattern
51 try test_one_floatunsisf(0, 0);
52 try test_one_floatunsisf(1, 0x3f800000);
53 try test_one_floatunsisf(0x7FFFFFFF, 0x4f000000);
54 try test_one_floatunsisf(0x80000000, 0x4f000000);
55 try test_one_floatunsisf(0xFFFFFFFF, 0x4f800000);
56}
57
58fn test__floatdisf(a: i64, expected: f32) !void {
59 const x = __floatdisf(a);
60 try testing.expect(x == expected);
61}
62
63fn test__floatundisf(a: u64, expected: f32) !void {
64 try std.testing.expectEqual(expected, __floatundisf(a));
65}
66
67test "floatdisf" {
68 try test__floatdisf(0, 0.0);
69 try test__floatdisf(1, 1.0);
70 try test__floatdisf(2, 2.0);
71 try test__floatdisf(-1, -1.0);
72 try test__floatdisf(-2, -2.0);
73 try test__floatdisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
74 try test__floatdisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
75 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000008000000000)), -0x1.FFFFFEp+62);
76 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000010000000000)), -0x1.FFFFFCp+62);
77 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000000000000000)), -0x1.000000p+63);
78 try test__floatdisf(@bitCast(i64, @as(u64, 0x8000000000000001)), -0x1.000000p+63);
79 try test__floatdisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
80 try test__floatdisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
81 try test__floatdisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
82 try test__floatdisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
83 try test__floatdisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
84 try test__floatdisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
85 try test__floatdisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
86 try test__floatdisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
87 try test__floatdisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
88 try test__floatdisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
89 try test__floatdisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
90}
91
92test "floatundisf" {
93 try test__floatundisf(0, 0.0);
94 try test__floatundisf(1, 1.0);
95 try test__floatundisf(2, 2.0);
96 try test__floatundisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
97 try test__floatundisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
98 try test__floatundisf(0x8000008000000000, 0x1p+63);
99 try test__floatundisf(0x8000010000000000, 0x1.000002p+63);
100 try test__floatundisf(0x8000000000000000, 0x1p+63);
101 try test__floatundisf(0x8000000000000001, 0x1p+63);
102 try test__floatundisf(0xFFFFFFFFFFFFFFFE, 0x1p+64);
103 try test__floatundisf(0xFFFFFFFFFFFFFFFF, 0x1p+64);
104 try test__floatundisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
105 try test__floatundisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
106 try test__floatundisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
107 try test__floatundisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
108 try test__floatundisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
109 try test__floatundisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
110 try test__floatundisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
111 try test__floatundisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
112 try test__floatundisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
113 try test__floatundisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
114 try test__floatundisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
115}
116
117fn test__floattisf(a: i128, expected: f32) !void {
118 const x = __floattisf(a);
119 try testing.expect(x == expected);
120}
121
122fn test__floatuntisf(a: u128, expected: f32) !void {
123 const x = __floatuntisf(a);
124 try testing.expect(x == expected);
125}
126
127test "floattisf" {
128 try test__floattisf(0, 0.0);
129
130 try test__floattisf(1, 1.0);
131 try test__floattisf(2, 2.0);
132 try test__floattisf(-1, -1.0);
133 try test__floattisf(-2, -2.0);
134
135 try test__floattisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
136 try test__floattisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
137
138 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000008000000000), -0x1.FFFFFEp+62);
139 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000010000000000), -0x1.FFFFFCp+62);
140
141 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000000000000000), -0x1.000000p+63);
142 try test__floattisf(make_ti(0xFFFFFFFFFFFFFFFF, 0x8000000000000001), -0x1.000000p+63);
143
144 try test__floattisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
145
146 try test__floattisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
147 try test__floattisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
148 try test__floattisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
149 try test__floattisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
150 try test__floattisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
151
152 try test__floattisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
153 try test__floattisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
154 try test__floattisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
155 try test__floattisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
156 try test__floattisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
157
158 try test__floattisf(make_ti(0x0007FB72E8000000, 0), 0x1.FEDCBAp+114);
159
160 try test__floattisf(make_ti(0x0007FB72EA000000, 0), 0x1.FEDCBAp+114);
161 try test__floattisf(make_ti(0x0007FB72EB000000, 0), 0x1.FEDCBAp+114);
162 try test__floattisf(make_ti(0x0007FB72EBFFFFFF, 0), 0x1.FEDCBAp+114);
163 try test__floattisf(make_ti(0x0007FB72EC000000, 0), 0x1.FEDCBCp+114);
164 try test__floattisf(make_ti(0x0007FB72E8000001, 0), 0x1.FEDCBAp+114);
165
166 try test__floattisf(make_ti(0x0007FB72E6000000, 0), 0x1.FEDCBAp+114);
167 try test__floattisf(make_ti(0x0007FB72E7000000, 0), 0x1.FEDCBAp+114);
168 try test__floattisf(make_ti(0x0007FB72E7FFFFFF, 0), 0x1.FEDCBAp+114);
169 try test__floattisf(make_ti(0x0007FB72E4000001, 0), 0x1.FEDCBAp+114);
170 try test__floattisf(make_ti(0x0007FB72E4000000, 0), 0x1.FEDCB8p+114);
171}
172
173test "floatuntisf" {
174 try test__floatuntisf(0, 0.0);
175
176 try test__floatuntisf(1, 1.0);
177 try test__floatuntisf(2, 2.0);
178 try test__floatuntisf(20, 20.0);
179
180 try test__floatuntisf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
181 try test__floatuntisf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
182
183 try test__floatuntisf(make_uti(0x8000008000000000, 0), 0x1.000001p+127);
184 try test__floatuntisf(make_uti(0x8000000000000800, 0), 0x1.0p+127);
185 try test__floatuntisf(make_uti(0x8000010000000000, 0), 0x1.000002p+127);
186
187 try test__floatuntisf(make_uti(0x8000000000000000, 0), 0x1.000000p+127);
188
189 try test__floatuntisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
190
191 try test__floatuntisf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
192 try test__floatuntisf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
193
194 try test__floatuntisf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
195
196 try test__floatuntisf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
197 try test__floatuntisf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
198 try test__floatuntisf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
199
200 try test__floatuntisf(0xFFFFFFFFFFFFFFFE, 0x1p+64);
201 try test__floatuntisf(0xFFFFFFFFFFFFFFFF, 0x1p+64);
202
203 try test__floatuntisf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
204
205 try test__floatuntisf(0x0007FB72EA000000, 0x1.FEDCBAp+50);
206 try test__floatuntisf(0x0007FB72EB000000, 0x1.FEDCBAp+50);
207 try test__floatuntisf(0x0007FB72EBFFFFFF, 0x1.FEDCBAp+50);
208 try test__floatuntisf(0x0007FB72EC000000, 0x1.FEDCBCp+50);
209 try test__floatuntisf(0x0007FB72E8000001, 0x1.FEDCBAp+50);
210
211 try test__floatuntisf(0x0007FB72E6000000, 0x1.FEDCBAp+50);
212 try test__floatuntisf(0x0007FB72E7000000, 0x1.FEDCBAp+50);
213 try test__floatuntisf(0x0007FB72E7FFFFFF, 0x1.FEDCBAp+50);
214 try test__floatuntisf(0x0007FB72E4000001, 0x1.FEDCBAp+50);
215 try test__floatuntisf(0x0007FB72E4000000, 0x1.FEDCB8p+50);
216
217 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCB90000000000001), 0x1.FEDCBAp+76);
218 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBA0000000000000), 0x1.FEDCBAp+76);
219 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBAFFFFFFFFFFFFF), 0x1.FEDCBAp+76);
220 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBB0000000000000), 0x1.FEDCBCp+76);
221 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBB0000000000001), 0x1.FEDCBCp+76);
222 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBBFFFFFFFFFFFFF), 0x1.FEDCBCp+76);
223 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBC0000000000000), 0x1.FEDCBCp+76);
224 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBC0000000000001), 0x1.FEDCBCp+76);
225 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBD0000000000000), 0x1.FEDCBCp+76);
226 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBD0000000000001), 0x1.FEDCBEp+76);
227 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBDFFFFFFFFFFFFF), 0x1.FEDCBEp+76);
228 try test__floatuntisf(make_uti(0x0000000000001FED, 0xCBE0000000000000), 0x1.FEDCBEp+76);
229
230 // Test overflow to infinity
231 try test__floatuntisf(@as(u128, math.maxInt(u128)), @bitCast(f32, math.inf(f32)));
232}
233
234fn test_one_floatsidf(a: i32, expected: u64) !void {
235 const r = __floatsidf(a);
236 try std.testing.expect(@bitCast(u64, r) == expected);
237}
238
239fn test_one_floatunsidf(a: u32, expected: u64) !void {
240 const r = __floatunsidf(a);
241 try std.testing.expect(@bitCast(u64, r) == expected);
242}
243
244test "floatsidf" {
245 try test_one_floatsidf(0, 0x0000000000000000);
246 try test_one_floatsidf(1, 0x3ff0000000000000);
247 try test_one_floatsidf(-1, 0xbff0000000000000);
248 try test_one_floatsidf(0x7FFFFFFF, 0x41dfffffffc00000);
249 try test_one_floatsidf(@bitCast(i32, @intCast(u32, 0x80000000)), 0xc1e0000000000000);
250}
251
252test "floatunsidf" {
253 try test_one_floatunsidf(0, 0x0000000000000000);
254 try test_one_floatunsidf(1, 0x3ff0000000000000);
255 try test_one_floatunsidf(0x7FFFFFFF, 0x41dfffffffc00000);
256 try test_one_floatunsidf(@intCast(u32, 0x80000000), 0x41e0000000000000);
257 try test_one_floatunsidf(@intCast(u32, 0xFFFFFFFF), 0x41efffffffe00000);
258}
259
260fn test__floatdidf(a: i64, expected: f64) !void {
261 const r = __floatdidf(a);
262 try testing.expect(r == expected);
263}
264
265fn test__floatundidf(a: u64, expected: f64) !void {
266 const r = __floatundidf(a);
267 try testing.expect(r == expected);
268}
269
270test "floatdidf" {
271 try test__floatdidf(0, 0.0);
272 try test__floatdidf(1, 1.0);
273 try test__floatdidf(2, 2.0);
274 try test__floatdidf(20, 20.0);
275 try test__floatdidf(-1, -1.0);
276 try test__floatdidf(-2, -2.0);
277 try test__floatdidf(-20, -20.0);
278 try test__floatdidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
279 try test__floatdidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
280 try test__floatdidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
281 try test__floatdidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
282 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000008000000000)), -0x1.FFFFFEp+62);
283 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000800)), -0x1.FFFFFFFFFFFFEp+62);
284 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000010000000000)), -0x1.FFFFFCp+62);
285 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000001000)), -0x1.FFFFFFFFFFFFCp+62);
286 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000000)), -0x1.000000p+63);
287 try test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000001)), -0x1.000000p+63); // 0x8000000000000001
288 try test__floatdidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
289 try test__floatdidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
290 try test__floatdidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
291 try test__floatdidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
292 try test__floatdidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
293 try test__floatdidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
294 try test__floatdidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
295 try test__floatdidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
296 try test__floatdidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
297 try test__floatdidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
298 try test__floatdidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
299 try test__floatdidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
300 try test__floatdidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
301 try test__floatdidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
302 try test__floatdidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
303 try test__floatdidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
304 try test__floatdidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
305 try test__floatdidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
306 try test__floatdidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
307 try test__floatdidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
308 try test__floatdidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
309 try test__floatdidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
310 try test__floatdidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
311 try test__floatdidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
312 try test__floatdidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
313 try test__floatdidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
314}
315
316test "floatundidf" {
317 try test__floatundidf(0, 0.0);
318 try test__floatundidf(1, 1.0);
319 try test__floatundidf(2, 2.0);
320 try test__floatundidf(20, 20.0);
321 try test__floatundidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
322 try test__floatundidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
323 try test__floatundidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
324 try test__floatundidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
325 try test__floatundidf(0x8000008000000000, 0x1.000001p+63);
326 try test__floatundidf(0x8000000000000800, 0x1.0000000000001p+63);
327 try test__floatundidf(0x8000010000000000, 0x1.000002p+63);
328 try test__floatundidf(0x8000000000001000, 0x1.0000000000002p+63);
329 try test__floatundidf(0x8000000000000000, 0x1p+63);
330 try test__floatundidf(0x8000000000000001, 0x1p+63);
331 try test__floatundidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
332 try test__floatundidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
333 try test__floatundidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
334 try test__floatundidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
335 try test__floatundidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
336 try test__floatundidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
337 try test__floatundidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
338 try test__floatundidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
339 try test__floatundidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
340 try test__floatundidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
341 try test__floatundidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
342 try test__floatundidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
343 try test__floatundidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
344 try test__floatundidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
345 try test__floatundidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
346 try test__floatundidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
347 try test__floatundidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
348 try test__floatundidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
349 try test__floatundidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
350 try test__floatundidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
351 try test__floatundidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
352 try test__floatundidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
353 try test__floatundidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
354 try test__floatundidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
355 try test__floatundidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
356 try test__floatundidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
357}
358
359fn test__floattidf(a: i128, expected: f64) !void {
360 const x = __floattidf(a);
361 try testing.expect(x == expected);
362}
363
364fn test__floatuntidf(a: u128, expected: f64) !void {
365 const x = __floatuntidf(a);
366 try testing.expect(x == expected);
367}
368
369test "floattidf" {
370 try test__floattidf(0, 0.0);
371
372 try test__floattidf(1, 1.0);
373 try test__floattidf(2, 2.0);
374 try test__floattidf(20, 20.0);
375 try test__floattidf(-1, -1.0);
376 try test__floattidf(-2, -2.0);
377 try test__floattidf(-20, -20.0);
378
379 try test__floattidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
380 try test__floattidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
381 try test__floattidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
382 try test__floattidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
383
384 try test__floattidf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126);
385 try test__floattidf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126);
386 try test__floattidf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126);
387 try test__floattidf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126);
388
389 try test__floattidf(make_ti(0x8000000000000000, 0), -0x1.000000p+127);
390 try test__floattidf(make_ti(0x8000000000000001, 0), -0x1.000000p+127);
391
392 try test__floattidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
393
394 try test__floattidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
395 try test__floattidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
396 try test__floattidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
397 try test__floattidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
398 try test__floattidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
399
400 try test__floattidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
401 try test__floattidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
402 try test__floattidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
403 try test__floattidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
404 try test__floattidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
405
406 try test__floattidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
407 try test__floattidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
408 try test__floattidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
409 try test__floattidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
410 try test__floattidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
411 try test__floattidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
412 try test__floattidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
413 try test__floattidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
414 try test__floattidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
415 try test__floattidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
416 try test__floattidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
417 try test__floattidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
418 try test__floattidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
419 try test__floattidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
420 try test__floattidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
421
422 try test__floattidf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
423 try test__floattidf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121);
424 try test__floattidf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121);
425 try test__floattidf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121);
426 try test__floattidf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121);
427 try test__floattidf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121);
428 try test__floattidf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121);
429 try test__floattidf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121);
430 try test__floattidf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121);
431 try test__floattidf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121);
432 try test__floattidf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121);
433 try test__floattidf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121);
434 try test__floattidf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121);
435 try test__floattidf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121);
436 try test__floattidf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
437}
438
439test "floatuntidf" {
440 try test__floatuntidf(0, 0.0);
441
442 try test__floatuntidf(1, 1.0);
443 try test__floatuntidf(2, 2.0);
444 try test__floatuntidf(20, 20.0);
445
446 try test__floatuntidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
447 try test__floatuntidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
448 try test__floatuntidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
449 try test__floatuntidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
450
451 try test__floatuntidf(make_uti(0x8000008000000000, 0), 0x1.000001p+127);
452 try test__floatuntidf(make_uti(0x8000000000000800, 0), 0x1.0000000000001p+127);
453 try test__floatuntidf(make_uti(0x8000010000000000, 0), 0x1.000002p+127);
454 try test__floatuntidf(make_uti(0x8000000000001000, 0), 0x1.0000000000002p+127);
455
456 try test__floatuntidf(make_uti(0x8000000000000000, 0), 0x1.000000p+127);
457 try test__floatuntidf(make_uti(0x8000000000000001, 0), 0x1.0000000000000002p+127);
458
459 try test__floatuntidf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
460
461 try test__floatuntidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
462 try test__floatuntidf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
463 try test__floatuntidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
464 try test__floatuntidf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
465 try test__floatuntidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
466
467 try test__floatuntidf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
468 try test__floatuntidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
469 try test__floatuntidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
470 try test__floatuntidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
471 try test__floatuntidf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
472
473 try test__floatuntidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
474 try test__floatuntidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57);
475 try test__floatuntidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57);
476 try test__floatuntidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57);
477 try test__floatuntidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57);
478 try test__floatuntidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57);
479 try test__floatuntidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57);
480 try test__floatuntidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57);
481 try test__floatuntidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57);
482 try test__floatuntidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57);
483 try test__floatuntidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57);
484 try test__floatuntidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57);
485 try test__floatuntidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57);
486 try test__floatuntidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57);
487 try test__floatuntidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
488
489 try test__floatuntidf(make_uti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
490 try test__floatuntidf(make_uti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496Dp+121);
491 try test__floatuntidf(make_uti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496Ep+121);
492 try test__floatuntidf(make_uti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496Ep+121);
493 try test__floatuntidf(make_uti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496Ep+121);
494 try test__floatuntidf(make_uti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496Ep+121);
495 try test__floatuntidf(make_uti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496Ep+121);
496 try test__floatuntidf(make_uti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496Ep+121);
497 try test__floatuntidf(make_uti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496Ep+121);
498 try test__floatuntidf(make_uti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496Ep+121);
499 try test__floatuntidf(make_uti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496Ep+121);
500 try test__floatuntidf(make_uti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496Fp+121);
501 try test__floatuntidf(make_uti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496Fp+121);
502 try test__floatuntidf(make_uti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496Fp+121);
503 try test__floatuntidf(make_uti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
504}
505
506fn test__floatsitf(a: i32, expected: u128) !void {
507 const r = __floatsitf(a);
508 try std.testing.expect(@bitCast(u128, r) == expected);
509}
510
511test "floatsitf" {
512 try test__floatsitf(0, 0);
513 try test__floatsitf(0x7FFFFFFF, 0x401dfffffffc00000000000000000000);
514 try test__floatsitf(0x12345678, 0x401b2345678000000000000000000000);
515 try test__floatsitf(-0x12345678, 0xc01b2345678000000000000000000000);
516 try test__floatsitf(@bitCast(i32, @intCast(u32, 0xffffffff)), 0xbfff0000000000000000000000000000);
517 try test__floatsitf(@bitCast(i32, @intCast(u32, 0x80000000)), 0xc01e0000000000000000000000000000);
518}
519
520fn test__floatunsitf(a: u32, expected_hi: u64, expected_lo: u64) !void {
521 const x = __floatunsitf(a);
522
523 const x_repr = @bitCast(u128, x);
524 const x_hi = @intCast(u64, x_repr >> 64);
525 const x_lo = @truncate(u64, x_repr);
526
527 if (x_hi == expected_hi and x_lo == expected_lo) {
528 return;
529 }
530 // nan repr
531 else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
532 if ((x_hi & 0x7fff000000000000) == 0x7fff000000000000 and ((x_hi & 0xffffffffffff) > 0 or x_lo > 0)) {
533 return;
534 }
535 }
536
537 @panic("__floatunsitf test failure");
538}
539
540test "floatunsitf" {
541 try test__floatunsitf(0x7fffffff, 0x401dfffffffc0000, 0x0);
542 try test__floatunsitf(0, 0x0, 0x0);
543 try test__floatunsitf(0xffffffff, 0x401efffffffe0000, 0x0);
544 try test__floatunsitf(0x12345678, 0x401b234567800000, 0x0);
545}
546
547fn test__floatditf(a: i64, expected: f128) !void {
548 const x = __floatditf(a);
549 try testing.expect(x == expected);
550}
551
552fn test__floatunditf(a: u64, expected_hi: u64, expected_lo: u64) !void {
553 const x = __floatunditf(a);
554
555 const x_repr = @bitCast(u128, x);
556 const x_hi = @intCast(u64, x_repr >> 64);
557 const x_lo = @truncate(u64, x_repr);
558
559 if (x_hi == expected_hi and x_lo == expected_lo) {
560 return;
561 }
562 // nan repr
563 else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
564 if ((x_hi & 0x7fff000000000000) == 0x7fff000000000000 and ((x_hi & 0xffffffffffff) > 0 or x_lo > 0)) {
565 return;
566 }
567 }
568
569 @panic("__floatunditf test failure");
570}
571
572test "floatditf" {
573 try test__floatditf(0x7fffffffffffffff, make_tf(0x403dffffffffffff, 0xfffc000000000000));
574 try test__floatditf(0x123456789abcdef1, make_tf(0x403b23456789abcd, 0xef10000000000000));
575 try test__floatditf(0x2, make_tf(0x4000000000000000, 0x0));
576 try test__floatditf(0x1, make_tf(0x3fff000000000000, 0x0));
577 try test__floatditf(0x0, make_tf(0x0, 0x0));
578 try test__floatditf(@bitCast(i64, @as(u64, 0xffffffffffffffff)), make_tf(0xbfff000000000000, 0x0));
579 try test__floatditf(@bitCast(i64, @as(u64, 0xfffffffffffffffe)), make_tf(0xc000000000000000, 0x0));
580 try test__floatditf(-0x123456789abcdef1, make_tf(0xc03b23456789abcd, 0xef10000000000000));
581 try test__floatditf(@bitCast(i64, @as(u64, 0x8000000000000000)), make_tf(0xc03e000000000000, 0x0));
582}
583
584test "floatunditf" {
585 try test__floatunditf(0xffffffffffffffff, 0x403effffffffffff, 0xfffe000000000000);
586 try test__floatunditf(0xfffffffffffffffe, 0x403effffffffffff, 0xfffc000000000000);
587 try test__floatunditf(0x8000000000000000, 0x403e000000000000, 0x0);
588 try test__floatunditf(0x7fffffffffffffff, 0x403dffffffffffff, 0xfffc000000000000);
589 try test__floatunditf(0x123456789abcdef1, 0x403b23456789abcd, 0xef10000000000000);
590 try test__floatunditf(0x2, 0x4000000000000000, 0x0);
591 try test__floatunditf(0x1, 0x3fff000000000000, 0x0);
592 try test__floatunditf(0x0, 0x0, 0x0);
593}
594
595fn test__floattitf(a: i128, expected: f128) !void {
596 const x = __floattitf(a);
597 try testing.expect(x == expected);
598}
599
600fn test__floatuntitf(a: u128, expected: f128) !void {
601 const x = __floatuntitf(a);
602 try testing.expect(x == expected);
603}
604
605test "floattitf" {
606 try test__floattitf(0, 0.0);
607
608 try test__floattitf(1, 1.0);
609 try test__floattitf(2, 2.0);
610 try test__floattitf(20, 20.0);
611 try test__floattitf(-1, -1.0);
612 try test__floattitf(-2, -2.0);
613 try test__floattitf(-20, -20.0);
614
615 try test__floattitf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
616 try test__floattitf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
617 try test__floattitf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
618 try test__floattitf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
619
620 try test__floattitf(make_ti(0x8000008000000000, 0), -0x1.FFFFFEp+126);
621 try test__floattitf(make_ti(0x8000000000000800, 0), -0x1.FFFFFFFFFFFFEp+126);
622 try test__floattitf(make_ti(0x8000010000000000, 0), -0x1.FFFFFCp+126);
623 try test__floattitf(make_ti(0x8000000000001000, 0), -0x1.FFFFFFFFFFFFCp+126);
624
625 try test__floattitf(make_ti(0x8000000000000000, 0), -0x1.000000p+127);
626 try test__floattitf(make_ti(0x8000000000000001, 0), -0x1.FFFFFFFFFFFFFFFCp+126);
627
628 try test__floattitf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
629
630 try test__floattitf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
631 try test__floattitf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
632 try test__floattitf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
633 try test__floattitf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
634 try test__floattitf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
635
636 try test__floattitf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
637 try test__floattitf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
638 try test__floattitf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
639 try test__floattitf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
640 try test__floattitf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
641
642 try test__floattitf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
643 try test__floattitf(0x023479FD0E092DA1, 0x1.1A3CFE870496D08p+57);
644 try test__floattitf(0x023479FD0E092DB0, 0x1.1A3CFE870496D8p+57);
645 try test__floattitf(0x023479FD0E092DB8, 0x1.1A3CFE870496DCp+57);
646 try test__floattitf(0x023479FD0E092DB6, 0x1.1A3CFE870496DBp+57);
647 try test__floattitf(0x023479FD0E092DBF, 0x1.1A3CFE870496DF8p+57);
648 try test__floattitf(0x023479FD0E092DC1, 0x1.1A3CFE870496E08p+57);
649 try test__floattitf(0x023479FD0E092DC7, 0x1.1A3CFE870496E38p+57);
650 try test__floattitf(0x023479FD0E092DC8, 0x1.1A3CFE870496E4p+57);
651 try test__floattitf(0x023479FD0E092DCF, 0x1.1A3CFE870496E78p+57);
652 try test__floattitf(0x023479FD0E092DD0, 0x1.1A3CFE870496E8p+57);
653 try test__floattitf(0x023479FD0E092DD1, 0x1.1A3CFE870496E88p+57);
654 try test__floattitf(0x023479FD0E092DD8, 0x1.1A3CFE870496ECp+57);
655 try test__floattitf(0x023479FD0E092DDF, 0x1.1A3CFE870496EF8p+57);
656 try test__floattitf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
657
658 try test__floattitf(make_ti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
659 try test__floattitf(make_ti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496D08p+121);
660 try test__floattitf(make_ti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496D8p+121);
661 try test__floattitf(make_ti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496DCp+121);
662 try test__floattitf(make_ti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496DBp+121);
663 try test__floattitf(make_ti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496DF8p+121);
664 try test__floattitf(make_ti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496E08p+121);
665 try test__floattitf(make_ti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496E38p+121);
666 try test__floattitf(make_ti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496E4p+121);
667 try test__floattitf(make_ti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496E78p+121);
668 try test__floattitf(make_ti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496E8p+121);
669 try test__floattitf(make_ti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496E88p+121);
670 try test__floattitf(make_ti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496ECp+121);
671 try test__floattitf(make_ti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496EF8p+121);
672 try test__floattitf(make_ti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
673
674 try test__floattitf(make_ti(0, 0xFFFFFFFFFFFFFFFF), 0x1.FFFFFFFFFFFFFFFEp+63);
675
676 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC2801), 0x1.23456789ABCDEF0123456789ABC3p+124);
677 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3000), 0x1.23456789ABCDEF0123456789ABC3p+124);
678 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC37FF), 0x1.23456789ABCDEF0123456789ABC3p+124);
679 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC3800), 0x1.23456789ABCDEF0123456789ABC4p+124);
680 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4000), 0x1.23456789ABCDEF0123456789ABC4p+124);
681 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC47FF), 0x1.23456789ABCDEF0123456789ABC4p+124);
682 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4800), 0x1.23456789ABCDEF0123456789ABC4p+124);
683 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC4801), 0x1.23456789ABCDEF0123456789ABC5p+124);
684 try test__floattitf(make_ti(0x123456789ABCDEF0, 0x123456789ABC57FF), 0x1.23456789ABCDEF0123456789ABC5p+124);
685}
686
687test "floatuntitf" {
688 try test__floatuntitf(0, 0.0);
689
690 try test__floatuntitf(1, 1.0);
691 try test__floatuntitf(2, 2.0);
692 try test__floatuntitf(20, 20.0);
693
694 try test__floatuntitf(0x7FFFFF8000000000, 0x1.FFFFFEp+62);
695 try test__floatuntitf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62);
696 try test__floatuntitf(0x7FFFFF0000000000, 0x1.FFFFFCp+62);
697 try test__floatuntitf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62);
698 try test__floatuntitf(0x7FFFFFFFFFFFFFFF, 0xF.FFFFFFFFFFFFFFEp+59);
699 try test__floatuntitf(0xFFFFFFFFFFFFFFFE, 0xF.FFFFFFFFFFFFFFEp+60);
700 try test__floatuntitf(0xFFFFFFFFFFFFFFFF, 0xF.FFFFFFFFFFFFFFFp+60);
701
702 try test__floatuntitf(0x8000008000000000, 0x8.000008p+60);
703 try test__floatuntitf(0x8000000000000800, 0x8.0000000000008p+60);
704 try test__floatuntitf(0x8000010000000000, 0x8.00001p+60);
705 try test__floatuntitf(0x8000000000001000, 0x8.000000000001p+60);
706
707 try test__floatuntitf(0x8000000000000000, 0x8p+60);
708 try test__floatuntitf(0x8000000000000001, 0x8.000000000000001p+60);
709
710 try test__floatuntitf(0x0007FB72E8000000, 0x1.FEDCBAp+50);
711
712 try test__floatuntitf(0x0007FB72EA000000, 0x1.FEDCBA8p+50);
713 try test__floatuntitf(0x0007FB72EB000000, 0x1.FEDCBACp+50);
714 try test__floatuntitf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50);
715 try test__floatuntitf(0x0007FB72EC000000, 0x1.FEDCBBp+50);
716 try test__floatuntitf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50);
717
718 try test__floatuntitf(0x0007FB72E6000000, 0x1.FEDCB98p+50);
719 try test__floatuntitf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50);
720 try test__floatuntitf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50);
721 try test__floatuntitf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50);
722 try test__floatuntitf(0x0007FB72E4000000, 0x1.FEDCB9p+50);
723
724 try test__floatuntitf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57);
725 try test__floatuntitf(0x023479FD0E092DA1, 0x1.1A3CFE870496D08p+57);
726 try test__floatuntitf(0x023479FD0E092DB0, 0x1.1A3CFE870496D8p+57);
727 try test__floatuntitf(0x023479FD0E092DB8, 0x1.1A3CFE870496DCp+57);
728 try test__floatuntitf(0x023479FD0E092DB6, 0x1.1A3CFE870496DBp+57);
729 try test__floatuntitf(0x023479FD0E092DBF, 0x1.1A3CFE870496DF8p+57);
730 try test__floatuntitf(0x023479FD0E092DC1, 0x1.1A3CFE870496E08p+57);
731 try test__floatuntitf(0x023479FD0E092DC7, 0x1.1A3CFE870496E38p+57);
732 try test__floatuntitf(0x023479FD0E092DC8, 0x1.1A3CFE870496E4p+57);
733 try test__floatuntitf(0x023479FD0E092DCF, 0x1.1A3CFE870496E78p+57);
734 try test__floatuntitf(0x023479FD0E092DD0, 0x1.1A3CFE870496E8p+57);
735 try test__floatuntitf(0x023479FD0E092DD1, 0x1.1A3CFE870496E88p+57);
736 try test__floatuntitf(0x023479FD0E092DD8, 0x1.1A3CFE870496ECp+57);
737 try test__floatuntitf(0x023479FD0E092DDF, 0x1.1A3CFE870496EF8p+57);
738 try test__floatuntitf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57);
739
740 try test__floatuntitf(make_uti(0x023479FD0E092DC0, 0), 0x1.1A3CFE870496Ep+121);
741 try test__floatuntitf(make_uti(0x023479FD0E092DA1, 1), 0x1.1A3CFE870496D08p+121);
742 try test__floatuntitf(make_uti(0x023479FD0E092DB0, 2), 0x1.1A3CFE870496D8p+121);
743 try test__floatuntitf(make_uti(0x023479FD0E092DB8, 3), 0x1.1A3CFE870496DCp+121);
744 try test__floatuntitf(make_uti(0x023479FD0E092DB6, 4), 0x1.1A3CFE870496DBp+121);
745 try test__floatuntitf(make_uti(0x023479FD0E092DBF, 5), 0x1.1A3CFE870496DF8p+121);
746 try test__floatuntitf(make_uti(0x023479FD0E092DC1, 6), 0x1.1A3CFE870496E08p+121);
747 try test__floatuntitf(make_uti(0x023479FD0E092DC7, 7), 0x1.1A3CFE870496E38p+121);
748 try test__floatuntitf(make_uti(0x023479FD0E092DC8, 8), 0x1.1A3CFE870496E4p+121);
749 try test__floatuntitf(make_uti(0x023479FD0E092DCF, 9), 0x1.1A3CFE870496E78p+121);
750 try test__floatuntitf(make_uti(0x023479FD0E092DD0, 0), 0x1.1A3CFE870496E8p+121);
751 try test__floatuntitf(make_uti(0x023479FD0E092DD1, 11), 0x1.1A3CFE870496E88p+121);
752 try test__floatuntitf(make_uti(0x023479FD0E092DD8, 12), 0x1.1A3CFE870496ECp+121);
753 try test__floatuntitf(make_uti(0x023479FD0E092DDF, 13), 0x1.1A3CFE870496EF8p+121);
754 try test__floatuntitf(make_uti(0x023479FD0E092DE0, 14), 0x1.1A3CFE870496Fp+121);
755
756 try test__floatuntitf(make_uti(0, 0xFFFFFFFFFFFFFFFF), 0x1.FFFFFFFFFFFFFFFEp+63);
757
758 try test__floatuntitf(make_uti(0xFFFFFFFFFFFFFFFF, 0x0000000000000000), 0x1.FFFFFFFFFFFFFFFEp+127);
759 try test__floatuntitf(make_uti(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF), 0x1.0000000000000000p+128);
760
761 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC2801), 0x1.23456789ABCDEF0123456789ABC3p+124);
762 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC3000), 0x1.23456789ABCDEF0123456789ABC3p+124);
763 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC37FF), 0x1.23456789ABCDEF0123456789ABC3p+124);
764 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC3800), 0x1.23456789ABCDEF0123456789ABC4p+124);
765 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC4000), 0x1.23456789ABCDEF0123456789ABC4p+124);
766 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC47FF), 0x1.23456789ABCDEF0123456789ABC4p+124);
767 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC4800), 0x1.23456789ABCDEF0123456789ABC4p+124);
768 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC4801), 0x1.23456789ABCDEF0123456789ABC5p+124);
769 try test__floatuntitf(make_uti(0x123456789ABCDEF0, 0x123456789ABC57FF), 0x1.23456789ABCDEF0123456789ABC5p+124);
770}
771
772fn make_ti(high: u64, low: u64) i128 {
773 var result: u128 = high;
774 result <<= 64;
775 result |= low;
776 return @bitCast(i128, result);
777}
778
779fn make_uti(high: u64, low: u64) u128 {
780 var result: u128 = high;
781 result <<= 64;
782 result |= low;
783 return result;
784}
785
786fn make_tf(high: u64, low: u64) f128 {
787 var result: u128 = high;
788 result <<= 64;
789 result |= low;
790 return @bitCast(f128, result);
791}
792
793test "conversion to f16" {
794 try testing.expect(__floatunsihf(@as(u32, 0)) == 0.0);
795 try testing.expect(__floatunsihf(@as(u32, 1)) == 1.0);
796 try testing.expect(__floatunsihf(@as(u32, 65504)) == 65504);
797 try testing.expect(__floatunsihf(@as(u32, 65504 + (1 << 4))) == math.inf(f16));
798}
799
800test "conversion to f32" {
801 try testing.expect(__floatunsisf(@as(u32, 0)) == 0.0);
802 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u32))) != 1.0);
803 try testing.expect(__floatsisf(@as(i32, math.minInt(i32))) != 1.0);
804 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24))) == math.maxInt(u24));
805 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 1) == math.maxInt(u24) + 1); // 0x100_0000 - Exact
806 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 2) == math.maxInt(u24) + 1); // 0x100_0001 - Tie: Rounds down to even
807 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 3) == math.maxInt(u24) + 3); // 0x100_0002 - Exact
808 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 4) == math.maxInt(u24) + 5); // 0x100_0003 - Tie: Rounds up to even
809 try testing.expect(__floatunsisf(@as(u32, math.maxInt(u24)) + 5) == math.maxInt(u24) + 5); // 0x100_0004 - Exact
810}
811
812test "conversion to f80" {
813 if (std.debug.runtime_safety) return error.SkipZigTest;
814
815 const intToFloat = @import("./int_to_float.zig").intToFloat;
816
817 try testing.expect(intToFloat(f80, @as(i80, -12)) == -12);
818 try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u64, math.maxInt(u64)) + 0)) == math.maxInt(u64) + 0);
819 try testing.expect(@floatToInt(u80, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1);
820
821 try testing.expect(intToFloat(f80, @as(u32, 0)) == 0.0);
822 try testing.expect(intToFloat(f80, @as(u32, 1)) == 1.0);
823 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u32, math.maxInt(u24)) + 0)) == math.maxInt(u24));
824 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 0)) == math.maxInt(u64));
825 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 1)) == math.maxInt(u64) + 1); // Exact
826 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 2)) == math.maxInt(u64) + 1); // Rounds down
827 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 3)) == math.maxInt(u64) + 3); // Tie - Exact
828 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u64)) + 4)) == math.maxInt(u64) + 5); // Rounds up
829
830 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 0)) == math.maxInt(u65) + 1); // Rounds up
831 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 1)) == math.maxInt(u65) + 1); // Exact
832 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 2)) == math.maxInt(u65) + 1); // Rounds down
833 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 3)) == math.maxInt(u65) + 1); // Tie - Rounds down
834 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 4)) == math.maxInt(u65) + 5); // Rounds up
835 try testing.expect(@floatToInt(u128, intToFloat(f80, @as(u80, math.maxInt(u65)) + 5)) == math.maxInt(u65) + 5); // Exact
836}
lib/compiler_rt/log.zig+2-2
......@@ -77,7 +77,7 @@ pub fn logf(x_: f32) callconv(.C) f32 {
7777 const t2 = z * (Lg1 + w * Lg3);
7878 const R = t2 + t1;
7979 const hfsq = 0.5 * f * f;
80 const dk = @intToFloat(f32, k);
80 const dk = @floatFromInt(f32, k);
8181
8282 return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
8383}
......@@ -133,7 +133,7 @@ pub fn log(x_: f64) callconv(.C) f64 {
133133 const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
134134 const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
135135 const R = t2 + t1;
136 const dk = @intToFloat(f64, k);
136 const dk = @floatFromInt(f64, k);
137137
138138 return s * (hfsq + R) + dk * ln2_lo - hfsq + f + dk * ln2_hi;
139139}
lib/compiler_rt/log10.zig+2-2
......@@ -86,7 +86,7 @@ pub fn log10f(x_: f32) callconv(.C) f32 {
8686 u &= 0xFFFFF000;
8787 hi = @bitCast(f32, u);
8888 const lo = f - hi - hfsq + s * (hfsq + R);
89 const dk = @intToFloat(f32, k);
89 const dk = @floatFromInt(f32, k);
9090
9191 return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;
9292}
......@@ -154,7 +154,7 @@ pub fn log10(x_: f64) callconv(.C) f64 {
154154
155155 // val_hi + val_lo ~ log10(1 + f) + k * log10(2)
156156 var val_hi = hi * ivln10hi;
157 const dk = @intToFloat(f64, k);
157 const dk = @floatFromInt(f64, k);
158158 const y = dk * log10_2hi;
159159 var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;
160160
lib/compiler_rt/log2.zig+2-2
......@@ -84,7 +84,7 @@ pub fn log2f(x_: f32) callconv(.C) f32 {
8484 u &= 0xFFFFF000;
8585 hi = @bitCast(f32, u);
8686 const lo = f - hi - hfsq + s * (hfsq + R);
87 return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @intToFloat(f32, k);
87 return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + @floatFromInt(f32, k);
8888}
8989
9090pub fn log2(x_: f64) callconv(.C) f64 {
......@@ -150,7 +150,7 @@ pub fn log2(x_: f64) callconv(.C) f64 {
150150 var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;
151151
152152 // spadd(val_hi, val_lo, y)
153 const y = @intToFloat(f64, k);
153 const y = @floatFromInt(f64, k);
154154 const ww = y + val_hi;
155155 val_lo += (y - ww) + val_hi;
156156 val_hi = ww;
lib/compiler_rt/memmove.zig+1-1
......@@ -8,7 +8,7 @@ comptime {
88pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 {
99 @setRuntimeSafety(false);
1010
11 if (@ptrToInt(dest) < @ptrToInt(src)) {
11 if (@intFromPtr(dest) < @intFromPtr(src)) {
1212 var index: usize = 0;
1313 while (index != n) : (index += 1) {
1414 dest.?[index] = src.?[index];
lib/compiler_rt/mulf3.zig+1-1
......@@ -126,7 +126,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
126126 // Otherwise, shift the significand of the result so that the round
127127 // bit is the high bit of productLo.
128128 const sticky = wideShrWithTruncation(ZSignificand, &productHi, &productLo, shift);
129 productLo |= @boolToInt(sticky);
129 productLo |= @intFromBool(sticky);
130130 result = productHi;
131131
132132 // We include the integer bit so that rounding will carry to the exponent,
lib/compiler_rt/os_version_check.zig+1-1
......@@ -36,7 +36,7 @@ const __isPlatformVersionAtLeast = if (builtin.os.tag.isDarwin()) struct {
3636 .platform = platform,
3737 .version = constructVersion(major, minor, subminor),
3838 };
39 return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
39 return @intFromBool(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
4040 }
4141
4242 // _availability_version_check darwin API support.
lib/compiler_rt/paritydi2_test.zig+1-1
......@@ -9,7 +9,7 @@ fn paritydi2Naive(a: i64) i32 {
99 has_parity = !has_parity;
1010 x = x & (x - 1);
1111 }
12 return @intCast(i32, @boolToInt(has_parity));
12 return @intCast(i32, @intFromBool(has_parity));
1313}
1414
1515fn test__paritydi2(a: i64) !void {
lib/compiler_rt/paritysi2_test.zig+1-1
......@@ -9,7 +9,7 @@ fn paritysi2Naive(a: i32) i32 {
99 has_parity = !has_parity;
1010 x = x & (x - 1);
1111 }
12 return @intCast(i32, @boolToInt(has_parity));
12 return @intCast(i32, @intFromBool(has_parity));
1313}
1414
1515fn test__paritysi2(a: i32) !void {
lib/compiler_rt/parityti2_test.zig+1-1
......@@ -9,7 +9,7 @@ fn parityti2Naive(a: i128) i32 {
99 has_parity = !has_parity;
1010 x = x & (x - 1);
1111 }
12 return @intCast(i32, @boolToInt(has_parity));
12 return @intCast(i32, @intFromBool(has_parity));
1313}
1414
1515fn test__parityti2(a: i128) !void {
lib/compiler_rt/rem_pio2.zig+2-2
......@@ -41,7 +41,7 @@ fn medium(ix: u32, x: f64, y: *[2]f64) i32 {
4141
4242 // rint(x/(pi/2))
4343 @"fn" = x * invpio2 + toint - toint;
44 n = @floatToInt(i32, @"fn");
44 n = @intFromFloat(i32, @"fn");
4545 r = x - @"fn" * pio2_1;
4646 w = @"fn" * pio2_1t; // 1st round, good to 85 bits
4747 // Matters with directed rounding.
......@@ -178,7 +178,7 @@ pub fn rem_pio2(x: f64, y: *[2]f64) i32 {
178178
179179 i = 0;
180180 while (i < 2) : (i += 1) {
181 tx[U(i)] = @intToFloat(f64, @floatToInt(i32, z));
181 tx[U(i)] = @floatFromInt(f64, @intFromFloat(i32, z));
182182 z = (z - tx[U(i)]) * 0x1p24;
183183 }
184184 tx[U(i)] = z;
lib/compiler_rt/rem_pio2_large.zig+11-11
......@@ -295,7 +295,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
295295 i += 1;
296296 j += 1;
297297 }) {
298 f[U(i)] = if (j < 0) 0.0 else @intToFloat(f64, ipio2[U(j)]);
298 f[U(i)] = if (j < 0) 0.0 else @floatFromInt(f64, ipio2[U(j)]);
299299 }
300300
301301 // 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 {
322322 i += 1;
323323 j -= 1;
324324 }) {
325 fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z));
326 iq[U(i)] = @floatToInt(i32, z - 0x1p24 * fw);
325 fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z));
326 iq[U(i)] = @intFromFloat(i32, z - 0x1p24 * fw);
327327 z = q[U(j - 1)] + fw;
328328 }
329329
330330 // compute n
331331 z = math.scalbn(z, q0); // actual value of z
332332 z -= 8.0 * @floor(z * 0.125); // trim off integer >= 8
333 n = @floatToInt(i32, z);
334 z -= @intToFloat(f64, n);
333 n = @intFromFloat(i32, z);
334 z -= @floatFromInt(f64, n);
335335 ih = 0;
336336 if (q0 > 0) { // need iq[jz-1] to determine n
337337 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 {
390390
391391 i = jz + 1;
392392 while (i <= jz + k) : (i += 1) { // add q[jz+1] to q[jz+k]
393 f[U(jx + i)] = @intToFloat(f64, ipio2[U(jv + i)]);
393 f[U(jx + i)] = @floatFromInt(f64, ipio2[U(jv + i)]);
394394 j = 0;
395395 fw = 0;
396396 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 {
414414 } else { // break z into 24-bit if necessary
415415 z = math.scalbn(z, -q0);
416416 if (z >= 0x1p24) {
417 fw = @intToFloat(f64, @floatToInt(i32, 0x1p-24 * z));
418 iq[U(jz)] = @floatToInt(i32, z - 0x1p24 * fw);
417 fw = @floatFromInt(f64, @intFromFloat(i32, 0x1p-24 * z));
418 iq[U(jz)] = @intFromFloat(i32, z - 0x1p24 * fw);
419419 jz += 1;
420420 q0 += 24;
421 iq[U(jz)] = @floatToInt(i32, fw);
421 iq[U(jz)] = @intFromFloat(i32, fw);
422422 } else {
423 iq[U(jz)] = @floatToInt(i32, z);
423 iq[U(jz)] = @intFromFloat(i32, z);
424424 }
425425 }
426426
......@@ -428,7 +428,7 @@ pub fn rem_pio2_large(x: []f64, y: []f64, e0: i32, nx: i32, prec: usize) i32 {
428428 fw = math.scalbn(@as(f64, 1.0), q0);
429429 i = jz;
430430 while (i >= 0) : (i -= 1) {
431 q[U(i)] = fw * @intToFloat(f64, iq[U(i)]);
431 q[U(i)] = fw * @floatFromInt(f64, iq[U(i)]);
432432 fw *= 0x1p-24;
433433 }
434434
lib/compiler_rt/rem_pio2f.zig+1-1
......@@ -37,7 +37,7 @@ pub fn rem_pio2f(x: f32, y: *f64) i32 {
3737 if (ix < 0x4dc90fdb) { // |x| ~< 2^28*(pi/2), medium size
3838 // Use a specialized rint() to get fn.
3939 @"fn" = @floatCast(f64, x) * invpio2 + toint - toint;
40 n = @floatToInt(i32, @"fn");
40 n = @intFromFloat(i32, @"fn");
4141 y.* = x - @"fn" * pio2_1 - @"fn" * pio2_1t;
4242 // Matters with directed rounding.
4343 if (y.* < -pio4) {
lib/compiler_rt/trig.zig+1-1
......@@ -222,7 +222,7 @@ pub fn __tan(x_: f64, y_: f64, odd: bool) f64 {
222222 r = y + z * (s * (r + v) + y) + s * T[0];
223223 w = x + r;
224224 if (big) {
225 s = 1 - 2 * @intToFloat(f64, @boolToInt(odd));
225 s = 1 - 2 * @floatFromInt(f64, @intFromBool(odd));
226226 v = s - 2.0 * (x + (r - w * w / (w + s)));
227227 return if (sign) -v else v;
228228 }
lib/compiler_rt/truncf.zig+2-2
......@@ -81,7 +81,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
8181 if (shift > srcSigBits) {
8282 absResult = 0;
8383 } else {
84 const sticky: src_rep_t = @boolToInt(significand << @intCast(SrcShift, srcBits - shift) != 0);
84 const sticky: src_rep_t = @intFromBool(significand << @intCast(SrcShift, srcBits - shift) != 0);
8585 const denormalizedSignificand: src_rep_t = significand >> @intCast(SrcShift, shift) | sticky;
8686 absResult = @intCast(dst_rep_t, denormalizedSignificand >> (srcSigBits - dstSigBits));
8787 const roundBits: src_rep_t = denormalizedSignificand & roundMask;
......@@ -164,7 +164,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
164164 if (shift > src_sig_bits) {
165165 abs_result = 0;
166166 } else {
167 const sticky = @boolToInt(a_rep.fraction << @intCast(u6, shift) != 0);
167 const sticky = @intFromBool(a_rep.fraction << @intCast(u6, shift) != 0);
168168 const denormalized_significand = a_rep.fraction >> @intCast(u6, shift) | sticky;
169169 abs_result = @intCast(dst_rep_t, denormalized_significand >> (src_sig_bits - dst_sig_bits));
170170 const round_bits = denormalized_significand & round_mask;
lib/docs/main.js+19-19
......@@ -1234,9 +1234,9 @@ const NAV_MODES = {
12341234 const name = getAstNode(field).name;
12351235 return name;
12361236 }
1237 case "enumToInt": {
1238 const enumToInt = zigAnalysis.exprs[expr.enumToInt];
1239 return "@enumToInt(" + exprName(enumToInt, opts) + ")";
1237 case "intFromEnum": {
1238 const intFromEnum = zigAnalysis.exprs[expr.intFromEnum];
1239 return "@intFromEnum(" + exprName(intFromEnum, opts) + ")";
12401240 }
12411241 case "bitSizeOf": {
12421242 const bitSizeOf = zigAnalysis.exprs[expr.bitSizeOf];
......@@ -1260,8 +1260,8 @@ const NAV_MODES = {
12601260 payloadHtml += "alignOf";
12611261 break;
12621262 }
1263 case "bool_to_int": {
1264 payloadHtml += "boolToInt";
1263 case "int_from_bool": {
1264 payloadHtml += "intFromBool";
12651265 break;
12661266 }
12671267 case "embed_file": {
......@@ -1368,16 +1368,16 @@ const NAV_MODES = {
13681368 payloadHtml += "workGroupId";
13691369 break;
13701370 }
1371 case "ptr_to_int": {
1372 payloadHtml += "ptrToInt";
1371 case "int_from_ptr": {
1372 payloadHtml += "intFromPtr";
13731373 break;
13741374 }
1375 case "error_to_int": {
1376 payloadHtml += "errorToInt";
1375 case "int_from_error": {
1376 payloadHtml += "intFromError";
13771377 break;
13781378 }
1379 case "int_to_error": {
1380 payloadHtml += "intToError";
1379 case "error_to_int": {
1380 payloadHtml += "errorFromInt";
13811381 break;
13821382 }
13831383 case "max": {
......@@ -1423,20 +1423,20 @@ const NAV_MODES = {
14231423
14241424 let payloadHtml = "@";
14251425 switch (expr.builtinBin.name) {
1426 case "float_to_int": {
1427 payloadHtml += "floatToInt";
1426 case "int_from_float": {
1427 payloadHtml += "intFromFloat";
14281428 break;
14291429 }
1430 case "int_to_float": {
1431 payloadHtml += "intToFloat";
1430 case "float_from_int": {
1431 payloadHtml += "floatFromInt";
14321432 break;
14331433 }
1434 case "int_to_ptr": {
1435 payloadHtml += "intToPtr";
1434 case "ptr_from_int": {
1435 payloadHtml += "ptrFromInt";
14361436 break;
14371437 }
1438 case "int_to_enum": {
1439 payloadHtml += "intToEnum";
1438 case "enum_from_int": {
1439 payloadHtml += "enumFromInt";
14401440 break;
14411441 }
14421442 case "float_cast": {
lib/std/Build/Step/Run.zig+3-3
......@@ -1035,9 +1035,9 @@ fn evalZigTest(
10351035
10361036 const TrHdr = std.zig.Server.Message.TestResults;
10371037 const tr_hdr = @ptrCast(*align(1) const TrHdr, body);
1038 fail_count += @boolToInt(tr_hdr.flags.fail);
1039 skip_count += @boolToInt(tr_hdr.flags.skip);
1040 leak_count += @boolToInt(tr_hdr.flags.leak);
1038 fail_count += @intFromBool(tr_hdr.flags.fail);
1039 skip_count += @intFromBool(tr_hdr.flags.skip);
1040 leak_count += @intFromBool(tr_hdr.flags.leak);
10411041
10421042 if (tr_hdr.flags.fail or tr_hdr.flags.leak) {
10431043 const name = std.mem.sliceTo(md.string_bytes[md.names[tr_hdr.index]..], 0);
lib/std/RingBuffer.zig+1-1
......@@ -102,7 +102,7 @@ pub fn isFull(self: RingBuffer) bool {
102102
103103/// Returns the length
104104pub fn len(self: RingBuffer) usize {
105 const wrap_offset = 2 * self.data.len * @boolToInt(self.write_index < self.read_index);
105 const wrap_offset = 2 * self.data.len * @intFromBool(self.write_index < self.read_index);
106106 const adjusted_write_index = self.write_index + wrap_offset;
107107 return adjusted_write_index - self.read_index;
108108}
lib/std/Thread.zig+18-18
......@@ -65,8 +65,8 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
6565 .linux => if (use_pthreads) {
6666 if (self.getHandle() == std.c.pthread_self()) {
6767 // Set the name of the calling thread (no thread id required).
68 const err = try os.prctl(.SET_NAME, .{@ptrToInt(name_with_terminator.ptr)});
69 switch (@intToEnum(os.E, err)) {
68 const err = try os.prctl(.SET_NAME, .{@intFromPtr(name_with_terminator.ptr)});
69 switch (@enumFromInt(os.E, err)) {
7070 .SUCCESS => return,
7171 else => |e| return os.unexpectedErrno(e),
7272 }
......@@ -175,8 +175,8 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
175175 .linux => if (use_pthreads) {
176176 if (self.getHandle() == std.c.pthread_self()) {
177177 // Get the name of the calling thread (no thread id required).
178 const err = try os.prctl(.GET_NAME, .{@ptrToInt(buffer.ptr)});
179 switch (@intToEnum(os.E, err)) {
178 const err = try os.prctl(.GET_NAME, .{@intFromPtr(buffer.ptr)});
179 switch (@enumFromInt(os.E, err)) {
180180 .SUCCESS => return std.mem.sliceTo(buffer, 0),
181181 else => |e| return os.unexpectedErrno(e),
182182 }
......@@ -611,7 +611,7 @@ const PosixThreadImpl = struct {
611611 return @bitCast(u32, c.find_thread(null));
612612 },
613613 else => {
614 return @ptrToInt(c.pthread_self());
614 return @intFromPtr(c.pthread_self());
615615 },
616616 }
617617 }
......@@ -776,7 +776,7 @@ const LinuxThreadImpl = struct {
776776 \\ movl $0, %%ebx
777777 \\ int $128
778778 :
779 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
779 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
780780 [len] "r" (self.mapped.len),
781781 : "memory"
782782 ),
......@@ -787,7 +787,7 @@ const LinuxThreadImpl = struct {
787787 \\ movq $1, %%rdi
788788 \\ syscall
789789 :
790 : [ptr] "{rdi}" (@ptrToInt(self.mapped.ptr)),
790 : [ptr] "{rdi}" (@intFromPtr(self.mapped.ptr)),
791791 [len] "{rsi}" (self.mapped.len),
792792 ),
793793 .arm, .armeb, .thumb, .thumbeb => asm volatile (
......@@ -799,7 +799,7 @@ const LinuxThreadImpl = struct {
799799 \\ mov r0, #0
800800 \\ svc 0
801801 :
802 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
802 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
803803 [len] "r" (self.mapped.len),
804804 : "memory"
805805 ),
......@@ -812,7 +812,7 @@ const LinuxThreadImpl = struct {
812812 \\ mov x0, #0
813813 \\ svc 0
814814 :
815 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
815 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
816816 [len] "r" (self.mapped.len),
817817 : "memory"
818818 ),
......@@ -826,7 +826,7 @@ const LinuxThreadImpl = struct {
826826 \\ li $4, 0
827827 \\ syscall
828828 :
829 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
829 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
830830 [len] "r" (self.mapped.len),
831831 : "memory"
832832 ),
......@@ -839,7 +839,7 @@ const LinuxThreadImpl = struct {
839839 \\ li $4, 0
840840 \\ syscall
841841 :
842 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
842 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
843843 [len] "r" (self.mapped.len),
844844 : "memory"
845845 ),
......@@ -853,7 +853,7 @@ const LinuxThreadImpl = struct {
853853 \\ sc
854854 \\ blr
855855 :
856 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
856 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
857857 [len] "r" (self.mapped.len),
858858 : "memory"
859859 ),
......@@ -866,7 +866,7 @@ const LinuxThreadImpl = struct {
866866 \\ mv a0, zero
867867 \\ ecall
868868 :
869 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
869 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
870870 [len] "r" (self.mapped.len),
871871 : "memory"
872872 ),
......@@ -893,7 +893,7 @@ const LinuxThreadImpl = struct {
893893 \\ mov 1, %%o0
894894 \\ t 0x6d
895895 :
896 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
896 : [ptr] "r" (@intFromPtr(self.mapped.ptr)),
897897 [len] "r" (self.mapped.len),
898898 : "memory"
899899 ),
......@@ -911,7 +911,7 @@ const LinuxThreadImpl = struct {
911911 thread: ThreadCompletion,
912912
913913 fn entryFn(raw_arg: usize) callconv(.C) u8 {
914 const self = @intToPtr(*@This(), raw_arg);
914 const self = @ptrFromInt(*@This(), raw_arg);
915915 defer switch (self.thread.completion.swap(.completed, .SeqCst)) {
916916 .running => {},
917917 .completed => unreachable,
......@@ -980,7 +980,7 @@ const LinuxThreadImpl = struct {
980980 var tls_ptr = os.linux.tls.prepareTLS(mapped[tls_offset..]);
981981 var user_desc: if (target.cpu.arch == .x86) os.linux.user_desc else void = undefined;
982982 if (target.cpu.arch == .x86) {
983 defer tls_ptr = @ptrToInt(&user_desc);
983 defer tls_ptr = @intFromPtr(&user_desc);
984984 user_desc = .{
985985 .entry_number = os.linux.tls.tls_image.gdt_entry_number,
986986 .base_addr = tls_ptr,
......@@ -1007,9 +1007,9 @@ const LinuxThreadImpl = struct {
10071007
10081008 switch (linux.getErrno(linux.clone(
10091009 Instance.entryFn,
1010 @ptrToInt(&mapped[stack_offset]),
1010 @intFromPtr(&mapped[stack_offset]),
10111011 flags,
1012 @ptrToInt(instance),
1012 @intFromPtr(instance),
10131013 &instance.thread.parent_tid,
10141014 tls_ptr,
10151015 &instance.thread.child_tid.value,
lib/std/Thread/Condition.zig+1-1
......@@ -487,7 +487,7 @@ test "Condition - multi signal" {
487487
488488 // The first paddle will be hit one last time by the last paddle.
489489 for (paddles, 0..) |p, i| {
490 const expected = @as(u32, num_iterations) + @boolToInt(i == 0);
490 const expected = @as(u32, num_iterations) + @intFromBool(i == 0);
491491 try testing.expectEqual(p.value, expected);
492492 }
493493}
lib/std/Thread/Futex.zig+8-8
......@@ -202,7 +202,7 @@ const DarwinImpl = struct {
202202 };
203203
204204 if (status >= 0) return;
205 switch (@intToEnum(std.os.E, -status)) {
205 switch (@enumFromInt(std.os.E, -status)) {
206206 // Wait was interrupted by the OS or other spurious signalling.
207207 .INTR => {},
208208 // Address of the futex was paged out. This is unlikely, but possible in theory, and
......@@ -229,7 +229,7 @@ const DarwinImpl = struct {
229229 const status = os.darwin.__ulock_wake(flags, addr, 0);
230230
231231 if (status >= 0) return;
232 switch (@intToEnum(std.os.E, -status)) {
232 switch (@enumFromInt(std.os.E, -status)) {
233233 .INTR => continue, // spurious wake()
234234 .FAULT => unreachable, // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t
235235 .NOENT => return, // nothing was woken up
......@@ -304,11 +304,11 @@ const FreebsdImpl = struct {
304304 }
305305
306306 const rc = os.freebsd._umtx_op(
307 @ptrToInt(&ptr.value),
308 @enumToInt(os.freebsd.UMTX_OP.WAIT_UINT_PRIVATE),
307 @intFromPtr(&ptr.value),
308 @intFromEnum(os.freebsd.UMTX_OP.WAIT_UINT_PRIVATE),
309309 @as(c_ulong, expect),
310310 tm_size,
311 @ptrToInt(tm_ptr),
311 @intFromPtr(tm_ptr),
312312 );
313313
314314 switch (os.errno(rc)) {
......@@ -326,8 +326,8 @@ const FreebsdImpl = struct {
326326
327327 fn wake(ptr: *const Atomic(u32), max_waiters: u32) void {
328328 const rc = os.freebsd._umtx_op(
329 @ptrToInt(&ptr.value),
330 @enumToInt(os.freebsd.UMTX_OP.WAKE_PRIVATE),
329 @intFromPtr(&ptr.value),
330 @intFromEnum(os.freebsd.UMTX_OP.WAKE_PRIVATE),
331331 @as(c_ulong, max_waiters),
332332 0, // there is no timeout struct
333333 0, // there is no timeout struct pointer
......@@ -719,7 +719,7 @@ const PosixImpl = struct {
719719
720720 // Make sure the pointer is aligned,
721721 // then cut off the zero bits from the alignment to get the unique address.
722 const addr = @ptrToInt(ptr);
722 const addr = @intFromPtr(ptr);
723723 assert(addr & (alignment - 1) == 0);
724724 return addr >> @ctz(@as(usize, alignment));
725725 }
lib/std/array_hash_map.zig+1-1
......@@ -2310,7 +2310,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context,
23102310 return struct {
23112311 fn hash(ctx: Context, key: K) u32 {
23122312 _ = ctx;
2313 return getAutoHashFn(usize, void)({}, @ptrToInt(key));
2313 return getAutoHashFn(usize, void)({}, @intFromPtr(key));
23142314 }
23152315 }.hash;
23162316}
lib/std/atomic/Atomic.zig+3-3
......@@ -227,7 +227,7 @@ pub fn Atomic(comptime T: type) type {
227227 .Toggle => self.fetchXor(mask, ordering),
228228 };
229229
230 return @boolToInt(value & mask != 0);
230 return @intFromBool(value & mask != 0);
231231 }
232232
233233 inline fn x86BitRmw(self: *Self, comptime op: BitRmwOp, bit: Bit, comptime ordering: Ordering) u1 {
......@@ -392,8 +392,8 @@ test "Atomic.swap" {
392392 try testing.expectEqual(a.load(.SeqCst), true);
393393
394394 var b = Atomic(?*u8).init(null);
395 try testing.expectEqual(b.swap(@intToPtr(?*u8, @alignOf(u8)), ordering), null);
396 try testing.expectEqual(b.load(.SeqCst), @intToPtr(?*u8, @alignOf(u8)));
395 try testing.expectEqual(b.swap(@ptrFromInt(?*u8, @alignOf(u8)), ordering), null);
396 try testing.expectEqual(b.load(.SeqCst), @ptrFromInt(?*u8, @alignOf(u8)));
397397 }
398398}
399399
lib/std/atomic/queue.zig+3-3
......@@ -135,7 +135,7 @@ pub fn Queue(comptime T: type) type {
135135 ) !void {
136136 try s.writeByteNTimes(' ', indent);
137137 if (optional_node) |node| {
138 try s.print("0x{x}={}\n", .{ @ptrToInt(node), node.data });
138 try s.print("0x{x}={}\n", .{ @intFromPtr(node), node.data });
139139 if (depth == 0) {
140140 try s.print("(max depth)\n", .{});
141141 return;
......@@ -387,7 +387,7 @@ test "std.atomic.Queue dump" {
387387 \\tail: 0x{x}=1
388388 \\ (null)
389389 \\
390 , .{ @ptrToInt(queue.head), @ptrToInt(queue.tail) });
390 , .{ @intFromPtr(queue.head), @intFromPtr(queue.tail) });
391391 try expect(mem.eql(u8, buffer[0..fbs.pos], expected));
392392
393393 // Test a stream with two elements
......@@ -408,6 +408,6 @@ test "std.atomic.Queue dump" {
408408 \\tail: 0x{x}=2
409409 \\ (null)
410410 \\
411 , .{ @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail) });
411 , .{ @intFromPtr(queue.head), @intFromPtr(queue.head.?.next), @intFromPtr(queue.tail) });
412412 try expect(mem.eql(u8, buffer[0..fbs.pos], expected));
413413}
lib/std/bit_set.zig+4-4
......@@ -306,7 +306,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
306306 }
307307 fn boolMaskBit(index: usize, value: bool) MaskInt {
308308 if (MaskInt == u0) return 0;
309 return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index);
309 return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index);
310310 }
311311 };
312312}
......@@ -640,7 +640,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
640640 return index >> @bitSizeOf(ShiftInt);
641641 }
642642 fn boolMaskBit(index: usize, value: bool) MaskInt {
643 return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index);
643 return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index);
644644 }
645645 };
646646}
......@@ -669,7 +669,7 @@ pub const DynamicBitSetUnmanaged = struct {
669669
670670 // Don't modify this value. Ideally it would go in const data so
671671 // modifications would cause a bus error, but the only way
672 // to discard a const qualifier is through ptrToInt, which
672 // to discard a const qualifier is through intFromPtr, which
673673 // cannot currently round trip at comptime.
674674 var empty_masks_data = [_]MaskInt{ 0, undefined };
675675 const empty_masks_ptr = empty_masks_data[1..2];
......@@ -1011,7 +1011,7 @@ pub const DynamicBitSetUnmanaged = struct {
10111011 return index >> @bitSizeOf(ShiftInt);
10121012 }
10131013 fn boolMaskBit(index: usize, value: bool) MaskInt {
1014 return @as(MaskInt, @boolToInt(value)) << @intCast(ShiftInt, index);
1014 return @as(MaskInt, @intFromBool(value)) << @intCast(ShiftInt, index);
10151015 }
10161016 fn numMasks(bit_length: usize) usize {
10171017 return (bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt);
lib/std/c.zig+1-1
......@@ -113,7 +113,7 @@ pub usingnamespace switch (builtin.os.tag) {
113113
114114pub fn getErrno(rc: anytype) c.E {
115115 if (rc == -1) {
116 return @intToEnum(c.E, c._errno().*);
116 return @enumFromInt(c.E, c._errno().*);
117117 } else {
118118 return .SUCCESS;
119119 }
lib/std/c/darwin.zig+31-31
......@@ -51,19 +51,19 @@ pub const EXC = enum(exception_type_t) {
5151
5252pub const EXC_SOFT_SIGNAL = 0x10003;
5353
54pub const EXC_MASK_BAD_ACCESS = 1 << @enumToInt(EXC.BAD_ACCESS);
55pub const EXC_MASK_BAD_INSTRUCTION = 1 << @enumToInt(EXC.BAD_INSTRUCTION);
56pub const EXC_MASK_ARITHMETIC = 1 << @enumToInt(EXC.ARITHMETIC);
57pub const EXC_MASK_EMULATION = 1 << @enumToInt(EXC.EMULATION);
58pub const EXC_MASK_SOFTWARE = 1 << @enumToInt(EXC.SOFTWARE);
59pub const EXC_MASK_BREAKPOINT = 1 << @enumToInt(EXC.BREAKPOINT);
60pub const EXC_MASK_SYSCALL = 1 << @enumToInt(EXC.SYSCALL);
61pub const EXC_MASK_MACH_SYSCALL = 1 << @enumToInt(EXC.MACH_SYSCALL);
62pub const EXC_MASK_RPC_ALERT = 1 << @enumToInt(EXC.RPC_ALERT);
63pub const EXC_MASK_CRASH = 1 << @enumToInt(EXC.CRASH);
64pub const EXC_MASK_RESOURCE = 1 << @enumToInt(EXC.RESOURCE);
65pub const EXC_MASK_GUARD = 1 << @enumToInt(EXC.GUARD);
66pub const EXC_MASK_CORPSE_NOTIFY = 1 << @enumToInt(EXC.CORPSE_NOTIFY);
54pub const EXC_MASK_BAD_ACCESS = 1 << @intFromEnum(EXC.BAD_ACCESS);
55pub const EXC_MASK_BAD_INSTRUCTION = 1 << @intFromEnum(EXC.BAD_INSTRUCTION);
56pub const EXC_MASK_ARITHMETIC = 1 << @intFromEnum(EXC.ARITHMETIC);
57pub const EXC_MASK_EMULATION = 1 << @intFromEnum(EXC.EMULATION);
58pub const EXC_MASK_SOFTWARE = 1 << @intFromEnum(EXC.SOFTWARE);
59pub const EXC_MASK_BREAKPOINT = 1 << @intFromEnum(EXC.BREAKPOINT);
60pub const EXC_MASK_SYSCALL = 1 << @intFromEnum(EXC.SYSCALL);
61pub const EXC_MASK_MACH_SYSCALL = 1 << @intFromEnum(EXC.MACH_SYSCALL);
62pub const EXC_MASK_RPC_ALERT = 1 << @intFromEnum(EXC.RPC_ALERT);
63pub const EXC_MASK_CRASH = 1 << @intFromEnum(EXC.CRASH);
64pub const EXC_MASK_RESOURCE = 1 << @intFromEnum(EXC.RESOURCE);
65pub const EXC_MASK_GUARD = 1 << @intFromEnum(EXC.GUARD);
66pub const EXC_MASK_CORPSE_NOTIFY = 1 << @intFromEnum(EXC.CORPSE_NOTIFY);
6767pub const EXC_MASK_MACHINE = arch_bits.EXC_MASK_MACHINE;
6868
6969pub const EXC_MASK_ALL = EXC_MASK_BAD_ACCESS |
......@@ -1177,10 +1177,10 @@ pub const sigset_t = u32;
11771177pub const empty_sigset: sigset_t = 0;
11781178
11791179pub const SIG = struct {
1180 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
1181 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
1182 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
1183 pub const HOLD = @intToPtr(?Sigaction.handler_fn, 5);
1180 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
1181 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
1182 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
1183 pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 5);
11841184
11851185 /// block specified signal set
11861186 pub const _BLOCK = 1;
......@@ -1411,7 +1411,7 @@ pub const MAP = struct {
14111411 pub const NOCACHE = 0x0400;
14121412 /// don't reserve needed swap area
14131413 pub const NORESERVE = 0x0040;
1414 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
1414 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
14151415};
14161416
14171417pub const MSF = struct {
......@@ -2463,7 +2463,7 @@ pub const KernE = enum(u32) {
24632463pub const mach_msg_return_t = kern_return_t;
24642464
24652465pub fn getMachMsgError(err: mach_msg_return_t) MachMsgE {
2466 return @intToEnum(MachMsgE, @truncate(u32, @intCast(usize, err)));
2466 return @enumFromInt(MachMsgE, @truncate(u32, @intCast(usize, err)));
24672467}
24682468
24692469/// All special error code bits defined below.
......@@ -2665,10 +2665,10 @@ pub const RTLD = struct {
26652665 pub const NODELETE = 0x80;
26662666 pub const FIRST = 0x100;
26672667
2668 pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)));
2669 pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2)));
2670 pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3)));
2671 pub const MAIN_ONLY = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -5)));
2668 pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1)));
2669 pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2)));
2670 pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3)));
2671 pub const MAIN_ONLY = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -5)));
26722672};
26732673
26742674pub const F = struct {
......@@ -3418,12 +3418,12 @@ pub const PosixSpawn = struct {
34183418};
34193419
34203420pub fn getKernError(err: kern_return_t) KernE {
3421 return @intToEnum(KernE, @truncate(u32, @intCast(usize, err)));
3421 return @enumFromInt(KernE, @truncate(u32, @intCast(usize, err)));
34223422}
34233423
34243424pub fn unexpectedKernError(err: KernE) std.os.UnexpectedError {
34253425 if (std.os.unexpected_error_tracing) {
3426 std.debug.print("unexpected error: {d}\n", .{@enumToInt(err)});
3426 std.debug.print("unexpected error: {d}\n", .{@intFromEnum(err)});
34273427 std.debug.dumpCurrentStackTrace(null);
34283428 }
34293429 return error.Unexpected;
......@@ -3455,7 +3455,7 @@ pub const MachTask = extern struct {
34553455 var out_port: mach_port_name_t = undefined;
34563456 switch (getKernError(mach_port_allocate(
34573457 self.port,
3458 @enumToInt(right),
3458 @intFromEnum(right),
34593459 &out_port,
34603460 ))) {
34613461 .SUCCESS => return .{ .port = out_port },
......@@ -3473,7 +3473,7 @@ pub const MachTask = extern struct {
34733473 self.port,
34743474 port.port,
34753475 port.port,
3476 @enumToInt(msg),
3476 @intFromEnum(msg),
34773477 ))) {
34783478 .SUCCESS => return,
34793479 .FAILURE => return error.PermissionDenied,
......@@ -3665,7 +3665,7 @@ pub const MachTask = extern struct {
36653665 }
36663666
36673667 fn setProtectionImpl(task: MachTask, address: u64, len: usize, set_max: bool, prot: vm_prot_t) MachError!void {
3668 switch (getKernError(mach_vm_protect(task.port, address, len, @boolToInt(set_max), prot))) {
3668 switch (getKernError(mach_vm_protect(task.port, address, len, @intFromBool(set_max), prot))) {
36693669 .SUCCESS => return,
36703670 .FAILURE => return error.PermissionDenied,
36713671 else => |err| return unexpectedKernError(err),
......@@ -3700,7 +3700,7 @@ pub const MachTask = extern struct {
37003700 switch (getKernError(mach_vm_write(
37013701 task.port,
37023702 curr_addr,
3703 @ptrToInt(out_buf.ptr),
3703 @intFromPtr(out_buf.ptr),
37043704 @intCast(mach_msg_type_number_t, curr_size),
37053705 ))) {
37063706 .SUCCESS => {},
......@@ -3752,7 +3752,7 @@ pub const MachTask = extern struct {
37523752 else => |err| return unexpectedKernError(err),
37533753 }
37543754
3755 @memcpy(out_buf[0..curr_bytes_read], @intToPtr([*]const u8, vm_memory));
3755 @memcpy(out_buf[0..curr_bytes_read], @ptrFromInt([*]const u8, vm_memory));
37563756 _ = vm_deallocate(mach_task_self(), vm_memory, curr_bytes_read);
37573757
37583758 out_buf = out_buf[curr_bytes_read..];
......@@ -3831,7 +3831,7 @@ pub const MachTask = extern struct {
38313831 const self_task = machTaskForSelf();
38323832 _ = vm_deallocate(
38333833 self_task.port,
3834 @ptrToInt(list.buf.ptr),
3834 @intFromPtr(list.buf.ptr),
38353835 @intCast(vm_size_t, list.buf.len * @sizeOf(mach_port_t)),
38363836 );
38373837 }
lib/std/c/dragonfly.zig+8-8
......@@ -172,7 +172,7 @@ pub const PROT = struct {
172172
173173pub const MAP = struct {
174174 pub const FILE = 0;
175 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
175 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
176176 pub const ANONYMOUS = ANON;
177177 pub const COPY = PRIVATE;
178178 pub const SHARED = 1;
......@@ -620,9 +620,9 @@ pub const S = struct {
620620pub const BADSIG = SIG.ERR;
621621
622622pub const SIG = struct {
623 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
624 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
625 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
623 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
624 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
625 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
626626
627627 pub const BLOCK = 1;
628628 pub const UNBLOCK = 2;
......@@ -871,10 +871,10 @@ pub const RTLD = struct {
871871 pub const NODELETE = 0x01000;
872872 pub const NOLOAD = 0x02000;
873873
874 pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)));
875 pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2)));
876 pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3)));
877 pub const ALL = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -4)));
874 pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1)));
875 pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2)));
876 pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3)));
877 pub const ALL = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -4)));
878878};
879879
880880pub const dl_phdr_info = extern struct {
lib/std/c/freebsd.zig+5-5
......@@ -961,7 +961,7 @@ pub const CLOCK = struct {
961961};
962962
963963pub const MAP = struct {
964 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
964 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
965965 pub const SHARED = 0x0001;
966966 pub const PRIVATE = 0x0002;
967967 pub const FIXED = 0x0010;
......@@ -1086,9 +1086,9 @@ pub const SIG = struct {
10861086 pub const UNBLOCK = 2;
10871087 pub const SETMASK = 3;
10881088
1089 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
1090 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
1091 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
1089 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
1090 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
1091 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
10921092
10931093 pub const WORDS = 4;
10941094 pub const MAXSIG = 128;
......@@ -2650,7 +2650,7 @@ const ioctl_cmd = enum(u32) {
26502650};
26512651
26522652fn ioImpl(cmd: ioctl_cmd, op: u8, nr: u8, comptime IT: type) u32 {
2653 return @bitCast(u32, @enumToInt(cmd) | @intCast(u32, @truncate(u8, @sizeOf(IT))) << 16 | @intCast(u32, op) << 8 | nr);
2653 return @bitCast(u32, @intFromEnum(cmd) | @intCast(u32, @truncate(u8, @sizeOf(IT))) << 16 | @intCast(u32, op) << 8 | nr);
26542654}
26552655
26562656pub fn IO(op: u8, nr: u8) u32 {
lib/std/c/haiku.zig+4-4
......@@ -414,7 +414,7 @@ pub const CLOCK = struct {
414414
415415pub const MAP = struct {
416416 /// mmap() error return code
417 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
417 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
418418 /// changes are seen by others
419419 pub const SHARED = 0x01;
420420 /// changes are only seen by caller
......@@ -481,9 +481,9 @@ pub const SA = struct {
481481};
482482
483483pub const SIG = struct {
484 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
485 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
486 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
484 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
485 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
486 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
487487
488488 pub const HUP = 1;
489489 pub const INT = 2;
lib/std/c/linux.zig+1-1
......@@ -32,7 +32,7 @@ pub const MADV = linux.MADV;
3232pub const MAP = struct {
3333 pub usingnamespace linux.MAP;
3434 /// Only used by libc to communicate failure.
35 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
35 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
3636};
3737pub const MSF = linux.MSF;
3838pub const MMAP2_UNIT = linux.MMAP2_UNIT;
lib/std/c/netbsd.zig+7-7
......@@ -172,9 +172,9 @@ pub const RTLD = struct {
172172 pub const NODELETE = 0x01000;
173173 pub const NOLOAD = 0x02000;
174174
175 pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)));
176 pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2)));
177 pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3)));
175 pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1)));
176 pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2)));
177 pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3)));
178178};
179179
180180pub const dl_phdr_info = extern struct {
......@@ -591,7 +591,7 @@ pub const CLOCK = struct {
591591};
592592
593593pub const MAP = struct {
594 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
594 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
595595 pub const SHARED = 0x0001;
596596 pub const PRIVATE = 0x0002;
597597 pub const REMAPDUP = 0x0004;
......@@ -1090,9 +1090,9 @@ pub const winsize = extern struct {
10901090const NSIG = 32;
10911091
10921092pub const SIG = struct {
1093 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
1094 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
1095 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
1093 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
1094 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
1095 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
10961096
10971097 pub const WORDS = 4;
10981098 pub const MAXSIG = 128;
lib/std/c/openbsd.zig+6-6
......@@ -449,7 +449,7 @@ pub const CLOCK = struct {
449449};
450450
451451pub const MAP = struct {
452 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
452 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
453453 pub const SHARED = 0x0001;
454454 pub const PRIVATE = 0x0002;
455455 pub const FIXED = 0x0010;
......@@ -990,11 +990,11 @@ pub const winsize = extern struct {
990990const NSIG = 33;
991991
992992pub const SIG = struct {
993 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
994 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
995 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
996 pub const CATCH = @intToPtr(?Sigaction.handler_fn, 2);
997 pub const HOLD = @intToPtr(?Sigaction.handler_fn, 3);
993 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
994 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
995 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
996 pub const CATCH = @ptrFromInt(?Sigaction.handler_fn, 2);
997 pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 3);
998998
999999 pub const HUP = 1;
10001000 pub const INT = 2;
lib/std/c/solaris.zig+10-10
......@@ -111,10 +111,10 @@ pub const RTLD = struct {
111111 pub const FIRST = 0x02000;
112112 pub const CONFGEN = 0x10000;
113113
114 pub const NEXT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1)));
115 pub const DEFAULT = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -2)));
116 pub const SELF = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -3)));
117 pub const PROBE = @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -4)));
114 pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1)));
115 pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2)));
116 pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3)));
117 pub const PROBE = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -4)));
118118};
119119
120120pub const Flock = extern struct {
......@@ -524,7 +524,7 @@ pub const CLOCK = struct {
524524};
525525
526526pub const MAP = struct {
527 pub const FAILED = @intToPtr(*anyopaque, maxInt(usize));
527 pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize));
528528 pub const SHARED = 0x0001;
529529 pub const PRIVATE = 0x0002;
530530 pub const TYPE = 0x000f;
......@@ -886,10 +886,10 @@ pub const winsize = extern struct {
886886const NSIG = 75;
887887
888888pub const SIG = struct {
889 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
890 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
891 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
892 pub const HOLD = @intToPtr(?Sigaction.handler_fn, 2);
889 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
890 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
891 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
892 pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 2);
893893
894894 pub const WORDS = 4;
895895 pub const MAXSIG = 75;
......@@ -1909,7 +1909,7 @@ const IoCtlCommand = enum(u32) {
19091909fn ioImpl(cmd: IoCtlCommand, io_type: u8, nr: u8, comptime IOT: type) i32 {
19101910 const size = @intCast(u32, @truncate(u8, @sizeOf(IOT))) << 16;
19111911 const t = @intCast(u32, io_type) << 8;
1912 return @bitCast(i32, @enumToInt(cmd) | size | t | nr);
1912 return @bitCast(i32, @intFromEnum(cmd) | size | t | nr);
19131913}
19141914
19151915pub fn IO(io_type: u8, nr: u8) i32 {
lib/std/child_process.zig+3-3
......@@ -449,7 +449,7 @@ pub const ChildProcess = struct {
449449 // has a value greater than 0
450450 if ((fd[0].revents & std.os.POLL.IN) != 0) {
451451 const err_int = try readIntFd(err_pipe[0]);
452 return @errSetCast(SpawnError, @intToError(err_int));
452 return @errSetCast(SpawnError, @errorFromInt(err_int));
453453 }
454454 } else {
455455 // Write maxInt(ErrInt) to the write end of the err_pipe. This is after
......@@ -462,7 +462,7 @@ pub const ChildProcess = struct {
462462 // Here we potentially return the fork child's error from the parent
463463 // pid.
464464 if (err_int != maxInt(ErrInt)) {
465 return @errSetCast(SpawnError, @intToError(err_int));
465 return @errSetCast(SpawnError, @errorFromInt(err_int));
466466 }
467467 }
468468 }
......@@ -1356,7 +1356,7 @@ fn destroyPipe(pipe: [2]os.fd_t) void {
13561356// Child of fork calls this to report an error to the fork parent.
13571357// Then the child exits.
13581358fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
1359 writeIntFd(fd, @as(ErrInt, @errorToInt(err))) catch {};
1359 writeIntFd(fd, @as(ErrInt, @intFromError(err))) catch {};
13601360 // If we're linking libc, some naughty applications may have registered atexit handlers
13611361 // which we really do not want to run in the fork child. I caught LLVM doing this and
13621362 // it caused a deadlock instead of doing an exit syscall. In the words of Avril Lavigne,
lib/std/coff.zig+5-5
......@@ -1105,7 +1105,7 @@ pub const Coff = struct {
11051105 assert(self.is_image);
11061106
11071107 const data_dirs = self.getDataDirectories();
1108 const debug_dir = data_dirs[@enumToInt(DirectoryEntry.DEBUG)];
1108 const debug_dir = data_dirs[@intFromEnum(DirectoryEntry.DEBUG)];
11091109
11101110 var stream = std.io.fixedBufferStream(self.data);
11111111 const reader = stream.reader();
......@@ -1303,9 +1303,9 @@ pub const Symtab = struct {
13031303 return .{
13041304 .name = raw[0..8].*,
13051305 .value = mem.readIntLittle(u32, raw[8..12]),
1306 .section_number = @intToEnum(SectionNumber, mem.readIntLittle(u16, raw[12..14])),
1306 .section_number = @enumFromInt(SectionNumber, mem.readIntLittle(u16, raw[12..14])),
13071307 .type = @bitCast(SymType, mem.readIntLittle(u16, raw[14..16])),
1308 .storage_class = @intToEnum(StorageClass, raw[16]),
1308 .storage_class = @enumFromInt(StorageClass, raw[16]),
13091309 .number_of_aux_symbols = raw[17],
13101310 };
13111311 }
......@@ -1333,7 +1333,7 @@ pub const Symtab = struct {
13331333 fn asWeakExtDef(raw: []const u8) WeakExternalDefinition {
13341334 return .{
13351335 .tag_index = mem.readIntLittle(u32, raw[0..4]),
1336 .flag = @intToEnum(WeakExternalFlag, mem.readIntLittle(u32, raw[4..8])),
1336 .flag = @enumFromInt(WeakExternalFlag, mem.readIntLittle(u32, raw[4..8])),
13371337 .unused = raw[8..18].*,
13381338 };
13391339 }
......@@ -1351,7 +1351,7 @@ pub const Symtab = struct {
13511351 .number_of_linenumbers = mem.readIntLittle(u16, raw[6..8]),
13521352 .checksum = mem.readIntLittle(u32, raw[8..12]),
13531353 .number = mem.readIntLittle(u16, raw[12..14]),
1354 .selection = @intToEnum(ComdatSelection, raw[14]),
1354 .selection = @enumFromInt(ComdatSelection, raw[14]),
13551355 .unused = raw[15..18].*,
13561356 };
13571357 }
lib/std/compress/deflate/huffman_bit_writer.zig+1-1
......@@ -527,7 +527,7 @@ pub fn HuffmanBitWriter(comptime WriterType: type) type {
527527 }
528528
529529 // Huffman.
530 if (@ptrToInt(literal_encoding) == @ptrToInt(&self.fixed_literal_encoding)) {
530 if (@intFromPtr(literal_encoding) == @intFromPtr(&self.fixed_literal_encoding)) {
531531 try self.writeFixedHeader(eof);
532532 } else {
533533 try self.writeDynamicHeader(num_literals, num_offsets, num_codegens, eof);
lib/std/compress/lzma/decode.zig+2-2
......@@ -326,7 +326,7 @@ pub const DecoderState = struct {
326326 while (result < 0x100) {
327327 const match_bit = (match_byte >> 7) & 1;
328328 match_byte <<= 1;
329 const bit = @boolToInt(try decoder.decodeBit(
329 const bit = @intFromBool(try decoder.decodeBit(
330330 reader,
331331 &probs[((@as(usize, 1) + match_bit) << 8) + result],
332332 update,
......@@ -339,7 +339,7 @@ pub const DecoderState = struct {
339339 }
340340
341341 while (result < 0x100) {
342 result = (result << 1) ^ @boolToInt(try decoder.decodeBit(reader, &probs[result], update));
342 result = (result << 1) ^ @intFromBool(try decoder.decodeBit(reader, &probs[result], update));
343343 }
344344
345345 return @truncate(u8, result - 0x100);
lib/std/compress/lzma/decode/rangecoder.zig+3-3
......@@ -57,7 +57,7 @@ pub const RangeDecoder = struct {
5757 var result: u32 = 0;
5858 var i: usize = 0;
5959 while (i < count) : (i += 1)
60 result = (result << 1) ^ @boolToInt(try self.getBit(reader));
60 result = (result << 1) ^ @intFromBool(try self.getBit(reader));
6161 return result;
6262 }
6363
......@@ -93,7 +93,7 @@ pub const RangeDecoder = struct {
9393 var i: @TypeOf(num_bits) = 0;
9494 while (i < num_bits) : (i += 1) {
9595 const bit = try self.decodeBit(reader, &probs[tmp], update);
96 tmp = (tmp << 1) ^ @boolToInt(bit);
96 tmp = (tmp << 1) ^ @intFromBool(bit);
9797 }
9898 return tmp - (@as(u32, 1) << num_bits);
9999 }
......@@ -110,7 +110,7 @@ pub const RangeDecoder = struct {
110110 var tmp: usize = 1;
111111 var i: @TypeOf(num_bits) = 0;
112112 while (i < num_bits) : (i += 1) {
113 const bit = @boolToInt(try self.decodeBit(reader, &probs[offset + tmp], update));
113 const bit = @intFromBool(try self.decodeBit(reader, &probs[offset + tmp], update));
114114 tmp = (tmp << 1) ^ bit;
115115 result ^= @as(u32, bit) << i;
116116 }
lib/std/compress/xz.zig+1-1
......@@ -18,7 +18,7 @@ fn readStreamFlags(reader: anytype, check: *Check) !void {
1818 if (reserved1 != 0)
1919 return error.CorruptInput;
2020
21 check.* = @intToEnum(Check, try bit_reader.readBitsNoEof(u4, 4));
21 check.* = @enumFromInt(Check, try bit_reader.readBitsNoEof(u4, 4));
2222
2323 const reserved2 = try bit_reader.readBitsNoEof(u4, 4);
2424 if (reserved2 != 0)
lib/std/compress/xz/block.zig+2-2
......@@ -124,12 +124,12 @@ pub fn Decoder(comptime ReaderType: type) type {
124124 _,
125125 };
126126
127 const filter_id = @intToEnum(
127 const filter_id = @enumFromInt(
128128 FilterId,
129129 try std.leb.readULEB128(u64, header_reader),
130130 );
131131
132 if (@enumToInt(filter_id) >= 0x4000_0000_0000_0000)
132 if (@intFromEnum(filter_id) >= 0x4000_0000_0000_0000)
133133 return error.CorruptInput;
134134
135135 if (filter_id != .lzma2)
lib/std/compress/zlib.zig+1-1
......@@ -126,7 +126,7 @@ pub fn CompressStream(comptime WriterType: type) type {
126126 var header = ZLibHeader{
127127 .compression_info = ZLibHeader.WINDOW_32K,
128128 .compression_method = ZLibHeader.DEFLATE,
129 .compression_level = @enumToInt(options.level),
129 .compression_level = @intFromEnum(options.level),
130130 .preset_dict = 0,
131131 .checksum = 0,
132132 };
lib/std/compress/zstandard/decode/block.zig+5-5
......@@ -894,7 +894,7 @@ pub fn decodeBlockReader(
894894/// Decode the header of a block.
895895pub fn decodeBlockHeader(src: *const [3]u8) frame.Zstandard.Block.Header {
896896 const last_block = src[0] & 1 == 1;
897 const block_type = @intToEnum(frame.Zstandard.Block.Type, (src[0] & 0b110) >> 1);
897 const block_type = @enumFromInt(frame.Zstandard.Block.Type, (src[0] & 0b110) >> 1);
898898 const block_size = ((src[0] & 0b11111000) >> 3) + (@as(u21, src[1]) << 5) + (@as(u21, src[2]) << 13);
899899 return .{
900900 .last_block = last_block,
......@@ -1058,7 +1058,7 @@ fn decodeStreams(size_format: u2, stream_data: []const u8) !LiteralsSection.Stre
10581058/// - `error.EndOfStream` if there are not enough bytes in `source`
10591059pub fn decodeLiteralsHeader(source: anytype) !LiteralsSection.Header {
10601060 const byte0 = try source.readByte();
1061 const block_type = @intToEnum(LiteralsSection.BlockType, byte0 & 0b11);
1061 const block_type = @enumFromInt(LiteralsSection.BlockType, byte0 & 0b11);
10621062 const size_format = @intCast(u2, (byte0 & 0b1100) >> 2);
10631063 var regenerated_size: u20 = undefined;
10641064 var compressed_size: ?u18 = null;
......@@ -1132,9 +1132,9 @@ pub fn decodeSequencesHeader(
11321132
11331133 const compression_modes = try source.readByte();
11341134
1135 const matches_mode = @intToEnum(SequencesSection.Header.Mode, (compression_modes & 0b00001100) >> 2);
1136 const offsets_mode = @intToEnum(SequencesSection.Header.Mode, (compression_modes & 0b00110000) >> 4);
1137 const literal_mode = @intToEnum(SequencesSection.Header.Mode, (compression_modes & 0b11000000) >> 6);
1135 const matches_mode = @enumFromInt(SequencesSection.Header.Mode, (compression_modes & 0b00001100) >> 2);
1136 const offsets_mode = @enumFromInt(SequencesSection.Header.Mode, (compression_modes & 0b00110000) >> 4);
1137 const literal_mode = @enumFromInt(SequencesSection.Header.Mode, (compression_modes & 0b11000000) >> 6);
11381138 if (compression_modes & 0b11 != 0) return error.ReservedBitSet;
11391139
11401140 return SequencesSection.Header{
lib/std/crypto/25519/edwards25519.zig+9-9
......@@ -38,11 +38,11 @@ pub const Edwards25519 = struct {
3838 const vxx = x.sq().mul(v);
3939 const has_m_root = vxx.sub(u).isZero();
4040 const has_p_root = vxx.add(u).isZero();
41 if ((@boolToInt(has_m_root) | @boolToInt(has_p_root)) == 0) { // best-effort to avoid two conditional branches
41 if ((@intFromBool(has_m_root) | @intFromBool(has_p_root)) == 0) { // best-effort to avoid two conditional branches
4242 return error.InvalidEncoding;
4343 }
44 x.cMov(x.mul(Fe.sqrtm1), 1 - @boolToInt(has_m_root));
45 x.cMov(x.neg(), @boolToInt(x.isNegative()) ^ (s[31] >> 7));
44 x.cMov(x.mul(Fe.sqrtm1), 1 - @intFromBool(has_m_root));
45 x.cMov(x.neg(), @intFromBool(x.isNegative()) ^ (s[31] >> 7));
4646 const t = x.mul(y);
4747 return Edwards25519{ .x = x, .y = y, .z = z, .t = t };
4848 }
......@@ -51,7 +51,7 @@ pub const Edwards25519 = struct {
5151 pub fn toBytes(p: Edwards25519) [encoded_length]u8 {
5252 const zi = p.z.invert();
5353 var s = p.y.mul(zi).toBytes();
54 s[31] ^= @as(u8, @boolToInt(p.x.mul(zi).isNegative())) << 7;
54 s[31] ^= @as(u8, @intFromBool(p.x.mul(zi).isNegative())) << 7;
5555 return s;
5656 }
5757
......@@ -369,7 +369,7 @@ pub const Edwards25519 = struct {
369369
370370 // yed = (x-1)/(x+1) or 1 if the denominator is 0
371371 var yed = x_plus_one_y_inv.mul(y).mul(x_minus_one);
372 yed.cMov(Fe.one, @boolToInt(x_plus_one_y_inv.isZero()));
372 yed.cMov(Fe.one, @intFromBool(x_plus_one_y_inv.isZero()));
373373
374374 return Edwards25519{
375375 .x = xed,
......@@ -390,9 +390,9 @@ pub const Edwards25519 = struct {
390390 const not_square = !gx1.isSquare();
391391
392392 // gx1 not a square => x = -x1-A
393 x.cMov(x.neg(), @boolToInt(not_square));
393 x.cMov(x.neg(), @intFromBool(not_square));
394394 x2 = Fe.zero;
395 x2.cMov(Fe.edwards25519a, @boolToInt(not_square));
395 x2.cMov(Fe.edwards25519a, @intFromBool(not_square));
396396 x = x.sub(x2);
397397
398398 // We have y = sqrt(gx1) or sqrt(gx2) with gx2 = gx1*(A+x1)/(-x1)
......@@ -408,7 +408,7 @@ pub const Edwards25519 = struct {
408408
409409 const y_sign = !elr.not_square;
410410 const y_neg = elr.y.neg();
411 elr.y.cMov(y_neg, @boolToInt(elr.y.isNegative()) ^ @boolToInt(y_sign));
411 elr.y.cMov(y_neg, @intFromBool(elr.y.isNegative()) ^ @intFromBool(y_sign));
412412 return montToEd(elr.x, elr.y).clearCofactor();
413413 }
414414
......@@ -486,7 +486,7 @@ pub const Edwards25519 = struct {
486486 const elr = elligator2(Fe.fromBytes(s));
487487 var p = montToEd(elr.x, elr.y);
488488 const p_neg = p.neg();
489 p.cMov(p_neg, @boolToInt(p.x.isNegative()) ^ x_sign);
489 p.cMov(p_neg, @intFromBool(p.x.isNegative()) ^ x_sign);
490490 return p.clearCofactor();
491491 }
492492};
lib/std/crypto/25519/field.zig+2-2
......@@ -387,7 +387,7 @@ pub const Fe = struct {
387387 /// Return the absolute value of a field element
388388 pub fn abs(a: Fe) Fe {
389389 var r = a;
390 r.cMov(a.neg(), @boolToInt(a.isNegative()));
390 r.cMov(a.neg(), @intFromBool(a.isNegative()));
391391 return r;
392392 }
393393
......@@ -412,7 +412,7 @@ pub const Fe = struct {
412412 const m_root2 = m_root.sq();
413413 e = x2.sub(m_root2);
414414 var x = p_root;
415 x.cMov(m_root, @boolToInt(e.isZero()));
415 x.cMov(m_root, @intFromBool(e.isZero()));
416416 return x;
417417 }
418418
lib/std/crypto/25519/ristretto255.zig+6-6
......@@ -30,8 +30,8 @@ pub const Ristretto255 = struct {
3030 const has_p_root = p_root_check.isZero();
3131 const has_f_root = f_root_check.isZero();
3232 const x_sqrtm1 = x.mul(Fe.sqrtm1); // x*sqrt(-1)
33 x.cMov(x_sqrtm1, @boolToInt(has_p_root) | @boolToInt(has_f_root));
34 return .{ .ratio_is_square = @boolToInt(has_m_root) | @boolToInt(has_p_root), .root = x.abs() };
33 x.cMov(x_sqrtm1, @intFromBool(has_p_root) | @intFromBool(has_f_root));
34 return .{ .ratio_is_square = @intFromBool(has_m_root) | @intFromBool(has_p_root), .root = x.abs() };
3535 }
3636
3737 fn rejectNonCanonical(s: [encoded_length]u8) NonCanonicalError!void {
......@@ -67,7 +67,7 @@ pub const Ristretto255 = struct {
6767 x = x.mul(s_);
6868 x = x.add(x).abs();
6969 const t = x.mul(y);
70 if ((1 - inv_sqrt.ratio_is_square) | @boolToInt(t.isNegative()) | @boolToInt(y.isZero()) != 0) {
70 if ((1 - inv_sqrt.ratio_is_square) | @intFromBool(t.isNegative()) | @intFromBool(y.isZero()) != 0) {
7171 return error.InvalidEncoding;
7272 }
7373 const p: Curve = .{
......@@ -96,7 +96,7 @@ pub const Ristretto255 = struct {
9696 const eden = den1.mul(Fe.edwards25519sqrtamd); // den1/sqrt(a-d)
9797 const t_z_inv = p.t.mul(z_inv); // T*z_inv
9898
99 const rotate = @boolToInt(t_z_inv.isNegative());
99 const rotate = @intFromBool(t_z_inv.isNegative());
100100 var x = p.x;
101101 var y = p.y;
102102 var den_inv = den2;
......@@ -106,7 +106,7 @@ pub const Ristretto255 = struct {
106106
107107 const x_z_inv = x.mul(z_inv);
108108 const yneg = y.neg();
109 y.cMov(yneg, @boolToInt(x_z_inv.isNegative()));
109 y.cMov(yneg, @intFromBool(x_z_inv.isNegative()));
110110
111111 return p.z.sub(y).mul(den_inv).abs().toBytes();
112112 }
......@@ -163,7 +163,7 @@ pub const Ristretto255 = struct {
163163 const q_ = &q.p;
164164 const a = p_.x.mul(q_.y).equivalent(p_.y.mul(q_.x));
165165 const b = p_.y.mul(q_.y).equivalent(p_.x.mul(q_.x));
166 return (@boolToInt(a) | @boolToInt(b)) != 0;
166 return (@intFromBool(a) | @intFromBool(b)) != 0;
167167 }
168168};
169169
lib/std/crypto/Certificate.zig+3-3
......@@ -312,7 +312,7 @@ pub const Parsed = struct {
312312 while (name_i < general_names.slice.end) {
313313 const general_name = try der.Element.parse(subject_alt_name, name_i);
314314 name_i = general_name.slice.end;
315 switch (@intToEnum(GeneralNameTag, @enumToInt(general_name.identifier.tag))) {
315 switch (@enumFromInt(GeneralNameTag, @intFromEnum(general_name.identifier.tag))) {
316316 .dNSName => {
317317 const dns_name = subject_alt_name[general_name.slice.start..general_name.slice.end];
318318 if (checkHostName(host_name, dns_name)) return;
......@@ -597,8 +597,8 @@ const Date = struct {
597597 var month: u4 = 1;
598598 while (month < date.month) : (month += 1) {
599599 const days: u64 = std.time.epoch.getDaysInMonth(
600 @intToEnum(std.time.epoch.YearLeapKind, @boolToInt(is_leap)),
601 @intToEnum(std.time.epoch.Month, month),
600 @enumFromInt(std.time.epoch.YearLeapKind, @intFromBool(is_leap)),
601 @enumFromInt(std.time.epoch.Month, month),
602602 );
603603 sec += days * std.time.epoch.secs_per_day;
604604 }
lib/std/crypto/Certificate/Bundle/macos.zig+1-1
......@@ -42,7 +42,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void {
4242
4343 const table_header = try reader.readStructBig(TableHeader);
4444
45 if (@intToEnum(std.os.darwin.cssm.DB_RECORDTYPE, table_header.table_id) != .X509_CERTIFICATE) {
45 if (@enumFromInt(std.os.darwin.cssm.DB_RECORDTYPE, table_header.table_id) != .X509_CERTIFICATE) {
4646 continue;
4747 }
4848
lib/std/crypto/argon2.zig+2-2
......@@ -115,7 +115,7 @@ fn initHash(
115115 mem.writeIntLittle(u32, parameters[8..12], params.m);
116116 mem.writeIntLittle(u32, parameters[12..16], params.t);
117117 mem.writeIntLittle(u32, parameters[16..20], version);
118 mem.writeIntLittle(u32, parameters[20..24], @enumToInt(mode));
118 mem.writeIntLittle(u32, parameters[20..24], @intFromEnum(mode));
119119 b2.update(&parameters);
120120 mem.writeIntLittle(u32, &tmp, @intCast(u32, password.len));
121121 b2.update(&tmp);
......@@ -292,7 +292,7 @@ fn processSegment(
292292 in[2] = slice;
293293 in[3] = memory;
294294 in[4] = passes;
295 in[5] = @enumToInt(mode);
295 in[5] = @intFromEnum(mode);
296296 }
297297 var index: u32 = 0;
298298 if (n == 0 and slice == 0) {
lib/std/crypto/benchmark.zig+25-25
......@@ -54,8 +54,8 @@ pub fn benchmarkHash(comptime Hash: anytype, comptime bytes: comptime_int) !u64
5454
5555 const end = timer.read();
5656
57 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
58 const throughput = @floatToInt(u64, bytes / elapsed_s);
57 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
58 const throughput = @intFromFloat(u64, bytes / elapsed_s);
5959
6060 return throughput;
6161}
......@@ -95,8 +95,8 @@ pub fn benchmarkMac(comptime Mac: anytype, comptime bytes: comptime_int) !u64 {
9595 }
9696 const end = timer.read();
9797
98 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
99 const throughput = @floatToInt(u64, bytes / elapsed_s);
98 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
99 const throughput = @intFromFloat(u64, bytes / elapsed_s);
100100
101101 return throughput;
102102}
......@@ -125,8 +125,8 @@ pub fn benchmarkKeyExchange(comptime DhKeyExchange: anytype, comptime exchange_c
125125 }
126126 const end = timer.read();
127127
128 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
129 const throughput = @floatToInt(u64, exchange_count / elapsed_s);
128 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
129 const throughput = @intFromFloat(u64, exchange_count / elapsed_s);
130130
131131 return throughput;
132132}
......@@ -148,8 +148,8 @@ pub fn benchmarkSignature(comptime Signature: anytype, comptime signatures_count
148148 }
149149 const end = timer.read();
150150
151 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
152 const throughput = @floatToInt(u64, signatures_count / elapsed_s);
151 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
152 const throughput = @intFromFloat(u64, signatures_count / elapsed_s);
153153
154154 return throughput;
155155}
......@@ -172,8 +172,8 @@ pub fn benchmarkSignatureVerification(comptime Signature: anytype, comptime sign
172172 }
173173 const end = timer.read();
174174
175 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
176 const throughput = @floatToInt(u64, signatures_count / elapsed_s);
175 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
176 const throughput = @intFromFloat(u64, signatures_count / elapsed_s);
177177
178178 return throughput;
179179}
......@@ -201,8 +201,8 @@ pub fn benchmarkBatchSignatureVerification(comptime Signature: anytype, comptime
201201 }
202202 const end = timer.read();
203203
204 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
205 const throughput = batch.len * @floatToInt(u64, signatures_count / elapsed_s);
204 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
205 const throughput = batch.len * @intFromFloat(u64, signatures_count / elapsed_s);
206206
207207 return throughput;
208208}
......@@ -227,8 +227,8 @@ pub fn benchmarkKem(comptime Kem: anytype, comptime kems_count: comptime_int) !u
227227 }
228228 const end = timer.read();
229229
230 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
231 const throughput = @floatToInt(u64, kems_count / elapsed_s);
230 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
231 const throughput = @intFromFloat(u64, kems_count / elapsed_s);
232232
233233 return throughput;
234234}
......@@ -249,8 +249,8 @@ pub fn benchmarkKemDecaps(comptime Kem: anytype, comptime kems_count: comptime_i
249249 }
250250 const end = timer.read();
251251
252 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
253 const throughput = @floatToInt(u64, kems_count / elapsed_s);
252 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
253 const throughput = @intFromFloat(u64, kems_count / elapsed_s);
254254
255255 return throughput;
256256}
......@@ -267,8 +267,8 @@ pub fn benchmarkKemKeyGen(comptime Kem: anytype, comptime kems_count: comptime_i
267267 }
268268 const end = timer.read();
269269
270 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
271 const throughput = @floatToInt(u64, kems_count / elapsed_s);
270 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
271 const throughput = @intFromFloat(u64, kems_count / elapsed_s);
272272
273273 return throughput;
274274}
......@@ -309,8 +309,8 @@ pub fn benchmarkAead(comptime Aead: anytype, comptime bytes: comptime_int) !u64
309309 mem.doNotOptimizeAway(&in);
310310 const end = timer.read();
311311
312 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
313 const throughput = @floatToInt(u64, 2 * bytes / elapsed_s);
312 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
313 const throughput = @intFromFloat(u64, 2 * bytes / elapsed_s);
314314
315315 return throughput;
316316}
......@@ -338,8 +338,8 @@ pub fn benchmarkAes(comptime Aes: anytype, comptime count: comptime_int) !u64 {
338338 mem.doNotOptimizeAway(&in);
339339 const end = timer.read();
340340
341 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
342 const throughput = @floatToInt(u64, count / elapsed_s);
341 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
342 const throughput = @intFromFloat(u64, count / elapsed_s);
343343
344344 return throughput;
345345}
......@@ -367,8 +367,8 @@ pub fn benchmarkAes8(comptime Aes: anytype, comptime count: comptime_int) !u64 {
367367 mem.doNotOptimizeAway(&in);
368368 const end = timer.read();
369369
370 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
371 const throughput = @floatToInt(u64, 8 * count / elapsed_s);
370 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
371 const throughput = @intFromFloat(u64, 8 * count / elapsed_s);
372372
373373 return throughput;
374374}
......@@ -422,7 +422,7 @@ fn benchmarkPwhash(
422422 }
423423 const end = timer.read();
424424
425 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
425 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
426426 const throughput = elapsed_s / count;
427427
428428 return throughput;
lib/std/crypto/ff.zig+4-4
......@@ -637,7 +637,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
637637 assert(x.limbs_count() == self.limbs_count());
638638 assert(y.limbs_count() == self.limbs_count());
639639 const overflow = self.montgomeryLoop(&d, x, y);
640 const underflow = 1 -% @boolToInt(ct.limbsCmpGeq(d.v, self.v));
640 const underflow = 1 -% @intFromBool(ct.limbsCmpGeq(d.v, self.v));
641641 const need_sub = ct.eql(overflow, underflow);
642642 _ = d.v.conditionalSubWithOverflow(need_sub, self.v);
643643 d.montgomery = x.montgomery == y.montgomery;
......@@ -649,7 +649,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
649649 var d = self.zero;
650650 assert(x.limbs_count() == self.limbs_count());
651651 const overflow = self.montgomeryLoop(&d, x, x);
652 const underflow = 1 -% @boolToInt(ct.limbsCmpGeq(d.v, self.v));
652 const underflow = 1 -% @intFromBool(ct.limbsCmpGeq(d.v, self.v));
653653 const need_sub = ct.eql(overflow, underflow);
654654 _ = d.v.conditionalSubWithOverflow(need_sub, self.v);
655655 d.montgomery = true;
......@@ -763,7 +763,7 @@ const ct = if (std.options.side_channels_mitigations == .none) ct_unprotected el
763763const ct_protected = struct {
764764 // Returns x if on is true, otherwise y.
765765 fn select(on: bool, x: Limb, y: Limb) Limb {
766 const mask = @as(Limb, 0) -% @boolToInt(on);
766 const mask = @as(Limb, 0) -% @intFromBool(on);
767767 return y ^ (mask & (y ^ x));
768768 }
769769
......@@ -789,7 +789,7 @@ const ct_protected = struct {
789789
790790 // Compares two big integers in constant time, returning true if x >= y.
791791 fn limbsCmpGeq(x: anytype, y: @TypeOf(x)) bool {
792 return @bitCast(bool, 1 - @boolToInt(ct.limbsCmpLt(x, y)));
792 return @bitCast(bool, 1 - @intFromBool(ct.limbsCmpLt(x, y)));
793793 }
794794
795795 // Multiplies two limbs and returns the result as a wide limb.
lib/std/crypto/kyber_d00.zig+1-1
......@@ -1454,7 +1454,7 @@ fn Mat(comptime K: u8) type {
14541454
14551455// Returns `true` if a ≠ b.
14561456fn ctneq(comptime len: usize, a: [len]u8, b: [len]u8) u1 {
1457 return 1 - @boolToInt(crypto.utils.timingSafeEql([len]u8, a, b));
1457 return 1 - @intFromBool(crypto.utils.timingSafeEql([len]u8, a, b));
14581458}
14591459
14601460// Copy src into dst given b = 1.
lib/std/crypto/pcurves/p256.zig+8-8
......@@ -36,8 +36,8 @@ pub const P256 = struct {
3636
3737 /// Reject the neutral element.
3838 pub fn rejectIdentity(p: P256) IdentityElementError!void {
39 const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y)));
40 const is_identity = @boolToInt(p.z.isZero()) | affine_0;
39 const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y)));
40 const is_identity = @intFromBool(p.z.isZero()) | affine_0;
4141 if (is_identity != 0) {
4242 return error.IdentityElement;
4343 }
......@@ -49,8 +49,8 @@ pub const P256 = struct {
4949 const y = p.y;
5050 const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B);
5151 const yy = y.sq();
52 const on_curve = @boolToInt(x3AxB.equivalent(yy));
53 const is_identity = @boolToInt(x.equivalent(AffineCoordinates.identityElement.x)) & @boolToInt(y.equivalent(AffineCoordinates.identityElement.y));
52 const on_curve = @intFromBool(x3AxB.equivalent(yy));
53 const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y));
5454 if ((on_curve | is_identity) == 0) {
5555 return error.InvalidEncoding;
5656 }
......@@ -71,7 +71,7 @@ pub const P256 = struct {
7171 const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B);
7272 var y = try x3AxB.sqrt();
7373 const yn = y.neg();
74 y.cMov(yn, @boolToInt(is_odd) ^ @boolToInt(y.isOdd()));
74 y.cMov(yn, @intFromBool(is_odd) ^ @intFromBool(y.isOdd()));
7575 return y;
7676 }
7777
......@@ -219,7 +219,7 @@ pub const P256 = struct {
219219 .y = Y3,
220220 .z = Z3,
221221 };
222 ret.cMov(p, @boolToInt(q.x.isZero()));
222 ret.cMov(p, @intFromBool(q.x.isZero()));
223223 return ret;
224224 }
225225
......@@ -288,8 +288,8 @@ pub const P256 = struct {
288288
289289 /// Return affine coordinates.
290290 pub fn affineCoordinates(p: P256) AffineCoordinates {
291 const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y)));
292 const is_identity = @boolToInt(p.z.isZero()) | affine_0;
291 const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y)));
292 const is_identity = @intFromBool(p.z.isZero()) | affine_0;
293293 const zinv = p.z.invert();
294294 var ret = AffineCoordinates{
295295 .x = p.x.mul(zinv),
lib/std/crypto/pcurves/p384.zig+8-8
......@@ -36,8 +36,8 @@ pub const P384 = struct {
3636
3737 /// Reject the neutral element.
3838 pub fn rejectIdentity(p: P384) IdentityElementError!void {
39 const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y)));
40 const is_identity = @boolToInt(p.z.isZero()) | affine_0;
39 const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y)));
40 const is_identity = @intFromBool(p.z.isZero()) | affine_0;
4141 if (is_identity != 0) {
4242 return error.IdentityElement;
4343 }
......@@ -49,8 +49,8 @@ pub const P384 = struct {
4949 const y = p.y;
5050 const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B);
5151 const yy = y.sq();
52 const on_curve = @boolToInt(x3AxB.equivalent(yy));
53 const is_identity = @boolToInt(x.equivalent(AffineCoordinates.identityElement.x)) & @boolToInt(y.equivalent(AffineCoordinates.identityElement.y));
52 const on_curve = @intFromBool(x3AxB.equivalent(yy));
53 const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y));
5454 if ((on_curve | is_identity) == 0) {
5555 return error.InvalidEncoding;
5656 }
......@@ -71,7 +71,7 @@ pub const P384 = struct {
7171 const x3AxB = x.sq().mul(x).sub(x).sub(x).sub(x).add(B);
7272 var y = try x3AxB.sqrt();
7373 const yn = y.neg();
74 y.cMov(yn, @boolToInt(is_odd) ^ @boolToInt(y.isOdd()));
74 y.cMov(yn, @intFromBool(is_odd) ^ @intFromBool(y.isOdd()));
7575 return y;
7676 }
7777
......@@ -219,7 +219,7 @@ pub const P384 = struct {
219219 .y = Y3,
220220 .z = Z3,
221221 };
222 ret.cMov(p, @boolToInt(q.x.isZero()));
222 ret.cMov(p, @intFromBool(q.x.isZero()));
223223 return ret;
224224 }
225225
......@@ -288,8 +288,8 @@ pub const P384 = struct {
288288
289289 /// Return affine coordinates.
290290 pub fn affineCoordinates(p: P384) AffineCoordinates {
291 const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y)));
292 const is_identity = @boolToInt(p.z.isZero()) | affine_0;
291 const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y)));
292 const is_identity = @intFromBool(p.z.isZero()) | affine_0;
293293 const zinv = p.z.invert();
294294 var ret = AffineCoordinates{
295295 .x = p.x.mul(zinv),
lib/std/crypto/pcurves/secp256k1.zig+8-8
......@@ -89,8 +89,8 @@ pub const Secp256k1 = struct {
8989
9090 /// Reject the neutral element.
9191 pub fn rejectIdentity(p: Secp256k1) IdentityElementError!void {
92 const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y)));
93 const is_identity = @boolToInt(p.z.isZero()) | affine_0;
92 const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y)));
93 const is_identity = @intFromBool(p.z.isZero()) | affine_0;
9494 if (is_identity != 0) {
9595 return error.IdentityElement;
9696 }
......@@ -102,8 +102,8 @@ pub const Secp256k1 = struct {
102102 const y = p.y;
103103 const x3B = x.sq().mul(x).add(B);
104104 const yy = y.sq();
105 const on_curve = @boolToInt(x3B.equivalent(yy));
106 const is_identity = @boolToInt(x.equivalent(AffineCoordinates.identityElement.x)) & @boolToInt(y.equivalent(AffineCoordinates.identityElement.y));
105 const on_curve = @intFromBool(x3B.equivalent(yy));
106 const is_identity = @intFromBool(x.equivalent(AffineCoordinates.identityElement.x)) & @intFromBool(y.equivalent(AffineCoordinates.identityElement.y));
107107 if ((on_curve | is_identity) == 0) {
108108 return error.InvalidEncoding;
109109 }
......@@ -124,7 +124,7 @@ pub const Secp256k1 = struct {
124124 const x3B = x.sq().mul(x).add(B);
125125 var y = try x3B.sqrt();
126126 const yn = y.neg();
127 y.cMov(yn, @boolToInt(is_odd) ^ @boolToInt(y.isOdd()));
127 y.cMov(yn, @intFromBool(is_odd) ^ @intFromBool(y.isOdd()));
128128 return y;
129129 }
130130
......@@ -253,7 +253,7 @@ pub const Secp256k1 = struct {
253253 .y = Y3,
254254 .z = Z3,
255255 };
256 ret.cMov(p, @boolToInt(q.x.isZero()));
256 ret.cMov(p, @intFromBool(q.x.isZero()));
257257 return ret;
258258 }
259259
......@@ -316,8 +316,8 @@ pub const Secp256k1 = struct {
316316
317317 /// Return affine coordinates.
318318 pub fn affineCoordinates(p: Secp256k1) AffineCoordinates {
319 const affine_0 = @boolToInt(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@boolToInt(p.y.isZero()) | @boolToInt(p.y.equivalent(AffineCoordinates.identityElement.y)));
320 const is_identity = @boolToInt(p.z.isZero()) | affine_0;
319 const affine_0 = @intFromBool(p.x.equivalent(AffineCoordinates.identityElement.x)) & (@intFromBool(p.y.isZero()) | @intFromBool(p.y.equivalent(AffineCoordinates.identityElement.y)));
320 const is_identity = @intFromBool(p.z.isZero()) | affine_0;
321321 const zinv = p.z.invert();
322322 var ret = AffineCoordinates{
323323 .x = p.x.mul(zinv),
lib/std/crypto/tls.zig+6-6
......@@ -48,8 +48,8 @@ pub const hello_retry_request_sequence = [32]u8{
4848};
4949
5050pub const close_notify_alert = [_]u8{
51 @enumToInt(AlertLevel.warning),
52 @enumToInt(AlertDescription.close_notify),
51 @intFromEnum(AlertLevel.warning),
52 @intFromEnum(AlertDescription.close_notify),
5353};
5454
5555pub const ProtocolVersion = enum(u16) {
......@@ -399,7 +399,7 @@ pub fn hmac(comptime Hmac: type, message: []const u8, key: [Hmac.key_length]u8)
399399}
400400
401401pub inline fn extension(comptime et: ExtensionType, bytes: anytype) [2 + 2 + bytes.len]u8 {
402 return int2(@enumToInt(et)) ++ array(1, bytes);
402 return int2(@intFromEnum(et)) ++ array(1, bytes);
403403}
404404
405405pub 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
411411 assert(@sizeOf(E) == 2);
412412 var result: [tags.len * 2]u8 = undefined;
413413 for (tags, 0..) |elem, i| {
414 result[i * 2] = @truncate(u8, @enumToInt(elem) >> 8);
415 result[i * 2 + 1] = @truncate(u8, @enumToInt(elem));
414 result[i * 2] = @truncate(u8, @intFromEnum(elem) >> 8);
415 result[i * 2 + 1] = @truncate(u8, @intFromEnum(elem));
416416 }
417417 return array(2, result);
418418}
......@@ -513,7 +513,7 @@ pub const Decoder = struct {
513513 .Enum => |info| {
514514 const int = d.decode(info.tag_type);
515515 if (info.is_exhaustive) @compileError("exhaustive enum cannot be used");
516 return @intToEnum(T, int);
516 return @enumFromInt(T, int);
517517 },
518518 else => @compileError("unsupported type: " ++ @typeName(T)),
519519 }
lib/std/crypto/tls/Client.zig+24-24
......@@ -180,14 +180,14 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
180180 .x25519,
181181 })) ++ tls.extension(
182182 .key_share,
183 array(1, int2(@enumToInt(tls.NamedGroup.x25519)) ++
183 array(1, int2(@intFromEnum(tls.NamedGroup.x25519)) ++
184184 array(1, x25519_kp.public_key) ++
185 int2(@enumToInt(tls.NamedGroup.secp256r1)) ++
185 int2(@intFromEnum(tls.NamedGroup.secp256r1)) ++
186186 array(1, secp256r1_kp.public_key.toUncompressedSec1()) ++
187 int2(@enumToInt(tls.NamedGroup.x25519_kyber768d00)) ++
187 int2(@intFromEnum(tls.NamedGroup.x25519_kyber768d00)) ++
188188 array(1, x25519_kp.public_key ++ kyber768_kp.public_key.toBytes())),
189189 ) ++
190 int2(@enumToInt(tls.ExtensionType.server_name)) ++
190 int2(@intFromEnum(tls.ExtensionType.server_name)) ++
191191 int2(host_len + 5) ++ // byte length of this extension payload
192192 int2(host_len + 3) ++ // server_name_list byte count
193193 [1]u8{0x00} ++ // name_type
......@@ -200,7 +200,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
200200 const legacy_compression_methods = 0x0100;
201201
202202 const client_hello =
203 int2(@enumToInt(tls.ProtocolVersion.tls_1_2)) ++
203 int2(@intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
204204 hello_rand ++
205205 [1]u8{32} ++ legacy_session_id ++
206206 cipher_suites ++
......@@ -208,12 +208,12 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
208208 extensions_header;
209209
210210 const out_handshake =
211 [_]u8{@enumToInt(tls.HandshakeType.client_hello)} ++
211 [_]u8{@intFromEnum(tls.HandshakeType.client_hello)} ++
212212 int3(@intCast(u24, client_hello.len + host_len)) ++
213213 client_hello;
214214
215215 const plaintext_header = [_]u8{
216 @enumToInt(tls.ContentType.handshake),
216 @intFromEnum(tls.ContentType.handshake),
217217 0x03, 0x01, // legacy_record_version
218218 } ++ int2(@intCast(u16, out_handshake.len + host_len)) ++ out_handshake;
219219
......@@ -348,7 +348,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
348348 if (!have_shared_key) return error.TlsIllegalParameter;
349349
350350 const tls_version = if (supported_version == 0) legacy_version else supported_version;
351 if (tls_version != @enumToInt(tls.ProtocolVersion.tls_1_3))
351 if (tls_version != @intFromEnum(tls.ProtocolVersion.tls_1_3))
352352 return error.TlsIllegalParameter;
353353
354354 switch (cipher_suite_tag) {
......@@ -466,7 +466,7 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
466466 },
467467 };
468468
469 const inner_ct = @intToEnum(tls.ContentType, cleartext[cleartext.len - 1]);
469 const inner_ct = @enumFromInt(tls.ContentType, cleartext[cleartext.len - 1]);
470470 if (inner_ct != .handshake) return error.TlsUnexpectedMessage;
471471
472472 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
624624 if (handshake_state != .finished) return error.TlsUnexpectedMessage;
625625 // This message is to trick buggy proxies into behaving correctly.
626626 const client_change_cipher_spec_msg = [_]u8{
627 @enumToInt(tls.ContentType.change_cipher_spec),
627 @intFromEnum(tls.ContentType.change_cipher_spec),
628628 0x03, 0x03, // legacy protocol version
629629 0x00, 0x01, // length
630630 0x01,
......@@ -640,14 +640,14 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
640640 const handshake_hash = p.transcript_hash.finalResult();
641641 const verify_data = tls.hmac(P.Hmac, &handshake_hash, p.client_finished_key);
642642 const out_cleartext = [_]u8{
643 @enumToInt(tls.HandshakeType.finished),
643 @intFromEnum(tls.HandshakeType.finished),
644644 0, 0, verify_data.len, // length
645 } ++ verify_data ++ [1]u8{@enumToInt(tls.ContentType.handshake)};
645 } ++ verify_data ++ [1]u8{@intFromEnum(tls.ContentType.handshake)};
646646
647647 const wrapped_len = out_cleartext.len + P.AEAD.tag_length;
648648
649649 var finished_msg = [_]u8{
650 @enumToInt(tls.ContentType.application_data),
650 @intFromEnum(tls.ContentType.application_data),
651651 0x03, 0x03, // legacy protocol version
652652 0, wrapped_len, // byte length of encrypted record
653653 } ++ @as([wrapped_len]u8, undefined);
......@@ -809,7 +809,7 @@ fn prepareCiphertextRecord(
809809 };
810810
811811 @memcpy(cleartext_buf[0..encrypted_content_len], bytes[bytes_i..][0..encrypted_content_len]);
812 cleartext_buf[encrypted_content_len] = @enumToInt(inner_content_type);
812 cleartext_buf[encrypted_content_len] = @intFromEnum(inner_content_type);
813813 bytes_i += encrypted_content_len;
814814 const ciphertext_len = encrypted_content_len + 1;
815815 const cleartext = cleartext_buf[0..ciphertext_len];
......@@ -817,8 +817,8 @@ fn prepareCiphertextRecord(
817817 const record_start = ciphertext_end;
818818 const ad = ciphertext_buf[ciphertext_end..][0..5];
819819 ad.* =
820 [_]u8{@enumToInt(tls.ContentType.application_data)} ++
821 int2(@enumToInt(tls.ProtocolVersion.tls_1_2)) ++
820 [_]u8{@intFromEnum(tls.ContentType.application_data)} ++
821 int2(@intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
822822 int2(ciphertext_len + P.AEAD.tag_length);
823823 ciphertext_end += ad.len;
824824 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)
10371037 in = 0;
10381038 continue;
10391039 }
1040 const ct = @intToEnum(tls.ContentType, frag[in]);
1040 const ct = @enumFromInt(tls.ContentType, frag[in]);
10411041 in += 1;
10421042 const legacy_version = mem.readIntBig(u16, frag[in..][0..2]);
10431043 in += 2;
......@@ -1070,8 +1070,8 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec)
10701070 switch (ct) {
10711071 .alert => {
10721072 if (in + 2 > frag.len) return error.TlsDecodeError;
1073 const level = @intToEnum(tls.AlertLevel, frag[in]);
1074 const desc = @intToEnum(tls.AlertDescription, frag[in + 1]);
1073 const level = @enumFromInt(tls.AlertLevel, frag[in]);
1074 const desc = @enumFromInt(tls.AlertDescription, frag[in + 1]);
10751075 _ = level;
10761076
10771077 try desc.toError();
......@@ -1105,11 +1105,11 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec)
11051105
11061106 c.read_seq = try std.math.add(u64, c.read_seq, 1);
11071107
1108 const inner_ct = @intToEnum(tls.ContentType, cleartext[cleartext.len - 1]);
1108 const inner_ct = @enumFromInt(tls.ContentType, cleartext[cleartext.len - 1]);
11091109 switch (inner_ct) {
11101110 .alert => {
1111 const level = @intToEnum(tls.AlertLevel, cleartext[0]);
1112 const desc = @intToEnum(tls.AlertDescription, cleartext[1]);
1111 const level = @enumFromInt(tls.AlertLevel, cleartext[0]);
1112 const desc = @enumFromInt(tls.AlertDescription, cleartext[1]);
11131113 if (desc == .close_notify) {
11141114 c.received_close_notify = true;
11151115 c.partial_ciphertext_end = c.partial_ciphertext_idx;
......@@ -1124,7 +1124,7 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec)
11241124 .handshake => {
11251125 var ct_i: usize = 0;
11261126 while (true) {
1127 const handshake_type = @intToEnum(tls.HandshakeType, cleartext[ct_i]);
1127 const handshake_type = @enumFromInt(tls.HandshakeType, cleartext[ct_i]);
11281128 ct_i += 1;
11291129 const handshake_len = mem.readIntBig(u24, cleartext[ct_i..][0..3]);
11301130 ct_i += 3;
......@@ -1148,7 +1148,7 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec)
11481148 }
11491149 c.read_seq = 0;
11501150
1151 switch (@intToEnum(tls.KeyUpdateRequest, handshake[0])) {
1151 switch (@enumFromInt(tls.KeyUpdateRequest, handshake[0])) {
11521152 .update_requested => {
11531153 switch (c.application_cipher) {
11541154 inline else => |*p| {
lib/std/debug.zig+15-15
......@@ -461,7 +461,7 @@ pub const StackIterator = struct {
461461 if (native_os == .freestanding) return true;
462462
463463 const aligned_address = address & ~@intCast(usize, (mem.page_size - 1));
464 const aligned_memory = @intToPtr([*]align(mem.page_size) u8, aligned_address)[0..mem.page_size];
464 const aligned_memory = @ptrFromInt([*]align(mem.page_size) u8, aligned_address)[0..mem.page_size];
465465
466466 if (native_os != .windows) {
467467 if (native_os != .wasi) {
......@@ -511,7 +511,7 @@ pub const StackIterator = struct {
511511 if (fp == 0 or !mem.isAligned(fp, @alignOf(usize)) or !isValidMemory(fp))
512512 return null;
513513
514 const new_fp = math.add(usize, @intToPtr(*const usize, fp).*, fp_bias) catch return null;
514 const new_fp = math.add(usize, @ptrFromInt(*const usize, fp).*, fp_bias) catch return null;
515515
516516 // Sanity check: the stack grows down thus all the parent frames must be
517517 // be at addresses that are greater (or equal) than the previous one.
......@@ -520,7 +520,7 @@ pub const StackIterator = struct {
520520 if (new_fp != 0 and new_fp < self.fp)
521521 return null;
522522
523 const new_pc = @intToPtr(
523 const new_pc = @ptrFromInt(
524524 *const usize,
525525 math.add(usize, fp, pc_offset) catch return null,
526526 ).*;
......@@ -584,12 +584,12 @@ pub noinline fn walkStackWindows(addresses: []usize) usize {
584584 );
585585 } else {
586586 // leaf function
587 context.setIp(@intToPtr(*u64, current_regs.sp).*);
587 context.setIp(@ptrFromInt(*u64, current_regs.sp).*);
588588 context.setSp(current_regs.sp + @sizeOf(usize));
589589 }
590590
591591 const next_regs = context.getRegs();
592 if (next_regs.sp < @ptrToInt(tib.StackLimit) or next_regs.sp > @ptrToInt(tib.StackBase)) {
592 if (next_regs.sp < @intFromPtr(tib.StackLimit) or next_regs.sp > @intFromPtr(tib.StackBase)) {
593593 break;
594594 }
595595
......@@ -1216,7 +1216,7 @@ pub const DebugInfo = struct {
12161216 var module_valid = true;
12171217 while (module_valid) {
12181218 const module_info = try debug_info.modules.addOne(allocator);
1219 module_info.base_address = @ptrToInt(module_entry.modBaseAddr);
1219 module_info.base_address = @intFromPtr(module_entry.modBaseAddr);
12201220 module_info.size = module_entry.modBaseSize;
12211221 module_info.name = allocator.dupe(u8, mem.sliceTo(&module_entry.szModule, 0)) catch &.{};
12221222 module_valid = windows.kernel32.Module32Next(handle, &module_entry) == 1;
......@@ -1283,9 +1283,9 @@ pub const DebugInfo = struct {
12831283
12841284 var it = macho.LoadCommandIterator{
12851285 .ncmds = header.ncmds,
1286 .buffer = @alignCast(@alignOf(u64), @intToPtr(
1286 .buffer = @alignCast(@alignOf(u64), @ptrFromInt(
12871287 [*]u8,
1288 @ptrToInt(header) + @sizeOf(macho.mach_header_64),
1288 @intFromPtr(header) + @sizeOf(macho.mach_header_64),
12891289 ))[0..header.sizeofcmds],
12901290 };
12911291 while (it.next()) |cmd| switch (cmd.cmd()) {
......@@ -1332,7 +1332,7 @@ pub const DebugInfo = struct {
13321332 return obj_di;
13331333 }
13341334
1335 const mapped_module = @intToPtr([*]const u8, module.base_address)[0..module.size];
1335 const mapped_module = @ptrFromInt([*]const u8, module.base_address)[0..module.size];
13361336 const obj_di = try self.allocator.create(ModuleDebugInfo);
13371337 errdefer self.allocator.destroy(obj_di);
13381338
......@@ -1897,11 +1897,11 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
18971897 resetSegfaultHandler();
18981898
18991899 const addr = switch (native_os) {
1900 .linux => @ptrToInt(info.fields.sigfault.addr),
1901 .freebsd, .macos => @ptrToInt(info.addr),
1902 .netbsd => @ptrToInt(info.info.reason.fault.addr),
1903 .openbsd => @ptrToInt(info.data.fault.addr),
1904 .solaris => @ptrToInt(info.reason.fault.addr),
1900 .linux => @intFromPtr(info.fields.sigfault.addr),
1901 .freebsd, .macos => @intFromPtr(info.addr),
1902 .netbsd => @intFromPtr(info.info.reason.fault.addr),
1903 .openbsd => @intFromPtr(info.data.fault.addr),
1904 .solaris => @intFromPtr(info.reason.fault.addr),
19051905 else => unreachable,
19061906 };
19071907
......@@ -2008,7 +2008,7 @@ fn handleSegfaultWindowsExtra(
20082008 msg: u8,
20092009 label: ?[]const u8,
20102010) noreturn {
2011 const exception_address = @ptrToInt(info.ExceptionRecord.ExceptionAddress);
2011 const exception_address = @intFromPtr(info.ExceptionRecord.ExceptionAddress);
20122012 if (@hasDecl(windows, "CONTEXT")) {
20132013 nosuspend switch (panic_stage) {
20142014 0 => {
lib/std/dynamic_library.zig+18-18
......@@ -71,18 +71,18 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
7171 while (_DYNAMIC[i].d_tag != elf.DT_NULL) : (i += 1) {
7272 switch (_DYNAMIC[i].d_tag) {
7373 elf.DT_DEBUG => {
74 const ptr = @intToPtr(?*RDebug, _DYNAMIC[i].d_val);
74 const ptr = @ptrFromInt(?*RDebug, _DYNAMIC[i].d_val);
7575 if (ptr) |r_debug| {
7676 if (r_debug.r_version != 1) return error.InvalidExe;
7777 break :init r_debug.r_map;
7878 }
7979 },
8080 elf.DT_PLTGOT => {
81 const ptr = @intToPtr(?[*]usize, _DYNAMIC[i].d_val);
81 const ptr = @ptrFromInt(?[*]usize, _DYNAMIC[i].d_val);
8282 if (ptr) |got_table| {
8383 // The address to the link_map structure is stored in
8484 // the second slot
85 break :init @intToPtr(?*LinkMap, got_table[1]);
85 break :init @ptrFromInt(?*LinkMap, got_table[1]);
8686 }
8787 },
8888 else => {},
......@@ -136,7 +136,7 @@ pub const ElfDynLib = struct {
136136 if (!mem.eql(u8, eh.e_ident[0..4], elf.MAGIC)) return error.NotElfFile;
137137 if (eh.e_type != elf.ET.DYN) return error.NotDynamicLibrary;
138138
139 const elf_addr = @ptrToInt(file_bytes.ptr);
139 const elf_addr = @intFromPtr(file_bytes.ptr);
140140
141141 // Iterate over the program header entries to find out the
142142 // dynamic vector as well as the total size of the virtual memory.
......@@ -149,10 +149,10 @@ pub const ElfDynLib = struct {
149149 i += 1;
150150 ph_addr += eh.e_phentsize;
151151 }) {
152 const ph = @intToPtr(*elf.Phdr, ph_addr);
152 const ph = @ptrFromInt(*elf.Phdr, ph_addr);
153153 switch (ph.p_type) {
154154 elf.PT_LOAD => virt_addr_end = @max(virt_addr_end, ph.p_vaddr + ph.p_memsz),
155 elf.PT_DYNAMIC => maybe_dynv = @intToPtr([*]usize, elf_addr + ph.p_offset),
155 elf.PT_DYNAMIC => maybe_dynv = @ptrFromInt([*]usize, elf_addr + ph.p_offset),
156156 else => {},
157157 }
158158 }
......@@ -170,7 +170,7 @@ pub const ElfDynLib = struct {
170170 );
171171 errdefer os.munmap(all_loaded_mem);
172172
173 const base = @ptrToInt(all_loaded_mem.ptr);
173 const base = @intFromPtr(all_loaded_mem.ptr);
174174
175175 // Now iterate again and actually load all the program sections.
176176 {
......@@ -180,7 +180,7 @@ pub const ElfDynLib = struct {
180180 i += 1;
181181 ph_addr += eh.e_phentsize;
182182 }) {
183 const ph = @intToPtr(*elf.Phdr, ph_addr);
183 const ph = @ptrFromInt(*elf.Phdr, ph_addr);
184184 switch (ph.p_type) {
185185 elf.PT_LOAD => {
186186 // The VirtAddr may not be page-aligned; in such case there will be
......@@ -188,7 +188,7 @@ pub const ElfDynLib = struct {
188188 const aligned_addr = (base + ph.p_vaddr) & ~(@as(usize, mem.page_size) - 1);
189189 const extra_bytes = (base + ph.p_vaddr) - aligned_addr;
190190 const extended_memsz = mem.alignForward(usize, ph.p_memsz + extra_bytes, mem.page_size);
191 const ptr = @intToPtr([*]align(mem.page_size) u8, aligned_addr);
191 const ptr = @ptrFromInt([*]align(mem.page_size) u8, aligned_addr);
192192 const prot = elfToMmapProt(ph.p_flags);
193193 if ((ph.p_flags & elf.PF_W) == 0) {
194194 // If it does not need write access, it can be mapped from the fd.
......@@ -228,11 +228,11 @@ pub const ElfDynLib = struct {
228228 while (dynv[i] != 0) : (i += 2) {
229229 const p = base + dynv[i + 1];
230230 switch (dynv[i]) {
231 elf.DT_STRTAB => maybe_strings = @intToPtr([*:0]u8, p),
232 elf.DT_SYMTAB => maybe_syms = @intToPtr([*]elf.Sym, p),
233 elf.DT_HASH => maybe_hashtab = @intToPtr([*]os.Elf_Symndx, p),
234 elf.DT_VERSYM => maybe_versym = @intToPtr([*]u16, p),
235 elf.DT_VERDEF => maybe_verdef = @intToPtr(*elf.Verdef, p),
231 elf.DT_STRTAB => maybe_strings = @ptrFromInt([*:0]u8, p),
232 elf.DT_SYMTAB => maybe_syms = @ptrFromInt([*]elf.Sym, p),
233 elf.DT_HASH => maybe_hashtab = @ptrFromInt([*]os.Elf_Symndx, p),
234 elf.DT_VERSYM => maybe_versym = @ptrFromInt([*]u16, p),
235 elf.DT_VERDEF => maybe_verdef = @ptrFromInt(*elf.Verdef, p),
236236 else => {},
237237 }
238238 }
......@@ -261,7 +261,7 @@ pub const ElfDynLib = struct {
261261
262262 pub fn lookup(self: *ElfDynLib, comptime T: type, name: [:0]const u8) ?T {
263263 if (self.lookupAddress("", name)) |symbol| {
264 return @intToPtr(T, symbol);
264 return @ptrFromInt(T, symbol);
265265 } else {
266266 return null;
267267 }
......@@ -284,7 +284,7 @@ pub const ElfDynLib = struct {
284284 if (!checkver(self.verdef.?, versym[i], vername, self.strings))
285285 continue;
286286 }
287 return @ptrToInt(self.memory.ptr) + self.syms[i].st_value;
287 return @intFromPtr(self.memory.ptr) + self.syms[i].st_value;
288288 }
289289
290290 return null;
......@@ -307,9 +307,9 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [
307307 break;
308308 if (def.vd_next == 0)
309309 return false;
310 def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next);
310 def = @ptrFromInt(*elf.Verdef, @intFromPtr(def) + def.vd_next);
311311 }
312 const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux);
312 const aux = @ptrFromInt(*elf.Verdaux, @intFromPtr(def) + def.vd_aux);
313313 return mem.eql(u8, vername, mem.sliceTo(strings + aux.vda_name, 0));
314314}
315315
lib/std/elf.zig+2-2
......@@ -453,8 +453,8 @@ pub const Header = struct {
453453 };
454454
455455 const machine = if (need_bswap) blk: {
456 const value = @enumToInt(hdr32.e_machine);
457 break :blk @intToEnum(EM, @byteSwap(value));
456 const value = @intFromEnum(hdr32.e_machine);
457 break :blk @enumFromInt(EM, @byteSwap(value));
458458 } else hdr32.e_machine;
459459
460460 return @as(Header, .{
lib/std/enums.zig+15-15
......@@ -53,7 +53,7 @@ pub fn values(comptime E: type) []const E {
5353/// Returns the tag name for `e` or null if no tag exists.
5454pub fn tagName(comptime E: type, e: E) ?[]const u8 {
5555 return inline for (@typeInfo(E).Enum.fields) |f| {
56 if (@enumToInt(e) == f.value) break f.name;
56 if (@intFromEnum(e) == f.value) break f.name;
5757 } else null;
5858}
5959
......@@ -61,11 +61,11 @@ test tagName {
6161 const E = enum(u8) { a, b, _ };
6262 try testing.expect(tagName(E, .a) != null);
6363 try testing.expectEqualStrings("a", tagName(E, .a).?);
64 try testing.expect(tagName(E, @intToEnum(E, 42)) == null);
64 try testing.expect(tagName(E, @enumFromInt(E, 42)) == null);
6565}
6666
6767/// Determines the length of a direct-mapped enum array, indexed by
68/// @intCast(usize, @enumToInt(enum_value)).
68/// @intCast(usize, @intFromEnum(enum_value)).
6969/// If the enum is non-exhaustive, the resulting length will only be enough
7070/// to hold all explicit fields.
7171/// 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_
100100}
101101
102102/// Initializes an array of Data which can be indexed by
103/// @intCast(usize, @enumToInt(enum_value)).
103/// @intCast(usize, @intFromEnum(enum_value)).
104104/// If the enum is non-exhaustive, the resulting array will only be large enough
105105/// to hold all explicit fields.
106106/// If the enum contains any fields with values that cannot be represented
......@@ -136,7 +136,7 @@ test "std.enums.directEnumArray" {
136136}
137137
138138/// Initializes an array of Data which can be indexed by
139/// @intCast(usize, @enumToInt(enum_value)). The enum must be exhaustive.
139/// @intCast(usize, @intFromEnum(enum_value)). The enum must be exhaustive.
140140/// If the enum contains any fields with values that cannot be represented
141141/// by usize, a compile error is issued. The max_unused_slots parameter limits
142142/// the total number of items which have no matching enum key (holes in the enum
......@@ -156,7 +156,7 @@ pub fn directEnumArrayDefault(
156156 var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;
157157 inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| {
158158 const enum_value = @field(E, f.name);
159 const index = @intCast(usize, @enumToInt(enum_value));
159 const index = @intCast(usize, @intFromEnum(enum_value));
160160 result[index] = @field(init_values, f.name);
161161 }
162162 return result;
......@@ -341,7 +341,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
341341 var self = initWithCount(0);
342342 inline for (@typeInfo(E).Enum.fields) |field| {
343343 const c = @field(init_counts, field.name);
344 const key = @intToEnum(E, field.value);
344 const key = @enumFromInt(E, field.value);
345345 self.counts.set(key, c);
346346 }
347347 return self;
......@@ -412,7 +412,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
412412 /// asserts operation will not overflow any key.
413413 pub fn addSetAssertSafe(self: *Self, other: Self) void {
414414 inline for (@typeInfo(E).Enum.fields) |field| {
415 const key = @intToEnum(E, field.value);
415 const key = @enumFromInt(E, field.value);
416416 self.addAssertSafe(key, other.getCount(key));
417417 }
418418 }
......@@ -420,7 +420,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
420420 /// Increases the all key counts by given multiset.
421421 pub fn addSet(self: *Self, other: Self) error{Overflow}!void {
422422 inline for (@typeInfo(E).Enum.fields) |field| {
423 const key = @intToEnum(E, field.value);
423 const key = @enumFromInt(E, field.value);
424424 try self.add(key, other.getCount(key));
425425 }
426426 }
......@@ -430,7 +430,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
430430 /// then that key will have a key count of zero.
431431 pub fn removeSet(self: *Self, other: Self) void {
432432 inline for (@typeInfo(E).Enum.fields) |field| {
433 const key = @intToEnum(E, field.value);
433 const key = @enumFromInt(E, field.value);
434434 self.remove(key, other.getCount(key));
435435 }
436436 }
......@@ -439,7 +439,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
439439 /// given multiset.
440440 pub fn eql(self: Self, other: Self) bool {
441441 inline for (@typeInfo(E).Enum.fields) |field| {
442 const key = @intToEnum(E, field.value);
442 const key = @enumFromInt(E, field.value);
443443 if (self.getCount(key) != other.getCount(key)) {
444444 return false;
445445 }
......@@ -451,7 +451,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
451451 /// equal to the given multiset.
452452 pub fn subsetOf(self: Self, other: Self) bool {
453453 inline for (@typeInfo(E).Enum.fields) |field| {
454 const key = @intToEnum(E, field.value);
454 const key = @enumFromInt(E, field.value);
455455 if (self.getCount(key) > other.getCount(key)) {
456456 return false;
457457 }
......@@ -463,7 +463,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
463463 /// equal to the given multiset.
464464 pub fn supersetOf(self: Self, other: Self) bool {
465465 inline for (@typeInfo(E).Enum.fields) |field| {
466 const key = @intToEnum(E, field.value);
466 const key = @enumFromInt(E, field.value);
467467 if (self.getCount(key) < other.getCount(key)) {
468468 return false;
469469 }
......@@ -1323,14 +1323,14 @@ pub fn EnumIndexer(comptime E: type) type {
13231323 pub const Key = E;
13241324 pub const count = fields_len;
13251325 pub fn indexOf(e: E) usize {
1326 return @intCast(usize, @enumToInt(e) - min);
1326 return @intCast(usize, @intFromEnum(e) - min);
13271327 }
13281328 pub fn keyForIndex(i: usize) E {
13291329 // TODO fix addition semantics. This calculation
13301330 // gives up some safety to avoid artificially limiting
13311331 // the range of signed enum values to max_isize.
13321332 const enum_value = if (min < 0) @bitCast(isize, i) +% min else i + min;
1333 return @intToEnum(E, @intCast(std.meta.Tag(E), enum_value));
1333 return @enumFromInt(E, @intCast(std.meta.Tag(E), enum_value));
13341334 }
13351335 };
13361336 }
lib/std/event/channel.zig+1-1
......@@ -247,7 +247,7 @@ pub fn Channel(comptime T: type) type {
247247 // All the "get or null" functions should resume now.
248248 var remove_count: usize = 0;
249249 while (self.or_null_queue.get()) |or_null_node| {
250 remove_count += @boolToInt(self.getters.remove(or_null_node.data));
250 remove_count += @intFromBool(self.getters.remove(or_null_node.data));
251251 global_event_loop.onNextTick(or_null_node.data.data.tick_node);
252252 }
253253 if (remove_count != 0) {
lib/std/event/lock.zig+4-4
......@@ -55,14 +55,14 @@ pub const Lock = struct {
5555 const head = switch (self.head) {
5656 UNLOCKED => unreachable,
5757 LOCKED => null,
58 else => @intToPtr(*Waiter, self.head),
58 else => @ptrFromInt(*Waiter, self.head),
5959 };
6060
6161 if (head) |h| {
6262 h.tail.next = &waiter;
6363 h.tail = &waiter;
6464 } else {
65 self.head = @ptrToInt(&waiter);
65 self.head = @intFromPtr(&waiter);
6666 }
6767
6868 suspend {
......@@ -102,8 +102,8 @@ pub const Lock = struct {
102102 break :blk null;
103103 },
104104 else => {
105 const waiter = @intToPtr(*Waiter, self.lock.head);
106 self.lock.head = if (waiter.next == null) LOCKED else @ptrToInt(waiter.next);
105 const waiter = @ptrFromInt(*Waiter, self.lock.head);
106 self.lock.head = if (waiter.next == null) LOCKED else @intFromPtr(waiter.next);
107107 if (waiter.next) |next|
108108 next.tail = waiter.tail;
109109 break :blk waiter;
lib/std/event/loop.zig+10-10
......@@ -244,7 +244,7 @@ pub const Loop = struct {
244244
245245 self.os_data.final_eventfd_event = os.linux.epoll_event{
246246 .events = os.linux.EPOLL.IN,
247 .data = os.linux.epoll_data{ .ptr = @ptrToInt(&self.final_resume_node) },
247 .data = os.linux.epoll_data{ .ptr = @intFromPtr(&self.final_resume_node) },
248248 };
249249 try os.epoll_ctl(
250250 self.os_data.epollfd,
......@@ -293,7 +293,7 @@ pub const Loop = struct {
293293 .flags = os.system.EV_CLEAR | os.system.EV_ADD | os.system.EV_DISABLE,
294294 .fflags = 0,
295295 .data = 0,
296 .udata = @ptrToInt(&eventfd_node.data.base),
296 .udata = @intFromPtr(&eventfd_node.data.base),
297297 },
298298 },
299299 .next = undefined,
......@@ -313,7 +313,7 @@ pub const Loop = struct {
313313 .flags = os.system.EV_ADD | os.system.EV_DISABLE,
314314 .fflags = 0,
315315 .data = 0,
316 .udata = @ptrToInt(&self.final_resume_node),
316 .udata = @intFromPtr(&self.final_resume_node),
317317 };
318318 const final_kev_arr = @as(*const [1]os.Kevent, &self.os_data.final_kevent);
319319 _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null);
......@@ -358,7 +358,7 @@ pub const Loop = struct {
358358 .flags = os.system.EV_CLEAR | os.system.EV_ADD | os.system.EV_DISABLE | os.system.EV_ONESHOT,
359359 .fflags = 0,
360360 .data = 0,
361 .udata = @ptrToInt(&eventfd_node.data.base),
361 .udata = @intFromPtr(&eventfd_node.data.base),
362362 },
363363 },
364364 .next = undefined,
......@@ -377,7 +377,7 @@ pub const Loop = struct {
377377 .flags = os.system.EV_ADD | os.system.EV_ONESHOT | os.system.EV_DISABLE,
378378 .fflags = 0,
379379 .data = 0,
380 .udata = @ptrToInt(&self.final_resume_node),
380 .udata = @intFromPtr(&self.final_resume_node),
381381 };
382382 const final_kev_arr = @as(*const [1]os.Kevent, &self.os_data.final_kevent);
383383 _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null);
......@@ -418,7 +418,7 @@ pub const Loop = struct {
418418 .overlapped = ResumeNode.overlapped_init,
419419 },
420420 // this one is for sending events
421 .completion_key = @ptrToInt(&eventfd_node.data.base),
421 .completion_key = @intFromPtr(&eventfd_node.data.base),
422422 },
423423 .next = undefined,
424424 };
......@@ -488,7 +488,7 @@ pub const Loop = struct {
488488 assert(flags & os.linux.EPOLL.ET == os.linux.EPOLL.ET);
489489 var ev = os.linux.epoll_event{
490490 .events = flags,
491 .data = os.linux.epoll_data{ .ptr = @ptrToInt(resume_node) },
491 .data = os.linux.epoll_data{ .ptr = @intFromPtr(resume_node) },
492492 };
493493 try os.epoll_ctl(self.os_data.epollfd, op, fd, &ev);
494494 }
......@@ -619,7 +619,7 @@ pub const Loop = struct {
619619 .flags = os.system.EV_ADD | os.system.EV_ENABLE | os.system.EV_CLEAR | flags,
620620 .fflags = 0,
621621 .data = 0,
622 .udata = @ptrToInt(&resume_node.base),
622 .udata = @intFromPtr(&resume_node.base),
623623 }};
624624 const empty_kevs = &[0]os.Kevent{};
625625 _ = try os.kevent(self.os_data.kqfd, &kev, empty_kevs, null);
......@@ -1415,7 +1415,7 @@ pub const Loop = struct {
14151415 var events: [1]os.linux.epoll_event = undefined;
14161416 const count = os.epoll_wait(self.os_data.epollfd, events[0..], -1);
14171417 for (events[0..count]) |ev| {
1418 const resume_node = @intToPtr(*ResumeNode, ev.data.ptr);
1418 const resume_node = @ptrFromInt(*ResumeNode, ev.data.ptr);
14191419 const handle = resume_node.handle;
14201420 const resume_node_id = resume_node.id;
14211421 switch (resume_node_id) {
......@@ -1439,7 +1439,7 @@ pub const Loop = struct {
14391439 const empty_kevs = &[0]os.Kevent{};
14401440 const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;
14411441 for (eventlist[0..count]) |ev| {
1442 const resume_node = @intToPtr(*ResumeNode, ev.udata);
1442 const resume_node = @ptrFromInt(*ResumeNode, ev.udata);
14431443 const handle = resume_node.handle;
14441444 const resume_node_id = resume_node.id;
14451445 switch (resume_node_id) {
lib/std/fmt.zig+16-16
......@@ -409,15 +409,15 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
409409 .Pointer => |info| {
410410 try writer.writeAll(@typeName(info.child) ++ "@");
411411 if (info.size == .Slice)
412 try formatInt(@ptrToInt(value.ptr), 16, .lower, FormatOptions{}, writer)
412 try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
413413 else
414 try formatInt(@ptrToInt(value), 16, .lower, FormatOptions{}, writer);
414 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
415415 return;
416416 },
417417 .Optional => |info| {
418418 if (@typeInfo(info.child) == .Pointer) {
419419 try writer.writeAll(@typeName(info.child) ++ "@");
420 try formatInt(@ptrToInt(value), 16, .lower, FormatOptions{}, writer);
420 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
421421 return;
422422 }
423423 },
......@@ -531,7 +531,7 @@ pub fn formatType(
531531 // Use @tagName only if value is one of known fields
532532 @setEvalBranchQuota(3 * enumInfo.fields.len);
533533 inline for (enumInfo.fields) |enumField| {
534 if (@enumToInt(value) == enumField.value) {
534 if (@intFromEnum(value) == enumField.value) {
535535 try writer.writeAll(".");
536536 try writer.writeAll(@tagName(value));
537537 return;
......@@ -539,7 +539,7 @@ pub fn formatType(
539539 }
540540
541541 try writer.writeAll("(");
542 try formatType(@enumToInt(value), actual_fmt, options, writer, max_depth);
542 try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth);
543543 try writer.writeAll(")");
544544 },
545545 .Union => |info| {
......@@ -559,7 +559,7 @@ pub fn formatType(
559559 }
560560 try writer.writeAll(" }");
561561 } else {
562 try format(writer, "@{x}", .{@ptrToInt(&value)});
562 try format(writer, "@{x}", .{@intFromPtr(&value)});
563563 }
564564 },
565565 .Struct => |info| {
......@@ -624,7 +624,7 @@ pub fn formatType(
624624 .Enum, .Union, .Struct => {
625625 return formatType(value.*, actual_fmt, options, writer, max_depth);
626626 },
627 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }),
627 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
628628 },
629629 .Many, .C => {
630630 if (actual_fmt.len == 0)
......@@ -1213,7 +1213,7 @@ pub fn formatFloatHexadecimal(
12131213 extra_bits -= 1;
12141214 }
12151215 // Round to nearest, tie to even.
1216 mantissa |= @boolToInt(mantissa & 0b100 != 0);
1216 mantissa |= @intFromBool(mantissa & 0b100 != 0);
12171217 mantissa += 1;
12181218 // Drop the excess bits.
12191219 mantissa >>= 2;
......@@ -2099,7 +2099,7 @@ test "optional" {
20992099 try expectFmt("optional: null\n", "optional: {?}\n", .{value});
21002100 }
21012101 {
2102 const value = @intToPtr(?*i32, 0xf000d000);
2102 const value = @ptrFromInt(?*i32, 0xf000d000);
21032103 try expectFmt("optional: *i32@f000d000\n", "optional: {*}\n", .{value});
21042104 }
21052105}
......@@ -2204,7 +2204,7 @@ test "array" {
22042204
22052205 var buf: [100]u8 = undefined;
22062206 try expectFmt(
2207 try bufPrint(buf[0..], "array: [3]u8@{x}\n", .{@ptrToInt(&value)}),
2207 try bufPrint(buf[0..], "array: [3]u8@{x}\n", .{@intFromPtr(&value)}),
22082208 "array: {*}\n",
22092209 .{&value},
22102210 );
......@@ -2218,7 +2218,7 @@ test "slice" {
22182218 }
22192219 {
22202220 var runtime_zero: usize = 0;
2221 const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero];
2221 const value = @ptrFromInt([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero];
22222222 try expectFmt("slice: []const u8@deadbeef\n", "slice: {*}\n", .{value});
22232223 }
22242224 {
......@@ -2248,17 +2248,17 @@ test "escape non-printable" {
22482248
22492249test "pointer" {
22502250 {
2251 const value = @intToPtr(*align(1) i32, 0xdeadbeef);
2251 const value = @ptrFromInt(*align(1) i32, 0xdeadbeef);
22522252 try expectFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value});
22532253 try expectFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value});
22542254 }
22552255 const FnPtr = *align(1) const fn () void;
22562256 {
2257 const value = @intToPtr(FnPtr, 0xdeadbeef);
2257 const value = @ptrFromInt(FnPtr, 0xdeadbeef);
22582258 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
22592259 }
22602260 {
2261 const value = @intToPtr(FnPtr, 0xdeadbeef);
2261 const value = @ptrFromInt(FnPtr, 0xdeadbeef);
22622262 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
22632263 }
22642264}
......@@ -2360,11 +2360,11 @@ test "non-exhaustive enum" {
23602360 };
23612361 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {}\n", .{Enum.One});
23622362 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {}\n", .{Enum.Two});
2363 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)});
2363 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(4660)\n", "enum: {}\n", .{@enumFromInt(Enum, 0x1234)});
23642364 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {x}\n", .{Enum.One});
23652365 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {x}\n", .{Enum.Two});
23662366 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {X}\n", .{Enum.Two});
2367 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)});
2367 try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(1234)\n", "enum: {x}\n", .{@enumFromInt(Enum, 0x1234)});
23682368}
23692369
23702370test "float.scientific" {
lib/std/fmt/errol.zig+21-21
......@@ -59,7 +59,7 @@ pub fn roundToPrecision(float_decimal: *FloatDecimal, precision: usize, mode: Ro
5959 float_decimal.exp += 1;
6060
6161 // Re-size the buffer to use the reserved leading byte.
62 const one_before = @intToPtr([*]u8, @ptrToInt(&float_decimal.digits[0]) - 1);
62 const one_before = @ptrFromInt([*]u8, @intFromPtr(&float_decimal.digits[0]) - 1);
6363 float_decimal.digits = one_before[0 .. float_decimal.digits.len + 1];
6464 float_decimal.digits[0] = '1';
6565 return;
......@@ -113,7 +113,7 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal {
113113 // normalize the midpoint
114114
115115 const e = math.frexp(val).exponent;
116 var exp = @floatToInt(i16, @floor(307 + @intToFloat(f64, e) * 0.30103));
116 var exp = @intFromFloat(i16, @floor(307 + @floatFromInt(f64, e) * 0.30103));
117117 if (exp < 20) {
118118 exp = 20;
119119 } else if (@intCast(usize, exp) >= lookup_table.len) {
......@@ -171,25 +171,25 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal {
171171 var buf_index: usize = 0;
172172 const bound = buffer.len - 1;
173173 while (buf_index < bound) {
174 var hdig = @floatToInt(u8, @floor(high.val));
175 if ((high.val == @intToFloat(f64, hdig)) and (high.off < 0)) hdig -= 1;
174 var hdig = @intFromFloat(u8, @floor(high.val));
175 if ((high.val == @floatFromInt(f64, hdig)) and (high.off < 0)) hdig -= 1;
176176
177 var ldig = @floatToInt(u8, @floor(low.val));
178 if ((low.val == @intToFloat(f64, ldig)) and (low.off < 0)) ldig -= 1;
177 var ldig = @intFromFloat(u8, @floor(low.val));
178 if ((low.val == @floatFromInt(f64, ldig)) and (low.off < 0)) ldig -= 1;
179179
180180 if (ldig != hdig) break;
181181
182182 buffer[buf_index] = hdig + '0';
183183 buf_index += 1;
184 high.val -= @intToFloat(f64, hdig);
185 low.val -= @intToFloat(f64, ldig);
184 high.val -= @floatFromInt(f64, hdig);
185 low.val -= @floatFromInt(f64, ldig);
186186 hpMul10(&high);
187187 hpMul10(&low);
188188 }
189189
190190 const tmp = (high.val + low.val) / 2.0;
191 var mdig = @floatToInt(u8, @floor(tmp + 0.5));
192 if ((@intToFloat(f64, mdig) - tmp) == 0.5 and (mdig & 0x1) != 0) mdig -= 1;
191 var mdig = @intFromFloat(u8, @floor(tmp + 0.5));
192 if ((@floatFromInt(f64, mdig) - tmp) == 0.5 and (mdig & 0x1) != 0) mdig -= 1;
193193
194194 buffer[buf_index] = mdig + '0';
195195 buf_index += 1;
......@@ -303,7 +303,7 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal {
303303
304304 assert((val > 9.007199254740992e15) and val < (3.40282366920938e38));
305305
306 var mid = @floatToInt(u128, val);
306 var mid = @intFromFloat(u128, val);
307307 var low: u128 = mid - fpeint((fpnext(val) - val) / 2.0);
308308 var high: u128 = mid + fpeint((val - fpprev(val)) / 2.0);
309309
......@@ -328,7 +328,7 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal {
328328 var mi: i32 = mismatch10(l64, h64);
329329 var x: u64 = 1;
330330 {
331 var i: i32 = @boolToInt(lf == hf);
331 var i: i32 = @intFromBool(lf == hf);
332332 while (i < mi) : (i += 1) {
333333 x *= 10;
334334 }
......@@ -342,7 +342,7 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal {
342342 if (mi != 0) {
343343 const round_up = buffer[buf_index] >= '5';
344344 if (buf_index == 0 or (round_up and buffer[buf_index - 1] == '9')) return errolSlow(val, buffer);
345 buffer[buf_index - 1] += @boolToInt(round_up);
345 buffer[buf_index - 1] += @intFromBool(round_up);
346346 } else {
347347 buf_index += 1;
348348 }
......@@ -360,8 +360,8 @@ fn errolInt(val: f64, buffer: []u8) FloatDecimal {
360360fn errolFixed(val: f64, buffer: []u8) FloatDecimal {
361361 assert((val >= 16.0) and (val < 9.007199254740992e15));
362362
363 const u = @floatToInt(u64, val);
364 const n = @intToFloat(f64, u);
363 const u = @intFromFloat(u64, val);
364 const n = @floatFromInt(f64, u);
365365
366366 var mid = val - n;
367367 var lo = ((fpprev(val) - n) + mid) / 2.0;
......@@ -375,16 +375,16 @@ fn errolFixed(val: f64, buffer: []u8) FloatDecimal {
375375 if (mid != 0.0) {
376376 while (mid != 0.0) {
377377 lo *= 10.0;
378 const ldig = @floatToInt(i32, lo);
379 lo -= @intToFloat(f64, ldig);
378 const ldig = @intFromFloat(i32, lo);
379 lo -= @floatFromInt(f64, ldig);
380380
381381 mid *= 10.0;
382 const mdig = @floatToInt(i32, mid);
383 mid -= @intToFloat(f64, mdig);
382 const mdig = @intFromFloat(i32, mid);
383 mid -= @floatFromInt(f64, mdig);
384384
385385 hi *= 10.0;
386 const hdig = @floatToInt(i32, hi);
387 hi -= @intToFloat(f64, hdig);
386 const hdig = @intFromFloat(i32, hi);
387 hi -= @floatFromInt(f64, hdig);
388388
389389 buffer[j] = @intCast(u8, mdig + '0');
390390 j += 1;
lib/std/fmt/parse_float/convert_eisel_lemire.zig+1-1
......@@ -74,7 +74,7 @@ pub fn convertEiselLemire(comptime T: type, q: i64, w_: u64) ?BiasedFp(f64) {
7474 mantissa = math.shr(u64, mantissa, -power2 + 1);
7575 mantissa += mantissa & 1;
7676 mantissa >>= 1;
77 power2 = @boolToInt(mantissa >= (1 << float_info.mantissa_explicit_bits));
77 power2 = @intFromBool(mantissa >= (1 << float_info.mantissa_explicit_bits));
7878 return BiasedFp(f64){ .f = mantissa, .e = power2 };
7979 }
8080
lib/std/fmt/parse_float/convert_fast.zig+2-2
......@@ -108,7 +108,7 @@ pub fn convertFast(comptime T: type, n: Number(T)) ?T {
108108 var value: T = 0;
109109 if (n.exponent <= info.max_exponent_fast_path) {
110110 // normal fast path
111 value = @intToFloat(T, n.mantissa);
111 value = @floatFromInt(T, n.mantissa);
112112 value = if (n.exponent < 0)
113113 value / fastPow10(T, @intCast(usize, -n.exponent))
114114 else
......@@ -120,7 +120,7 @@ pub fn convertFast(comptime T: type, n: Number(T)) ?T {
120120 if (mantissa > info.max_mantissa_fast_path) {
121121 return null;
122122 }
123 value = @intToFloat(T, mantissa) * fastPow10(T, info.max_exponent_fast_path);
123 value = @floatFromInt(T, mantissa) * fastPow10(T, info.max_exponent_fast_path);
124124 }
125125
126126 if (n.negative) {
lib/std/fs.zig+4-4
......@@ -1268,8 +1268,8 @@ pub const Dir = struct {
12681268 &range_off,
12691269 &range_len,
12701270 null,
1271 @boolToInt(flags.lock_nonblocking),
1272 @boolToInt(exclusive),
1271 @intFromBool(flags.lock_nonblocking),
1272 @intFromBool(exclusive),
12731273 );
12741274 return file;
12751275 }
......@@ -1429,8 +1429,8 @@ pub const Dir = struct {
14291429 &range_off,
14301430 &range_len,
14311431 null,
1432 @boolToInt(flags.lock_nonblocking),
1433 @boolToInt(exclusive),
1432 @intFromBool(flags.lock_nonblocking),
1433 @intFromBool(exclusive),
14341434 );
14351435 return file;
14361436 }
lib/std/fs/file.zig+5-5
......@@ -516,7 +516,7 @@ pub const File = struct {
516516 /// Returns `true` if the chosen class has the selected permission.
517517 /// This method is only available on Unix platforms.
518518 pub fn unixHas(self: Self, class: Class, permission: Permission) bool {
519 const mask = @as(Mode, @enumToInt(permission)) << @as(u3, @enumToInt(class)) * 3;
519 const mask = @as(Mode, @intFromEnum(permission)) << @as(u3, @intFromEnum(class)) * 3;
520520 return self.mode & mask != 0;
521521 }
522522
......@@ -527,7 +527,7 @@ pub const File = struct {
527527 write: ?bool = null,
528528 execute: ?bool = null,
529529 }) void {
530 const shift = @as(u3, @enumToInt(class)) * 3;
530 const shift = @as(u3, @intFromEnum(class)) * 3;
531531 if (permissions.read) |r| {
532532 if (r) {
533533 self.mode |= @as(Mode, 0o4) << shift;
......@@ -973,7 +973,7 @@ pub const File = struct {
973973 // The file size returned by stat is used as hint to set the buffer
974974 // size. If the reported size is zero, as it happens on Linux for files
975975 // in /proc, a small buffer is allocated instead.
976 const initial_cap = (if (size > 0) size else 1024) + @boolToInt(optional_sentinel != null);
976 const initial_cap = (if (size > 0) size else 1024) + @intFromBool(optional_sentinel != null);
977977 var array_list = try std.ArrayListAligned(u8, alignment).initCapacity(allocator, initial_cap);
978978 defer array_list.deinit();
979979
......@@ -1488,7 +1488,7 @@ pub const File = struct {
14881488 &range_len,
14891489 null,
14901490 windows.FALSE, // non-blocking=false
1491 @boolToInt(exclusive),
1491 @intFromBool(exclusive),
14921492 ) catch |err| switch (err) {
14931493 error.WouldBlock => unreachable, // non-blocking=false
14941494 else => |e| return e,
......@@ -1555,7 +1555,7 @@ pub const File = struct {
15551555 &range_len,
15561556 null,
15571557 windows.TRUE, // non-blocking=true
1558 @boolToInt(exclusive),
1558 @intFromBool(exclusive),
15591559 ) catch |err| switch (err) {
15601560 error.WouldBlock => return false,
15611561 else => |e| return e,
lib/std/fs/path.zig+3-3
......@@ -67,7 +67,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn
6767 if (this_path.len == 0) continue;
6868 const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);
6969 const this_sep = sepPredicate(this_path[0]);
70 sum += @boolToInt(!prev_sep and !this_sep);
70 sum += @intFromBool(!prev_sep and !this_sep);
7171 sum += if (prev_sep and this_sep) this_path.len - 1 else this_path.len;
7272 prev_path = this_path;
7373 }
......@@ -663,7 +663,7 @@ pub fn resolvePosix(allocator: Allocator, paths: []const []const u8) Allocator.E
663663 continue;
664664 } else if (mem.eql(u8, component, "..")) {
665665 if (result.items.len == 0) {
666 negative_count += @boolToInt(!is_abs);
666 negative_count += @intFromBool(!is_abs);
667667 continue;
668668 }
669669 while (true) {
......@@ -1092,7 +1092,7 @@ pub fn relativeWindows(allocator: Allocator, from: []const u8, to: []const u8) !
10921092 while (from_it.next()) |_| {
10931093 up_index_end += "\\..".len;
10941094 }
1095 const result = try allocator.alloc(u8, up_index_end + @boolToInt(to_rest.len > 0) + to_rest.len);
1095 const result = try allocator.alloc(u8, up_index_end + @intFromBool(to_rest.len > 0) + to_rest.len);
10961096 errdefer allocator.free(result);
10971097
10981098 result[0..2].* = "..".*;
lib/std/fs/watch.zig+3-3
......@@ -285,7 +285,7 @@ pub fn Watch(comptime V: type) type {
285285 os.NOTE_WRITE | os.NOTE_DELETE | os.NOTE_REVOKE,
286286 .fflags = 0,
287287 .data = 0,
288 .udata = @ptrToInt(&resume_node.base),
288 .udata = @intFromPtr(&resume_node.base),
289289 };
290290 suspend {
291291 global_event_loop.beginOneEvent();
......@@ -486,7 +486,7 @@ pub fn Watch(comptime V: type) type {
486486 } else {
487487 var ptr: [*]u8 = &event_buf;
488488 const end_ptr = ptr + bytes_transferred;
489 while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) {
489 while (@intFromPtr(ptr) < @intFromPtr(end_ptr)) {
490490 const ev = @ptrCast(*const windows.FILE_NOTIFY_INFORMATION, ptr);
491491 const emit = switch (ev.Action) {
492492 windows.FILE_ACTION_REMOVED => WatchEventId.Delete,
......@@ -585,7 +585,7 @@ pub fn Watch(comptime V: type) type {
585585
586586 var ptr: [*]u8 = &event_buf;
587587 const end_ptr = ptr + bytes_read;
588 while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) {
588 while (@intFromPtr(ptr) < @intFromPtr(end_ptr)) {
589589 const ev = @ptrCast(*const os.linux.inotify_event, ptr);
590590 if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) {
591591 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);
lib/std/hash/auto_hash.zig+6-6
......@@ -25,7 +25,7 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
2525
2626 switch (info.Pointer.size) {
2727 .One => switch (strat) {
28 .Shallow => hash(hasher, @ptrToInt(key), .Shallow),
28 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
2929 .Deep => hash(hasher, key.*, .Shallow),
3030 .DeepRecursive => hash(hasher, key.*, .DeepRecursive),
3131 },
......@@ -44,7 +44,7 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
4444 .Many,
4545 .C,
4646 => switch (strat) {
47 .Shallow => hash(hasher, @ptrToInt(key), .Shallow),
47 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
4848 else => @compileError(
4949 \\ unknown-length pointers and C pointers cannot be hashed deeply.
5050 \\ Consider providing your own hash function.
......@@ -108,10 +108,10 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
108108 },
109109 },
110110
111 .Bool => hash(hasher, @boolToInt(key), strat),
112 .Enum => hash(hasher, @enumToInt(key), strat),
113 .ErrorSet => hash(hasher, @errorToInt(key), strat),
114 .AnyFrame, .Fn => hash(hasher, @ptrToInt(key), strat),
111 .Bool => hash(hasher, @intFromBool(key), strat),
112 .Enum => hash(hasher, @intFromEnum(key), strat),
113 .ErrorSet => hash(hasher, @intFromError(key), strat),
114 .AnyFrame, .Fn => hash(hasher, @intFromPtr(key), strat),
115115
116116 .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }),
117117
lib/std/hash/benchmark.zig+4-4
......@@ -127,8 +127,8 @@ pub fn benchmarkHash(comptime H: anytype, bytes: usize, allocator: std.mem.Alloc
127127
128128 const end = timer.read();
129129
130 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
131 const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s);
130 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
131 const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s);
132132
133133 return Result{
134134 .hash = final,
......@@ -166,8 +166,8 @@ pub fn benchmarkHashSmallKeys(comptime H: anytype, key_size: usize, bytes: usize
166166 }
167167 const end = timer.read();
168168
169 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
170 const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s);
169 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
170 const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s);
171171
172172 std.mem.doNotOptimizeAway(sum);
173173
lib/std/hash/crc.zig+2-2
......@@ -129,7 +129,7 @@ pub fn Crc32WithPoly(comptime poly: Polynomial) type {
129129 var j: usize = 0;
130130 while (j < 8) : (j += 1) {
131131 if (crc & 1 == 1) {
132 crc = (crc >> 1) ^ @enumToInt(poly);
132 crc = (crc >> 1) ^ @intFromEnum(poly);
133133 } else {
134134 crc = (crc >> 1);
135135 }
......@@ -222,7 +222,7 @@ pub fn Crc32SmallWithPoly(comptime poly: Polynomial) type {
222222 var j: usize = 0;
223223 while (j < 8) : (j += 1) {
224224 if (crc & 1 == 1) {
225 crc = (crc >> 1) ^ @enumToInt(poly);
225 crc = (crc >> 1) ^ @intFromEnum(poly);
226226 } else {
227227 crc = (crc >> 1);
228228 }
lib/std/hash_map.zig+7-7
......@@ -1442,7 +1442,7 @@ pub fn HashMapUnmanaged(
14421442 // map, which is assumed to exist as keyPtr must be valid. This
14431443 // item must be at index 0.
14441444 const idx = if (@sizeOf(K) > 0)
1445 (@ptrToInt(keyPtr) - @ptrToInt(self.keys())) / @sizeOf(K)
1445 (@intFromPtr(keyPtr) - @intFromPtr(self.keys())) / @sizeOf(K)
14461446 else
14471447 0;
14481448
......@@ -1554,19 +1554,19 @@ pub fn HashMapUnmanaged(
15541554 const total_size = std.mem.alignForward(usize, vals_end, max_align);
15551555
15561556 const slice = try allocator.alignedAlloc(u8, max_align, total_size);
1557 const ptr = @ptrToInt(slice.ptr);
1557 const ptr = @intFromPtr(slice.ptr);
15581558
15591559 const metadata = ptr + @sizeOf(Header);
15601560
1561 const hdr = @intToPtr(*Header, ptr);
1561 const hdr = @ptrFromInt(*Header, ptr);
15621562 if (@sizeOf([*]V) != 0) {
1563 hdr.values = @intToPtr([*]V, ptr + vals_start);
1563 hdr.values = @ptrFromInt([*]V, ptr + vals_start);
15641564 }
15651565 if (@sizeOf([*]K) != 0) {
1566 hdr.keys = @intToPtr([*]K, ptr + keys_start);
1566 hdr.keys = @ptrFromInt([*]K, ptr + keys_start);
15671567 }
15681568 hdr.capacity = new_capacity;
1569 self.metadata = @intToPtr([*]Metadata, metadata);
1569 self.metadata = @ptrFromInt([*]Metadata, metadata);
15701570 }
15711571
15721572 fn deallocate(self: *Self, allocator: Allocator) void {
......@@ -1589,7 +1589,7 @@ pub fn HashMapUnmanaged(
15891589
15901590 const total_size = std.mem.alignForward(usize, vals_end, max_align);
15911591
1592 const slice = @intToPtr([*]align(max_align) u8, @ptrToInt(self.header()))[0..total_size];
1592 const slice = @ptrFromInt([*]align(max_align) u8, @intFromPtr(self.header()))[0..total_size];
15931593 allocator.free(slice);
15941594
15951595 self.metadata = null;
lib/std/heap.zig+18-18
......@@ -61,7 +61,7 @@ const CAllocator = struct {
6161 pub const supports_posix_memalign = @hasDecl(c, "posix_memalign");
6262
6363 fn getHeader(ptr: [*]u8) *[*]u8 {
64 return @intToPtr(*[*]u8, @ptrToInt(ptr) - @sizeOf(usize));
64 return @ptrFromInt(*[*]u8, @intFromPtr(ptr) - @sizeOf(usize));
6565 }
6666
6767 fn alignedAlloc(len: usize, log2_align: u8) ?[*]u8 {
......@@ -82,7 +82,7 @@ const CAllocator = struct {
8282 // alignment padding and store the original malloc()'ed pointer before
8383 // the aligned address.
8484 var unaligned_ptr = @ptrCast([*]u8, c.malloc(len + alignment - 1 + @sizeOf(usize)) orelse return null);
85 const unaligned_addr = @ptrToInt(unaligned_ptr);
85 const unaligned_addr = @intFromPtr(unaligned_ptr);
8686 const aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), alignment);
8787 var aligned_ptr = unaligned_ptr + (aligned_addr - unaligned_addr);
8888 getHeader(aligned_ptr).* = unaligned_ptr;
......@@ -105,7 +105,7 @@ const CAllocator = struct {
105105 }
106106
107107 const unaligned_ptr = getHeader(ptr).*;
108 const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr);
108 const delta = @intFromPtr(ptr) - @intFromPtr(unaligned_ptr);
109109 return CAllocator.malloc_size(unaligned_ptr) - delta;
110110 }
111111
......@@ -283,7 +283,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {
283283 }
284284
285285 fn getRecordPtr(buf: []u8) *align(1) usize {
286 return @intToPtr(*align(1) usize, @ptrToInt(buf.ptr) + buf.len);
286 return @ptrFromInt(*align(1) usize, @intFromPtr(buf.ptr) + buf.len);
287287 }
288288
289289 fn alloc(
......@@ -306,9 +306,9 @@ pub const HeapAllocator = switch (builtin.os.tag) {
306306 break :blk other_hh.?; // can't be null because of the cmpxchg
307307 };
308308 const ptr = os.windows.kernel32.HeapAlloc(heap_handle, 0, amt) orelse return null;
309 const root_addr = @ptrToInt(ptr);
309 const root_addr = @intFromPtr(ptr);
310310 const aligned_addr = mem.alignForward(usize, root_addr, ptr_align);
311 const buf = @intToPtr([*]u8, aligned_addr)[0..n];
311 const buf = @ptrFromInt([*]u8, aligned_addr)[0..n];
312312 getRecordPtr(buf).* = root_addr;
313313 return buf.ptr;
314314 }
......@@ -325,15 +325,15 @@ pub const HeapAllocator = switch (builtin.os.tag) {
325325 const self = @ptrCast(*HeapAllocator, @alignCast(@alignOf(HeapAllocator), ctx));
326326
327327 const root_addr = getRecordPtr(buf).*;
328 const align_offset = @ptrToInt(buf.ptr) - root_addr;
328 const align_offset = @intFromPtr(buf.ptr) - root_addr;
329329 const amt = align_offset + new_size + @sizeOf(usize);
330330 const new_ptr = os.windows.kernel32.HeapReAlloc(
331331 self.heap_handle.?,
332332 os.windows.HEAP_REALLOC_IN_PLACE_ONLY,
333 @intToPtr(*anyopaque, root_addr),
333 @ptrFromInt(*anyopaque, root_addr),
334334 amt,
335335 ) orelse return false;
336 assert(new_ptr == @intToPtr(*anyopaque, root_addr));
336 assert(new_ptr == @ptrFromInt(*anyopaque, root_addr));
337337 getRecordPtr(buf.ptr[0..new_size]).* = root_addr;
338338 return true;
339339 }
......@@ -347,20 +347,20 @@ pub const HeapAllocator = switch (builtin.os.tag) {
347347 _ = log2_buf_align;
348348 _ = return_address;
349349 const self = @ptrCast(*HeapAllocator, @alignCast(@alignOf(HeapAllocator), ctx));
350 os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*anyopaque, getRecordPtr(buf).*));
350 os.windows.HeapFree(self.heap_handle.?, 0, @ptrFromInt(*anyopaque, getRecordPtr(buf).*));
351351 }
352352 },
353353 else => @compileError("Unsupported OS"),
354354};
355355
356356fn sliceContainsPtr(container: []u8, ptr: [*]u8) bool {
357 return @ptrToInt(ptr) >= @ptrToInt(container.ptr) and
358 @ptrToInt(ptr) < (@ptrToInt(container.ptr) + container.len);
357 return @intFromPtr(ptr) >= @intFromPtr(container.ptr) and
358 @intFromPtr(ptr) < (@intFromPtr(container.ptr) + container.len);
359359}
360360
361361fn sliceContainsSlice(container: []u8, slice: []u8) bool {
362 return @ptrToInt(slice.ptr) >= @ptrToInt(container.ptr) and
363 (@ptrToInt(slice.ptr) + slice.len) <= (@ptrToInt(container.ptr) + container.len);
362 return @intFromPtr(slice.ptr) >= @intFromPtr(container.ptr) and
363 (@intFromPtr(slice.ptr) + slice.len) <= (@intFromPtr(container.ptr) + container.len);
364364}
365365
366366pub const FixedBufferAllocator = struct {
......@@ -804,21 +804,21 @@ pub fn testAllocatorLargeAlignment(base_allocator: mem.Allocator) !void {
804804 align_mask = @shlWithOverflow(~@as(usize, 0), @as(Allocator.Log2Align, @ctz(large_align)))[0];
805805
806806 var slice = try allocator.alignedAlloc(u8, large_align, 500);
807 try testing.expect(@ptrToInt(slice.ptr) & align_mask == @ptrToInt(slice.ptr));
807 try testing.expect(@intFromPtr(slice.ptr) & align_mask == @intFromPtr(slice.ptr));
808808
809809 if (allocator.resize(slice, 100)) {
810810 slice = slice[0..100];
811811 }
812812
813813 slice = try allocator.realloc(slice, 5000);
814 try testing.expect(@ptrToInt(slice.ptr) & align_mask == @ptrToInt(slice.ptr));
814 try testing.expect(@intFromPtr(slice.ptr) & align_mask == @intFromPtr(slice.ptr));
815815
816816 if (allocator.resize(slice, 10)) {
817817 slice = slice[0..10];
818818 }
819819
820820 slice = try allocator.realloc(slice, 20000);
821 try testing.expect(@ptrToInt(slice.ptr) & align_mask == @ptrToInt(slice.ptr));
821 try testing.expect(@intFromPtr(slice.ptr) & align_mask == @intFromPtr(slice.ptr));
822822
823823 allocator.free(slice);
824824}
......@@ -840,7 +840,7 @@ pub fn testAllocatorAlignedShrink(base_allocator: mem.Allocator) !void {
840840 // which is 16 pages, hence the 32. This test may require to increase
841841 // the size of the allocations feeding the `allocator` parameter if they
842842 // fail, because of this high over-alignment we want to have.
843 while (@ptrToInt(slice.ptr) == mem.alignForward(usize, @ptrToInt(slice.ptr), mem.page_size * 32)) {
843 while (@intFromPtr(slice.ptr) == mem.alignForward(usize, @intFromPtr(slice.ptr), mem.page_size * 32)) {
844844 try stuff_to_free.append(slice);
845845 slice = try allocator.alignedAlloc(u8, 16, alloc_size);
846846 }
lib/std/heap/PageAllocator.zig+3-3
......@@ -39,7 +39,7 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 {
3939 -1,
4040 0,
4141 ) catch return null;
42 assert(mem.isAligned(@ptrToInt(slice.ptr), mem.page_size));
42 assert(mem.isAligned(@intFromPtr(slice.ptr), mem.page_size));
4343 const new_hint = @alignCast(mem.page_size, slice.ptr + aligned_len);
4444 _ = @cmpxchgStrong(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, hint, new_hint, .Monotonic, .Monotonic);
4545 return slice.ptr;
......@@ -59,14 +59,14 @@ fn resize(
5959 if (builtin.os.tag == .windows) {
6060 const w = os.windows;
6161 if (new_size <= buf_unaligned.len) {
62 const base_addr = @ptrToInt(buf_unaligned.ptr);
62 const base_addr = @intFromPtr(buf_unaligned.ptr);
6363 const old_addr_end = base_addr + buf_unaligned.len;
6464 const new_addr_end = mem.alignForward(usize, base_addr + new_size, mem.page_size);
6565 if (old_addr_end > new_addr_end) {
6666 // For shrinking that is not releasing, we will only
6767 // decommit the pages not needed anymore.
6868 w.VirtualFree(
69 @intToPtr(*anyopaque, new_addr_end),
69 @ptrFromInt(*anyopaque, new_addr_end),
7070 old_addr_end - new_addr_end,
7171 w.MEM_DECOMMIT,
7272 );
lib/std/heap/WasmAllocator.zig+7-7
......@@ -55,7 +55,7 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, return_address: usize) ?[*
5555 const addr = a: {
5656 const top_free_ptr = frees[class];
5757 if (top_free_ptr != 0) {
58 const node = @intToPtr(*usize, top_free_ptr + (slot_size - @sizeOf(usize)));
58 const node = @ptrFromInt(*usize, top_free_ptr + (slot_size - @sizeOf(usize)));
5959 frees[class] = node.*;
6060 break :a top_free_ptr;
6161 }
......@@ -74,11 +74,11 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, return_address: usize) ?[*
7474 break :a next_addr;
7575 }
7676 };
77 return @intToPtr([*]u8, addr);
77 return @ptrFromInt([*]u8, addr);
7878 }
7979 const bigpages_needed = bigPagesNeeded(actual_len);
8080 const addr = allocBigPages(bigpages_needed);
81 return @intToPtr([*]u8, addr);
81 return @ptrFromInt([*]u8, addr);
8282}
8383
8484fn resize(
......@@ -121,16 +121,16 @@ fn free(
121121 const actual_len = @max(buf.len + @sizeOf(usize), buf_align);
122122 const slot_size = math.ceilPowerOfTwoAssert(usize, actual_len);
123123 const class = math.log2(slot_size) - min_class;
124 const addr = @ptrToInt(buf.ptr);
124 const addr = @intFromPtr(buf.ptr);
125125 if (class < size_class_count) {
126 const node = @intToPtr(*usize, addr + (slot_size - @sizeOf(usize)));
126 const node = @ptrFromInt(*usize, addr + (slot_size - @sizeOf(usize)));
127127 node.* = frees[class];
128128 frees[class] = addr;
129129 } else {
130130 const bigpages_needed = bigPagesNeeded(actual_len);
131131 const pow2_pages = math.ceilPowerOfTwoAssert(usize, bigpages_needed);
132132 const big_slot_size_bytes = pow2_pages * bigpage_size;
133 const node = @intToPtr(*usize, addr + (big_slot_size_bytes - @sizeOf(usize)));
133 const node = @ptrFromInt(*usize, addr + (big_slot_size_bytes - @sizeOf(usize)));
134134 const big_class = math.log2(pow2_pages);
135135 node.* = big_frees[big_class];
136136 big_frees[big_class] = addr;
......@@ -148,7 +148,7 @@ fn allocBigPages(n: usize) usize {
148148
149149 const top_free_ptr = big_frees[class];
150150 if (top_free_ptr != 0) {
151 const node = @intToPtr(*usize, top_free_ptr + (slot_size_bytes - @sizeOf(usize)));
151 const node = @ptrFromInt(*usize, top_free_ptr + (slot_size_bytes - @sizeOf(usize)));
152152 big_frees[class] = node.*;
153153 return top_free_ptr;
154154 }
lib/std/heap/WasmPageAllocator.zig+8-8
......@@ -40,14 +40,14 @@ const FreeBlock = struct {
4040
4141 fn getBit(self: FreeBlock, idx: usize) PageStatus {
4242 const bit_offset = 0;
43 return @intToEnum(PageStatus, Io.get(mem.sliceAsBytes(self.data), idx, bit_offset));
43 return @enumFromInt(PageStatus, Io.get(mem.sliceAsBytes(self.data), idx, bit_offset));
4444 }
4545
4646 fn setBits(self: FreeBlock, start_idx: usize, len: usize, val: PageStatus) void {
4747 const bit_offset = 0;
4848 var i: usize = 0;
4949 while (i < len) : (i += 1) {
50 Io.set(mem.sliceAsBytes(self.data), start_idx + i, bit_offset, @enumToInt(val));
50 Io.set(mem.sliceAsBytes(self.data), start_idx + i, bit_offset, @intFromEnum(val));
5151 }
5252 }
5353
......@@ -109,7 +109,7 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, ra: usize) ?[*]u8 {
109109 if (len > maxInt(usize) - (mem.page_size - 1)) return null;
110110 const page_count = nPages(len);
111111 const page_idx = allocPages(page_count, log2_align) catch return null;
112 return @intToPtr([*]u8, page_idx * mem.page_size);
112 return @ptrFromInt([*]u8, page_idx * mem.page_size);
113113}
114114
115115fn allocPages(page_count: usize, log2_align: u8) !usize {
......@@ -151,7 +151,7 @@ fn freePages(start: usize, end: usize) void {
151151 // TODO: would it be better if we use the first page instead?
152152 new_end -= 1;
153153
154 extended.data = @intToPtr([*]u128, new_end * mem.page_size)[0 .. mem.page_size / @sizeOf(u128)];
154 extended.data = @ptrFromInt([*]u128, new_end * mem.page_size)[0 .. mem.page_size / @sizeOf(u128)];
155155 // Since this is the first page being freed and we consume it, assume *nothing* is free.
156156 @memset(extended.data, PageStatus.none_free);
157157 }
......@@ -175,7 +175,7 @@ fn resize(
175175 const current_n = nPages(aligned_len);
176176 const new_n = nPages(new_len);
177177 if (new_n != current_n) {
178 const base = nPages(@ptrToInt(buf.ptr));
178 const base = nPages(@intFromPtr(buf.ptr));
179179 freePages(base + new_n, base + current_n);
180180 }
181181 return true;
......@@ -192,7 +192,7 @@ fn free(
192192 _ = return_address;
193193 const aligned_len = mem.alignForward(usize, buf.len, mem.page_size);
194194 const current_n = nPages(aligned_len);
195 const base = nPages(@ptrToInt(buf.ptr));
195 const base = nPages(@intFromPtr(buf.ptr));
196196 freePages(base, base + current_n);
197197}
198198
......@@ -202,7 +202,7 @@ test "internals" {
202202
203203 const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size;
204204 const initial = try page_allocator.alloc(u8, mem.page_size);
205 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.
205 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.
206206
207207 var inplace = try page_allocator.realloc(initial, 1);
208208 try testing.expectEqual(initial.ptr, inplace.ptr);
......@@ -219,7 +219,7 @@ test "internals" {
219219 page_allocator.free(padding);
220220
221221 const ext = try page_allocator.alloc(u8, conventional_memsize);
222 try testing.expect(@ptrToInt(ext.ptr) >= conventional_memsize);
222 try testing.expect(@intFromPtr(ext.ptr) >= conventional_memsize);
223223
224224 const use_small = try page_allocator.alloc(u8, 1);
225225 try testing.expectEqual(initial.ptr, use_small.ptr);
lib/std/heap/arena_allocator.zig+4-4
......@@ -185,7 +185,7 @@ pub const ArenaAllocator = struct {
185185 while (true) {
186186 const cur_alloc_buf = @ptrCast([*]u8, cur_node)[0..cur_node.data];
187187 const cur_buf = cur_alloc_buf[@sizeOf(BufNode)..];
188 const addr = @ptrToInt(cur_buf.ptr) + self.state.end_index;
188 const addr = @intFromPtr(cur_buf.ptr) + self.state.end_index;
189189 const adjusted_addr = mem.alignForward(usize, addr, ptr_align);
190190 const adjusted_index = self.state.end_index + (adjusted_addr - addr);
191191 const new_end_index = adjusted_index + n;
......@@ -214,7 +214,7 @@ pub const ArenaAllocator = struct {
214214
215215 const cur_node = self.state.buffer_list.first orelse return false;
216216 const cur_buf = @ptrCast([*]u8, cur_node)[@sizeOf(BufNode)..cur_node.data];
217 if (@ptrToInt(cur_buf.ptr) + self.state.end_index != @ptrToInt(buf.ptr) + buf.len) {
217 if (@intFromPtr(cur_buf.ptr) + self.state.end_index != @intFromPtr(buf.ptr) + buf.len) {
218218 // It's not the most recent allocation, so it cannot be expanded,
219219 // but it's fine if they want to make it smaller.
220220 return new_len <= buf.len;
......@@ -240,7 +240,7 @@ pub const ArenaAllocator = struct {
240240 const cur_node = self.state.buffer_list.first orelse return;
241241 const cur_buf = @ptrCast([*]u8, cur_node)[@sizeOf(BufNode)..cur_node.data];
242242
243 if (@ptrToInt(cur_buf.ptr) + self.state.end_index == @ptrToInt(buf.ptr) + buf.len) {
243 if (@intFromPtr(cur_buf.ptr) + self.state.end_index == @intFromPtr(buf.ptr) + buf.len) {
244244 self.state.end_index -= buf.len;
245245 }
246246 }
......@@ -262,7 +262,7 @@ test "ArenaAllocator (reset with preheating)" {
262262 const size = random.intRangeAtMost(usize, 16, 256);
263263 const alignment = 32;
264264 const slice = try arena_allocator.allocator().alignedAlloc(u8, alignment, size);
265 try std.testing.expect(std.mem.isAligned(@ptrToInt(slice.ptr), alignment));
265 try std.testing.expect(std.mem.isAligned(@intFromPtr(slice.ptr), alignment));
266266 try std.testing.expectEqual(size, slice.len);
267267 alloced_bytes += slice.len;
268268 }
lib/std/heap/general_purpose_allocator.zig+41-41
......@@ -216,8 +216,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
216216 }
217217
218218 fn getStackTrace(self: *LargeAlloc, trace_kind: TraceKind) std.builtin.StackTrace {
219 assert(@enumToInt(trace_kind) < trace_n);
220 const stack_addresses = &self.stack_addresses[@enumToInt(trace_kind)];
219 assert(@intFromEnum(trace_kind) < trace_n);
220 const stack_addresses = &self.stack_addresses[@intFromEnum(trace_kind)];
221221 var len: usize = 0;
222222 while (len < stack_n and stack_addresses[len] != 0) {
223223 len += 1;
......@@ -229,8 +229,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
229229 }
230230
231231 fn captureStackTrace(self: *LargeAlloc, ret_addr: usize, trace_kind: TraceKind) void {
232 assert(@enumToInt(trace_kind) < trace_n);
233 const stack_addresses = &self.stack_addresses[@enumToInt(trace_kind)];
232 assert(@intFromEnum(trace_kind) < trace_n);
233 const stack_addresses = &self.stack_addresses[@intFromEnum(trace_kind)];
234234 collectStackTrace(ret_addr, stack_addresses);
235235 }
236236 };
......@@ -250,7 +250,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
250250 used_count: SlotIndex,
251251
252252 fn usedBits(bucket: *BucketHeader, index: usize) *u8 {
253 return @intToPtr(*u8, @ptrToInt(bucket) + @sizeOf(BucketHeader) + index);
253 return @ptrFromInt(*u8, @intFromPtr(bucket) + @sizeOf(BucketHeader) + index);
254254 }
255255
256256 fn stackTracePtr(
......@@ -261,7 +261,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
261261 ) *[stack_n]usize {
262262 const start_ptr = @ptrCast([*]u8, bucket) + bucketStackFramesStart(size_class);
263263 const addr = start_ptr + one_trace_size * traces_per_slot * slot_index +
264 @enumToInt(trace_kind) * @as(usize, one_trace_size);
264 @intFromEnum(trace_kind) * @as(usize, one_trace_size);
265265 return @ptrCast(*[stack_n]usize, @alignCast(@alignOf(usize), addr));
266266 }
267267
......@@ -344,7 +344,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
344344 const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc);
345345 const addr = bucket.page + slot_index * size_class;
346346 log.err("memory address 0x{x} leaked: {}", .{
347 @ptrToInt(addr), stack_trace,
347 @intFromPtr(addr), stack_trace,
348348 });
349349 leaks = true;
350350 }
......@@ -376,7 +376,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
376376 if (config.retain_metadata and large_alloc.freed) continue;
377377 const stack_trace = large_alloc.getStackTrace(.alloc);
378378 log.err("memory address 0x{x} leaked: {}", .{
379 @ptrToInt(large_alloc.bytes.ptr), stack_trace,
379 @intFromPtr(large_alloc.bytes.ptr), stack_trace,
380380 });
381381 leaks = true;
382382 }
......@@ -427,7 +427,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
427427 var it = self.large_allocations.iterator();
428428 while (it.next()) |large| {
429429 if (large.value_ptr.freed) {
430 _ = self.large_allocations.remove(@ptrToInt(large.value_ptr.bytes.ptr));
430 _ = self.large_allocations.remove(@intFromPtr(large.value_ptr.bytes.ptr));
431431 }
432432 }
433433 }
......@@ -444,7 +444,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
444444 self.small_allocations.deinit(self.backing_allocator);
445445 }
446446 self.* = undefined;
447 return @intToEnum(Check, @boolToInt(leaks));
447 return @enumFromInt(Check, @intFromBool(leaks));
448448 }
449449
450450 fn collectStackTrace(first_trace_addr: usize, addresses: *[stack_n]usize) void {
......@@ -510,8 +510,8 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
510510 const first_bucket = bucket_list orelse return null;
511511 var bucket = first_bucket;
512512 while (true) {
513 const in_bucket_range = (addr >= @ptrToInt(bucket.page) and
514 addr < @ptrToInt(bucket.page) + page_size);
513 const in_bucket_range = (addr >= @intFromPtr(bucket.page) and
514 addr < @intFromPtr(bucket.page) + page_size);
515515 if (in_bucket_range) return bucket;
516516 bucket = bucket.prev;
517517 if (bucket == first_bucket) {
......@@ -529,7 +529,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
529529 new_size: usize,
530530 ret_addr: usize,
531531 ) bool {
532 const entry = self.large_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse {
532 const entry = self.large_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse {
533533 if (config.safety) {
534534 @panic("Invalid free");
535535 } else {
......@@ -604,7 +604,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
604604 log2_old_align: u8,
605605 ret_addr: usize,
606606 ) void {
607 const entry = self.large_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse {
607 const entry = self.large_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse {
608608 if (config.safety) {
609609 @panic("Invalid free");
610610 } else {
......@@ -649,7 +649,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
649649 }
650650
651651 if (!config.retain_metadata) {
652 assert(self.large_allocations.remove(@ptrToInt(old_mem.ptr)));
652 assert(self.large_allocations.remove(@intFromPtr(old_mem.ptr)));
653653 } else {
654654 entry.value_ptr.freed = true;
655655 entry.value_ptr.captureStackTrace(ret_addr, .free);
......@@ -683,7 +683,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
683683 var bucket_index = math.log2(size_class_hint);
684684 var size_class: usize = size_class_hint;
685685 const bucket = while (bucket_index < small_bucket_count) : (bucket_index += 1) {
686 if (searchBucket(self.buckets[bucket_index], @ptrToInt(old_mem.ptr))) |bucket| {
686 if (searchBucket(self.buckets[bucket_index], @intFromPtr(old_mem.ptr))) |bucket| {
687687 // move bucket to head of list to optimize search for nearby allocations
688688 self.buckets[bucket_index] = bucket;
689689 break bucket;
......@@ -691,9 +691,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
691691 size_class *= 2;
692692 } else blk: {
693693 if (config.retain_metadata) {
694 if (!self.large_allocations.contains(@ptrToInt(old_mem.ptr))) {
694 if (!self.large_allocations.contains(@intFromPtr(old_mem.ptr))) {
695695 // object not in active buckets or a large allocation, so search empty buckets
696 if (searchBucket(self.empty_buckets, @ptrToInt(old_mem.ptr))) |bucket| {
696 if (searchBucket(self.empty_buckets, @intFromPtr(old_mem.ptr))) |bucket| {
697697 // bucket is empty so is_used below will always be false and we exit there
698698 break :blk bucket;
699699 } else {
......@@ -703,7 +703,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
703703 }
704704 return self.resizeLarge(old_mem, log2_old_align, new_size, ret_addr);
705705 };
706 const byte_offset = @ptrToInt(old_mem.ptr) - @ptrToInt(bucket.page);
706 const byte_offset = @intFromPtr(old_mem.ptr) - @intFromPtr(bucket.page);
707707 const slot_index = @intCast(SlotIndex, byte_offset / size_class);
708708 const used_byte_index = slot_index / 8;
709709 const used_bit_index = @intCast(u3, slot_index % 8);
......@@ -720,7 +720,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
720720
721721 // Definitely an in-use small alloc now.
722722 if (config.safety) {
723 const entry = self.small_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse
723 const entry = self.small_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse
724724 @panic("Invalid free");
725725 if (old_mem.len != entry.value_ptr.requested_size or log2_old_align != entry.value_ptr.log2_ptr_align) {
726726 var addresses: [stack_n]usize = [1]usize{0} ** stack_n;
......@@ -768,7 +768,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
768768 });
769769 }
770770 if (config.safety) {
771 const entry = self.small_allocations.getEntry(@ptrToInt(old_mem.ptr)).?;
771 const entry = self.small_allocations.getEntry(@intFromPtr(old_mem.ptr)).?;
772772 entry.value_ptr.requested_size = new_size;
773773 }
774774 return true;
......@@ -803,7 +803,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
803803 var bucket_index = math.log2(size_class_hint);
804804 var size_class: usize = size_class_hint;
805805 const bucket = while (bucket_index < small_bucket_count) : (bucket_index += 1) {
806 if (searchBucket(self.buckets[bucket_index], @ptrToInt(old_mem.ptr))) |bucket| {
806 if (searchBucket(self.buckets[bucket_index], @intFromPtr(old_mem.ptr))) |bucket| {
807807 // move bucket to head of list to optimize search for nearby allocations
808808 self.buckets[bucket_index] = bucket;
809809 break bucket;
......@@ -811,9 +811,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
811811 size_class *= 2;
812812 } else blk: {
813813 if (config.retain_metadata) {
814 if (!self.large_allocations.contains(@ptrToInt(old_mem.ptr))) {
814 if (!self.large_allocations.contains(@intFromPtr(old_mem.ptr))) {
815815 // object not in active buckets or a large allocation, so search empty buckets
816 if (searchBucket(self.empty_buckets, @ptrToInt(old_mem.ptr))) |bucket| {
816 if (searchBucket(self.empty_buckets, @intFromPtr(old_mem.ptr))) |bucket| {
817817 // bucket is empty so is_used below will always be false and we exit there
818818 break :blk bucket;
819819 } else {
......@@ -824,7 +824,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
824824 self.freeLarge(old_mem, log2_old_align, ret_addr);
825825 return;
826826 };
827 const byte_offset = @ptrToInt(old_mem.ptr) - @ptrToInt(bucket.page);
827 const byte_offset = @intFromPtr(old_mem.ptr) - @intFromPtr(bucket.page);
828828 const slot_index = @intCast(SlotIndex, byte_offset / size_class);
829829 const used_byte_index = slot_index / 8;
830830 const used_bit_index = @intCast(u3, slot_index % 8);
......@@ -842,7 +842,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
842842
843843 // Definitely an in-use small alloc now.
844844 if (config.safety) {
845 const entry = self.small_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse
845 const entry = self.small_allocations.getEntry(@intFromPtr(old_mem.ptr)) orelse
846846 @panic("Invalid free");
847847 if (old_mem.len != entry.value_ptr.requested_size or log2_old_align != entry.value_ptr.log2_ptr_align) {
848848 var addresses: [stack_n]usize = [1]usize{0} ** stack_n;
......@@ -915,7 +915,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
915915 @memset(old_mem, undefined);
916916 }
917917 if (config.safety) {
918 assert(self.small_allocations.remove(@ptrToInt(old_mem.ptr)));
918 assert(self.small_allocations.remove(@intFromPtr(old_mem.ptr)));
919919 }
920920 if (config.verbose_log) {
921921 log.info("small free {d} bytes at {*}", .{ old_mem.len, old_mem.ptr });
......@@ -956,7 +956,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
956956 return error.OutOfMemory;
957957 const slice = ptr[0..len];
958958
959 const gop = self.large_allocations.getOrPutAssumeCapacity(@ptrToInt(slice.ptr));
959 const gop = self.large_allocations.getOrPutAssumeCapacity(@intFromPtr(slice.ptr));
960960 if (config.retain_metadata and !config.never_unmap) {
961961 // Backing allocator may be reusing memory that we're retaining metadata for
962962 assert(!gop.found_existing or gop.value_ptr.freed);
......@@ -986,7 +986,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
986986 const new_size_class = math.ceilPowerOfTwoAssert(usize, new_aligned_size);
987987 const ptr = try self.allocSlot(new_size_class, ret_addr);
988988 if (config.safety) {
989 const gop = self.small_allocations.getOrPutAssumeCapacity(@ptrToInt(ptr));
989 const gop = self.small_allocations.getOrPutAssumeCapacity(@intFromPtr(ptr));
990990 gop.value_ptr.requested_size = len;
991991 gop.value_ptr.log2_ptr_align = log2_ptr_align;
992992 }
......@@ -1212,7 +1212,7 @@ test "shrink large object to large object with larger alignment" {
12121212 // alignment. Then we shrink the allocation after the loop, but increase the
12131213 // alignment to the higher one, that we know will force it to realloc.
12141214 var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator);
1215 while (mem.isAligned(@ptrToInt(slice.ptr), big_alignment)) {
1215 while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) {
12161216 try stuff_to_free.append(slice);
12171217 slice = try allocator.alignedAlloc(u8, 16, alloc_size);
12181218 }
......@@ -1281,7 +1281,7 @@ test "realloc large object to larger alignment" {
12811281 };
12821282 // This loop allocates until we find a page that is not aligned to the big alignment.
12831283 var stuff_to_free = std.ArrayList([]align(16) u8).init(debug_allocator);
1284 while (mem.isAligned(@ptrToInt(slice.ptr), big_alignment)) {
1284 while (mem.isAligned(@intFromPtr(slice.ptr), big_alignment)) {
12851285 try stuff_to_free.append(slice);
12861286 slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50);
12871287 }
......@@ -1375,18 +1375,18 @@ test "double frees" {
13751375 const index: usize = 6;
13761376 const size_class: usize = @as(usize, 1) << 6;
13771377 const small = try allocator.alloc(u8, size_class);
1378 try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @ptrToInt(small.ptr)) != null);
1378 try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @intFromPtr(small.ptr)) != null);
13791379 allocator.free(small);
1380 try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @ptrToInt(small.ptr)) == null);
1381 try std.testing.expect(GPA.searchBucket(gpa.empty_buckets, @ptrToInt(small.ptr)) != null);
1380 try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @intFromPtr(small.ptr)) == null);
1381 try std.testing.expect(GPA.searchBucket(gpa.empty_buckets, @intFromPtr(small.ptr)) != null);
13821382
13831383 // detect a large allocation double free
13841384 const large = try allocator.alloc(u8, 2 * page_size);
1385 try std.testing.expect(gpa.large_allocations.contains(@ptrToInt(large.ptr)));
1386 try std.testing.expectEqual(gpa.large_allocations.getEntry(@ptrToInt(large.ptr)).?.value_ptr.bytes, large);
1385 try std.testing.expect(gpa.large_allocations.contains(@intFromPtr(large.ptr)));
1386 try std.testing.expectEqual(gpa.large_allocations.getEntry(@intFromPtr(large.ptr)).?.value_ptr.bytes, large);
13871387 allocator.free(large);
1388 try std.testing.expect(gpa.large_allocations.contains(@ptrToInt(large.ptr)));
1389 try std.testing.expect(gpa.large_allocations.getEntry(@ptrToInt(large.ptr)).?.value_ptr.freed);
1388 try std.testing.expect(gpa.large_allocations.contains(@intFromPtr(large.ptr)));
1389 try std.testing.expect(gpa.large_allocations.getEntry(@intFromPtr(large.ptr)).?.value_ptr.freed);
13901390
13911391 const normal_small = try allocator.alloc(u8, size_class);
13921392 defer allocator.free(normal_small);
......@@ -1396,9 +1396,9 @@ test "double frees" {
13961396 // check that flushing retained metadata doesn't disturb live allocations
13971397 gpa.flushRetainedMetadata();
13981398 try std.testing.expect(gpa.empty_buckets == null);
1399 try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @ptrToInt(normal_small.ptr)) != null);
1400 try std.testing.expect(gpa.large_allocations.contains(@ptrToInt(normal_large.ptr)));
1401 try std.testing.expect(!gpa.large_allocations.contains(@ptrToInt(large.ptr)));
1399 try std.testing.expect(GPA.searchBucket(gpa.buckets[index], @intFromPtr(normal_small.ptr)) != null);
1400 try std.testing.expect(gpa.large_allocations.contains(@intFromPtr(normal_large.ptr)));
1401 try std.testing.expect(!gpa.large_allocations.contains(@intFromPtr(large.ptr)));
14021402}
14031403
14041404test "bug 9995 fix, large allocs count requested size not backing size" {
lib/std/http.zig+1-1
......@@ -232,7 +232,7 @@ pub const Status = enum(u10) {
232232 };
233233
234234 pub fn class(self: Status) Class {
235 return switch (@enumToInt(self)) {
235 return switch (@intFromEnum(self)) {
236236 100...199 => .informational,
237237 200...299 => .success,
238238 300...399 => .redirect,
lib/std/http/Client.zig+1-1
......@@ -343,7 +343,7 @@ pub const Response = struct {
343343 else => return error.HttpHeadersInvalid,
344344 };
345345 if (first_line[8] != ' ') return error.HttpHeadersInvalid;
346 const status = @intToEnum(http.Status, parseInt3(first_line[9..12].*));
346 const status = @enumFromInt(http.Status, parseInt3(first_line[9..12].*));
347347 const reason = mem.trimLeft(u8, first_line[12..], " ");
348348
349349 res.version = version;
lib/std/http/Server.zig+1-1
......@@ -402,7 +402,7 @@ pub const Response = struct {
402402
403403 try w.writeAll(@tagName(res.version));
404404 try w.writeByte(' ');
405 try w.print("{d}", .{@enumToInt(res.status)});
405 try w.print("{d}", .{@intFromEnum(res.status)});
406406 try w.writeByte(' ');
407407 if (res.reason) |reason| {
408408 try w.writeAll(reason);
lib/std/io.zig+3-3
......@@ -257,7 +257,7 @@ pub fn Poller(comptime StreamEnum: type) type {
257257 }
258258
259259 pub inline fn fifo(self: *Self, comptime which: StreamEnum) *PollFifo {
260 return &self.fifos[@enumToInt(which)];
260 return &self.fifos[@intFromEnum(which)];
261261 }
262262
263263 fn pollWindows(self: *Self) !bool {
......@@ -275,7 +275,7 @@ pub fn Poller(comptime StreamEnum: type) type {
275275 )) {
276276 .pending => {
277277 self.windows.active.handles_buf[self.windows.active.count] = handle;
278 self.windows.active.stream_map[self.windows.active.count] = @intToEnum(StreamEnum, i);
278 self.windows.active.stream_map[self.windows.active.count] = @enumFromInt(StreamEnum, i);
279279 self.windows.active.count += 1;
280280 },
281281 .closed => {}, // don't add to the wait_objects list
......@@ -302,7 +302,7 @@ pub fn Poller(comptime StreamEnum: type) type {
302302 const active_idx = status - os.windows.WAIT_OBJECT_0;
303303
304304 const handle = self.windows.active.handles_buf[active_idx];
305 const stream_idx = @enumToInt(self.windows.active.stream_map[active_idx]);
305 const stream_idx = @intFromEnum(self.windows.active.stream_map[active_idx]);
306306 var read_bytes: u32 = undefined;
307307 if (0 == os.windows.kernel32.GetOverlappedResult(
308308 handle,
lib/std/io/bit_reader.zig+1-1
......@@ -143,7 +143,7 @@ pub fn BitReader(comptime endian: std.builtin.Endian, comptime ReaderType: type)
143143 b.* = try self.readBits(u8, u8_bit_count, &out_bits);
144144 out_bits_total += out_bits;
145145 }
146 const incomplete_byte = @boolToInt(out_bits_total % u8_bit_count > 0);
146 const incomplete_byte = @intFromBool(out_bits_total % u8_bit_count > 0);
147147 return (out_bits_total / u8_bit_count) + incomplete_byte;
148148 }
149149
lib/std/io/c_writer.zig+1-1
......@@ -13,7 +13,7 @@ pub fn cWriter(c_file: *std.c.FILE) CWriter {
1313fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!usize {
1414 const amt_written = std.c.fwrite(bytes.ptr, 1, bytes.len, c_file);
1515 if (amt_written >= 0) return amt_written;
16 switch (@intToEnum(os.E, std.c._errno().*)) {
16 switch (@enumFromInt(os.E, std.c._errno().*)) {
1717 .SUCCESS => unreachable,
1818 .INVAL => unreachable,
1919 .FAULT => unreachable,
lib/std/json/static.zig+1-1
......@@ -176,7 +176,7 @@ fn parseInternal(
176176 const float = try std.fmt.parseFloat(f128, slice);
177177 if (@round(float) != float) return error.InvalidNumber;
178178 if (float > std.math.maxInt(T) or float < std.math.minInt(T)) return error.Overflow;
179 return @floatToInt(T, float);
179 return @intFromFloat(T, float);
180180 },
181181 .Optional => |optionalInfo| {
182182 switch (try source.peekNextTokenType()) {
lib/std/leb128.zig+1-1
......@@ -318,7 +318,7 @@ fn test_write_leb128(value: anytype) !void {
318318 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);
319319
320320 const unused_bits = if (value < 0) @clz(~value) else @clz(value);
321 const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @boolToInt(t_signed);
321 const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @intFromBool(t_signed);
322322 if (used_bits <= 7) break :bn @as(u16, 1);
323323 break :bn ((used_bits + 6) / 7);
324324 };
lib/std/log.zig+3-3
......@@ -36,7 +36,7 @@
3636//! // .my_project, .nice_library and the default
3737//! const scope_prefix = "(" ++ switch (scope) {
3838//! .my_project, .nice_library, std.log.default_log_scope => @tagName(scope),
39//! else => if (@enumToInt(level) <= @enumToInt(std.log.Level.err))
39//! else => if (@intFromEnum(level) <= @intFromEnum(std.log.Level.err))
4040//! @tagName(scope)
4141//! else
4242//! return,
......@@ -128,9 +128,9 @@ fn log(
128128/// Determine if a specific log message level and scope combination are enabled for logging.
129129pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.EnumLiteral)) bool {
130130 inline for (scope_levels) |scope_level| {
131 if (scope_level.scope == scope) return @enumToInt(message_level) <= @enumToInt(scope_level.level);
131 if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level);
132132 }
133 return @enumToInt(message_level) <= @enumToInt(level);
133 return @intFromEnum(message_level) <= @intFromEnum(level);
134134}
135135
136136/// Determine if a specific log message level using the default log scope is enabled for logging.
lib/std/math.zig+10-10
......@@ -1104,7 +1104,7 @@ pub const AlignCastError = error{UnalignedMemory};
11041104
11051105/// Align cast a pointer but return an error if it's the wrong alignment
11061106pub fn alignCast(comptime alignment: u29, ptr: anytype) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) {
1107 const addr = @ptrToInt(ptr);
1107 const addr = @intFromPtr(ptr);
11081108 if (addr % alignment != 0) {
11091109 return error.UnalignedMemory;
11101110 }
......@@ -1311,7 +1311,7 @@ pub fn lossyCast(comptime T: type, value: anytype) T {
13111311 switch (@typeInfo(T)) {
13121312 .Float => {
13131313 switch (@typeInfo(@TypeOf(value))) {
1314 .Int => return @intToFloat(T, value),
1314 .Int => return @floatFromInt(T, value),
13151315 .Float => return @floatCast(T, value),
13161316 .ComptimeInt => return @as(T, value),
13171317 .ComptimeFloat => return @as(T, value),
......@@ -1335,7 +1335,7 @@ pub fn lossyCast(comptime T: type, value: anytype) T {
13351335 } else if (value <= minInt(T)) {
13361336 return @as(T, minInt(T));
13371337 } else {
1338 return @floatToInt(T, value);
1338 return @intFromFloat(T, value);
13391339 }
13401340 },
13411341 else => @compileError("bad type"),
......@@ -1401,7 +1401,7 @@ pub fn maxInt(comptime T: type) comptime_int {
14011401 const info = @typeInfo(T);
14021402 const bit_count = info.Int.bits;
14031403 if (bit_count == 0) return 0;
1404 return (1 << (bit_count - @boolToInt(info.Int.signedness == .signed))) - 1;
1404 return (1 << (bit_count - @intFromBool(info.Int.signedness == .signed))) - 1;
14051405}
14061406
14071407/// Returns the minimum value of integer type T.
......@@ -1624,7 +1624,7 @@ test "order.compare" {
16241624
16251625test "compare.reverse" {
16261626 inline for (@typeInfo(CompareOperator).Enum.fields) |op_field| {
1627 const op = @intToEnum(CompareOperator, op_field.value);
1627 const op = @enumFromInt(CompareOperator, op_field.value);
16281628 try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2));
16291629 try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3));
16301630 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 {
16431643
16441644 // The u1 and i1 cases tend to overflow,
16451645 // so we special case them here.
1646 if (MaskInt == u1) return @boolToInt(value);
1646 if (MaskInt == u1) return @intFromBool(value);
16471647 if (MaskInt == i1) {
16481648 // The @as here is a workaround for #7950
1649 return @bitCast(i1, @as(u1, @boolToInt(value)));
1649 return @bitCast(i1, @as(u1, @intFromBool(value)));
16501650 }
16511651
1652 return -%@intCast(MaskInt, @boolToInt(value));
1652 return -%@intCast(MaskInt, @intFromBool(value));
16531653}
16541654
16551655test "boolMask" {
......@@ -1708,8 +1708,8 @@ pub fn break_f80(x: f80) F80 {
17081708pub inline fn sign(i: anytype) @TypeOf(i) {
17091709 const T = @TypeOf(i);
17101710 return switch (@typeInfo(T)) {
1711 .Int, .ComptimeInt => @as(T, @boolToInt(i > 0)) - @as(T, @boolToInt(i < 0)),
1712 .Float, .ComptimeFloat => @intToFloat(T, @boolToInt(i > 0)) - @intToFloat(T, @boolToInt(i < 0)),
1711 .Int, .ComptimeInt => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)),
1712 .Float, .ComptimeFloat => @floatFromInt(T, @intFromBool(i > 0)) - @floatFromInt(T, @intFromBool(i < 0)),
17131713 .Vector => |vinfo| blk: {
17141714 switch (@typeInfo(vinfo.child)) {
17151715 .Int, .Float => {
lib/std/math/big/int.zig+9-9
......@@ -1127,7 +1127,7 @@ pub const Mutable = struct {
11271127 return;
11281128 }
11291129
1130 const checkbit = bit_count - shift - @boolToInt(signedness == .signed);
1130 const checkbit = bit_count - shift - @intFromBool(signedness == .signed);
11311131 // If `checkbit` and more significant bits are zero, no overflow will take place.
11321132
11331133 if (checkbit >= a.limbs.len * limb_bits) {
......@@ -1274,10 +1274,10 @@ pub const Mutable = struct {
12741274
12751275 if (a.limbs.len > b.limbs.len) {
12761276 r.positive = llsignedxor(r.limbs, a.limbs, a.positive, b.limbs, b.positive);
1277 r.normalize(a.limbs.len + @boolToInt(a.positive != b.positive));
1277 r.normalize(a.limbs.len + @intFromBool(a.positive != b.positive));
12781278 } else {
12791279 r.positive = llsignedxor(r.limbs, b.limbs, b.positive, a.limbs, a.positive);
1280 r.normalize(b.limbs.len + @boolToInt(a.positive != b.positive));
1280 r.normalize(b.limbs.len + @intFromBool(a.positive != b.positive));
12811281 }
12821282 }
12831283
......@@ -2128,7 +2128,7 @@ pub const Const = struct {
21282128 return false;
21292129 }
21302130
2131 const req_bits = self.bitCountTwosComp() + @boolToInt(self.positive and signedness == .signed);
2131 const req_bits = self.bitCountTwosComp() + @intFromBool(self.positive and signedness == .signed);
21322132 return bit_count >= req_bits;
21332133 }
21342134
......@@ -2143,7 +2143,7 @@ pub const Const = struct {
21432143 /// value. It is inexact and may exceed the given value by ~1-2 bytes.
21442144 /// TODO See if we can make this exact.
21452145 pub fn sizeInBaseUpperBound(self: Const, base: usize) usize {
2146 const bit_count = @as(usize, @boolToInt(!self.positive)) + self.bitCountAbs();
2146 const bit_count = @as(usize, @intFromBool(!self.positive)) + self.bitCountAbs();
21472147 return (bit_count / math.log2(base)) + 2;
21482148 }
21492149
......@@ -3143,7 +3143,7 @@ pub const Managed = struct {
31433143
31443144 /// r = a ^ b
31453145 pub fn bitXor(r: *Managed, a: *const Managed, b: *const Managed) !void {
3146 var cap = @max(a.len(), b.len()) + @boolToInt(a.isPositive() != b.isPositive());
3146 var cap = @max(a.len(), b.len()) + @intFromBool(a.isPositive() != b.isPositive());
31473147 try r.ensureCapacity(cap);
31483148
31493149 var m = r.toMutable();
......@@ -4048,9 +4048,9 @@ fn llsignedxor(r: []Limb, a: []const Limb, a_positive: bool, b: []const Limb, b_
40484048 // - if the result is supposed to be negative, add 1.
40494049
40504050 var i: usize = 0;
4051 var a_borrow = @boolToInt(!a_positive);
4052 var b_borrow = @boolToInt(!b_positive);
4053 var r_carry = @boolToInt(a_positive != b_positive);
4051 var a_borrow = @intFromBool(!a_positive);
4052 var b_borrow = @intFromBool(!b_positive);
4053 var r_carry = @intFromBool(a_positive != b_positive);
40544054
40554055 while (i < b.len) : (i += 1) {
40564056 const ov1 = @subWithOverflow(a[i], a_borrow);
lib/std/math/big/rational.zig+3-3
......@@ -276,7 +276,7 @@ pub const Rational = struct {
276276 }
277277 mantissa >>= 1;
278278
279 const f = math.scalbn(@intToFloat(T, mantissa), @intCast(i32, exp - msize1));
279 const f = math.scalbn(@floatFromInt(T, mantissa), @intCast(i32, exp - msize1));
280280 if (math.isInf(f)) {
281281 exact = false;
282282 }
......@@ -289,7 +289,7 @@ pub const Rational = struct {
289289 try self.p.set(p);
290290 try self.q.set(q);
291291
292 self.p.setSign(@boolToInt(self.p.isPositive()) ^ @boolToInt(self.q.isPositive()) == 0);
292 self.p.setSign(@intFromBool(self.p.isPositive()) ^ @intFromBool(self.q.isPositive()) == 0);
293293 self.q.setSign(true);
294294
295295 try self.reduce();
......@@ -310,7 +310,7 @@ pub const Rational = struct {
310310 try self.p.copy(a.toConst());
311311 try self.q.copy(b.toConst());
312312
313 self.p.setSign(@boolToInt(self.p.isPositive()) ^ @boolToInt(self.q.isPositive()) == 0);
313 self.p.setSign(@intFromBool(self.p.isPositive()) ^ @intFromBool(self.q.isPositive()) == 0);
314314 self.q.setSign(true);
315315
316316 try self.reduce();
lib/std/math/complex/atan.zig+2-2
......@@ -32,7 +32,7 @@ fn redupif32(x: f32) f32 {
3232 t -= 0.5;
3333 }
3434
35 const u = @intToFloat(f32, @floatToInt(i32, t));
35 const u = @floatFromInt(f32, @intFromFloat(i32, t));
3636 return ((x - u * DP1) - u * DP2) - t * DP3;
3737}
3838
......@@ -81,7 +81,7 @@ fn redupif64(x: f64) f64 {
8181 t -= 0.5;
8282 }
8383
84 const u = @intToFloat(f64, @floatToInt(i64, t));
84 const u = @floatFromInt(f64, @intFromFloat(i64, t));
8585 return ((x - u * DP1) - u * DP2) - t * DP3;
8686}
8787
lib/std/math/expm1.zig+4-4
......@@ -88,8 +88,8 @@ fn expm1_32(x_: f32) f32 {
8888 kf += 0.5;
8989 }
9090
91 k = @floatToInt(i32, kf);
92 const t = @intToFloat(f32, k);
91 k = @intFromFloat(i32, kf);
92 const t = @floatFromInt(f32, k);
9393 hi = x - t * ln2_hi;
9494 lo = t * ln2_lo;
9595 }
......@@ -219,8 +219,8 @@ fn expm1_64(x_: f64) f64 {
219219 kf += 0.5;
220220 }
221221
222 k = @floatToInt(i32, kf);
223 const t = @intToFloat(f64, k);
222 k = @intFromFloat(i32, kf);
223 const t = @floatFromInt(f64, k);
224224 hi = x - t * ln2_hi;
225225 lo = t * ln2_lo;
226226 }
lib/std/math/ilogb.zig+1-1
......@@ -48,7 +48,7 @@ fn ilogbX(comptime T: type, x: T) i32 {
4848 }
4949
5050 // offset sign bit, exponent bits, and integer bit (if present) + bias
51 const offset = 1 + exponentBits + @as(comptime_int, @boolToInt(T == f80)) - exponentBias;
51 const offset = 1 + exponentBits + @as(comptime_int, @intFromBool(T == f80)) - exponentBias;
5252 return offset - @intCast(i32, @clz(u));
5353 }
5454
lib/std/math/ldexp.zig+3-3
......@@ -24,7 +24,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) {
2424
2525 var exponent: i32 = @intCast(i32, (repr << 1) >> (mantissa_bits + 1));
2626 if (exponent == 0)
27 exponent += (@as(i32, exponent_bits) + @boolToInt(T == f80)) - @clz(repr << 1);
27 exponent += (@as(i32, exponent_bits) + @intFromBool(T == f80)) - @clz(repr << 1);
2828
2929 if (n >= 0) {
3030 if (n > max_biased_exponent - exponent) {
......@@ -53,11 +53,11 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) {
5353 var result = repr & mantissa_mask;
5454
5555 if (T != f80) // Include integer bit
56 result |= @as(TBits, @boolToInt(exponent > 0)) << fractional_bits;
56 result |= @as(TBits, @intFromBool(exponent > 0)) << fractional_bits;
5757 result = @intCast(TBits, (result >> (shift - 1)));
5858
5959 // Round result, including round-to-even for exact ties
60 result = ((result + 1) >> 1) & ~@as(TBits, @boolToInt(exact_tie));
60 result = ((result + 1) >> 1) & ~@as(TBits, @intFromBool(exact_tie));
6161 return @bitCast(T, result | sign_bit);
6262 }
6363
lib/std/math/log.zig+1-1
......@@ -30,7 +30,7 @@ pub fn log(comptime T: type, base: T, x: T) T {
3030 // TODO implement integer log without using float math
3131 .Int => |IntType| switch (IntType.signedness) {
3232 .signed => @compileError("log not implemented for signed integers"),
33 .unsigned => return @floatToInt(T, @floor(@log(@intToFloat(f64, x)) / @log(float_base))),
33 .unsigned => return @intFromFloat(T, @floor(@log(@floatFromInt(f64, x)) / @log(float_base))),
3434 },
3535
3636 .Float => {
lib/std/math/log10.zig+1-1
......@@ -134,7 +134,7 @@ inline fn less_than_5(x: u32) u32 {
134134}
135135
136136fn oldlog10(x: anytype) u8 {
137 return @floatToInt(u8, @log10(@intToFloat(f64, x)));
137 return @intFromFloat(u8, @log10(@floatFromInt(f64, x)));
138138}
139139
140140test "oldlog10 doesn't work" {
lib/std/math/log1p.zig+2-2
......@@ -96,7 +96,7 @@ fn log1p_32(x: f32) f32 {
9696 const t2 = z * (Lg1 + w * Lg3);
9797 const R = t2 + t1;
9898 const hfsq = 0.5 * f * f;
99 const dk = @intToFloat(f32, k);
99 const dk = @floatFromInt(f32, k);
100100
101101 return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;
102102}
......@@ -176,7 +176,7 @@ fn log1p_64(x: f64) f64 {
176176 const t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
177177 const t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
178178 const R = t2 + t1;
179 const dk = @intToFloat(f64, k);
179 const dk = @floatFromInt(f64, k);
180180
181181 return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;
182182}
lib/std/math/pow.zig+2-2
......@@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
144144 var xe = r2.exponent;
145145 var x1 = r2.significand;
146146
147 var i = @floatToInt(std.meta.Int(.signed, @typeInfo(T).Float.bits), yi);
147 var i = @intFromFloat(std.meta.Int(.signed, @typeInfo(T).Float.bits), yi);
148148 while (i != 0) : (i >>= 1) {
149149 const overflow_shift = math.floatExponentBits(T) + 1;
150150 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 {
179179
180180fn isOddInteger(x: f64) bool {
181181 const r = math.modf(x);
182 return r.fpart == 0.0 and @floatToInt(i64, r.ipart) & 1 == 1;
182 return r.fpart == 0.0 and @intFromFloat(i64, r.ipart) & 1 == 1;
183183}
184184
185185test "math.pow" {
lib/std/mem.zig+11-11
......@@ -73,7 +73,7 @@ pub fn ValidationAllocator(comptime T: type) type {
7373 const underlying = self.getUnderlyingAllocatorPtr();
7474 const result = underlying.rawAlloc(n, log2_ptr_align, ret_addr) orelse
7575 return null;
76 assert(mem.isAlignedLog2(@ptrToInt(result), log2_ptr_align));
76 assert(mem.isAlignedLog2(@intFromPtr(result), log2_ptr_align));
7777 return result;
7878 }
7979
......@@ -185,7 +185,7 @@ test "Allocator.resize" {
185185 var values = try testing.allocator.alloc(T, 100);
186186 defer testing.allocator.free(values);
187187
188 for (values, 0..) |*v, i| v.* = @intToFloat(T, i);
188 for (values, 0..) |*v, i| v.* = @floatFromInt(T, i);
189189 if (!testing.allocator.resize(values, values.len + 10)) return error.OutOfMemory;
190190 values = values.ptr[0 .. values.len + 10];
191191 try testing.expect(values.len == 110);
......@@ -233,7 +233,7 @@ pub fn zeroes(comptime T: type) T {
233233 return @as(T, 0);
234234 },
235235 .Enum, .EnumLiteral => {
236 return @intToEnum(T, 0);
236 return @enumFromInt(T, 0);
237237 },
238238 .Void => {
239239 return {};
......@@ -1374,7 +1374,7 @@ pub fn readVarPackedInt(
13741374 const value = if (read_size == 1) b: {
13751375 break :b @truncate(uN, read_bytes[0] >> bit_shift);
13761376 } else b: {
1377 const i: u1 = @boolToInt(endian == .Big);
1377 const i: u1 = @intFromBool(endian == .Big);
13781378 const head = @truncate(uN, read_bytes[i] >> bit_shift);
13791379 const tail_shift = @intCast(Log2N, @as(u4, 8) - bit_shift);
13801380 const tail = @truncate(uN, read_bytes[1 - i]);
......@@ -3778,7 +3778,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
37783778 return 0;
37793779
37803780 // Calculate the aligned base address with an eye out for overflow.
3781 const addr = @ptrToInt(ptr);
3781 const addr = @intFromPtr(ptr);
37823782 var ov = @addWithOverflow(addr, align_to - 1);
37833783 if (ov[1] != 0) return null;
37843784 ov[0] &= ~@as(usize, align_to - 1);
......@@ -3800,16 +3800,16 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
38003800pub fn alignPointer(ptr: anytype, align_to: usize) ?@TypeOf(ptr) {
38013801 const adjust_off = alignPointerOffset(ptr, align_to) orelse return null;
38023802 const T = @TypeOf(ptr);
3803 // Avoid the use of intToPtr to avoid losing the pointer provenance info.
3803 // Avoid the use of ptrFromInt to avoid losing the pointer provenance info.
38043804 return @alignCast(@typeInfo(T).Pointer.alignment, ptr + adjust_off);
38053805}
38063806
38073807test "alignPointer" {
38083808 const S = struct {
38093809 fn checkAlign(comptime T: type, base: usize, align_to: usize, expected: usize) !void {
3810 var ptr = @intToPtr(T, base);
3810 var ptr = @ptrFromInt(T, base);
38113811 var aligned = alignPointer(ptr, align_to);
3812 try testing.expectEqual(expected, @ptrToInt(aligned));
3812 try testing.expectEqual(expected, @intFromPtr(aligned));
38133813 }
38143814 };
38153815
......@@ -4236,8 +4236,8 @@ pub fn doNotOptimizeAway(val: anytype) void {
42364236 const t = @typeInfo(@TypeOf(val));
42374237 switch (t) {
42384238 .Void, .Null, .ComptimeInt, .ComptimeFloat => return,
4239 .Enum => doNotOptimizeAway(@enumToInt(val)),
4240 .Bool => doNotOptimizeAway(@boolToInt(val)),
4239 .Enum => doNotOptimizeAway(@intFromEnum(val)),
4240 .Bool => doNotOptimizeAway(@intFromBool(val)),
42414241 .Int => {
42424242 const bits = t.Int.bits;
42434243 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
44254425/// Returns the largest slice in the given bytes that conforms to the new alignment,
44264426/// or `null` if the given bytes contain no conforming address.
44274427pub fn alignInBytes(bytes: []u8, comptime new_alignment: usize) ?[]align(new_alignment) u8 {
4428 const begin_address = @ptrToInt(bytes.ptr);
4428 const begin_address = @intFromPtr(bytes.ptr);
44294429 const end_address = begin_address + bytes.len;
44304430
44314431 const begin_address_aligned = mem.alignForward(usize, begin_address, new_alignment);
lib/std/mem/Allocator.zig+4-4
......@@ -101,7 +101,7 @@ pub inline fn rawFree(self: Allocator, buf: []u8, log2_buf_align: u8, ret_addr:
101101/// Returns a pointer to undefined memory.
102102/// Call `destroy` with the result to free the memory.
103103pub fn create(self: Allocator, comptime T: type) Error!*T {
104 if (@sizeOf(T) == 0) return @intToPtr(*T, math.maxInt(usize));
104 if (@sizeOf(T) == 0) return @ptrFromInt(*T, math.maxInt(usize));
105105 const slice = try self.allocAdvancedWithRetAddr(T, null, 1, @returnAddress());
106106 return &slice[0];
107107}
......@@ -209,7 +209,7 @@ pub fn allocAdvancedWithRetAddr(
209209
210210 if (n == 0) {
211211 const ptr = comptime std.mem.alignBackward(usize, math.maxInt(usize), a);
212 return @intToPtr([*]align(a) T, ptr)[0..0];
212 return @ptrFromInt([*]align(a) T, ptr)[0..0];
213213 }
214214
215215 const byte_count = math.mul(usize, @sizeOf(T), n) catch return Error.OutOfMemory;
......@@ -268,13 +268,13 @@ pub fn reallocAdvanced(
268268 if (new_n == 0) {
269269 self.free(old_mem);
270270 const ptr = comptime std.mem.alignBackward(usize, math.maxInt(usize), Slice.alignment);
271 return @intToPtr([*]align(Slice.alignment) T, ptr)[0..0];
271 return @ptrFromInt([*]align(Slice.alignment) T, ptr)[0..0];
272272 }
273273
274274 const old_byte_slice = mem.sliceAsBytes(old_mem);
275275 const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory;
276276 // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure
277 if (mem.isAligned(@ptrToInt(old_byte_slice.ptr), Slice.alignment)) {
277 if (mem.isAligned(@intFromPtr(old_byte_slice.ptr), Slice.alignment)) {
278278 if (self.rawResize(old_byte_slice, log2a(Slice.alignment), byte_count, return_address)) {
279279 return mem.bytesAsSlice(T, @alignCast(Slice.alignment, old_byte_slice.ptr[0..byte_count]));
280280 }
lib/std/meta.zig+6-6
......@@ -453,7 +453,7 @@ pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeIn
453453 .Enum => Type.EnumField,
454454 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
455455} {
456 return fields(T)[@enumToInt(field)];
456 return fields(T)[@intFromEnum(field)];
457457}
458458
459459test "std.meta.fieldInfo" {
......@@ -591,7 +591,7 @@ pub fn FieldEnum(comptime T: type) type {
591591 if (@typeInfo(T) == .Union) {
592592 if (@typeInfo(T).Union.tag_type) |tag_type| {
593593 for (std.enums.values(tag_type), 0..) |v, i| {
594 if (@enumToInt(v) != i) break; // enum values not consecutive
594 if (@intFromEnum(v) != i) break; // enum values not consecutive
595595 if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order
596596 } else {
597597 return tag_type;
......@@ -929,8 +929,8 @@ test "intToEnum with error return" {
929929 try testing.expect(intToEnum(E1, zero) catch unreachable == E1.A);
930930 try testing.expect(intToEnum(E2, one) catch unreachable == E2.B);
931931 try testing.expect(intToEnum(E3, zero) catch unreachable == E3.A);
932 try testing.expect(intToEnum(E3, 127) catch unreachable == @intToEnum(E3, 127));
933 try testing.expect(intToEnum(E3, -128) catch unreachable == @intToEnum(E3, -128));
932 try testing.expect(intToEnum(E3, 127) catch unreachable == @enumFromInt(E3, 127));
933 try testing.expect(intToEnum(E3, -128) catch unreachable == @enumFromInt(E3, -128));
934934 try testing.expectError(error.InvalidEnumTag, intToEnum(E1, one));
935935 try testing.expectError(error.InvalidEnumTag, intToEnum(E3, 128));
936936 try testing.expectError(error.InvalidEnumTag, intToEnum(E3, -129));
......@@ -943,14 +943,14 @@ pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTa
943943
944944 if (!enum_info.is_exhaustive) {
945945 if (std.math.cast(enum_info.tag_type, tag_int)) |tag| {
946 return @intToEnum(EnumTag, tag);
946 return @enumFromInt(EnumTag, tag);
947947 }
948948 return error.InvalidEnumTag;
949949 }
950950
951951 inline for (enum_info.fields) |f| {
952952 const this_tag_value = @field(EnumTag, f.name);
953 if (tag_int == @enumToInt(this_tag_value)) {
953 if (tag_int == @intFromEnum(this_tag_value)) {
954954 return this_tag_value;
955955 }
956956 }
lib/std/meta/trailer_flags.zig+5-5
......@@ -43,7 +43,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
4343 pub const Self = @This();
4444
4545 pub fn has(self: Self, comptime field: FieldEnum) bool {
46 const field_index = @enumToInt(field);
46 const field_index = @intFromEnum(field);
4747 return (self.bits & (1 << field_index)) != 0;
4848 }
4949
......@@ -54,7 +54,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
5454 }
5555
5656 pub fn setFlag(self: *Self, comptime field: FieldEnum) void {
57 const field_index = @enumToInt(field);
57 const field_index = @intFromEnum(field);
5858 self.bits |= 1 << field_index;
5959 }
6060
......@@ -72,7 +72,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
7272 pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void {
7373 inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {
7474 if (@field(fields, field.name)) |value|
75 self.set(p, @intToEnum(FieldEnum, i), value);
75 self.set(p, @enumFromInt(FieldEnum, i), value);
7676 }
7777 }
7878
......@@ -103,7 +103,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
103103 var off: usize = 0;
104104 inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| {
105105 const active = (self.bits & (1 << i)) != 0;
106 if (i == @enumToInt(field)) {
106 if (i == @intFromEnum(field)) {
107107 assert(active);
108108 return mem.alignForward(usize, off, @alignOf(field_info.type));
109109 } else if (active) {
......@@ -114,7 +114,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
114114 }
115115
116116 pub fn Field(comptime field: FieldEnum) type {
117 return @typeInfo(Fields).Struct.fields[@enumToInt(field)].type;
117 return @typeInfo(Fields).Struct.fields[@intFromEnum(field)].type;
118118 }
119119
120120 pub fn sizeInBytes(self: Self) usize {
lib/std/multi_array_list.zig+12-12
......@@ -64,7 +64,7 @@ pub fn MultiArrayList(comptime T: type) type {
6464 /// and then get the field arrays from the slice.
6565 pub const Slice = struct {
6666 /// This array is indexed by the field index which can be obtained
67 /// by using @enumToInt() on the Field enum
67 /// by using @intFromEnum() on the Field enum
6868 ptrs: [fields.len][*]u8,
6969 len: usize,
7070 capacity: usize,
......@@ -74,7 +74,7 @@ pub fn MultiArrayList(comptime T: type) type {
7474 if (self.capacity == 0) {
7575 return &[_]F{};
7676 }
77 const byte_ptr = self.ptrs[@enumToInt(field)];
77 const byte_ptr = self.ptrs[@intFromEnum(field)];
7878 const casted_ptr: [*]F = if (@sizeOf(F) == 0)
7979 undefined
8080 else
......@@ -89,14 +89,14 @@ pub fn MultiArrayList(comptime T: type) type {
8989 else => unreachable,
9090 };
9191 inline for (fields, 0..) |field_info, i| {
92 self.items(@intToEnum(Field, i))[index] = @field(e, field_info.name);
92 self.items(@enumFromInt(Field, i))[index] = @field(e, field_info.name);
9393 }
9494 }
9595
9696 pub fn get(self: Slice, index: usize) T {
9797 var result: Elem = undefined;
9898 inline for (fields, 0..) |field_info, i| {
99 @field(result, field_info.name) = self.items(@intToEnum(Field, i))[index];
99 @field(result, field_info.name) = self.items(@enumFromInt(Field, i))[index];
100100 }
101101 return switch (@typeInfo(T)) {
102102 .Struct => result,
......@@ -294,7 +294,7 @@ pub fn MultiArrayList(comptime T: type) type {
294294 };
295295 const slices = self.slice();
296296 inline for (fields, 0..) |field_info, field_index| {
297 const field_slice = slices.items(@intToEnum(Field, field_index));
297 const field_slice = slices.items(@enumFromInt(Field, field_index));
298298 var i: usize = self.len - 1;
299299 while (i > index) : (i -= 1) {
300300 field_slice[i] = field_slice[i - 1];
......@@ -309,7 +309,7 @@ pub fn MultiArrayList(comptime T: type) type {
309309 pub fn swapRemove(self: *Self, index: usize) void {
310310 const slices = self.slice();
311311 inline for (fields, 0..) |_, i| {
312 const field_slice = slices.items(@intToEnum(Field, i));
312 const field_slice = slices.items(@enumFromInt(Field, i));
313313 field_slice[index] = field_slice[self.len - 1];
314314 field_slice[self.len - 1] = undefined;
315315 }
......@@ -321,7 +321,7 @@ pub fn MultiArrayList(comptime T: type) type {
321321 pub fn orderedRemove(self: *Self, index: usize) void {
322322 const slices = self.slice();
323323 inline for (fields, 0..) |_, field_index| {
324 const field_slice = slices.items(@intToEnum(Field, field_index));
324 const field_slice = slices.items(@enumFromInt(Field, field_index));
325325 var i = index;
326326 while (i < self.len - 1) : (i += 1) {
327327 field_slice[i] = field_slice[i + 1];
......@@ -358,7 +358,7 @@ pub fn MultiArrayList(comptime T: type) type {
358358 const self_slice = self.slice();
359359 inline for (fields, 0..) |field_info, i| {
360360 if (@sizeOf(field_info.type) != 0) {
361 const field = @intToEnum(Field, i);
361 const field = @enumFromInt(Field, i);
362362 const dest_slice = self_slice.items(field)[new_len..];
363363 // We use memset here for more efficient codegen in safety-checked,
364364 // valgrind-enabled builds. Otherwise the valgrind client request
......@@ -379,7 +379,7 @@ pub fn MultiArrayList(comptime T: type) type {
379379 const other_slice = other.slice();
380380 inline for (fields, 0..) |field_info, i| {
381381 if (@sizeOf(field_info.type) != 0) {
382 const field = @intToEnum(Field, i);
382 const field = @enumFromInt(Field, i);
383383 @memcpy(other_slice.items(field), self_slice.items(field));
384384 }
385385 }
......@@ -440,7 +440,7 @@ pub fn MultiArrayList(comptime T: type) type {
440440 const other_slice = other.slice();
441441 inline for (fields, 0..) |field_info, i| {
442442 if (@sizeOf(field_info.type) != 0) {
443 const field = @intToEnum(Field, i);
443 const field = @enumFromInt(Field, i);
444444 @memcpy(other_slice.items(field), self_slice.items(field));
445445 }
446446 }
......@@ -459,7 +459,7 @@ pub fn MultiArrayList(comptime T: type) type {
459459 const result_slice = result.slice();
460460 inline for (fields, 0..) |field_info, i| {
461461 if (@sizeOf(field_info.type) != 0) {
462 const field = @intToEnum(Field, i);
462 const field = @enumFromInt(Field, i);
463463 @memcpy(result_slice.items(field), self_slice.items(field));
464464 }
465465 }
......@@ -476,7 +476,7 @@ pub fn MultiArrayList(comptime T: type) type {
476476 pub fn swap(sc: @This(), a_index: usize, b_index: usize) void {
477477 inline for (fields, 0..) |field_info, i| {
478478 if (@sizeOf(field_info.type) != 0) {
479 const field = @intToEnum(Field, i);
479 const field = @enumFromInt(Field, i);
480480 const ptr = sc.slice.items(field);
481481 mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]);
482482 }
lib/std/net.zig+10-10
......@@ -804,8 +804,8 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get
804804 var first = true;
805805 while (true) {
806806 const rc = ws2_32.getaddrinfo(name_c.ptr, port_c.ptr, &hints, &res);
807 switch (@intToEnum(os.windows.ws2_32.WinsockError, @intCast(u16, rc))) {
808 @intToEnum(os.windows.ws2_32.WinsockError, 0) => break,
807 switch (@enumFromInt(os.windows.ws2_32.WinsockError, @intCast(u16, rc))) {
808 @enumFromInt(os.windows.ws2_32.WinsockError, 0) => break,
809809 .WSATRY_AGAIN => return error.TemporaryNameServerFailure,
810810 .WSANO_RECOVERY => return error.NameServerFailure,
811811 .WSAEAFNOSUPPORT => return error.AddressFamilyNotSupported,
......@@ -874,7 +874,7 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) Get
874874 };
875875 var res: ?*os.addrinfo = null;
876876 switch (sys.getaddrinfo(name_c.ptr, port_c.ptr, &hints, &res)) {
877 @intToEnum(sys.EAI, 0) => {},
877 @enumFromInt(sys.EAI, 0) => {},
878878 .ADDRFAMILY => return error.HostLacksNetworkAddresses,
879879 .AGAIN => return error.TemporaryNameServerFailure,
880880 .BADFLAGS => unreachable, // Invalid hints
......@@ -1688,19 +1688,19 @@ fn dnsParse(
16881688 if (qdcount + ancount > 64) return error.InvalidDnsPacket;
16891689 while (qdcount != 0) {
16901690 qdcount -= 1;
1691 while (@ptrToInt(p) - @ptrToInt(r.ptr) < r.len and p[0] -% 1 < 127) p += 1;
1692 if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @ptrToInt(p) > @ptrToInt(r.ptr) + r.len - 6)
1691 while (@intFromPtr(p) - @intFromPtr(r.ptr) < r.len and p[0] -% 1 < 127) p += 1;
1692 if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @intFromPtr(p) > @intFromPtr(r.ptr) + r.len - 6)
16931693 return error.InvalidDnsPacket;
1694 p += @as(usize, 5) + @boolToInt(p[0] != 0);
1694 p += @as(usize, 5) + @intFromBool(p[0] != 0);
16951695 }
16961696 while (ancount != 0) {
16971697 ancount -= 1;
1698 while (@ptrToInt(p) - @ptrToInt(r.ptr) < r.len and p[0] -% 1 < 127) p += 1;
1699 if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @ptrToInt(p) > @ptrToInt(r.ptr) + r.len - 6)
1698 while (@intFromPtr(p) - @intFromPtr(r.ptr) < r.len and p[0] -% 1 < 127) p += 1;
1699 if (p[0] > 193 or (p[0] == 193 and p[1] > 254) or @intFromPtr(p) > @intFromPtr(r.ptr) + r.len - 6)
17001700 return error.InvalidDnsPacket;
1701 p += @as(usize, 1) + @boolToInt(p[0] != 0);
1701 p += @as(usize, 1) + @intFromBool(p[0] != 0);
17021702 const len = p[8] * @as(usize, 256) + p[9];
1703 if (@ptrToInt(p) + len > @ptrToInt(r.ptr) + r.len) return error.InvalidDnsPacket;
1703 if (@intFromPtr(p) + len > @intFromPtr(r.ptr) + r.len) return error.InvalidDnsPacket;
17041704 try callback(ctx, p[1], p[10..][0..len], r);
17051705 p += 10 + len;
17061706 }
lib/std/os.zig+27-27
......@@ -608,7 +608,7 @@ pub fn abort() noreturn {
608608 sigprocmask(SIG.UNBLOCK, &sigabrtmask, null);
609609
610610 // Beyond this point should be unreachable.
611 @intToPtr(*allowzero volatile u8, 0).* = 0;
611 @ptrFromInt(*allowzero volatile u8, 0).* = 0;
612612 raise(SIG.KILL) catch {};
613613 exit(127); // Pid 1 might not be signalled in some containers.
614614 }
......@@ -678,10 +678,10 @@ pub fn exit(status: u8) noreturn {
678678 // exit() is only available if exitBootServices() has not been called yet.
679679 // This call to exit should not fail, so we don't care about its return value.
680680 if (uefi.system_table.boot_services) |bs| {
681 _ = bs.exit(uefi.handle, @intToEnum(uefi.Status, status), 0, null);
681 _ = bs.exit(uefi.handle, @enumFromInt(uefi.Status, status), 0, null);
682682 }
683683 // If we can't exit, reboot the system instead.
684 uefi.system_table.runtime_services.resetSystem(uefi.tables.ResetType.ResetCold, @intToEnum(uefi.Status, status), 0, null);
684 uefi.system_table.runtime_services.resetSystem(uefi.tables.ResetType.ResetCold, @enumFromInt(uefi.Status, status), 0, null);
685685 }
686686 system.exit(status);
687687}
......@@ -2045,7 +2045,7 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 {
20452045
20462046 const err = if (builtin.link_libc) blk: {
20472047 const c_err = if (std.c.getcwd(out_buffer.ptr, out_buffer.len)) |_| 0 else std.c._errno().*;
2048 break :blk @intToEnum(E, c_err);
2048 break :blk @enumFromInt(E, c_err);
20492049 } else blk: {
20502050 break :blk errno(system.getcwd(out_buffer.ptr, out_buffer.len));
20512051 };
......@@ -3249,7 +3249,7 @@ pub fn isatty(handle: fd_t) bool {
32493249 while (true) {
32503250 var wsz: linux.winsize = undefined;
32513251 const fd = @bitCast(usize, @as(isize, handle));
3252 const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @ptrToInt(&wsz));
3252 const rc = linux.syscall3(.ioctl, fd, linux.T.IOCGWINSZ, @intFromPtr(&wsz));
32533253 switch (linux.getErrno(rc)) {
32543254 .SUCCESS => return true,
32553255 .INTR => continue,
......@@ -4016,7 +4016,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
40164016 const rc = system.getsockopt(sockfd, SOL.SOCKET, SO.ERROR, @ptrCast([*]u8, &err_code), &size);
40174017 assert(size == 4);
40184018 switch (errno(rc)) {
4019 .SUCCESS => switch (@intToEnum(E, err_code)) {
4019 .SUCCESS => switch (@enumFromInt(E, err_code)) {
40204020 .SUCCESS => return,
40214021 .ACCES => return error.PermissionDenied,
40224022 .PERM => return error.PermissionDenied,
......@@ -4425,10 +4425,10 @@ pub fn mmap(
44254425 const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset);
44264426 const err = if (builtin.link_libc) blk: {
44274427 if (rc != std.c.MAP.FAILED) return @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length];
4428 break :blk @intToEnum(E, system._errno().*);
4428 break :blk @enumFromInt(E, system._errno().*);
44294429 } else blk: {
44304430 const err = errno(rc);
4431 if (err == .SUCCESS) return @intToPtr([*]align(mem.page_size) u8, rc)[0..length];
4431 if (err == .SUCCESS) return @ptrFromInt([*]align(mem.page_size) u8, rc)[0..length];
44324432 break :blk err;
44334433 };
44344434 switch (err) {
......@@ -5164,7 +5164,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
51645164
51655165 return getFdPath(fd, out_buffer);
51665166 }
5167 const result_path = std.c.realpath(pathname, out_buffer) orelse switch (@intToEnum(E, std.c._errno().*)) {
5167 const result_path = std.c.realpath(pathname, out_buffer) orelse switch (@enumFromInt(E, std.c._errno().*)) {
51685168 .SUCCESS => unreachable,
51695169 .INVAL => unreachable,
51705170 .BADF => unreachable,
......@@ -5275,7 +5275,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
52755275 if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0, .patch = 0 }) == .gt) {
52765276 var kfile: system.kinfo_file = undefined;
52775277 kfile.structsize = system.KINFO_FILE_SIZE;
5278 switch (errno(system.fcntl(fd, system.F.KINFO, @ptrToInt(&kfile)))) {
5278 switch (errno(system.fcntl(fd, system.F.KINFO, @intFromPtr(&kfile)))) {
52795279 .SUCCESS => {},
52805280 .BADF => return error.FileNotFound,
52815281 else => |err| return unexpectedErrno(err),
......@@ -5400,21 +5400,21 @@ pub fn dl_iterate_phdr(
54005400 switch (system.dl_iterate_phdr(struct {
54015401 fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int {
54025402 const context_ptr = @ptrCast(*const Context, @alignCast(@alignOf(*const Context), data));
5403 callback(info, size, context_ptr.*) catch |err| return @errorToInt(err);
5403 callback(info, size, context_ptr.*) catch |err| return @intFromError(err);
54045404 return 0;
54055405 }
5406 }.callbackC, @intToPtr(?*anyopaque, @ptrToInt(&context)))) {
5406 }.callbackC, @ptrFromInt(?*anyopaque, @intFromPtr(&context)))) {
54075407 0 => return,
5408 else => |err| return @errSetCast(Error, @intToError(@intCast(u16, err))), // TODO don't hardcode u16
5408 else => |err| return @errSetCast(Error, @errorFromInt(@intCast(u16, err))), // TODO don't hardcode u16
54095409 }
54105410 }
54115411
54125412 const elf_base = std.process.getBaseAddress();
5413 const ehdr = @intToPtr(*elf.Ehdr, elf_base);
5413 const ehdr = @ptrFromInt(*elf.Ehdr, elf_base);
54145414 // Make sure the base address points to an ELF image.
54155415 assert(mem.eql(u8, ehdr.e_ident[0..4], elf.MAGIC));
54165416 const n_phdr = ehdr.e_phnum;
5417 const phdrs = (@intToPtr([*]elf.Phdr, elf_base + ehdr.e_phoff))[0..n_phdr];
5417 const phdrs = (@ptrFromInt([*]elf.Phdr, elf_base + ehdr.e_phoff))[0..n_phdr];
54185418
54195419 var it = dl.linkmap_iterator(phdrs) catch unreachable;
54205420
......@@ -5425,7 +5425,7 @@ pub fn dl_iterate_phdr(
54255425 // is non-zero.
54265426 const base_address = for (phdrs) |*phdr| {
54275427 if (phdr.p_type == elf.PT_PHDR) {
5428 break @ptrToInt(phdrs.ptr) - phdr.p_vaddr;
5428 break @intFromPtr(phdrs.ptr) - phdr.p_vaddr;
54295429 // We could try computing the difference between _DYNAMIC and
54305430 // the p_vaddr of the PT_DYNAMIC section, but using the phdr is
54315431 // good enough (Is it?).
......@@ -5448,12 +5448,12 @@ pub fn dl_iterate_phdr(
54485448 var dlpi_phnum: u16 = undefined;
54495449
54505450 if (entry.l_addr != 0) {
5451 const elf_header = @intToPtr(*elf.Ehdr, entry.l_addr);
5452 dlpi_phdr = @intToPtr([*]elf.Phdr, entry.l_addr + elf_header.e_phoff);
5451 const elf_header = @ptrFromInt(*elf.Ehdr, entry.l_addr);
5452 dlpi_phdr = @ptrFromInt([*]elf.Phdr, entry.l_addr + elf_header.e_phoff);
54535453 dlpi_phnum = elf_header.e_phnum;
54545454 } else {
54555455 // This is the running ELF image
5456 dlpi_phdr = @intToPtr([*]elf.Phdr, elf_base + ehdr.e_phoff);
5456 dlpi_phdr = @ptrFromInt([*]elf.Phdr, elf_base + ehdr.e_phoff);
54575457 dlpi_phnum = ehdr.e_phnum;
54585458 }
54595459
......@@ -5626,7 +5626,7 @@ pub const UnexpectedError = error{
56265626/// and you get an unexpected error.
56275627pub fn unexpectedErrno(err: E) UnexpectedError {
56285628 if (unexpected_error_tracing) {
5629 std.debug.print("unexpected errno: {d}\n", .{@enumToInt(err)});
5629 std.debug.print("unexpected errno: {d}\n", .{@intFromEnum(err)});
56305630 std.debug.dumpCurrentStackTrace(null);
56315631 }
56325632 return error.Unexpected;
......@@ -5773,7 +5773,7 @@ pub fn res_mkquery(
57735773 var name = dname;
57745774 if (mem.endsWith(u8, name, ".")) name.len -= 1;
57755775 assert(name.len <= 253);
5776 const n = 17 + name.len + @boolToInt(name.len != 0);
5776 const n = 17 + name.len + @intFromBool(name.len != 0);
57775777
57785778 // Construct query template - ID will be filled later
57795779 var q: [280]u8 = undefined;
......@@ -6673,7 +6673,7 @@ pub fn dn_expand(
66736673 if ((p[0] & 0xc0) != 0) {
66746674 if (p + 1 == end) return error.InvalidDnsPacket;
66756675 var j = ((p[0] & @as(usize, 0x3f)) << 8) | p[1];
6676 if (len == std.math.maxInt(usize)) len = @ptrToInt(p) + 2 - @ptrToInt(comp_dn.ptr);
6676 if (len == std.math.maxInt(usize)) len = @intFromPtr(p) + 2 - @intFromPtr(comp_dn.ptr);
66776677 if (j >= msg.len) return error.InvalidDnsPacket;
66786678 p = msg.ptr + j;
66796679 } else if (p[0] != 0) {
......@@ -6683,7 +6683,7 @@ pub fn dn_expand(
66836683 }
66846684 var j = p[0];
66856685 p += 1;
6686 if (j >= @ptrToInt(end) - @ptrToInt(p) or j >= @ptrToInt(dend) - @ptrToInt(dest)) {
6686 if (j >= @intFromPtr(end) - @intFromPtr(p) or j >= @intFromPtr(dend) - @intFromPtr(dest)) {
66876687 return error.InvalidDnsPacket;
66886688 }
66896689 while (j != 0) {
......@@ -6694,7 +6694,7 @@ pub fn dn_expand(
66946694 }
66956695 } else {
66966696 dest[0] = 0;
6697 if (len == std.math.maxInt(usize)) len = @ptrToInt(p) + 1 - @ptrToInt(comp_dn.ptr);
6697 if (len == std.math.maxInt(usize)) len = @intFromPtr(p) + 1 - @intFromPtr(comp_dn.ptr);
66986698 return len;
66996699 }
67006700 }
......@@ -6908,7 +6908,7 @@ pub const IoCtl_SIOCGIFINDEX_Error = error{
69086908
69096909pub fn ioctl_SIOCGIFINDEX(fd: fd_t, ifr: *ifreq) IoCtl_SIOCGIFINDEX_Error!void {
69106910 while (true) {
6911 switch (errno(system.ioctl(fd, SIOCGIFINDEX, @ptrToInt(ifr)))) {
6911 switch (errno(system.ioctl(fd, SIOCGIFINDEX, @intFromPtr(ifr)))) {
69126912 .SUCCESS => return,
69136913 .INVAL => unreachable, // Bad parameters.
69146914 .NOTTY => unreachable,
......@@ -7032,7 +7032,7 @@ pub fn prctl(option: PR, args: anytype) PrctlError!u31 {
70327032 inline while (i < args.len) : (i += 1) buf[i] = args[i];
70337033 }
70347034
7035 const rc = system.prctl(@enumToInt(option), buf[0], buf[1], buf[2], buf[3]);
7035 const rc = system.prctl(@intFromEnum(option), buf[0], buf[1], buf[2], buf[3]);
70367036 switch (errno(rc)) {
70377037 .SUCCESS => return @intCast(u31, rc),
70387038 .ACCES => return error.AccessDenied,
......@@ -7318,7 +7318,7 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError!
73187318 .macos, .ios, .tvos, .watchos => switch (errno(darwin.ptrace(
73197319 math.cast(i32, request) orelse return error.Overflow,
73207320 pid,
7321 @intToPtr(?[*]u8, addr),
7321 @ptrFromInt(?[*]u8, addr),
73227322 math.cast(i32, signal) orelse return error.Overflow,
73237323 ))) {
73247324 .SUCCESS => {},
lib/std/os/linux.zig+227-227
......@@ -206,7 +206,7 @@ fn splitValue64(val: i64) [2]u32 {
206206pub fn getErrno(r: usize) E {
207207 const signed_r = @bitCast(isize, r);
208208 const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0;
209 return @intToEnum(E, int);
209 return @enumFromInt(E, int);
210210}
211211
212212pub fn dup(old: i32) usize {
......@@ -234,7 +234,7 @@ pub fn dup3(old: i32, new: i32, flags: u32) usize {
234234}
235235
236236pub fn chdir(path: [*:0]const u8) usize {
237 return syscall1(.chdir, @ptrToInt(path));
237 return syscall1(.chdir, @intFromPtr(path));
238238}
239239
240240pub fn fchdir(fd: fd_t) usize {
......@@ -242,11 +242,11 @@ pub fn fchdir(fd: fd_t) usize {
242242}
243243
244244pub fn chroot(path: [*:0]const u8) usize {
245 return syscall1(.chroot, @ptrToInt(path));
245 return syscall1(.chroot, @intFromPtr(path));
246246}
247247
248248pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize {
249 return syscall3(.execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp));
249 return syscall3(.execve, @intFromPtr(path), @intFromPtr(argv), @intFromPtr(envp));
250250}
251251
252252pub fn fork() usize {
......@@ -273,7 +273,7 @@ pub fn futimens(fd: i32, times: *const [2]timespec) usize {
273273}
274274
275275pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, flags: u32) usize {
276 return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);
276 return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(times), flags);
277277}
278278
279279pub 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 {
301301}
302302
303303pub fn futex_wait(uaddr: *const i32, futex_op: u32, val: i32, timeout: ?*const timespec) usize {
304 return syscall4(.futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val), @ptrToInt(timeout));
304 return syscall4(.futex, @intFromPtr(uaddr), futex_op, @bitCast(u32, val), @intFromPtr(timeout));
305305}
306306
307307pub fn futex_wake(uaddr: *const i32, futex_op: u32, val: i32) usize {
308 return syscall3(.futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val));
308 return syscall3(.futex, @intFromPtr(uaddr), futex_op, @bitCast(u32, val));
309309}
310310
311311pub fn getcwd(buf: [*]u8, size: usize) usize {
312 return syscall2(.getcwd, @ptrToInt(buf), size);
312 return syscall2(.getcwd, @intFromPtr(buf), size);
313313}
314314
315315pub fn getdents(fd: i32, dirp: [*]u8, len: usize) usize {
316316 return syscall3(
317317 .getdents,
318318 @bitCast(usize, @as(isize, fd)),
319 @ptrToInt(dirp),
319 @intFromPtr(dirp),
320320 @min(len, maxInt(c_int)),
321321 );
322322}
......@@ -325,7 +325,7 @@ pub fn getdents64(fd: i32, dirp: [*]u8, len: usize) usize {
325325 return syscall3(
326326 .getdents64,
327327 @bitCast(usize, @as(isize, fd)),
328 @ptrToInt(dirp),
328 @intFromPtr(dirp),
329329 @min(len, maxInt(c_int)),
330330 );
331331}
......@@ -335,7 +335,7 @@ pub fn inotify_init1(flags: u32) usize {
335335}
336336
337337pub fn inotify_add_watch(fd: i32, pathname: [*:0]const u8, mask: u32) usize {
338 return syscall3(.inotify_add_watch, @bitCast(usize, @as(isize, fd)), @ptrToInt(pathname), mask);
338 return syscall3(.inotify_add_watch, @bitCast(usize, @as(isize, fd)), @intFromPtr(pathname), mask);
339339}
340340
341341pub fn inotify_rm_watch(fd: i32, wd: i32) usize {
......@@ -344,61 +344,61 @@ pub fn inotify_rm_watch(fd: i32, wd: i32) usize {
344344
345345pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
346346 if (@hasField(SYS, "readlink")) {
347 return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
347 return syscall3(.readlink, @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
348348 } else {
349 return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
349 return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
350350 }
351351}
352352
353353pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
354 return syscall4(.readlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
354 return syscall4(.readlinkat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
355355}
356356
357357pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
358358 if (@hasField(SYS, "mkdir")) {
359 return syscall2(.mkdir, @ptrToInt(path), mode);
359 return syscall2(.mkdir, @intFromPtr(path), mode);
360360 } else {
361 return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode);
361 return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), mode);
362362 }
363363}
364364
365365pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: u32) usize {
366 return syscall3(.mkdirat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode);
366 return syscall3(.mkdirat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), mode);
367367}
368368
369369pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize {
370370 if (@hasField(SYS, "mknod")) {
371 return syscall3(.mknod, @ptrToInt(path), mode, dev);
371 return syscall3(.mknod, @intFromPtr(path), mode, dev);
372372 } else {
373373 return mknodat(AT.FDCWD, path, mode, dev);
374374 }
375375}
376376
377377pub fn mknodat(dirfd: i32, path: [*:0]const u8, mode: u32, dev: u32) usize {
378 return syscall4(.mknodat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, dev);
378 return syscall4(.mknodat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), mode, dev);
379379}
380380
381381pub fn mount(special: [*:0]const u8, dir: [*:0]const u8, fstype: ?[*:0]const u8, flags: u32, data: usize) usize {
382 return syscall5(.mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data);
382 return syscall5(.mount, @intFromPtr(special), @intFromPtr(dir), @intFromPtr(fstype), flags, data);
383383}
384384
385385pub fn umount(special: [*:0]const u8) usize {
386 return syscall2(.umount2, @ptrToInt(special), 0);
386 return syscall2(.umount2, @intFromPtr(special), 0);
387387}
388388
389389pub fn umount2(special: [*:0]const u8, flags: u32) usize {
390 return syscall2(.umount2, @ptrToInt(special), flags);
390 return syscall2(.umount2, @intFromPtr(special), flags);
391391}
392392
393393pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: i64) usize {
394394 if (@hasField(SYS, "mmap2")) {
395395 // Make sure the offset is also specified in multiples of page size
396396 if ((offset & (MMAP2_UNIT - 1)) != 0)
397 return @bitCast(usize, -@as(isize, @enumToInt(E.INVAL)));
397 return @bitCast(usize, -@as(isize, @intFromEnum(E.INVAL)));
398398
399399 return syscall6(
400400 .mmap2,
401 @ptrToInt(address),
401 @intFromPtr(address),
402402 length,
403403 prot,
404404 flags,
......@@ -408,7 +408,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of
408408 } else {
409409 return syscall6(
410410 .mmap,
411 @ptrToInt(address),
411 @intFromPtr(address),
412412 length,
413413 prot,
414414 flags,
......@@ -419,7 +419,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of
419419}
420420
421421pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize {
422 return syscall3(.mprotect, @ptrToInt(address), length, protection);
422 return syscall3(.mprotect, @intFromPtr(address), length, protection);
423423}
424424
425425pub const MSF = struct {
......@@ -429,22 +429,22 @@ pub const MSF = struct {
429429};
430430
431431pub fn msync(address: [*]const u8, length: usize, flags: i32) usize {
432 return syscall3(.msync, @ptrToInt(address), length, @bitCast(u32, flags));
432 return syscall3(.msync, @intFromPtr(address), length, @bitCast(u32, flags));
433433}
434434
435435pub fn munmap(address: [*]const u8, length: usize) usize {
436 return syscall2(.munmap, @ptrToInt(address), length);
436 return syscall2(.munmap, @intFromPtr(address), length);
437437}
438438
439439pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
440440 if (@hasField(SYS, "poll")) {
441 return syscall3(.poll, @ptrToInt(fds), n, @bitCast(u32, timeout));
441 return syscall3(.poll, @intFromPtr(fds), n, @bitCast(u32, timeout));
442442 } else {
443443 return syscall5(
444444 .ppoll,
445 @ptrToInt(fds),
445 @intFromPtr(fds),
446446 n,
447 @ptrToInt(if (timeout >= 0)
447 @intFromPtr(if (timeout >= 0)
448448 &timespec{
449449 .tv_sec = @divTrunc(timeout, 1000),
450450 .tv_nsec = @rem(timeout, 1000) * 1000000,
......@@ -458,11 +458,11 @@ pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
458458}
459459
460460pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize {
461 return syscall5(.ppoll, @ptrToInt(fds), n, @ptrToInt(timeout), @ptrToInt(sigmask), NSIG / 8);
461 return syscall5(.ppoll, @intFromPtr(fds), n, @intFromPtr(timeout), @intFromPtr(sigmask), NSIG / 8);
462462}
463463
464464pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
465 return syscall3(.read, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
465 return syscall3(.read, @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), count);
466466}
467467
468468pub 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 {
470470 return syscall5(
471471 .preadv,
472472 @bitCast(usize, @as(isize, fd)),
473 @ptrToInt(iov),
473 @intFromPtr(iov),
474474 count,
475475 // Kernel expects the offset is split into largest natural word-size.
476476 // See following link for detail:
......@@ -485,7 +485,7 @@ pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: i64, flags: k
485485 return syscall6(
486486 .preadv2,
487487 @bitCast(usize, @as(isize, fd)),
488 @ptrToInt(iov),
488 @intFromPtr(iov),
489489 count,
490490 // See comments in preadv
491491 @truncate(usize, offset_u),
......@@ -495,11 +495,11 @@ pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: i64, flags: k
495495}
496496
497497pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize {
498 return syscall3(.readv, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count);
498 return syscall3(.readv, @bitCast(usize, @as(isize, fd)), @intFromPtr(iov), count);
499499}
500500
501501pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize {
502 return syscall3(.writev, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count);
502 return syscall3(.writev, @bitCast(usize, @as(isize, fd)), @intFromPtr(iov), count);
503503}
504504
505505pub 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
507507 return syscall5(
508508 .pwritev,
509509 @bitCast(usize, @as(isize, fd)),
510 @ptrToInt(iov),
510 @intFromPtr(iov),
511511 count,
512512 // See comments in preadv
513513 @truncate(usize, offset_u),
......@@ -520,7 +520,7 @@ pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64, f
520520 return syscall6(
521521 .pwritev2,
522522 @bitCast(usize, @as(isize, fd)),
523 @ptrToInt(iov),
523 @intFromPtr(iov),
524524 count,
525525 // See comments in preadv
526526 @truncate(usize, offset_u),
......@@ -531,22 +531,22 @@ pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64, f
531531
532532pub fn rmdir(path: [*:0]const u8) usize {
533533 if (@hasField(SYS, "rmdir")) {
534 return syscall1(.rmdir, @ptrToInt(path));
534 return syscall1(.rmdir, @intFromPtr(path));
535535 } else {
536 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), AT.REMOVEDIR);
536 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), AT.REMOVEDIR);
537537 }
538538}
539539
540540pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
541541 if (@hasField(SYS, "symlink")) {
542 return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new));
542 return syscall2(.symlink, @intFromPtr(existing), @intFromPtr(new));
543543 } else {
544 return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new));
544 return syscall3(.symlinkat, @intFromPtr(existing), @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(new));
545545 }
546546}
547547
548548pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) usize {
549 return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, newfd)), @ptrToInt(newpath));
549 return syscall3(.symlinkat, @intFromPtr(existing), @bitCast(usize, @as(isize, newfd)), @intFromPtr(newpath));
550550}
551551
552552pub 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 {
556556 return syscall6(
557557 .pread64,
558558 @bitCast(usize, @as(isize, fd)),
559 @ptrToInt(buf),
559 @intFromPtr(buf),
560560 count,
561561 0,
562562 offset_halves[0],
......@@ -566,7 +566,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {
566566 return syscall5(
567567 .pread64,
568568 @bitCast(usize, @as(isize, fd)),
569 @ptrToInt(buf),
569 @intFromPtr(buf),
570570 count,
571571 offset_halves[0],
572572 offset_halves[1],
......@@ -581,7 +581,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {
581581 return syscall4(
582582 syscall_number,
583583 @bitCast(usize, @as(isize, fd)),
584 @ptrToInt(buf),
584 @intFromPtr(buf),
585585 count,
586586 @bitCast(u64, offset),
587587 );
......@@ -590,32 +590,32 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize {
590590
591591pub fn access(path: [*:0]const u8, mode: u32) usize {
592592 if (@hasField(SYS, "access")) {
593 return syscall2(.access, @ptrToInt(path), mode);
593 return syscall2(.access, @intFromPtr(path), mode);
594594 } else {
595 return syscall4(.faccessat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), mode, 0);
595 return syscall4(.faccessat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), mode, 0);
596596 }
597597}
598598
599599pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {
600 return syscall4(.faccessat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, flags);
600 return syscall4(.faccessat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), mode, flags);
601601}
602602
603603pub fn pipe(fd: *[2]i32) usize {
604604 if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) {
605605 return syscall_pipe(fd);
606606 } else if (@hasField(SYS, "pipe")) {
607 return syscall1(.pipe, @ptrToInt(fd));
607 return syscall1(.pipe, @intFromPtr(fd));
608608 } else {
609 return syscall2(.pipe2, @ptrToInt(fd), 0);
609 return syscall2(.pipe2, @intFromPtr(fd), 0);
610610 }
611611}
612612
613613pub fn pipe2(fd: *[2]i32, flags: u32) usize {
614 return syscall2(.pipe2, @ptrToInt(fd), flags);
614 return syscall2(.pipe2, @intFromPtr(fd), flags);
615615}
616616
617617pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
618 return syscall3(.write, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
618 return syscall3(.write, @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), count);
619619}
620620
621621pub fn ftruncate(fd: i32, length: i64) usize {
......@@ -654,7 +654,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
654654 return syscall6(
655655 .pwrite64,
656656 @bitCast(usize, @as(isize, fd)),
657 @ptrToInt(buf),
657 @intFromPtr(buf),
658658 count,
659659 0,
660660 offset_halves[0],
......@@ -664,7 +664,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
664664 return syscall5(
665665 .pwrite64,
666666 @bitCast(usize, @as(isize, fd)),
667 @ptrToInt(buf),
667 @intFromPtr(buf),
668668 count,
669669 offset_halves[0],
670670 offset_halves[1],
......@@ -679,7 +679,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
679679 return syscall4(
680680 syscall_number,
681681 @bitCast(usize, @as(isize, fd)),
682 @ptrToInt(buf),
682 @intFromPtr(buf),
683683 count,
684684 @bitCast(u64, offset),
685685 );
......@@ -688,11 +688,11 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize {
688688
689689pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
690690 if (@hasField(SYS, "rename")) {
691 return syscall2(.rename, @ptrToInt(old), @ptrToInt(new));
691 return syscall2(.rename, @intFromPtr(old), @intFromPtr(new));
692692 } else if (@hasField(SYS, "renameat")) {
693 return syscall4(.renameat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new));
693 return syscall4(.renameat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(old), @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(new));
694694 } else {
695 return syscall5(.renameat2, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(new), 0);
695 return syscall5(.renameat2, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(old), @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(new), 0);
696696 }
697697}
698698
......@@ -701,17 +701,17 @@ pub fn renameat(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const
701701 return syscall4(
702702 .renameat,
703703 @bitCast(usize, @as(isize, oldfd)),
704 @ptrToInt(oldpath),
704 @intFromPtr(oldpath),
705705 @bitCast(usize, @as(isize, newfd)),
706 @ptrToInt(newpath),
706 @intFromPtr(newpath),
707707 );
708708 } else {
709709 return syscall5(
710710 .renameat2,
711711 @bitCast(usize, @as(isize, oldfd)),
712 @ptrToInt(oldpath),
712 @intFromPtr(oldpath),
713713 @bitCast(usize, @as(isize, newfd)),
714 @ptrToInt(newpath),
714 @intFromPtr(newpath),
715715 0,
716716 );
717717 }
......@@ -721,21 +721,21 @@ pub fn renameat2(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]c
721721 return syscall5(
722722 .renameat2,
723723 @bitCast(usize, @as(isize, oldfd)),
724 @ptrToInt(oldpath),
724 @intFromPtr(oldpath),
725725 @bitCast(usize, @as(isize, newfd)),
726 @ptrToInt(newpath),
726 @intFromPtr(newpath),
727727 flags,
728728 );
729729}
730730
731731pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize {
732732 if (@hasField(SYS, "open")) {
733 return syscall3(.open, @ptrToInt(path), flags, perm);
733 return syscall3(.open, @intFromPtr(path), flags, perm);
734734 } else {
735735 return syscall4(
736736 .openat,
737737 @bitCast(usize, @as(isize, AT.FDCWD)),
738 @ptrToInt(path),
738 @intFromPtr(path),
739739 flags,
740740 perm,
741741 );
......@@ -743,17 +743,17 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: mode_t) usize {
743743}
744744
745745pub fn create(path: [*:0]const u8, perm: mode_t) usize {
746 return syscall2(.creat, @ptrToInt(path), perm);
746 return syscall2(.creat, @intFromPtr(path), perm);
747747}
748748
749749pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: mode_t) usize {
750750 // dirfd could be negative, for example AT.FDCWD is -100
751 return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
751 return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), flags, mode);
752752}
753753
754754/// See also `clone` (from the arch-specific include)
755755pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *i32, child_tid: *i32, newtls: usize) usize {
756 return syscall5(.clone, flags, child_stack_ptr, @ptrToInt(parent_tid), @ptrToInt(child_tid), newtls);
756 return syscall5(.clone, flags, child_stack_ptr, @intFromPtr(parent_tid), @intFromPtr(child_tid), newtls);
757757}
758758
759759/// See also `clone` (from the arch-specific include)
......@@ -771,12 +771,12 @@ pub fn fchmod(fd: i32, mode: mode_t) usize {
771771
772772pub fn chmod(path: [*:0]const u8, mode: mode_t) usize {
773773 if (@hasField(SYS, "chmod")) {
774 return syscall2(.chmod, @ptrToInt(path), mode);
774 return syscall2(.chmod, @intFromPtr(path), mode);
775775 } else {
776776 return syscall4(
777777 .fchmodat,
778778 @bitCast(usize, @as(isize, AT.FDCWD)),
779 @ptrToInt(path),
779 @intFromPtr(path),
780780 mode,
781781 0,
782782 );
......@@ -792,7 +792,7 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize {
792792}
793793
794794pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize {
795 return syscall4(.fchmodat, @bitCast(usize, @as(isize, fd)), @ptrToInt(path), mode, flags);
795 return syscall4(.fchmodat, @bitCast(usize, @as(isize, fd)), @intFromPtr(path), mode, flags);
796796}
797797
798798/// 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 {
804804 @bitCast(usize, @as(isize, fd)),
805805 @truncate(usize, offset >> 32),
806806 @truncate(usize, offset),
807 @ptrToInt(result),
807 @intFromPtr(result),
808808 whence,
809809 );
810810}
......@@ -874,15 +874,15 @@ pub const LINUX_REBOOT = struct {
874874pub fn reboot(magic: LINUX_REBOOT.MAGIC1, magic2: LINUX_REBOOT.MAGIC2, cmd: LINUX_REBOOT.CMD, arg: ?*const anyopaque) usize {
875875 return std.os.linux.syscall4(
876876 .reboot,
877 @enumToInt(magic),
878 @enumToInt(magic2),
879 @enumToInt(cmd),
880 @ptrToInt(arg),
877 @intFromEnum(magic),
878 @intFromEnum(magic2),
879 @intFromEnum(cmd),
880 @intFromPtr(arg),
881881 );
882882}
883883
884884pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize {
885 return syscall3(.getrandom, @ptrToInt(buf), count, flags);
885 return syscall3(.getrandom, @intFromPtr(buf), count, flags);
886886}
887887
888888pub 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 {
901901 if (@hasField(SYS, "link")) {
902902 return syscall3(
903903 .link,
904 @ptrToInt(oldpath),
905 @ptrToInt(newpath),
904 @intFromPtr(oldpath),
905 @intFromPtr(newpath),
906906 @bitCast(usize, @as(isize, flags)),
907907 );
908908 } else {
909909 return syscall5(
910910 .linkat,
911911 @bitCast(usize, @as(isize, AT.FDCWD)),
912 @ptrToInt(oldpath),
912 @intFromPtr(oldpath),
913913 @bitCast(usize, @as(isize, AT.FDCWD)),
914 @ptrToInt(newpath),
914 @intFromPtr(newpath),
915915 @bitCast(usize, @as(isize, flags)),
916916 );
917917 }
......@@ -921,41 +921,41 @@ pub fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]co
921921 return syscall5(
922922 .linkat,
923923 @bitCast(usize, @as(isize, oldfd)),
924 @ptrToInt(oldpath),
924 @intFromPtr(oldpath),
925925 @bitCast(usize, @as(isize, newfd)),
926 @ptrToInt(newpath),
926 @intFromPtr(newpath),
927927 @bitCast(usize, @as(isize, flags)),
928928 );
929929}
930930
931931pub fn unlink(path: [*:0]const u8) usize {
932932 if (@hasField(SYS, "unlink")) {
933 return syscall1(.unlink, @ptrToInt(path));
933 return syscall1(.unlink, @intFromPtr(path));
934934 } else {
935 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @ptrToInt(path), 0);
935 return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT.FDCWD)), @intFromPtr(path), 0);
936936 }
937937}
938938
939939pub fn unlinkat(dirfd: i32, path: [*:0]const u8, flags: u32) usize {
940 return syscall3(.unlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags);
940 return syscall3(.unlinkat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), flags);
941941}
942942
943943pub fn waitpid(pid: pid_t, status: *u32, flags: u32) usize {
944 return syscall4(.wait4, @bitCast(usize, @as(isize, pid)), @ptrToInt(status), flags, 0);
944 return syscall4(.wait4, @bitCast(usize, @as(isize, pid)), @intFromPtr(status), flags, 0);
945945}
946946
947947pub fn wait4(pid: pid_t, status: *u32, flags: u32, usage: ?*rusage) usize {
948948 return syscall4(
949949 .wait4,
950950 @bitCast(usize, @as(isize, pid)),
951 @ptrToInt(status),
951 @intFromPtr(status),
952952 flags,
953 @ptrToInt(usage),
953 @intFromPtr(usage),
954954 );
955955}
956956
957957pub fn waitid(id_type: P, id: i32, infop: *siginfo_t, flags: u32) usize {
958 return syscall5(.waitid, @enumToInt(id_type), @bitCast(usize, @as(isize, id)), @ptrToInt(infop), flags, 0);
958 return syscall5(.waitid, @intFromEnum(id_type), @bitCast(usize, @as(isize, id)), @intFromPtr(infop), flags, 0);
959959}
960960
961961pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize {
......@@ -978,16 +978,16 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
978978 const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
979979 const rc = f(clk_id, tp);
980980 switch (rc) {
981 0, @bitCast(usize, -@as(isize, @enumToInt(E.INVAL))) => return rc,
981 0, @bitCast(usize, -@as(isize, @intFromEnum(E.INVAL))) => return rc,
982982 else => {},
983983 }
984984 }
985985 }
986 return syscall2(.clock_gettime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
986 return syscall2(.clock_gettime, @bitCast(usize, @as(isize, clk_id)), @intFromPtr(tp));
987987}
988988
989989fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
990 const ptr = @intToPtr(?*const anyopaque, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
990 const ptr = @ptrFromInt(?*const anyopaque, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
991991 // Note that we may not have a VDSO at all, update the stub address anyway
992992 // so that clock_gettime will fall back on the good old (and slow) syscall
993993 @atomicStore(?*const anyopaque, &vdso_clock_gettime, ptr, .Monotonic);
......@@ -996,27 +996,27 @@ fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
996996 const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
997997 return f(clk, ts);
998998 }
999 return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS)));
999 return @bitCast(usize, -@as(isize, @intFromEnum(E.NOSYS)));
10001000}
10011001
10021002pub fn clock_getres(clk_id: i32, tp: *timespec) usize {
1003 return syscall2(.clock_getres, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
1003 return syscall2(.clock_getres, @bitCast(usize, @as(isize, clk_id)), @intFromPtr(tp));
10041004}
10051005
10061006pub fn clock_settime(clk_id: i32, tp: *const timespec) usize {
1007 return syscall2(.clock_settime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
1007 return syscall2(.clock_settime, @bitCast(usize, @as(isize, clk_id)), @intFromPtr(tp));
10081008}
10091009
10101010pub fn gettimeofday(tv: *timeval, tz: *timezone) usize {
1011 return syscall2(.gettimeofday, @ptrToInt(tv), @ptrToInt(tz));
1011 return syscall2(.gettimeofday, @intFromPtr(tv), @intFromPtr(tz));
10121012}
10131013
10141014pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize {
1015 return syscall2(.settimeofday, @ptrToInt(tv), @ptrToInt(tz));
1015 return syscall2(.settimeofday, @intFromPtr(tv), @intFromPtr(tz));
10161016}
10171017
10181018pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
1019 return syscall2(.nanosleep, @ptrToInt(req), @ptrToInt(rem));
1019 return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem));
10201020}
10211021
10221022pub fn setuid(uid: uid_t) usize {
......@@ -1107,17 +1107,17 @@ pub fn setegid(egid: gid_t) usize {
11071107
11081108pub fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) usize {
11091109 if (@hasField(SYS, "getresuid32")) {
1110 return syscall3(.getresuid32, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
1110 return syscall3(.getresuid32, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid));
11111111 } else {
1112 return syscall3(.getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
1112 return syscall3(.getresuid, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid));
11131113 }
11141114}
11151115
11161116pub fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) usize {
11171117 if (@hasField(SYS, "getresgid32")) {
1118 return syscall3(.getresgid32, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
1118 return syscall3(.getresgid32, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid));
11191119 } else {
1120 return syscall3(.getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
1120 return syscall3(.getresgid, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid));
11211121 }
11221122}
11231123
......@@ -1139,17 +1139,17 @@ pub fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) usize {
11391139
11401140pub fn getgroups(size: usize, list: *gid_t) usize {
11411141 if (@hasField(SYS, "getgroups32")) {
1142 return syscall2(.getgroups32, size, @ptrToInt(list));
1142 return syscall2(.getgroups32, size, @intFromPtr(list));
11431143 } else {
1144 return syscall2(.getgroups, size, @ptrToInt(list));
1144 return syscall2(.getgroups, size, @intFromPtr(list));
11451145 }
11461146}
11471147
11481148pub fn setgroups(size: usize, list: [*]const gid_t) usize {
11491149 if (@hasField(SYS, "setgroups32")) {
1150 return syscall2(.setgroups32, size, @ptrToInt(list));
1150 return syscall2(.setgroups32, size, @intFromPtr(list));
11511151 } else {
1152 return syscall2(.setgroups, size, @ptrToInt(list));
1152 return syscall2(.setgroups, size, @intFromPtr(list));
11531153 }
11541154}
11551155
......@@ -1162,7 +1162,7 @@ pub fn gettid() pid_t {
11621162}
11631163
11641164pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize {
1165 return syscall4(.rt_sigprocmask, flags, @ptrToInt(set), @ptrToInt(oldset), NSIG / 8);
1165 return syscall4(.rt_sigprocmask, flags, @intFromPtr(set), @intFromPtr(oldset), NSIG / 8);
11661166}
11671167
11681168pub 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
11871187 @memcpy(@ptrCast([*]u8, &ksa.mask)[0..mask_size], @ptrCast([*]const u8, &new.mask));
11881188 }
11891189
1190 const ksa_arg = if (act != null) @ptrToInt(&ksa) else 0;
1191 const oldksa_arg = if (oact != null) @ptrToInt(&oldksa) else 0;
1190 const ksa_arg = if (act != null) @intFromPtr(&ksa) else 0;
1191 const oldksa_arg = if (oact != null) @intFromPtr(&oldksa) else 0;
11921192
11931193 const result = switch (native_arch) {
11941194 // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too.
1195 .sparc, .sparc64 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @ptrToInt(ksa.restorer), mask_size),
1195 .sparc, .sparc64 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @intFromPtr(ksa.restorer), mask_size),
11961196 else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size),
11971197 };
11981198 if (getErrno(result) != .SUCCESS) return result;
......@@ -1223,16 +1223,16 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool {
12231223
12241224pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
12251225 if (native_arch == .x86) {
1226 return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
1226 return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len) });
12271227 }
1228 return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
1228 return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len));
12291229}
12301230
12311231pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
12321232 if (native_arch == .x86) {
1233 return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
1233 return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len) });
12341234 }
1235 return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
1235 return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len));
12361236}
12371237
12381238pub 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 {
12441244
12451245pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
12461246 if (native_arch == .x86) {
1247 return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
1247 return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intCast(usize, optlen) });
12481248 }
1249 return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
1249 return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intCast(usize, optlen));
12501250}
12511251
12521252pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
12531253 if (native_arch == .x86) {
1254 return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
1254 return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intFromPtr(optlen) });
12551255 }
1256 return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
1256 return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @intFromPtr(optval), @intFromPtr(optlen));
12571257}
12581258
12591259pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize {
12601260 const fd_usize = @bitCast(usize, @as(isize, fd));
1261 const msg_usize = @ptrToInt(msg);
1261 const msg_usize = @intFromPtr(msg);
12621262 if (native_arch == .x86) {
12631263 return socketcall(SC.sendmsg, &[3]usize{ fd_usize, msg_usize, flags });
12641264 } else {
......@@ -1281,7 +1281,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
12811281 // batch-send all messages up to the current message
12821282 if (next_unsent < i) {
12831283 const batch_size = i - next_unsent;
1284 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
1284 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @intFromPtr(&msgvec[next_unsent]), batch_size, flags);
12851285 if (getErrno(r) != 0) return next_unsent;
12861286 if (r < batch_size) return next_unsent + r;
12871287 }
......@@ -1297,18 +1297,18 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
12971297 }
12981298 if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR)
12991299 const batch_size = kvlen - next_unsent;
1300 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
1300 const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @intFromPtr(&msgvec[next_unsent]), batch_size, flags);
13011301 if (getErrno(r) != 0) return r;
13021302 return next_unsent + r;
13031303 }
13041304 return kvlen;
13051305 }
1306 return syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msgvec), vlen, flags);
1306 return syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @intFromPtr(msgvec), vlen, flags);
13071307}
13081308
13091309pub fn connect(fd: i32, addr: *const anyopaque, len: socklen_t) usize {
13101310 const fd_usize = @bitCast(usize, @as(isize, fd));
1311 const addr_usize = @ptrToInt(addr);
1311 const addr_usize = @intFromPtr(addr);
13121312 if (native_arch == .x86) {
13131313 return socketcall(SC.connect, &[3]usize{ fd_usize, addr_usize, len });
13141314 } else {
......@@ -1318,7 +1318,7 @@ pub fn connect(fd: i32, addr: *const anyopaque, len: socklen_t) usize {
13181318
13191319pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize {
13201320 const fd_usize = @bitCast(usize, @as(isize, fd));
1321 const msg_usize = @ptrToInt(msg);
1321 const msg_usize = @intFromPtr(msg);
13221322 if (native_arch == .x86) {
13231323 return socketcall(SC.recvmsg, &[3]usize{ fd_usize, msg_usize, flags });
13241324 } else {
......@@ -1335,9 +1335,9 @@ pub fn recvfrom(
13351335 noalias alen: ?*socklen_t,
13361336) usize {
13371337 const fd_usize = @bitCast(usize, @as(isize, fd));
1338 const buf_usize = @ptrToInt(buf);
1339 const addr_usize = @ptrToInt(addr);
1340 const alen_usize = @ptrToInt(alen);
1338 const buf_usize = @intFromPtr(buf);
1339 const addr_usize = @intFromPtr(addr);
1340 const alen_usize = @intFromPtr(alen);
13411341 if (native_arch == .x86) {
13421342 return socketcall(SC.recvfrom, &[6]usize{ fd_usize, buf_usize, len, flags, addr_usize, alen_usize });
13431343 } else {
......@@ -1354,9 +1354,9 @@ pub fn shutdown(fd: i32, how: i32) usize {
13541354
13551355pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
13561356 if (native_arch == .x86) {
1357 return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
1357 return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intCast(usize, len) });
13581358 }
1359 return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
1359 return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intCast(usize, len));
13601360}
13611361
13621362pub fn listen(fd: i32, backlog: u32) usize {
......@@ -1368,9 +1368,9 @@ pub fn listen(fd: i32, backlog: u32) usize {
13681368
13691369pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
13701370 if (native_arch == .x86) {
1371 return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
1371 return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), len, flags, @intFromPtr(addr), @intCast(usize, alen) });
13721372 }
1373 return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
1373 return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @intFromPtr(buf), len, flags, @intFromPtr(addr), @intCast(usize, alen));
13741374}
13751375
13761376pub 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 {
13791379 .sendfile64,
13801380 @bitCast(usize, @as(isize, outfd)),
13811381 @bitCast(usize, @as(isize, infd)),
1382 @ptrToInt(offset),
1382 @intFromPtr(offset),
13831383 count,
13841384 );
13851385 } else {
......@@ -1387,7 +1387,7 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
13871387 .sendfile,
13881388 @bitCast(usize, @as(isize, outfd)),
13891389 @bitCast(usize, @as(isize, infd)),
1390 @ptrToInt(offset),
1390 @intFromPtr(offset),
13911391 count,
13921392 );
13931393 }
......@@ -1395,9 +1395,9 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
13951395
13961396pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: *[2]i32) usize {
13971397 if (native_arch == .x86) {
1398 return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(fd) });
1398 return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @intFromPtr(fd) });
13991399 }
1400 return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(fd));
1400 return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @intFromPtr(fd));
14011401}
14021402
14031403pub 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
14091409
14101410pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {
14111411 if (native_arch == .x86) {
1412 return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
1412 return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len), flags });
14131413 }
1414 return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
1414 return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @intFromPtr(addr), @intFromPtr(len), flags);
14151415}
14161416
14171417pub fn fstat(fd: i32, stat_buf: *Stat) usize {
14181418 if (@hasField(SYS, "fstat64")) {
1419 return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
1419 return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @intFromPtr(stat_buf));
14201420 } else {
1421 return syscall2(.fstat, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
1421 return syscall2(.fstat, @bitCast(usize, @as(isize, fd)), @intFromPtr(stat_buf));
14221422 }
14231423}
14241424
14251425pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
14261426 if (@hasField(SYS, "stat64")) {
1427 return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
1427 return syscall2(.stat64, @intFromPtr(pathname), @intFromPtr(statbuf));
14281428 } else {
1429 return syscall2(.stat, @ptrToInt(pathname), @ptrToInt(statbuf));
1429 return syscall2(.stat, @intFromPtr(pathname), @intFromPtr(statbuf));
14301430 }
14311431}
14321432
14331433pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
14341434 if (@hasField(SYS, "lstat64")) {
1435 return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
1435 return syscall2(.lstat64, @intFromPtr(pathname), @intFromPtr(statbuf));
14361436 } else {
1437 return syscall2(.lstat, @ptrToInt(pathname), @ptrToInt(statbuf));
1437 return syscall2(.lstat, @intFromPtr(pathname), @intFromPtr(statbuf));
14381438 }
14391439}
14401440
14411441pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {
14421442 if (@hasField(SYS, "fstatat64")) {
1443 return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
1443 return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(stat_buf), flags);
14441444 } else {
1445 return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
1445 return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @intFromPtr(path), @intFromPtr(stat_buf), flags);
14461446 }
14471447}
14481448
......@@ -1451,61 +1451,61 @@ pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *S
14511451 return syscall5(
14521452 .statx,
14531453 @bitCast(usize, @as(isize, dirfd)),
1454 @ptrToInt(path),
1454 @intFromPtr(path),
14551455 flags,
14561456 mask,
1457 @ptrToInt(statx_buf),
1457 @intFromPtr(statx_buf),
14581458 );
14591459 }
1460 return @bitCast(usize, -@as(isize, @enumToInt(E.NOSYS)));
1460 return @bitCast(usize, -@as(isize, @intFromEnum(E.NOSYS)));
14611461}
14621462
14631463pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
1464 return syscall3(.listxattr, @ptrToInt(path), @ptrToInt(list), size);
1464 return syscall3(.listxattr, @intFromPtr(path), @intFromPtr(list), size);
14651465}
14661466
14671467pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
1468 return syscall3(.llistxattr, @ptrToInt(path), @ptrToInt(list), size);
1468 return syscall3(.llistxattr, @intFromPtr(path), @intFromPtr(list), size);
14691469}
14701470
14711471pub fn flistxattr(fd: usize, list: [*]u8, size: usize) usize {
1472 return syscall3(.flistxattr, fd, @ptrToInt(list), size);
1472 return syscall3(.flistxattr, fd, @intFromPtr(list), size);
14731473}
14741474
14751475pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
1476 return syscall4(.getxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
1476 return syscall4(.getxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size);
14771477}
14781478
14791479pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
1480 return syscall4(.lgetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
1480 return syscall4(.lgetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size);
14811481}
14821482
14831483pub fn fgetxattr(fd: usize, name: [*:0]const u8, value: [*]u8, size: usize) usize {
1484 return syscall4(.lgetxattr, fd, @ptrToInt(name), @ptrToInt(value), size);
1484 return syscall4(.lgetxattr, fd, @intFromPtr(name), @intFromPtr(value), size);
14851485}
14861486
14871487pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
1488 return syscall5(.setxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
1488 return syscall5(.setxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags);
14891489}
14901490
14911491pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
1492 return syscall5(.lsetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
1492 return syscall5(.lsetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags);
14931493}
14941494
14951495pub fn fsetxattr(fd: usize, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
1496 return syscall5(.fsetxattr, fd, @ptrToInt(name), @ptrToInt(value), size, flags);
1496 return syscall5(.fsetxattr, fd, @intFromPtr(name), @intFromPtr(value), size, flags);
14971497}
14981498
14991499pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
1500 return syscall2(.removexattr, @ptrToInt(path), @ptrToInt(name));
1500 return syscall2(.removexattr, @intFromPtr(path), @intFromPtr(name));
15011501}
15021502
15031503pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
1504 return syscall2(.lremovexattr, @ptrToInt(path), @ptrToInt(name));
1504 return syscall2(.lremovexattr, @intFromPtr(path), @intFromPtr(name));
15051505}
15061506
15071507pub fn fremovexattr(fd: usize, name: [*:0]const u8) usize {
1508 return syscall2(.fremovexattr, fd, @ptrToInt(name));
1508 return syscall2(.fremovexattr, fd, @intFromPtr(name));
15091509}
15101510
15111511pub fn sched_yield() usize {
......@@ -1513,30 +1513,30 @@ pub fn sched_yield() usize {
15131513}
15141514
15151515pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize {
1516 const rc = syscall3(.sched_getaffinity, @bitCast(usize, @as(isize, pid)), size, @ptrToInt(set));
1516 const rc = syscall3(.sched_getaffinity, @bitCast(usize, @as(isize, pid)), size, @intFromPtr(set));
15171517 if (@bitCast(isize, rc) < 0) return rc;
15181518 if (rc < size) @memset(@ptrCast([*]u8, set)[rc..size], 0);
15191519 return 0;
15201520}
15211521
15221522pub fn getcpu(cpu: *u32, node: *u32) usize {
1523 return syscall3(.getcpu, @ptrToInt(cpu), @ptrToInt(node), 0);
1523 return syscall3(.getcpu, @intFromPtr(cpu), @intFromPtr(node), 0);
15241524}
15251525
15261526pub fn sched_getcpu() usize {
15271527 var cpu: u32 = undefined;
1528 const rc = syscall3(.getcpu, @ptrToInt(&cpu), 0, 0);
1528 const rc = syscall3(.getcpu, @intFromPtr(&cpu), 0, 0);
15291529 if (@bitCast(isize, rc) < 0) return rc;
15301530 return @intCast(usize, cpu);
15311531}
15321532
15331533/// libc has no wrapper for this syscall
15341534pub fn mbind(addr: ?*anyopaque, len: u32, mode: i32, nodemask: *const u32, maxnode: u32, flags: u32) usize {
1535 return syscall6(.mbind, @ptrToInt(addr), len, @bitCast(usize, @as(isize, mode)), @ptrToInt(nodemask), maxnode, flags);
1535 return syscall6(.mbind, @intFromPtr(addr), len, @bitCast(usize, @as(isize, mode)), @intFromPtr(nodemask), maxnode, flags);
15361536}
15371537
15381538pub fn sched_setaffinity(pid: pid_t, size: usize, set: *const cpu_set_t) usize {
1539 const rc = syscall3(.sched_setaffinity, @bitCast(usize, @as(isize, pid)), size, @ptrToInt(set));
1539 const rc = syscall3(.sched_setaffinity, @bitCast(usize, @as(isize, pid)), size, @intFromPtr(set));
15401540 if (@bitCast(isize, rc) < 0) return rc;
15411541 return 0;
15421542}
......@@ -1550,7 +1550,7 @@ pub fn epoll_create1(flags: usize) usize {
15501550}
15511551
15521552pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize {
1553 return syscall4(.epoll_ctl, @bitCast(usize, @as(isize, epoll_fd)), @intCast(usize, op), @bitCast(usize, @as(isize, fd)), @ptrToInt(ev));
1553 return syscall4(.epoll_ctl, @bitCast(usize, @as(isize, epoll_fd)), @intCast(usize, op), @bitCast(usize, @as(isize, fd)), @intFromPtr(ev));
15541554}
15551555
15561556pub 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
15611561 return syscall6(
15621562 .epoll_pwait,
15631563 @bitCast(usize, @as(isize, epoll_fd)),
1564 @ptrToInt(events),
1564 @intFromPtr(events),
15651565 @intCast(usize, maxevents),
15661566 @bitCast(usize, @as(isize, timeout)),
1567 @ptrToInt(sigmask),
1567 @intFromPtr(sigmask),
15681568 @sizeOf(sigset_t),
15691569 );
15701570}
......@@ -1583,11 +1583,11 @@ pub const itimerspec = extern struct {
15831583};
15841584
15851585pub fn timerfd_gettime(fd: i32, curr_value: *itimerspec) usize {
1586 return syscall2(.timerfd_gettime, @bitCast(usize, @as(isize, fd)), @ptrToInt(curr_value));
1586 return syscall2(.timerfd_gettime, @bitCast(usize, @as(isize, fd)), @intFromPtr(curr_value));
15871587}
15881588
15891589pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
1590 return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @ptrToInt(new_value), @ptrToInt(old_value));
1590 return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @intFromPtr(new_value), @intFromPtr(old_value));
15911591}
15921592
15931593pub const sigevent = extern struct {
......@@ -1609,7 +1609,7 @@ pub const timer_t = ?*anyopaque;
16091609
16101610pub fn timer_create(clockid: i32, sevp: *sigevent, timerid: *timer_t) usize {
16111611 var t: timer_t = undefined;
1612 const rc = syscall3(.timer_create, @bitCast(usize, @as(isize, clockid)), @ptrToInt(sevp), @ptrToInt(&t));
1612 const rc = syscall3(.timer_create, @bitCast(usize, @as(isize, clockid)), @intFromPtr(sevp), @intFromPtr(&t));
16131613 if (@bitCast(isize, rc) < 0) return rc;
16141614 timerid.* = t;
16151615 return rc;
......@@ -1620,11 +1620,11 @@ pub fn timer_delete(timerid: timer_t) usize {
16201620}
16211621
16221622pub fn timer_gettime(timerid: timer_t, curr_value: *itimerspec) usize {
1623 return syscall2(.timer_gettime, @ptrToInt(timerid), @ptrToInt(curr_value));
1623 return syscall2(.timer_gettime, @intFromPtr(timerid), @intFromPtr(curr_value));
16241624}
16251625
16261626pub fn timer_settime(timerid: timer_t, flags: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
1627 return syscall4(.timer_settime, @ptrToInt(timerid), @bitCast(usize, @as(isize, flags)), @ptrToInt(new_value), @ptrToInt(old_value));
1627 return syscall4(.timer_settime, @intFromPtr(timerid), @bitCast(usize, @as(isize, flags)), @intFromPtr(new_value), @intFromPtr(old_value));
16281628}
16291629
16301630// Flags for the 'setitimer' system call
......@@ -1635,11 +1635,11 @@ pub const ITIMER = enum(i32) {
16351635};
16361636
16371637pub fn getitimer(which: i32, curr_value: *itimerspec) usize {
1638 return syscall2(.getitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(curr_value));
1638 return syscall2(.getitimer, @bitCast(usize, @as(isize, which)), @intFromPtr(curr_value));
16391639}
16401640
16411641pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
1642 return syscall3(.setitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(new_value), @ptrToInt(old_value));
1642 return syscall3(.setitimer, @bitCast(usize, @as(isize, which)), @intFromPtr(new_value), @intFromPtr(old_value));
16431643}
16441644
16451645pub fn unshare(flags: usize) usize {
......@@ -1647,55 +1647,55 @@ pub fn unshare(flags: usize) usize {
16471647}
16481648
16491649pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize {
1650 return syscall2(.capget, @ptrToInt(hdrp), @ptrToInt(datap));
1650 return syscall2(.capget, @intFromPtr(hdrp), @intFromPtr(datap));
16511651}
16521652
16531653pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize {
1654 return syscall2(.capset, @ptrToInt(hdrp), @ptrToInt(datap));
1654 return syscall2(.capset, @intFromPtr(hdrp), @intFromPtr(datap));
16551655}
16561656
16571657pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) usize {
1658 return syscall2(.sigaltstack, @ptrToInt(ss), @ptrToInt(old_ss));
1658 return syscall2(.sigaltstack, @intFromPtr(ss), @intFromPtr(old_ss));
16591659}
16601660
16611661pub fn uname(uts: *utsname) usize {
1662 return syscall1(.uname, @ptrToInt(uts));
1662 return syscall1(.uname, @intFromPtr(uts));
16631663}
16641664
16651665pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize {
1666 return syscall2(.io_uring_setup, entries, @ptrToInt(p));
1666 return syscall2(.io_uring_setup, entries, @intFromPtr(p));
16671667}
16681668
16691669pub fn io_uring_enter(fd: i32, to_submit: u32, min_complete: u32, flags: u32, sig: ?*sigset_t) usize {
1670 return syscall6(.io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8);
1670 return syscall6(.io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @intFromPtr(sig), NSIG / 8);
16711671}
16721672
16731673pub fn io_uring_register(fd: i32, opcode: IORING_REGISTER, arg: ?*const anyopaque, nr_args: u32) usize {
1674 return syscall4(.io_uring_register, @bitCast(usize, @as(isize, fd)), @enumToInt(opcode), @ptrToInt(arg), nr_args);
1674 return syscall4(.io_uring_register, @bitCast(usize, @as(isize, fd)), @intFromEnum(opcode), @intFromPtr(arg), nr_args);
16751675}
16761676
16771677pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {
1678 return syscall2(.memfd_create, @ptrToInt(name), flags);
1678 return syscall2(.memfd_create, @intFromPtr(name), flags);
16791679}
16801680
16811681pub fn getrusage(who: i32, usage: *rusage) usize {
1682 return syscall2(.getrusage, @bitCast(usize, @as(isize, who)), @ptrToInt(usage));
1682 return syscall2(.getrusage, @bitCast(usize, @as(isize, who)), @intFromPtr(usage));
16831683}
16841684
16851685pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {
1686 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @ptrToInt(termios_p));
1686 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @intFromPtr(termios_p));
16871687}
16881688
16891689pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {
1690 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
1690 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @intFromEnum(optional_action), @intFromPtr(termios_p));
16911691}
16921692
16931693pub fn tcgetpgrp(fd: fd_t, pgrp: *pid_t) usize {
1694 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCGPGRP, @ptrToInt(pgrp));
1694 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCGPGRP, @intFromPtr(pgrp));
16951695}
16961696
16971697pub fn tcsetpgrp(fd: fd_t, pgrp: *const pid_t) usize {
1698 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCSPGRP, @ptrToInt(pgrp));
1698 return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.IOCSPGRP, @intFromPtr(pgrp));
16991699}
17001700
17011701pub fn tcdrain(fd: fd_t) usize {
......@@ -1707,23 +1707,23 @@ pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {
17071707}
17081708
17091709pub fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) usize {
1710 return syscall4(.signalfd4, @bitCast(usize, @as(isize, fd)), @ptrToInt(mask), NSIG / 8, flags);
1710 return syscall4(.signalfd4, @bitCast(usize, @as(isize, fd)), @intFromPtr(mask), NSIG / 8, flags);
17111711}
17121712
17131713pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) usize {
17141714 return syscall6(
17151715 .copy_file_range,
17161716 @bitCast(usize, @as(isize, fd_in)),
1717 @ptrToInt(off_in),
1717 @intFromPtr(off_in),
17181718 @bitCast(usize, @as(isize, fd_out)),
1719 @ptrToInt(off_out),
1719 @intFromPtr(off_out),
17201720 len,
17211721 flags,
17221722 );
17231723}
17241724
17251725pub fn bpf(cmd: BPF.Cmd, attr: *BPF.Attr, size: u32) usize {
1726 return syscall3(.bpf, @enumToInt(cmd), @ptrToInt(attr), size);
1726 return syscall3(.bpf, @intFromEnum(cmd), @intFromPtr(attr), size);
17271727}
17281728
17291729pub fn sync() void {
......@@ -1760,18 +1760,18 @@ pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit,
17601760 return syscall4(
17611761 .prlimit64,
17621762 @bitCast(usize, @as(isize, pid)),
1763 @bitCast(usize, @as(isize, @enumToInt(resource))),
1764 @ptrToInt(new_limit),
1765 @ptrToInt(old_limit),
1763 @bitCast(usize, @as(isize, @intFromEnum(resource))),
1764 @intFromPtr(new_limit),
1765 @intFromPtr(old_limit),
17661766 );
17671767}
17681768
17691769pub fn mincore(address: [*]u8, len: usize, vec: [*]u8) usize {
1770 return syscall3(.mincore, @ptrToInt(address), len, @ptrToInt(vec));
1770 return syscall3(.mincore, @intFromPtr(address), len, @intFromPtr(vec));
17711771}
17721772
17731773pub fn madvise(address: [*]u8, len: usize, advice: u32) usize {
1774 return syscall3(.madvise, @ptrToInt(address), len, advice);
1774 return syscall3(.madvise, @intFromPtr(address), len, advice);
17751775}
17761776
17771777pub 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
17921792 .pidfd_send_signal,
17931793 @bitCast(usize, @as(isize, pidfd)),
17941794 @bitCast(usize, @as(isize, sig)),
1795 @ptrToInt(info),
1795 @intFromPtr(info),
17961796 flags,
17971797 );
17981798}
......@@ -1801,9 +1801,9 @@ pub fn process_vm_readv(pid: pid_t, local: []iovec, remote: []const iovec_const,
18011801 return syscall6(
18021802 .process_vm_readv,
18031803 @bitCast(usize, @as(isize, pid)),
1804 @ptrToInt(local.ptr),
1804 @intFromPtr(local.ptr),
18051805 local.len,
1806 @ptrToInt(remote.ptr),
1806 @intFromPtr(remote.ptr),
18071807 remote.len,
18081808 flags,
18091809 );
......@@ -1813,9 +1813,9 @@ pub fn process_vm_writev(pid: pid_t, local: []const iovec_const, remote: []const
18131813 return syscall6(
18141814 .process_vm_writev,
18151815 @bitCast(usize, @as(isize, pid)),
1816 @ptrToInt(local.ptr),
1816 @intFromPtr(local.ptr),
18171817 local.len,
1818 @ptrToInt(remote.ptr),
1818 @intFromPtr(remote.ptr),
18191819 remote.len,
18201820 flags,
18211821 );
......@@ -1889,7 +1889,7 @@ pub fn perf_event_open(
18891889) usize {
18901890 return syscall5(
18911891 .perf_event_open,
1892 @ptrToInt(attr),
1892 @intFromPtr(attr),
18931893 @bitCast(usize, @as(isize, pid)),
18941894 @bitCast(usize, @as(isize, cpu)),
18951895 @bitCast(usize, @as(isize, group_fd)),
......@@ -1898,7 +1898,7 @@ pub fn perf_event_open(
18981898}
18991899
19001900pub fn seccomp(operation: u32, flags: u32, args: ?*const anyopaque) usize {
1901 return syscall3(.seccomp, operation, flags, @ptrToInt(args));
1901 return syscall3(.seccomp, operation, flags, @intFromPtr(args));
19021902}
19031903
19041904pub fn ptrace(
......@@ -2154,9 +2154,9 @@ pub const SIG = if (is_mips) struct {
21542154 pub const SYS = 31;
21552155 pub const UNUSED = SIG.SYS;
21562156
2157 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
2158 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
2159 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
2157 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
2158 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
2159 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
21602160} else if (is_sparc) struct {
21612161 pub const BLOCK = 1;
21622162 pub const UNBLOCK = 2;
......@@ -2198,9 +2198,9 @@ pub const SIG = if (is_mips) struct {
21982198 pub const PWR = LOST;
21992199 pub const IO = SIG.POLL;
22002200
2201 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
2202 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
2203 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
2201 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
2202 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
2203 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
22042204} else struct {
22052205 pub const BLOCK = 0;
22062206 pub const UNBLOCK = 1;
......@@ -2241,9 +2241,9 @@ pub const SIG = if (is_mips) struct {
22412241 pub const SYS = 31;
22422242 pub const UNUSED = SIG.SYS;
22432243
2244 pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
2245 pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
2246 pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
2244 pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize));
2245 pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0);
2246 pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1);
22472247};
22482248
22492249pub const kernel_rwf = u32;
......@@ -3876,26 +3876,26 @@ pub const IOSQE_BIT = enum(u8) {
38763876// io_uring_sqe.flags
38773877
38783878/// use fixed fileset
3879pub const IOSQE_FIXED_FILE = 1 << @enumToInt(IOSQE_BIT.FIXED_FILE);
3879pub const IOSQE_FIXED_FILE = 1 << @intFromEnum(IOSQE_BIT.FIXED_FILE);
38803880
38813881/// issue after inflight IO
3882pub const IOSQE_IO_DRAIN = 1 << @enumToInt(IOSQE_BIT.IO_DRAIN);
3882pub const IOSQE_IO_DRAIN = 1 << @intFromEnum(IOSQE_BIT.IO_DRAIN);
38833883
38843884/// links next sqe
3885pub const IOSQE_IO_LINK = 1 << @enumToInt(IOSQE_BIT.IO_LINK);
3885pub const IOSQE_IO_LINK = 1 << @intFromEnum(IOSQE_BIT.IO_LINK);
38863886
38873887/// like LINK, but stronger
3888pub const IOSQE_IO_HARDLINK = 1 << @enumToInt(IOSQE_BIT.IO_HARDLINK);
3888pub const IOSQE_IO_HARDLINK = 1 << @intFromEnum(IOSQE_BIT.IO_HARDLINK);
38893889
38903890/// always go async
3891pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC);
3891pub const IOSQE_ASYNC = 1 << @intFromEnum(IOSQE_BIT.ASYNC);
38923892
38933893/// select buffer from buf_group
3894pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT);
3894pub const IOSQE_BUFFER_SELECT = 1 << @intFromEnum(IOSQE_BIT.BUFFER_SELECT);
38953895
38963896/// don't post CQE if request succeeded
38973897/// Available since Linux 5.17
3898pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @enumToInt(IOSQE_BIT.CQE_SKIP_SUCCESS);
3898pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @intFromEnum(IOSQE_BIT.CQE_SKIP_SUCCESS);
38993899
39003900pub const IORING_OP = enum(u8) {
39013901 NOP,
......@@ -3999,7 +3999,7 @@ pub const io_uring_cqe = extern struct {
39993999
40004000 pub fn err(self: io_uring_cqe) E {
40014001 if (self.res > -4096 and self.res < 0) {
4002 return @intToEnum(E, -self.res);
4002 return @enumFromInt(E, -self.res);
40034003 }
40044004 return .SUCCESS;
40054005 }
......@@ -5827,7 +5827,7 @@ pub const AUDIT = struct {
58275827 ARM = toAudit(.arm),
58285828 ARMEB = toAudit(.armeb),
58295829 CSKY = toAudit(.csky),
5830 HEXAGON = @enumToInt(std.elf.EM.HEXAGON),
5830 HEXAGON = @intFromEnum(std.elf.EM.HEXAGON),
58315831 X86 = toAudit(.x86),
58325832 M68K = toAudit(.m68k),
58335833 MIPS = toAudit(.mips),
......@@ -5845,7 +5845,7 @@ pub const AUDIT = struct {
58455845 X86_64 = toAudit(.x86_64),
58465846
58475847 fn toAudit(arch: std.Target.Cpu.Arch) u32 {
5848 var res: u32 = @enumToInt(arch.toElfMachine());
5848 var res: u32 = @intFromEnum(arch.toElfMachine());
58495849 if (arch.endian() == .Little) res |= LE;
58505850 switch (arch) {
58515851 .aarch64,
lib/std/os/linux/arm-eabi.zig+9-9
......@@ -16,7 +16,7 @@ const timespec = linux.timespec;
1616pub fn syscall0(number: SYS) usize {
1717 return asm volatile ("svc #0"
1818 : [ret] "={r0}" (-> usize),
19 : [number] "{r7}" (@enumToInt(number)),
19 : [number] "{r7}" (@intFromEnum(number)),
2020 : "memory"
2121 );
2222}
......@@ -24,7 +24,7 @@ pub fn syscall0(number: SYS) usize {
2424pub fn syscall1(number: SYS, arg1: usize) usize {
2525 return asm volatile ("svc #0"
2626 : [ret] "={r0}" (-> usize),
27 : [number] "{r7}" (@enumToInt(number)),
27 : [number] "{r7}" (@intFromEnum(number)),
2828 [arg1] "{r0}" (arg1),
2929 : "memory"
3030 );
......@@ -33,7 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3333pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
3434 return asm volatile ("svc #0"
3535 : [ret] "={r0}" (-> usize),
36 : [number] "{r7}" (@enumToInt(number)),
36 : [number] "{r7}" (@intFromEnum(number)),
3737 [arg1] "{r0}" (arg1),
3838 [arg2] "{r1}" (arg2),
3939 : "memory"
......@@ -43,7 +43,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4343pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
4444 return asm volatile ("svc #0"
4545 : [ret] "={r0}" (-> usize),
46 : [number] "{r7}" (@enumToInt(number)),
46 : [number] "{r7}" (@intFromEnum(number)),
4747 [arg1] "{r0}" (arg1),
4848 [arg2] "{r1}" (arg2),
4949 [arg3] "{r2}" (arg3),
......@@ -54,7 +54,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
5454pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
5555 return asm volatile ("svc #0"
5656 : [ret] "={r0}" (-> usize),
57 : [number] "{r7}" (@enumToInt(number)),
57 : [number] "{r7}" (@intFromEnum(number)),
5858 [arg1] "{r0}" (arg1),
5959 [arg2] "{r1}" (arg2),
6060 [arg3] "{r2}" (arg3),
......@@ -66,7 +66,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
6666pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
6767 return asm volatile ("svc #0"
6868 : [ret] "={r0}" (-> usize),
69 : [number] "{r7}" (@enumToInt(number)),
69 : [number] "{r7}" (@intFromEnum(number)),
7070 [arg1] "{r0}" (arg1),
7171 [arg2] "{r1}" (arg2),
7272 [arg3] "{r2}" (arg3),
......@@ -87,7 +87,7 @@ pub fn syscall6(
8787) usize {
8888 return asm volatile ("svc #0"
8989 : [ret] "={r0}" (-> usize),
90 : [number] "{r7}" (@enumToInt(number)),
90 : [number] "{r7}" (@intFromEnum(number)),
9191 [arg1] "{r0}" (arg1),
9292 [arg2] "{r1}" (arg2),
9393 [arg3] "{r2}" (arg3),
......@@ -106,7 +106,7 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *
106106pub fn restore() callconv(.Naked) void {
107107 return asm volatile ("svc #0"
108108 :
109 : [number] "{r7}" (@enumToInt(SYS.sigreturn)),
109 : [number] "{r7}" (@intFromEnum(SYS.sigreturn)),
110110 : "memory"
111111 );
112112}
......@@ -114,7 +114,7 @@ pub fn restore() callconv(.Naked) void {
114114pub fn restore_rt() callconv(.Naked) void {
115115 return asm volatile ("svc #0"
116116 :
117 : [number] "{r7}" (@enumToInt(SYS.rt_sigreturn)),
117 : [number] "{r7}" (@intFromEnum(SYS.rt_sigreturn)),
118118 : "memory"
119119 );
120120}
lib/std/os/linux/arm64.zig+9-9
......@@ -16,7 +16,7 @@ const timespec = std.os.linux.timespec;
1616pub fn syscall0(number: SYS) usize {
1717 return asm volatile ("svc #0"
1818 : [ret] "={x0}" (-> usize),
19 : [number] "{x8}" (@enumToInt(number)),
19 : [number] "{x8}" (@intFromEnum(number)),
2020 : "memory", "cc"
2121 );
2222}
......@@ -24,7 +24,7 @@ pub fn syscall0(number: SYS) usize {
2424pub fn syscall1(number: SYS, arg1: usize) usize {
2525 return asm volatile ("svc #0"
2626 : [ret] "={x0}" (-> usize),
27 : [number] "{x8}" (@enumToInt(number)),
27 : [number] "{x8}" (@intFromEnum(number)),
2828 [arg1] "{x0}" (arg1),
2929 : "memory", "cc"
3030 );
......@@ -33,7 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3333pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
3434 return asm volatile ("svc #0"
3535 : [ret] "={x0}" (-> usize),
36 : [number] "{x8}" (@enumToInt(number)),
36 : [number] "{x8}" (@intFromEnum(number)),
3737 [arg1] "{x0}" (arg1),
3838 [arg2] "{x1}" (arg2),
3939 : "memory", "cc"
......@@ -43,7 +43,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4343pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
4444 return asm volatile ("svc #0"
4545 : [ret] "={x0}" (-> usize),
46 : [number] "{x8}" (@enumToInt(number)),
46 : [number] "{x8}" (@intFromEnum(number)),
4747 [arg1] "{x0}" (arg1),
4848 [arg2] "{x1}" (arg2),
4949 [arg3] "{x2}" (arg3),
......@@ -54,7 +54,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
5454pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
5555 return asm volatile ("svc #0"
5656 : [ret] "={x0}" (-> usize),
57 : [number] "{x8}" (@enumToInt(number)),
57 : [number] "{x8}" (@intFromEnum(number)),
5858 [arg1] "{x0}" (arg1),
5959 [arg2] "{x1}" (arg2),
6060 [arg3] "{x2}" (arg3),
......@@ -66,7 +66,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
6666pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
6767 return asm volatile ("svc #0"
6868 : [ret] "={x0}" (-> usize),
69 : [number] "{x8}" (@enumToInt(number)),
69 : [number] "{x8}" (@intFromEnum(number)),
7070 [arg1] "{x0}" (arg1),
7171 [arg2] "{x1}" (arg2),
7272 [arg3] "{x2}" (arg3),
......@@ -87,7 +87,7 @@ pub fn syscall6(
8787) usize {
8888 return asm volatile ("svc #0"
8989 : [ret] "={x0}" (-> usize),
90 : [number] "{x8}" (@enumToInt(number)),
90 : [number] "{x8}" (@intFromEnum(number)),
9191 [arg1] "{x0}" (arg1),
9292 [arg2] "{x1}" (arg2),
9393 [arg3] "{x2}" (arg3),
......@@ -111,12 +111,12 @@ pub fn restore_rt() callconv(.Naked) void {
111111 \\ mov x8, %[number]
112112 \\ svc #0
113113 :
114 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
114 : [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
115115 : "memory", "cc"
116116 ),
117117 else => return asm volatile ("svc #0"
118118 :
119 : [number] "{x8}" (@enumToInt(SYS.rt_sigreturn)),
119 : [number] "{x8}" (@intFromEnum(SYS.rt_sigreturn)),
120120 : "memory", "cc"
121121 ),
122122 }
lib/std/os/linux/bpf.zig+34-34
......@@ -472,10 +472,10 @@ pub const Insn = packed struct {
472472
473473 return Insn{
474474 .code = code | src_type,
475 .dst = @enumToInt(dst),
475 .dst = @intFromEnum(dst),
476476 .src = switch (imm_or_reg) {
477477 .imm => 0,
478 .reg => |r| @enumToInt(r),
478 .reg => |r| @intFromEnum(r),
479479 },
480480 .off = off,
481481 .imm = switch (imm_or_reg) {
......@@ -492,7 +492,7 @@ pub const Insn = packed struct {
492492 else => @compileError("width must be 32 or 64"),
493493 };
494494
495 return imm_reg(width_bitfield | @enumToInt(op), dst, src, 0);
495 return imm_reg(width_bitfield | @intFromEnum(op), dst, src, 0);
496496 }
497497
498498 pub fn mov(dst: Reg, src: anytype) Insn {
......@@ -548,7 +548,7 @@ pub const Insn = packed struct {
548548 }
549549
550550 pub fn jmp(op: JmpOp, dst: Reg, src: anytype, off: i16) Insn {
551 return imm_reg(JMP | @enumToInt(op), dst, src, off);
551 return imm_reg(JMP | @intFromEnum(op), dst, src, off);
552552 }
553553
554554 pub fn ja(off: i16) Insn {
......@@ -602,8 +602,8 @@ pub const Insn = packed struct {
602602 pub fn xadd(dst: Reg, src: Reg) Insn {
603603 return Insn{
604604 .code = STX | XADD | DW,
605 .dst = @enumToInt(dst),
606 .src = @enumToInt(src),
605 .dst = @intFromEnum(dst),
606 .src = @intFromEnum(src),
607607 .off = 0,
608608 .imm = 0,
609609 };
......@@ -611,9 +611,9 @@ pub const Insn = packed struct {
611611
612612 fn ld(mode: Mode, size: Size, dst: Reg, src: Reg, imm: i32) Insn {
613613 return Insn{
614 .code = @enumToInt(mode) | @enumToInt(size) | LD,
615 .dst = @enumToInt(dst),
616 .src = @enumToInt(src),
614 .code = @intFromEnum(mode) | @intFromEnum(size) | LD,
615 .dst = @intFromEnum(dst),
616 .src = @intFromEnum(src),
617617 .off = 0,
618618 .imm = imm,
619619 };
......@@ -629,9 +629,9 @@ pub const Insn = packed struct {
629629
630630 pub fn ldx(size: Size, dst: Reg, src: Reg, off: i16) Insn {
631631 return Insn{
632 .code = MEM | @enumToInt(size) | LDX,
633 .dst = @enumToInt(dst),
634 .src = @enumToInt(src),
632 .code = MEM | @intFromEnum(size) | LDX,
633 .dst = @intFromEnum(dst),
634 .src = @intFromEnum(src),
635635 .off = off,
636636 .imm = 0,
637637 };
......@@ -640,8 +640,8 @@ pub const Insn = packed struct {
640640 fn ld_imm_impl1(dst: Reg, src: Reg, imm: u64) Insn {
641641 return Insn{
642642 .code = LD | DW | IMM,
643 .dst = @enumToInt(dst),
644 .src = @enumToInt(src),
643 .dst = @intFromEnum(dst),
644 .src = @intFromEnum(src),
645645 .off = 0,
646646 .imm = @intCast(i32, @truncate(u32, imm)),
647647 };
......@@ -666,7 +666,7 @@ pub const Insn = packed struct {
666666 }
667667
668668 pub fn ld_map_fd1(dst: Reg, map_fd: fd_t) Insn {
669 return ld_imm_impl1(dst, @intToEnum(Reg, PSEUDO_MAP_FD), @intCast(u64, map_fd));
669 return ld_imm_impl1(dst, @enumFromInt(Reg, PSEUDO_MAP_FD), @intCast(u64, map_fd));
670670 }
671671
672672 pub fn ld_map_fd2(map_fd: fd_t) Insn {
......@@ -675,8 +675,8 @@ pub const Insn = packed struct {
675675
676676 pub fn st(comptime size: Size, dst: Reg, off: i16, imm: i32) Insn {
677677 return Insn{
678 .code = MEM | @enumToInt(size) | ST,
679 .dst = @enumToInt(dst),
678 .code = MEM | @intFromEnum(size) | ST,
679 .dst = @intFromEnum(dst),
680680 .src = 0,
681681 .off = off,
682682 .imm = imm,
......@@ -685,9 +685,9 @@ pub const Insn = packed struct {
685685
686686 pub fn stx(size: Size, dst: Reg, off: i16, src: Reg) Insn {
687687 return Insn{
688 .code = MEM | @enumToInt(size) | STX,
689 .dst = @enumToInt(dst),
690 .src = @enumToInt(src),
688 .code = MEM | @intFromEnum(size) | STX,
689 .dst = @intFromEnum(dst),
690 .src = @intFromEnum(src),
691691 .off = off,
692692 .imm = 0,
693693 };
......@@ -699,7 +699,7 @@ pub const Insn = packed struct {
699699 .Big => 0xdc,
700700 .Little => 0xd4,
701701 },
702 .dst = @enumToInt(dst),
702 .dst = @intFromEnum(dst),
703703 .src = 0,
704704 .off = 0,
705705 .imm = switch (size) {
......@@ -725,7 +725,7 @@ pub const Insn = packed struct {
725725 .dst = 0,
726726 .src = 0,
727727 .off = 0,
728 .imm = @enumToInt(helper),
728 .imm = @intFromEnum(helper),
729729 };
730730 }
731731
......@@ -1511,7 +1511,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
15111511 .map_create = std.mem.zeroes(MapCreateAttr),
15121512 };
15131513
1514 attr.map_create.map_type = @enumToInt(map_type);
1514 attr.map_create.map_type = @intFromEnum(map_type);
15151515 attr.map_create.key_size = key_size;
15161516 attr.map_create.value_size = value_size;
15171517 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 {
15371537 };
15381538
15391539 attr.map_elem.map_fd = fd;
1540 attr.map_elem.key = @ptrToInt(key.ptr);
1541 attr.map_elem.result.value = @ptrToInt(value.ptr);
1540 attr.map_elem.key = @intFromPtr(key.ptr);
1541 attr.map_elem.result.value = @intFromPtr(value.ptr);
15421542
15431543 const rc = linux.bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr));
15441544 switch (errno(rc)) {
......@@ -1558,8 +1558,8 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64)
15581558 };
15591559
15601560 attr.map_elem.map_fd = fd;
1561 attr.map_elem.key = @ptrToInt(key.ptr);
1562 attr.map_elem.result = .{ .value = @ptrToInt(value.ptr) };
1561 attr.map_elem.key = @intFromPtr(key.ptr);
1562 attr.map_elem.result = .{ .value = @intFromPtr(value.ptr) };
15631563 attr.map_elem.flags = flags;
15641564
15651565 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 {
15811581 };
15821582
15831583 attr.map_elem.map_fd = fd;
1584 attr.map_elem.key = @ptrToInt(key.ptr);
1584 attr.map_elem.key = @intFromPtr(key.ptr);
15851585
15861586 const rc = linux.bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr));
15871587 switch (errno(rc)) {
......@@ -1601,8 +1601,8 @@ pub fn map_get_next_key(fd: fd_t, key: []const u8, next_key: []u8) !bool {
16011601 };
16021602
16031603 attr.map_elem.map_fd = fd;
1604 attr.map_elem.key = @ptrToInt(key.ptr);
1605 attr.map_elem.result.next_key = @ptrToInt(next_key.ptr);
1604 attr.map_elem.key = @intFromPtr(key.ptr);
1605 attr.map_elem.result.next_key = @intFromPtr(next_key.ptr);
16061606
16071607 const rc = linux.bpf(.map_get_next_key, &attr, @sizeOf(MapElemAttr));
16081608 switch (errno(rc)) {
......@@ -1666,15 +1666,15 @@ pub fn prog_load(
16661666 .prog_load = std.mem.zeroes(ProgLoadAttr),
16671667 };
16681668
1669 attr.prog_load.prog_type = @enumToInt(prog_type);
1670 attr.prog_load.insns = @ptrToInt(insns.ptr);
1669 attr.prog_load.prog_type = @intFromEnum(prog_type);
1670 attr.prog_load.insns = @intFromPtr(insns.ptr);
16711671 attr.prog_load.insn_cnt = @intCast(u32, insns.len);
1672 attr.prog_load.license = @ptrToInt(license.ptr);
1672 attr.prog_load.license = @intFromPtr(license.ptr);
16731673 attr.prog_load.kern_version = kern_version;
16741674 attr.prog_load.prog_flags = flags;
16751675
16761676 if (log) |l| {
1677 attr.prog_load.log_buf = @ptrToInt(l.buf.ptr);
1677 attr.prog_load.log_buf = @intFromPtr(l.buf.ptr);
16781678 attr.prog_load.log_size = @intCast(u32, l.buf.len);
16791679 attr.prog_load.log_level = l.level;
16801680 }
lib/std/os/linux/bpf/helpers.zig+141-141
......@@ -11,147 +11,147 @@ const SkFullSock = @compileError("TODO missing os bits: SkFullSock");
1111//
1212// Note, these function signatures were created from documentation found in
1313// '/usr/include/linux/bpf.h'
14pub const map_lookup_elem = @intToPtr(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) ?*anyopaque, 1);
15pub const map_update_elem = @intToPtr(*const fn (map: *const kern.MapDef, key: ?*const anyopaque, value: ?*const anyopaque, flags: u64) c_long, 2);
16pub const map_delete_elem = @intToPtr(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) c_long, 3);
17pub const probe_read = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 4);
18pub const ktime_get_ns = @intToPtr(*const fn () u64, 5);
19pub const trace_printk = @intToPtr(*const fn (fmt: [*:0]const u8, fmt_size: u32, arg1: u64, arg2: u64, arg3: u64) c_long, 6);
20pub const get_prandom_u32 = @intToPtr(*const fn () u32, 7);
21pub const get_smp_processor_id = @intToPtr(*const fn () u32, 8);
22pub const skb_store_bytes = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32, flags: u64) c_long, 9);
23pub const l3_csum_replace = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, size: u64) c_long, 10);
24pub const l4_csum_replace = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, flags: u64) c_long, 11);
25pub const tail_call = @intToPtr(*const fn (ctx: ?*anyopaque, prog_array_map: *const kern.MapDef, index: u32) c_long, 12);
26pub const clone_redirect = @intToPtr(*const fn (skb: *kern.SkBuff, ifindex: u32, flags: u64) c_long, 13);
27pub const get_current_pid_tgid = @intToPtr(*const fn () u64, 14);
28pub const get_current_uid_gid = @intToPtr(*const fn () u64, 15);
29pub const get_current_comm = @intToPtr(*const fn (buf: ?*anyopaque, size_of_buf: u32) c_long, 16);
30pub const get_cgroup_classid = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 17);
14pub const map_lookup_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) ?*anyopaque, 1);
15pub const map_update_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, key: ?*const anyopaque, value: ?*const anyopaque, flags: u64) c_long, 2);
16pub const map_delete_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, key: ?*const anyopaque) c_long, 3);
17pub const probe_read = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 4);
18pub const ktime_get_ns = @ptrFromInt(*const fn () u64, 5);
19pub const trace_printk = @ptrFromInt(*const fn (fmt: [*:0]const u8, fmt_size: u32, arg1: u64, arg2: u64, arg3: u64) c_long, 6);
20pub const get_prandom_u32 = @ptrFromInt(*const fn () u32, 7);
21pub const get_smp_processor_id = @ptrFromInt(*const fn () u32, 8);
22pub const skb_store_bytes = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32, flags: u64) c_long, 9);
23pub const l3_csum_replace = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, size: u64) c_long, 10);
24pub const l4_csum_replace = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: u64, to: u64, flags: u64) c_long, 11);
25pub const tail_call = @ptrFromInt(*const fn (ctx: ?*anyopaque, prog_array_map: *const kern.MapDef, index: u32) c_long, 12);
26pub const clone_redirect = @ptrFromInt(*const fn (skb: *kern.SkBuff, ifindex: u32, flags: u64) c_long, 13);
27pub const get_current_pid_tgid = @ptrFromInt(*const fn () u64, 14);
28pub const get_current_uid_gid = @ptrFromInt(*const fn () u64, 15);
29pub const get_current_comm = @ptrFromInt(*const fn (buf: ?*anyopaque, size_of_buf: u32) c_long, 16);
30pub const get_cgroup_classid = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 17);
3131// Note vlan_proto is big endian
32pub const skb_vlan_push = @intToPtr(*const fn (skb: *kern.SkBuff, vlan_proto: u16, vlan_tci: u16) c_long, 18);
33pub const skb_vlan_pop = @intToPtr(*const fn (skb: *kern.SkBuff) c_long, 19);
34pub const skb_get_tunnel_key = @intToPtr(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 20);
35pub const skb_set_tunnel_key = @intToPtr(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 21);
36pub const perf_event_read = @intToPtr(*const fn (map: *const kern.MapDef, flags: u64) u64, 22);
37pub const redirect = @intToPtr(*const fn (ifindex: u32, flags: u64) c_long, 23);
38pub const get_route_realm = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 24);
39pub const perf_event_output = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 25);
40pub const skb_load_bytes = @intToPtr(*const fn (skb: ?*anyopaque, offset: u32, to: ?*anyopaque, len: u32) c_long, 26);
41pub const get_stackid = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64) c_long, 27);
32pub const skb_vlan_push = @ptrFromInt(*const fn (skb: *kern.SkBuff, vlan_proto: u16, vlan_tci: u16) c_long, 18);
33pub const skb_vlan_pop = @ptrFromInt(*const fn (skb: *kern.SkBuff) c_long, 19);
34pub const skb_get_tunnel_key = @ptrFromInt(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 20);
35pub const skb_set_tunnel_key = @ptrFromInt(*const fn (skb: *kern.SkBuff, key: *kern.TunnelKey, size: u32, flags: u64) c_long, 21);
36pub const perf_event_read = @ptrFromInt(*const fn (map: *const kern.MapDef, flags: u64) u64, 22);
37pub const redirect = @ptrFromInt(*const fn (ifindex: u32, flags: u64) c_long, 23);
38pub const get_route_realm = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 24);
39pub const perf_event_output = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 25);
40pub const skb_load_bytes = @ptrFromInt(*const fn (skb: ?*anyopaque, offset: u32, to: ?*anyopaque, len: u32) c_long, 26);
41pub const get_stackid = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64) c_long, 27);
4242// from and to point to __be32
43pub const csum_diff = @intToPtr(*const fn (from: *u32, from_size: u32, to: *u32, to_size: u32, seed: u32) i64, 28);
44pub const skb_get_tunnel_opt = @intToPtr(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 29);
45pub const skb_set_tunnel_opt = @intToPtr(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 30);
43pub const csum_diff = @ptrFromInt(*const fn (from: *u32, from_size: u32, to: *u32, to_size: u32, seed: u32) i64, 28);
44pub const skb_get_tunnel_opt = @ptrFromInt(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 29);
45pub const skb_set_tunnel_opt = @ptrFromInt(*const fn (skb: *kern.SkBuff, opt: ?*anyopaque, size: u32) c_long, 30);
4646// proto is __be16
47pub const skb_change_proto = @intToPtr(*const fn (skb: *kern.SkBuff, proto: u16, flags: u64) c_long, 31);
48pub const skb_change_type = @intToPtr(*const fn (skb: *kern.SkBuff, skb_type: u32) c_long, 32);
49pub const skb_under_cgroup = @intToPtr(*const fn (skb: *kern.SkBuff, map: ?*const anyopaque, index: u32) c_long, 33);
50pub const get_hash_recalc = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 34);
51pub const get_current_task = @intToPtr(*const fn () u64, 35);
52pub const probe_write_user = @intToPtr(*const fn (dst: ?*anyopaque, src: ?*const anyopaque, len: u32) c_long, 36);
53pub const current_task_under_cgroup = @intToPtr(*const fn (map: *const kern.MapDef, index: u32) c_long, 37);
54pub const skb_change_tail = @intToPtr(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 38);
55pub const skb_pull_data = @intToPtr(*const fn (skb: *kern.SkBuff, len: u32) c_long, 39);
56pub const csum_update = @intToPtr(*const fn (skb: *kern.SkBuff, csum: u32) i64, 40);
57pub const set_hash_invalid = @intToPtr(*const fn (skb: *kern.SkBuff) void, 41);
58pub const get_numa_node_id = @intToPtr(*const fn () c_long, 42);
59pub const skb_change_head = @intToPtr(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 43);
60pub const xdp_adjust_head = @intToPtr(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 44);
61pub const probe_read_str = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 45);
62pub const get_socket_cookie = @intToPtr(*const fn (ctx: ?*anyopaque) u64, 46);
63pub const get_socket_uid = @intToPtr(*const fn (skb: *kern.SkBuff) u32, 47);
64pub const set_hash = @intToPtr(*const fn (skb: *kern.SkBuff, hash: u32) c_long, 48);
65pub const setsockopt = @intToPtr(*const fn (bpf_socket: *kern.SockOps, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 49);
66pub const skb_adjust_room = @intToPtr(*const fn (skb: *kern.SkBuff, len_diff: i32, mode: u32, flags: u64) c_long, 50);
67pub const redirect_map = @intToPtr(*const fn (map: *const kern.MapDef, key: u32, flags: u64) c_long, 51);
68pub const sk_redirect_map = @intToPtr(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: u32, flags: u64) c_long, 52);
69pub const sock_map_update = @intToPtr(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 53);
70pub const xdp_adjust_meta = @intToPtr(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 54);
71pub const perf_event_read_value = @intToPtr(*const fn (map: *const kern.MapDef, flags: u64, buf: *kern.PerfEventValue, buf_size: u32) c_long, 55);
72pub const perf_prog_read_value = @intToPtr(*const fn (ctx: *kern.PerfEventData, buf: *kern.PerfEventValue, buf_size: u32) c_long, 56);
73pub const getsockopt = @intToPtr(*const fn (bpf_socket: ?*anyopaque, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 57);
74pub const override_return = @intToPtr(*const fn (regs: *PtRegs, rc: u64) c_long, 58);
75pub const sock_ops_cb_flags_set = @intToPtr(*const fn (bpf_sock: *kern.SockOps, argval: c_int) c_long, 59);
76pub const msg_redirect_map = @intToPtr(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: u32, flags: u64) c_long, 60);
77pub const msg_apply_bytes = @intToPtr(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 61);
78pub const msg_cork_bytes = @intToPtr(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 62);
79pub const msg_pull_data = @intToPtr(*const fn (msg: *kern.SkMsgMd, start: u32, end: u32, flags: u64) c_long, 63);
80pub const bind = @intToPtr(*const fn (ctx: *kern.BpfSockAddr, addr: *kern.SockAddr, addr_len: c_int) c_long, 64);
81pub const xdp_adjust_tail = @intToPtr(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 65);
82pub const skb_get_xfrm_state = @intToPtr(*const fn (skb: *kern.SkBuff, index: u32, xfrm_state: *kern.XfrmState, size: u32, flags: u64) c_long, 66);
83pub const get_stack = @intToPtr(*const fn (ctx: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 67);
84pub const skb_load_bytes_relative = @intToPtr(*const fn (skb: ?*const anyopaque, offset: u32, to: ?*anyopaque, len: u32, start_header: u32) c_long, 68);
85pub const fib_lookup = @intToPtr(*const fn (ctx: ?*anyopaque, params: *kern.FibLookup, plen: c_int, flags: u32) c_long, 69);
86pub const sock_hash_update = @intToPtr(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 70);
87pub const msg_redirect_hash = @intToPtr(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 71);
88pub const sk_redirect_hash = @intToPtr(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 72);
89pub const lwt_push_encap = @intToPtr(*const fn (skb: *kern.SkBuff, typ: u32, hdr: ?*anyopaque, len: u32) c_long, 73);
90pub const lwt_seg6_store_bytes = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32) c_long, 74);
91pub const lwt_seg6_adjust_srh = @intToPtr(*const fn (skb: *kern.SkBuff, offset: u32, delta: i32) c_long, 75);
92pub const lwt_seg6_action = @intToPtr(*const fn (skb: *kern.SkBuff, action: u32, param: ?*anyopaque, param_len: u32) c_long, 76);
93pub const rc_repeat = @intToPtr(*const fn (ctx: ?*anyopaque) c_long, 77);
94pub const rc_keydown = @intToPtr(*const fn (ctx: ?*anyopaque, protocol: u32, scancode: u64, toggle: u32) c_long, 78);
95pub const skb_cgroup_id = @intToPtr(*const fn (skb: *kern.SkBuff) u64, 79);
96pub const get_current_cgroup_id = @intToPtr(*const fn () u64, 80);
97pub const get_local_storage = @intToPtr(*const fn (map: ?*anyopaque, flags: u64) ?*anyopaque, 81);
98pub const sk_select_reuseport = @intToPtr(*const fn (reuse: *kern.SkReusePortMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 82);
99pub const skb_ancestor_cgroup_id = @intToPtr(*const fn (skb: *kern.SkBuff, ancestor_level: c_int) u64, 83);
100pub const sk_lookup_tcp = @intToPtr(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 84);
101pub const sk_lookup_udp = @intToPtr(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 85);
102pub const sk_release = @intToPtr(*const fn (sock: *kern.Sock) c_long, 86);
103pub const map_push_elem = @intToPtr(*const fn (map: *const kern.MapDef, value: ?*const anyopaque, flags: u64) c_long, 87);
104pub const map_pop_elem = @intToPtr(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 88);
105pub const map_peek_elem = @intToPtr(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 89);
106pub const msg_push_data = @intToPtr(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 90);
107pub const msg_pop_data = @intToPtr(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 91);
108pub const rc_pointer_rel = @intToPtr(*const fn (ctx: ?*anyopaque, rel_x: i32, rel_y: i32) c_long, 92);
109pub const spin_lock = @intToPtr(*const fn (lock: *kern.SpinLock) c_long, 93);
110pub const spin_unlock = @intToPtr(*const fn (lock: *kern.SpinLock) c_long, 94);
111pub const sk_fullsock = @intToPtr(*const fn (sk: *kern.Sock) ?*SkFullSock, 95);
112pub const tcp_sock = @intToPtr(*const fn (sk: *kern.Sock) ?*kern.TcpSock, 96);
113pub const skb_ecn_set_ce = @intToPtr(*const fn (skb: *kern.SkBuff) c_long, 97);
114pub const get_listener_sock = @intToPtr(*const fn (sk: *kern.Sock) ?*kern.Sock, 98);
115pub const skc_lookup_tcp = @intToPtr(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 99);
116pub const tcp_check_syncookie = @intToPtr(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) c_long, 100);
117pub const sysctl_get_name = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong, flags: u64) c_long, 101);
118pub const sysctl_get_current_value = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 102);
119pub const sysctl_get_new_value = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 103);
120pub const sysctl_set_new_value = @intToPtr(*const fn (ctx: *kern.SysCtl, buf: ?*const u8, buf_len: c_ulong) c_long, 104);
121pub const strtol = @intToPtr(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_long) c_long, 105);
122pub const strtoul = @intToPtr(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_ulong) c_long, 106);
123pub const sk_storage_get = @intToPtr(*const fn (map: *const kern.MapDef, sk: *kern.Sock, value: ?*anyopaque, flags: u64) ?*anyopaque, 107);
124pub const sk_storage_delete = @intToPtr(*const fn (map: *const kern.MapDef, sk: *kern.Sock) c_long, 108);
125pub const send_signal = @intToPtr(*const fn (sig: u32) c_long, 109);
126pub const tcp_gen_syncookie = @intToPtr(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) i64, 110);
127pub const skb_output = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 111);
128pub const probe_read_user = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 112);
129pub const probe_read_kernel = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 113);
130pub const probe_read_user_str = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 114);
131pub const probe_read_kernel_str = @intToPtr(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 115);
132pub const tcp_send_ack = @intToPtr(*const fn (tp: ?*anyopaque, rcv_nxt: u32) c_long, 116);
133pub const send_signal_thread = @intToPtr(*const fn (sig: u32) c_long, 117);
134pub const jiffies64 = @intToPtr(*const fn () u64, 118);
135pub const read_branch_records = @intToPtr(*const fn (ctx: *kern.PerfEventData, buf: ?*anyopaque, size: u32, flags: u64) c_long, 119);
136pub const get_ns_current_pid_tgid = @intToPtr(*const fn (dev: u64, ino: u64, nsdata: *kern.PidNsInfo, size: u32) c_long, 120);
137pub const xdp_output = @intToPtr(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 121);
138pub const get_netns_cookie = @intToPtr(*const fn (ctx: ?*anyopaque) u64, 122);
139pub const get_current_ancestor_cgroup_id = @intToPtr(*const fn (ancestor_level: c_int) u64, 123);
140pub const sk_assign = @intToPtr(*const fn (skb: *kern.SkBuff, sk: *kern.Sock, flags: u64) c_long, 124);
141pub const ktime_get_boot_ns = @intToPtr(*const fn () u64, 125);
142pub const seq_printf = @intToPtr(*const fn (m: *kern.SeqFile, fmt: ?*const u8, fmt_size: u32, data: ?*const anyopaque, data_len: u32) c_long, 126);
143pub const seq_write = @intToPtr(*const fn (m: *kern.SeqFile, data: ?*const u8, len: u32) c_long, 127);
144pub const sk_cgroup_id = @intToPtr(*const fn (sk: *kern.BpfSock) u64, 128);
145pub const sk_ancestor_cgroup_id = @intToPtr(*const fn (sk: *kern.BpfSock, ancestor_level: c_long) u64, 129);
146pub const ringbuf_output = @intToPtr(*const fn (ringbuf: ?*anyopaque, data: ?*anyopaque, size: u64, flags: u64) c_long, 130);
147pub const ringbuf_reserve = @intToPtr(*const fn (ringbuf: ?*anyopaque, size: u64, flags: u64) ?*anyopaque, 131);
148pub const ringbuf_submit = @intToPtr(*const fn (data: ?*anyopaque, flags: u64) void, 132);
149pub const ringbuf_discard = @intToPtr(*const fn (data: ?*anyopaque, flags: u64) void, 133);
150pub const ringbuf_query = @intToPtr(*const fn (ringbuf: ?*anyopaque, flags: u64) u64, 134);
151pub const csum_level = @intToPtr(*const fn (skb: *kern.SkBuff, level: u64) c_long, 135);
152pub const skc_to_tcp6_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.Tcp6Sock, 136);
153pub const skc_to_tcp_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.TcpSock, 137);
154pub const skc_to_tcp_timewait_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.TcpTimewaitSock, 138);
155pub const skc_to_tcp_request_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.TcpRequestSock, 139);
156pub const skc_to_udp6_sock = @intToPtr(*const fn (sk: ?*anyopaque) ?*kern.Udp6Sock, 140);
157pub const get_task_stack = @intToPtr(*const fn (task: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 141);
47pub const skb_change_proto = @ptrFromInt(*const fn (skb: *kern.SkBuff, proto: u16, flags: u64) c_long, 31);
48pub const skb_change_type = @ptrFromInt(*const fn (skb: *kern.SkBuff, skb_type: u32) c_long, 32);
49pub const skb_under_cgroup = @ptrFromInt(*const fn (skb: *kern.SkBuff, map: ?*const anyopaque, index: u32) c_long, 33);
50pub const get_hash_recalc = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 34);
51pub const get_current_task = @ptrFromInt(*const fn () u64, 35);
52pub const probe_write_user = @ptrFromInt(*const fn (dst: ?*anyopaque, src: ?*const anyopaque, len: u32) c_long, 36);
53pub const current_task_under_cgroup = @ptrFromInt(*const fn (map: *const kern.MapDef, index: u32) c_long, 37);
54pub const skb_change_tail = @ptrFromInt(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 38);
55pub const skb_pull_data = @ptrFromInt(*const fn (skb: *kern.SkBuff, len: u32) c_long, 39);
56pub const csum_update = @ptrFromInt(*const fn (skb: *kern.SkBuff, csum: u32) i64, 40);
57pub const set_hash_invalid = @ptrFromInt(*const fn (skb: *kern.SkBuff) void, 41);
58pub const get_numa_node_id = @ptrFromInt(*const fn () c_long, 42);
59pub const skb_change_head = @ptrFromInt(*const fn (skb: *kern.SkBuff, len: u32, flags: u64) c_long, 43);
60pub const xdp_adjust_head = @ptrFromInt(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 44);
61pub const probe_read_str = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 45);
62pub const get_socket_cookie = @ptrFromInt(*const fn (ctx: ?*anyopaque) u64, 46);
63pub const get_socket_uid = @ptrFromInt(*const fn (skb: *kern.SkBuff) u32, 47);
64pub const set_hash = @ptrFromInt(*const fn (skb: *kern.SkBuff, hash: u32) c_long, 48);
65pub const setsockopt = @ptrFromInt(*const fn (bpf_socket: *kern.SockOps, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 49);
66pub const skb_adjust_room = @ptrFromInt(*const fn (skb: *kern.SkBuff, len_diff: i32, mode: u32, flags: u64) c_long, 50);
67pub const redirect_map = @ptrFromInt(*const fn (map: *const kern.MapDef, key: u32, flags: u64) c_long, 51);
68pub const sk_redirect_map = @ptrFromInt(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: u32, flags: u64) c_long, 52);
69pub const sock_map_update = @ptrFromInt(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 53);
70pub const xdp_adjust_meta = @ptrFromInt(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 54);
71pub const perf_event_read_value = @ptrFromInt(*const fn (map: *const kern.MapDef, flags: u64, buf: *kern.PerfEventValue, buf_size: u32) c_long, 55);
72pub const perf_prog_read_value = @ptrFromInt(*const fn (ctx: *kern.PerfEventData, buf: *kern.PerfEventValue, buf_size: u32) c_long, 56);
73pub const getsockopt = @ptrFromInt(*const fn (bpf_socket: ?*anyopaque, level: c_int, optname: c_int, optval: ?*anyopaque, optlen: c_int) c_long, 57);
74pub const override_return = @ptrFromInt(*const fn (regs: *PtRegs, rc: u64) c_long, 58);
75pub const sock_ops_cb_flags_set = @ptrFromInt(*const fn (bpf_sock: *kern.SockOps, argval: c_int) c_long, 59);
76pub const msg_redirect_map = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: u32, flags: u64) c_long, 60);
77pub const msg_apply_bytes = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 61);
78pub const msg_cork_bytes = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, bytes: u32) c_long, 62);
79pub const msg_pull_data = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, start: u32, end: u32, flags: u64) c_long, 63);
80pub const bind = @ptrFromInt(*const fn (ctx: *kern.BpfSockAddr, addr: *kern.SockAddr, addr_len: c_int) c_long, 64);
81pub const xdp_adjust_tail = @ptrFromInt(*const fn (xdp_md: *kern.XdpMd, delta: c_int) c_long, 65);
82pub const skb_get_xfrm_state = @ptrFromInt(*const fn (skb: *kern.SkBuff, index: u32, xfrm_state: *kern.XfrmState, size: u32, flags: u64) c_long, 66);
83pub const get_stack = @ptrFromInt(*const fn (ctx: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 67);
84pub const skb_load_bytes_relative = @ptrFromInt(*const fn (skb: ?*const anyopaque, offset: u32, to: ?*anyopaque, len: u32, start_header: u32) c_long, 68);
85pub const fib_lookup = @ptrFromInt(*const fn (ctx: ?*anyopaque, params: *kern.FibLookup, plen: c_int, flags: u32) c_long, 69);
86pub const sock_hash_update = @ptrFromInt(*const fn (skops: *kern.SockOps, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 70);
87pub const msg_redirect_hash = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 71);
88pub const sk_redirect_hash = @ptrFromInt(*const fn (skb: *kern.SkBuff, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 72);
89pub const lwt_push_encap = @ptrFromInt(*const fn (skb: *kern.SkBuff, typ: u32, hdr: ?*anyopaque, len: u32) c_long, 73);
90pub const lwt_seg6_store_bytes = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, from: ?*const anyopaque, len: u32) c_long, 74);
91pub const lwt_seg6_adjust_srh = @ptrFromInt(*const fn (skb: *kern.SkBuff, offset: u32, delta: i32) c_long, 75);
92pub const lwt_seg6_action = @ptrFromInt(*const fn (skb: *kern.SkBuff, action: u32, param: ?*anyopaque, param_len: u32) c_long, 76);
93pub const rc_repeat = @ptrFromInt(*const fn (ctx: ?*anyopaque) c_long, 77);
94pub const rc_keydown = @ptrFromInt(*const fn (ctx: ?*anyopaque, protocol: u32, scancode: u64, toggle: u32) c_long, 78);
95pub const skb_cgroup_id = @ptrFromInt(*const fn (skb: *kern.SkBuff) u64, 79);
96pub const get_current_cgroup_id = @ptrFromInt(*const fn () u64, 80);
97pub const get_local_storage = @ptrFromInt(*const fn (map: ?*anyopaque, flags: u64) ?*anyopaque, 81);
98pub const sk_select_reuseport = @ptrFromInt(*const fn (reuse: *kern.SkReusePortMd, map: *const kern.MapDef, key: ?*anyopaque, flags: u64) c_long, 82);
99pub const skb_ancestor_cgroup_id = @ptrFromInt(*const fn (skb: *kern.SkBuff, ancestor_level: c_int) u64, 83);
100pub const sk_lookup_tcp = @ptrFromInt(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 84);
101pub const sk_lookup_udp = @ptrFromInt(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 85);
102pub const sk_release = @ptrFromInt(*const fn (sock: *kern.Sock) c_long, 86);
103pub const map_push_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, value: ?*const anyopaque, flags: u64) c_long, 87);
104pub const map_pop_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 88);
105pub const map_peek_elem = @ptrFromInt(*const fn (map: *const kern.MapDef, value: ?*anyopaque) c_long, 89);
106pub const msg_push_data = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 90);
107pub const msg_pop_data = @ptrFromInt(*const fn (msg: *kern.SkMsgMd, start: u32, len: u32, flags: u64) c_long, 91);
108pub const rc_pointer_rel = @ptrFromInt(*const fn (ctx: ?*anyopaque, rel_x: i32, rel_y: i32) c_long, 92);
109pub const spin_lock = @ptrFromInt(*const fn (lock: *kern.SpinLock) c_long, 93);
110pub const spin_unlock = @ptrFromInt(*const fn (lock: *kern.SpinLock) c_long, 94);
111pub const sk_fullsock = @ptrFromInt(*const fn (sk: *kern.Sock) ?*SkFullSock, 95);
112pub const tcp_sock = @ptrFromInt(*const fn (sk: *kern.Sock) ?*kern.TcpSock, 96);
113pub const skb_ecn_set_ce = @ptrFromInt(*const fn (skb: *kern.SkBuff) c_long, 97);
114pub const get_listener_sock = @ptrFromInt(*const fn (sk: *kern.Sock) ?*kern.Sock, 98);
115pub const skc_lookup_tcp = @ptrFromInt(*const fn (ctx: ?*anyopaque, tuple: *kern.SockTuple, tuple_size: u32, netns: u64, flags: u64) ?*kern.Sock, 99);
116pub const tcp_check_syncookie = @ptrFromInt(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) c_long, 100);
117pub const sysctl_get_name = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong, flags: u64) c_long, 101);
118pub const sysctl_get_current_value = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 102);
119pub const sysctl_get_new_value = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*u8, buf_len: c_ulong) c_long, 103);
120pub const sysctl_set_new_value = @ptrFromInt(*const fn (ctx: *kern.SysCtl, buf: ?*const u8, buf_len: c_ulong) c_long, 104);
121pub const strtol = @ptrFromInt(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_long) c_long, 105);
122pub const strtoul = @ptrFromInt(*const fn (buf: *const u8, buf_len: c_ulong, flags: u64, res: *c_ulong) c_long, 106);
123pub const sk_storage_get = @ptrFromInt(*const fn (map: *const kern.MapDef, sk: *kern.Sock, value: ?*anyopaque, flags: u64) ?*anyopaque, 107);
124pub const sk_storage_delete = @ptrFromInt(*const fn (map: *const kern.MapDef, sk: *kern.Sock) c_long, 108);
125pub const send_signal = @ptrFromInt(*const fn (sig: u32) c_long, 109);
126pub const tcp_gen_syncookie = @ptrFromInt(*const fn (sk: *kern.Sock, iph: ?*anyopaque, iph_len: u32, th: *TcpHdr, th_len: u32) i64, 110);
127pub const skb_output = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 111);
128pub const probe_read_user = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 112);
129pub const probe_read_kernel = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 113);
130pub const probe_read_user_str = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 114);
131pub const probe_read_kernel_str = @ptrFromInt(*const fn (dst: ?*anyopaque, size: u32, unsafe_ptr: ?*const anyopaque) c_long, 115);
132pub const tcp_send_ack = @ptrFromInt(*const fn (tp: ?*anyopaque, rcv_nxt: u32) c_long, 116);
133pub const send_signal_thread = @ptrFromInt(*const fn (sig: u32) c_long, 117);
134pub const jiffies64 = @ptrFromInt(*const fn () u64, 118);
135pub const read_branch_records = @ptrFromInt(*const fn (ctx: *kern.PerfEventData, buf: ?*anyopaque, size: u32, flags: u64) c_long, 119);
136pub const get_ns_current_pid_tgid = @ptrFromInt(*const fn (dev: u64, ino: u64, nsdata: *kern.PidNsInfo, size: u32) c_long, 120);
137pub const xdp_output = @ptrFromInt(*const fn (ctx: ?*anyopaque, map: *const kern.MapDef, flags: u64, data: ?*anyopaque, size: u64) c_long, 121);
138pub const get_netns_cookie = @ptrFromInt(*const fn (ctx: ?*anyopaque) u64, 122);
139pub const get_current_ancestor_cgroup_id = @ptrFromInt(*const fn (ancestor_level: c_int) u64, 123);
140pub const sk_assign = @ptrFromInt(*const fn (skb: *kern.SkBuff, sk: *kern.Sock, flags: u64) c_long, 124);
141pub const ktime_get_boot_ns = @ptrFromInt(*const fn () u64, 125);
142pub const seq_printf = @ptrFromInt(*const fn (m: *kern.SeqFile, fmt: ?*const u8, fmt_size: u32, data: ?*const anyopaque, data_len: u32) c_long, 126);
143pub const seq_write = @ptrFromInt(*const fn (m: *kern.SeqFile, data: ?*const u8, len: u32) c_long, 127);
144pub const sk_cgroup_id = @ptrFromInt(*const fn (sk: *kern.BpfSock) u64, 128);
145pub const sk_ancestor_cgroup_id = @ptrFromInt(*const fn (sk: *kern.BpfSock, ancestor_level: c_long) u64, 129);
146pub const ringbuf_output = @ptrFromInt(*const fn (ringbuf: ?*anyopaque, data: ?*anyopaque, size: u64, flags: u64) c_long, 130);
147pub const ringbuf_reserve = @ptrFromInt(*const fn (ringbuf: ?*anyopaque, size: u64, flags: u64) ?*anyopaque, 131);
148pub const ringbuf_submit = @ptrFromInt(*const fn (data: ?*anyopaque, flags: u64) void, 132);
149pub const ringbuf_discard = @ptrFromInt(*const fn (data: ?*anyopaque, flags: u64) void, 133);
150pub const ringbuf_query = @ptrFromInt(*const fn (ringbuf: ?*anyopaque, flags: u64) u64, 134);
151pub const csum_level = @ptrFromInt(*const fn (skb: *kern.SkBuff, level: u64) c_long, 135);
152pub const skc_to_tcp6_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.Tcp6Sock, 136);
153pub const skc_to_tcp_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.TcpSock, 137);
154pub const skc_to_tcp_timewait_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.TcpTimewaitSock, 138);
155pub const skc_to_tcp_request_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.TcpRequestSock, 139);
156pub const skc_to_udp6_sock = @ptrFromInt(*const fn (sk: ?*anyopaque) ?*kern.Udp6Sock, 140);
157pub const get_task_stack = @ptrFromInt(*const fn (task: ?*anyopaque, buf: ?*anyopaque, size: u32, flags: u64) c_long, 141);
lib/std/os/linux/io_uring.zig+40-40
......@@ -962,7 +962,7 @@ pub const IO_Uring = struct {
962962 var update = FilesUpdate{
963963 .offset = offset,
964964 .resv = @as(u32, 0),
965 .fds = @as(u64, @ptrToInt(fds.ptr)),
965 .fds = @as(u64, @intFromPtr(fds.ptr)),
966966 };
967967
968968 const res = linux.io_uring_register(
......@@ -1244,11 +1244,11 @@ pub fn io_uring_prep_rw(
12441244}
12451245
12461246pub fn io_uring_prep_read(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, offset: u64) void {
1247 io_uring_prep_rw(.READ, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset);
1247 io_uring_prep_rw(.READ, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, offset);
12481248}
12491249
12501250pub fn io_uring_prep_write(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, offset: u64) void {
1251 io_uring_prep_rw(.WRITE, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, offset);
1251 io_uring_prep_rw(.WRITE, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, offset);
12521252}
12531253
12541254pub fn io_uring_prep_readv(
......@@ -1257,7 +1257,7 @@ pub fn io_uring_prep_readv(
12571257 iovecs: []const os.iovec,
12581258 offset: u64,
12591259) void {
1260 io_uring_prep_rw(.READV, sqe, fd, @ptrToInt(iovecs.ptr), iovecs.len, offset);
1260 io_uring_prep_rw(.READV, sqe, fd, @intFromPtr(iovecs.ptr), iovecs.len, offset);
12611261}
12621262
12631263pub fn io_uring_prep_writev(
......@@ -1266,16 +1266,16 @@ pub fn io_uring_prep_writev(
12661266 iovecs: []const os.iovec_const,
12671267 offset: u64,
12681268) void {
1269 io_uring_prep_rw(.WRITEV, sqe, fd, @ptrToInt(iovecs.ptr), iovecs.len, offset);
1269 io_uring_prep_rw(.WRITEV, sqe, fd, @intFromPtr(iovecs.ptr), iovecs.len, offset);
12701270}
12711271
12721272pub fn io_uring_prep_read_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void {
1273 io_uring_prep_rw(.READ_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset);
1273 io_uring_prep_rw(.READ_FIXED, sqe, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset);
12741274 sqe.buf_index = buffer_index;
12751275}
12761276
12771277pub fn io_uring_prep_write_fixed(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: *os.iovec, offset: u64, buffer_index: u16) void {
1278 io_uring_prep_rw(.WRITE_FIXED, sqe, fd, @ptrToInt(buffer.iov_base), buffer.iov_len, offset);
1278 io_uring_prep_rw(.WRITE_FIXED, sqe, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset);
12791279 sqe.buf_index = buffer_index;
12801280}
12811281
......@@ -1298,7 +1298,7 @@ pub fn io_uring_prep_accept(
12981298) void {
12991299 // `addr` holds a pointer to `sockaddr`, and `addr2` holds a pointer to socklen_t`.
13001300 // `addr2` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32).
1301 io_uring_prep_rw(.ACCEPT, sqe, fd, @ptrToInt(addr), 0, @ptrToInt(addrlen));
1301 io_uring_prep_rw(.ACCEPT, sqe, fd, @intFromPtr(addr), 0, @intFromPtr(addrlen));
13021302 sqe.rw_flags = flags;
13031303}
13041304
......@@ -1309,7 +1309,7 @@ pub fn io_uring_prep_connect(
13091309 addrlen: os.socklen_t,
13101310) void {
13111311 // `addrlen` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32).
1312 io_uring_prep_rw(.CONNECT, sqe, fd, @ptrToInt(addr), 0, addrlen);
1312 io_uring_prep_rw(.CONNECT, sqe, fd, @intFromPtr(addr), 0, addrlen);
13131313}
13141314
13151315pub fn io_uring_prep_epoll_ctl(
......@@ -1319,16 +1319,16 @@ pub fn io_uring_prep_epoll_ctl(
13191319 op: u32,
13201320 ev: ?*linux.epoll_event,
13211321) void {
1322 io_uring_prep_rw(.EPOLL_CTL, sqe, epfd, @ptrToInt(ev), op, @intCast(u64, fd));
1322 io_uring_prep_rw(.EPOLL_CTL, sqe, epfd, @intFromPtr(ev), op, @intCast(u64, fd));
13231323}
13241324
13251325pub fn io_uring_prep_recv(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []u8, flags: u32) void {
1326 io_uring_prep_rw(.RECV, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0);
1326 io_uring_prep_rw(.RECV, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, 0);
13271327 sqe.rw_flags = flags;
13281328}
13291329
13301330pub fn io_uring_prep_send(sqe: *linux.io_uring_sqe, fd: os.fd_t, buffer: []const u8, flags: u32) void {
1331 io_uring_prep_rw(.SEND, sqe, fd, @ptrToInt(buffer.ptr), buffer.len, 0);
1331 io_uring_prep_rw(.SEND, sqe, fd, @intFromPtr(buffer.ptr), buffer.len, 0);
13321332 sqe.rw_flags = flags;
13331333}
13341334
......@@ -1338,7 +1338,7 @@ pub fn io_uring_prep_recvmsg(
13381338 msg: *os.msghdr,
13391339 flags: u32,
13401340) void {
1341 linux.io_uring_prep_rw(.RECVMSG, sqe, fd, @ptrToInt(msg), 1, 0);
1341 linux.io_uring_prep_rw(.RECVMSG, sqe, fd, @intFromPtr(msg), 1, 0);
13421342 sqe.rw_flags = flags;
13431343}
13441344
......@@ -1348,7 +1348,7 @@ pub fn io_uring_prep_sendmsg(
13481348 msg: *const os.msghdr_const,
13491349 flags: u32,
13501350) void {
1351 linux.io_uring_prep_rw(.SENDMSG, sqe, fd, @ptrToInt(msg), 1, 0);
1351 linux.io_uring_prep_rw(.SENDMSG, sqe, fd, @intFromPtr(msg), 1, 0);
13521352 sqe.rw_flags = flags;
13531353}
13541354
......@@ -1359,7 +1359,7 @@ pub fn io_uring_prep_openat(
13591359 flags: u32,
13601360 mode: os.mode_t,
13611361) void {
1362 io_uring_prep_rw(.OPENAT, sqe, fd, @ptrToInt(path), mode, 0);
1362 io_uring_prep_rw(.OPENAT, sqe, fd, @intFromPtr(path), mode, 0);
13631363 sqe.rw_flags = flags;
13641364}
13651365
......@@ -1387,7 +1387,7 @@ pub fn io_uring_prep_timeout(
13871387 count: u32,
13881388 flags: u32,
13891389) void {
1390 io_uring_prep_rw(.TIMEOUT, sqe, -1, @ptrToInt(ts), 1, count);
1390 io_uring_prep_rw(.TIMEOUT, sqe, -1, @intFromPtr(ts), 1, count);
13911391 sqe.rw_flags = flags;
13921392}
13931393
......@@ -1414,7 +1414,7 @@ pub fn io_uring_prep_link_timeout(
14141414 ts: *const os.linux.kernel_timespec,
14151415 flags: u32,
14161416) void {
1417 linux.io_uring_prep_rw(.LINK_TIMEOUT, sqe, -1, @ptrToInt(ts), 1, 0);
1417 linux.io_uring_prep_rw(.LINK_TIMEOUT, sqe, -1, @intFromPtr(ts), 1, 0);
14181418 sqe.rw_flags = flags;
14191419}
14201420
......@@ -1423,7 +1423,7 @@ pub fn io_uring_prep_poll_add(
14231423 fd: os.fd_t,
14241424 poll_mask: u32,
14251425) void {
1426 io_uring_prep_rw(.POLL_ADD, sqe, fd, @ptrToInt(@as(?*anyopaque, null)), 0, 0);
1426 io_uring_prep_rw(.POLL_ADD, sqe, fd, @intFromPtr(@as(?*anyopaque, null)), 0, 0);
14271427 sqe.rw_flags = __io_uring_prep_poll_mask(poll_mask);
14281428}
14291429
......@@ -1477,7 +1477,7 @@ pub fn io_uring_prep_statx(
14771477 mask: u32,
14781478 buf: *linux.Statx,
14791479) void {
1480 io_uring_prep_rw(.STATX, sqe, fd, @ptrToInt(path), mask, @ptrToInt(buf));
1480 io_uring_prep_rw(.STATX, sqe, fd, @intFromPtr(path), mask, @intFromPtr(buf));
14811481 sqe.rw_flags = flags;
14821482}
14831483
......@@ -1510,9 +1510,9 @@ pub fn io_uring_prep_renameat(
15101510 .RENAMEAT,
15111511 sqe,
15121512 old_dir_fd,
1513 @ptrToInt(old_path),
1513 @intFromPtr(old_path),
15141514 0,
1515 @ptrToInt(new_path),
1515 @intFromPtr(new_path),
15161516 );
15171517 sqe.len = @bitCast(u32, new_dir_fd);
15181518 sqe.rw_flags = flags;
......@@ -1524,7 +1524,7 @@ pub fn io_uring_prep_unlinkat(
15241524 path: [*:0]const u8,
15251525 flags: u32,
15261526) void {
1527 io_uring_prep_rw(.UNLINKAT, sqe, dir_fd, @ptrToInt(path), 0, 0);
1527 io_uring_prep_rw(.UNLINKAT, sqe, dir_fd, @intFromPtr(path), 0, 0);
15281528 sqe.rw_flags = flags;
15291529}
15301530
......@@ -1534,7 +1534,7 @@ pub fn io_uring_prep_mkdirat(
15341534 path: [*:0]const u8,
15351535 mode: os.mode_t,
15361536) void {
1537 io_uring_prep_rw(.MKDIRAT, sqe, dir_fd, @ptrToInt(path), mode, 0);
1537 io_uring_prep_rw(.MKDIRAT, sqe, dir_fd, @intFromPtr(path), mode, 0);
15381538}
15391539
15401540pub fn io_uring_prep_symlinkat(
......@@ -1547,9 +1547,9 @@ pub fn io_uring_prep_symlinkat(
15471547 .SYMLINKAT,
15481548 sqe,
15491549 new_dir_fd,
1550 @ptrToInt(target),
1550 @intFromPtr(target),
15511551 0,
1552 @ptrToInt(link_path),
1552 @intFromPtr(link_path),
15531553 );
15541554}
15551555
......@@ -1565,9 +1565,9 @@ pub fn io_uring_prep_linkat(
15651565 .LINKAT,
15661566 sqe,
15671567 old_dir_fd,
1568 @ptrToInt(old_path),
1568 @intFromPtr(old_path),
15691569 0,
1570 @ptrToInt(new_path),
1570 @intFromPtr(new_path),
15711571 );
15721572 sqe.len = @bitCast(u32, new_dir_fd);
15731573 sqe.rw_flags = flags;
......@@ -1581,7 +1581,7 @@ pub fn io_uring_prep_provide_buffers(
15811581 group_id: usize,
15821582 buffer_id: usize,
15831583) void {
1584 const ptr = @ptrToInt(buffers);
1584 const ptr = @intFromPtr(buffers);
15851585 io_uring_prep_rw(.PROVIDE_BUFFERS, sqe, @intCast(i32, num), ptr, buffer_len, buffer_id);
15861586 sqe.buf_index = @intCast(u16, group_id);
15871587}
......@@ -1918,8 +1918,8 @@ test "openat" {
19181918 // Workaround for LLVM bug: https://github.com/ziglang/zig/issues/12014
19191919 const path_addr = if (builtin.zig_backend == .stage2_llvm) p: {
19201920 var workaround = path;
1921 break :p @ptrToInt(workaround);
1922 } else @ptrToInt(path);
1921 break :p @intFromPtr(workaround);
1922 } else @intFromPtr(path);
19231923
19241924 const flags: u32 = os.O.CLOEXEC | os.O.RDWR | os.O.CREAT;
19251925 const mode: os.mode_t = 0o666;
......@@ -2098,7 +2098,7 @@ test "sendmsg/recvmsg" {
20982098 try testing.expectEqual(@as(u32, 2), ring.cq_ready());
20992099
21002100 const cqe_sendmsg = try ring.copy_cqe();
2101 if (cqe_sendmsg.res == -@as(i32, @enumToInt(linux.E.INVAL))) return error.SkipZigTest;
2101 if (cqe_sendmsg.res == -@as(i32, @intFromEnum(linux.E.INVAL))) return error.SkipZigTest;
21022102 try testing.expectEqual(linux.io_uring_cqe{
21032103 .user_data = 0x11111111,
21042104 .res = buffer_send.len,
......@@ -2106,7 +2106,7 @@ test "sendmsg/recvmsg" {
21062106 }, cqe_sendmsg);
21072107
21082108 const cqe_recvmsg = try ring.copy_cqe();
2109 if (cqe_recvmsg.res == -@as(i32, @enumToInt(linux.E.INVAL))) return error.SkipZigTest;
2109 if (cqe_recvmsg.res == -@as(i32, @intFromEnum(linux.E.INVAL))) return error.SkipZigTest;
21102110 try testing.expectEqual(linux.io_uring_cqe{
21112111 .user_data = 0x22222222,
21122112 .res = buffer_recv.len,
......@@ -2140,12 +2140,12 @@ test "timeout (after a relative time)" {
21402140
21412141 try testing.expectEqual(linux.io_uring_cqe{
21422142 .user_data = 0x55555555,
2143 .res = -@as(i32, @enumToInt(linux.E.TIME)),
2143 .res = -@as(i32, @intFromEnum(linux.E.TIME)),
21442144 .flags = 0,
21452145 }, cqe);
21462146
21472147 // Tests should not depend on timings: skip test if outside margin.
2148 if (!std.math.approxEqAbs(f64, ms, @intToFloat(f64, stopped - started), margin)) return error.SkipZigTest;
2148 if (!std.math.approxEqAbs(f64, ms, @floatFromInt(f64, stopped - started), margin)) return error.SkipZigTest;
21492149}
21502150
21512151test "timeout (after a number of completions)" {
......@@ -2227,7 +2227,7 @@ test "timeout_remove" {
22272227 if (cqe.user_data == 0x88888888) {
22282228 try testing.expectEqual(linux.io_uring_cqe{
22292229 .user_data = 0x88888888,
2230 .res = -@as(i32, @enumToInt(linux.E.CANCELED)),
2230 .res = -@as(i32, @intFromEnum(linux.E.CANCELED)),
22312231 .flags = 0,
22322232 }, cqe);
22332233 } else if (cqe.user_data == 0x99999999) {
......@@ -2274,16 +2274,16 @@ test "accept/connect/recv/link_timeout" {
22742274 const cqe = try ring.copy_cqe();
22752275 switch (cqe.user_data) {
22762276 0xffffffff => {
2277 if (cqe.res != -@as(i32, @enumToInt(linux.E.INTR)) and
2278 cqe.res != -@as(i32, @enumToInt(linux.E.CANCELED)))
2277 if (cqe.res != -@as(i32, @intFromEnum(linux.E.INTR)) and
2278 cqe.res != -@as(i32, @intFromEnum(linux.E.CANCELED)))
22792279 {
22802280 std.debug.print("Req 0x{x} got {d}\n", .{ cqe.user_data, cqe.res });
22812281 try testing.expect(false);
22822282 }
22832283 },
22842284 0x22222222 => {
2285 if (cqe.res != -@as(i32, @enumToInt(linux.E.ALREADY)) and
2286 cqe.res != -@as(i32, @enumToInt(linux.E.TIME)))
2285 if (cqe.res != -@as(i32, @intFromEnum(linux.E.ALREADY)) and
2286 cqe.res != -@as(i32, @intFromEnum(linux.E.TIME)))
22872287 {
22882288 std.debug.print("Req 0x{x} got {d}\n", .{ cqe.user_data, cqe.res });
22892289 try testing.expect(false);
......@@ -2439,7 +2439,7 @@ test "accept/connect/recv/cancel" {
24392439
24402440 try testing.expectEqual(linux.io_uring_cqe{
24412441 .user_data = 0xffffffff,
2442 .res = -@as(i32, @enumToInt(linux.E.CANCELED)),
2442 .res = -@as(i32, @intFromEnum(linux.E.CANCELED)),
24432443 .flags = 0,
24442444 }, cqe_recv);
24452445
lib/std/os/linux/mips.zig+11-11
......@@ -18,7 +18,7 @@ pub fn syscall0(number: SYS) usize {
1818 \\ subu $2, $0, $2
1919 \\ 1:
2020 : [ret] "={$2}" (-> usize),
21 : [number] "{$2}" (@enumToInt(number)),
21 : [number] "{$2}" (@intFromEnum(number)),
2222 : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
2323 );
2424}
......@@ -37,7 +37,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
3737 \\ sw $3, 4($4)
3838 \\ 2:
3939 : [ret] "={$2}" (-> usize),
40 : [number] "{$2}" (@enumToInt(SYS.pipe)),
40 : [number] "{$2}" (@intFromEnum(SYS.pipe)),
4141 [fd] "{$4}" (fd),
4242 : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
4343 );
......@@ -50,7 +50,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
5050 \\ subu $2, $0, $2
5151 \\ 1:
5252 : [ret] "={$2}" (-> usize),
53 : [number] "{$2}" (@enumToInt(number)),
53 : [number] "{$2}" (@intFromEnum(number)),
5454 [arg1] "{$4}" (arg1),
5555 : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
5656 );
......@@ -63,7 +63,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
6363 \\ subu $2, $0, $2
6464 \\ 1:
6565 : [ret] "={$2}" (-> usize),
66 : [number] "{$2}" (@enumToInt(number)),
66 : [number] "{$2}" (@intFromEnum(number)),
6767 [arg1] "{$4}" (arg1),
6868 [arg2] "{$5}" (arg2),
6969 : "$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 {
7777 \\ subu $2, $0, $2
7878 \\ 1:
7979 : [ret] "={$2}" (-> usize),
80 : [number] "{$2}" (@enumToInt(number)),
80 : [number] "{$2}" (@intFromEnum(number)),
8181 [arg1] "{$4}" (arg1),
8282 [arg2] "{$5}" (arg2),
8383 [arg3] "{$6}" (arg3),
......@@ -92,7 +92,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
9292 \\ subu $2, $0, $2
9393 \\ 1:
9494 : [ret] "={$2}" (-> usize),
95 : [number] "{$2}" (@enumToInt(number)),
95 : [number] "{$2}" (@intFromEnum(number)),
9696 [arg1] "{$4}" (arg1),
9797 [arg2] "{$5}" (arg2),
9898 [arg3] "{$6}" (arg3),
......@@ -112,7 +112,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
112112 \\ subu $2, $0, $2
113113 \\ 1:
114114 : [ret] "={$2}" (-> usize),
115 : [number] "{$2}" (@enumToInt(number)),
115 : [number] "{$2}" (@intFromEnum(number)),
116116 [arg1] "{$4}" (arg1),
117117 [arg2] "{$5}" (arg2),
118118 [arg3] "{$6}" (arg3),
......@@ -145,7 +145,7 @@ pub fn syscall6(
145145 \\ subu $2, $0, $2
146146 \\ 1:
147147 : [ret] "={$2}" (-> usize),
148 : [number] "{$2}" (@enumToInt(number)),
148 : [number] "{$2}" (@intFromEnum(number)),
149149 [arg1] "{$4}" (arg1),
150150 [arg2] "{$5}" (arg2),
151151 [arg3] "{$6}" (arg3),
......@@ -178,7 +178,7 @@ pub fn syscall7(
178178 \\ subu $2, $0, $2
179179 \\ 1:
180180 : [ret] "={$2}" (-> usize),
181 : [number] "{$2}" (@enumToInt(number)),
181 : [number] "{$2}" (@intFromEnum(number)),
182182 [arg1] "{$4}" (arg1),
183183 [arg2] "{$5}" (arg2),
184184 [arg3] "{$6}" (arg3),
......@@ -198,7 +198,7 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *
198198pub fn restore() callconv(.Naked) void {
199199 return asm volatile ("syscall"
200200 :
201 : [number] "{$2}" (@enumToInt(SYS.sigreturn)),
201 : [number] "{$2}" (@intFromEnum(SYS.sigreturn)),
202202 : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
203203 );
204204}
......@@ -206,7 +206,7 @@ pub fn restore() callconv(.Naked) void {
206206pub fn restore_rt() callconv(.Naked) void {
207207 return asm volatile ("syscall"
208208 :
209 : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)),
209 : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)),
210210 : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
211211 );
212212}
lib/std/os/linux/mips64.zig+11-11
......@@ -18,7 +18,7 @@ pub fn syscall0(number: SYS) usize {
1818 \\ dsubu $2, $0, $2
1919 \\ 1:
2020 : [ret] "={$2}" (-> usize),
21 : [number] "{$2}" (@enumToInt(number)),
21 : [number] "{$2}" (@intFromEnum(number)),
2222 : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
2323 );
2424}
......@@ -37,7 +37,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
3737 \\ sw $3, 4($4)
3838 \\ 2:
3939 : [ret] "={$2}" (-> usize),
40 : [number] "{$2}" (@enumToInt(SYS.pipe)),
40 : [number] "{$2}" (@intFromEnum(SYS.pipe)),
4141 [fd] "{$4}" (fd),
4242 : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
4343 );
......@@ -50,7 +50,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
5050 \\ dsubu $2, $0, $2
5151 \\ 1:
5252 : [ret] "={$2}" (-> usize),
53 : [number] "{$2}" (@enumToInt(number)),
53 : [number] "{$2}" (@intFromEnum(number)),
5454 [arg1] "{$4}" (arg1),
5555 : "$1", "$3", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
5656 );
......@@ -63,7 +63,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
6363 \\ dsubu $2, $0, $2
6464 \\ 1:
6565 : [ret] "={$2}" (-> usize),
66 : [number] "{$2}" (@enumToInt(number)),
66 : [number] "{$2}" (@intFromEnum(number)),
6767 [arg1] "{$4}" (arg1),
6868 [arg2] "{$5}" (arg2),
6969 : "$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 {
7777 \\ dsubu $2, $0, $2
7878 \\ 1:
7979 : [ret] "={$2}" (-> usize),
80 : [number] "{$2}" (@enumToInt(number)),
80 : [number] "{$2}" (@intFromEnum(number)),
8181 [arg1] "{$4}" (arg1),
8282 [arg2] "{$5}" (arg2),
8383 [arg3] "{$6}" (arg3),
......@@ -92,7 +92,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
9292 \\ dsubu $2, $0, $2
9393 \\ 1:
9494 : [ret] "={$2}" (-> usize),
95 : [number] "{$2}" (@enumToInt(number)),
95 : [number] "{$2}" (@intFromEnum(number)),
9696 [arg1] "{$4}" (arg1),
9797 [arg2] "{$5}" (arg2),
9898 [arg3] "{$6}" (arg3),
......@@ -108,7 +108,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
108108 \\ dsubu $2, $0, $2
109109 \\ 1:
110110 : [ret] "={$2}" (-> usize),
111 : [number] "{$2}" (@enumToInt(number)),
111 : [number] "{$2}" (@intFromEnum(number)),
112112 [arg1] "{$4}" (arg1),
113113 [arg2] "{$5}" (arg2),
114114 [arg3] "{$6}" (arg3),
......@@ -136,7 +136,7 @@ pub fn syscall6(
136136 \\ dsubu $2, $0, $2
137137 \\ 1:
138138 : [ret] "={$2}" (-> usize),
139 : [number] "{$2}" (@enumToInt(number)),
139 : [number] "{$2}" (@intFromEnum(number)),
140140 [arg1] "{$4}" (arg1),
141141 [arg2] "{$5}" (arg2),
142142 [arg3] "{$6}" (arg3),
......@@ -163,7 +163,7 @@ pub fn syscall7(
163163 \\ dsubu $2, $0, $2
164164 \\ 1:
165165 : [ret] "={$2}" (-> usize),
166 : [number] "{$2}" (@enumToInt(number)),
166 : [number] "{$2}" (@intFromEnum(number)),
167167 [arg1] "{$4}" (arg1),
168168 [arg2] "{$5}" (arg2),
169169 [arg3] "{$6}" (arg3),
......@@ -183,7 +183,7 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *
183183pub fn restore() callconv(.Naked) void {
184184 return asm volatile ("syscall"
185185 :
186 : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)),
186 : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)),
187187 : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
188188 );
189189}
......@@ -191,7 +191,7 @@ pub fn restore() callconv(.Naked) void {
191191pub fn restore_rt() callconv(.Naked) void {
192192 return asm volatile ("syscall"
193193 :
194 : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)),
194 : [number] "{$2}" (@intFromEnum(SYS.rt_sigreturn)),
195195 : "$1", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", "hi", "lo", "memory"
196196 );
197197}
lib/std/os/linux/powerpc.zig+8-8
......@@ -20,7 +20,7 @@ pub fn syscall0(number: SYS) usize {
2020 \\ neg 3, 3
2121 \\ 1:
2222 : [ret] "={r3}" (-> usize),
23 : [number] "{r0}" (@enumToInt(number)),
23 : [number] "{r0}" (@intFromEnum(number)),
2424 : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
2525 );
2626}
......@@ -32,7 +32,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3232 \\ neg 3, 3
3333 \\ 1:
3434 : [ret] "={r3}" (-> usize),
35 : [number] "{r0}" (@enumToInt(number)),
35 : [number] "{r0}" (@intFromEnum(number)),
3636 [arg1] "{r3}" (arg1),
3737 : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
3838 );
......@@ -45,7 +45,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4545 \\ neg 3, 3
4646 \\ 1:
4747 : [ret] "={r3}" (-> usize),
48 : [number] "{r0}" (@enumToInt(number)),
48 : [number] "{r0}" (@intFromEnum(number)),
4949 [arg1] "{r3}" (arg1),
5050 [arg2] "{r4}" (arg2),
5151 : "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 {
5959 \\ neg 3, 3
6060 \\ 1:
6161 : [ret] "={r3}" (-> usize),
62 : [number] "{r0}" (@enumToInt(number)),
62 : [number] "{r0}" (@intFromEnum(number)),
6363 [arg1] "{r3}" (arg1),
6464 [arg2] "{r4}" (arg2),
6565 [arg3] "{r5}" (arg3),
......@@ -74,7 +74,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
7474 \\ neg 3, 3
7575 \\ 1:
7676 : [ret] "={r3}" (-> usize),
77 : [number] "{r0}" (@enumToInt(number)),
77 : [number] "{r0}" (@intFromEnum(number)),
7878 [arg1] "{r3}" (arg1),
7979 [arg2] "{r4}" (arg2),
8080 [arg3] "{r5}" (arg3),
......@@ -90,7 +90,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
9090 \\ neg 3, 3
9191 \\ 1:
9292 : [ret] "={r3}" (-> usize),
93 : [number] "{r0}" (@enumToInt(number)),
93 : [number] "{r0}" (@intFromEnum(number)),
9494 [arg1] "{r3}" (arg1),
9595 [arg2] "{r4}" (arg2),
9696 [arg3] "{r5}" (arg3),
......@@ -115,7 +115,7 @@ pub fn syscall6(
115115 \\ neg 3, 3
116116 \\ 1:
117117 : [ret] "={r3}" (-> usize),
118 : [number] "{r0}" (@enumToInt(number)),
118 : [number] "{r0}" (@intFromEnum(number)),
119119 [arg1] "{r3}" (arg1),
120120 [arg2] "{r4}" (arg2),
121121 [arg3] "{r5}" (arg3),
......@@ -136,7 +136,7 @@ pub const restore = restore_rt;
136136pub fn restore_rt() callconv(.Naked) void {
137137 return asm volatile ("sc"
138138 :
139 : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)),
139 : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)),
140140 : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
141141 );
142142}
lib/std/os/linux/powerpc64.zig+8-8
......@@ -20,7 +20,7 @@ pub fn syscall0(number: SYS) usize {
2020 \\ neg 3, 3
2121 \\ 1:
2222 : [ret] "={r3}" (-> usize),
23 : [number] "{r0}" (@enumToInt(number)),
23 : [number] "{r0}" (@intFromEnum(number)),
2424 : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
2525 );
2626}
......@@ -32,7 +32,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3232 \\ neg 3, 3
3333 \\ 1:
3434 : [ret] "={r3}" (-> usize),
35 : [number] "{r0}" (@enumToInt(number)),
35 : [number] "{r0}" (@intFromEnum(number)),
3636 [arg1] "{r3}" (arg1),
3737 : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
3838 );
......@@ -45,7 +45,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4545 \\ neg 3, 3
4646 \\ 1:
4747 : [ret] "={r3}" (-> usize),
48 : [number] "{r0}" (@enumToInt(number)),
48 : [number] "{r0}" (@intFromEnum(number)),
4949 [arg1] "{r3}" (arg1),
5050 [arg2] "{r4}" (arg2),
5151 : "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 {
5959 \\ neg 3, 3
6060 \\ 1:
6161 : [ret] "={r3}" (-> usize),
62 : [number] "{r0}" (@enumToInt(number)),
62 : [number] "{r0}" (@intFromEnum(number)),
6363 [arg1] "{r3}" (arg1),
6464 [arg2] "{r4}" (arg2),
6565 [arg3] "{r5}" (arg3),
......@@ -74,7 +74,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
7474 \\ neg 3, 3
7575 \\ 1:
7676 : [ret] "={r3}" (-> usize),
77 : [number] "{r0}" (@enumToInt(number)),
77 : [number] "{r0}" (@intFromEnum(number)),
7878 [arg1] "{r3}" (arg1),
7979 [arg2] "{r4}" (arg2),
8080 [arg3] "{r5}" (arg3),
......@@ -90,7 +90,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
9090 \\ neg 3, 3
9191 \\ 1:
9292 : [ret] "={r3}" (-> usize),
93 : [number] "{r0}" (@enumToInt(number)),
93 : [number] "{r0}" (@intFromEnum(number)),
9494 [arg1] "{r3}" (arg1),
9595 [arg2] "{r4}" (arg2),
9696 [arg3] "{r5}" (arg3),
......@@ -115,7 +115,7 @@ pub fn syscall6(
115115 \\ neg 3, 3
116116 \\ 1:
117117 : [ret] "={r3}" (-> usize),
118 : [number] "{r0}" (@enumToInt(number)),
118 : [number] "{r0}" (@intFromEnum(number)),
119119 [arg1] "{r3}" (arg1),
120120 [arg2] "{r4}" (arg2),
121121 [arg3] "{r5}" (arg3),
......@@ -136,7 +136,7 @@ pub const restore = restore_rt;
136136pub fn restore_rt() callconv(.Naked) void {
137137 return asm volatile ("sc"
138138 :
139 : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)),
139 : [number] "{r0}" (@intFromEnum(SYS.rt_sigreturn)),
140140 : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
141141 );
142142}
lib/std/os/linux/riscv64.zig+8-8
......@@ -13,7 +13,7 @@ const timespec = std.os.linux.timespec;
1313pub fn syscall0(number: SYS) usize {
1414 return asm volatile ("ecall"
1515 : [ret] "={x10}" (-> usize),
16 : [number] "{x17}" (@enumToInt(number)),
16 : [number] "{x17}" (@intFromEnum(number)),
1717 : "memory"
1818 );
1919}
......@@ -21,7 +21,7 @@ pub fn syscall0(number: SYS) usize {
2121pub fn syscall1(number: SYS, arg1: usize) usize {
2222 return asm volatile ("ecall"
2323 : [ret] "={x10}" (-> usize),
24 : [number] "{x17}" (@enumToInt(number)),
24 : [number] "{x17}" (@intFromEnum(number)),
2525 [arg1] "{x10}" (arg1),
2626 : "memory"
2727 );
......@@ -30,7 +30,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3030pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
3131 return asm volatile ("ecall"
3232 : [ret] "={x10}" (-> usize),
33 : [number] "{x17}" (@enumToInt(number)),
33 : [number] "{x17}" (@intFromEnum(number)),
3434 [arg1] "{x10}" (arg1),
3535 [arg2] "{x11}" (arg2),
3636 : "memory"
......@@ -40,7 +40,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4040pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
4141 return asm volatile ("ecall"
4242 : [ret] "={x10}" (-> usize),
43 : [number] "{x17}" (@enumToInt(number)),
43 : [number] "{x17}" (@intFromEnum(number)),
4444 [arg1] "{x10}" (arg1),
4545 [arg2] "{x11}" (arg2),
4646 [arg3] "{x12}" (arg3),
......@@ -51,7 +51,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
5151pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
5252 return asm volatile ("ecall"
5353 : [ret] "={x10}" (-> usize),
54 : [number] "{x17}" (@enumToInt(number)),
54 : [number] "{x17}" (@intFromEnum(number)),
5555 [arg1] "{x10}" (arg1),
5656 [arg2] "{x11}" (arg2),
5757 [arg3] "{x12}" (arg3),
......@@ -63,7 +63,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
6363pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
6464 return asm volatile ("ecall"
6565 : [ret] "={x10}" (-> usize),
66 : [number] "{x17}" (@enumToInt(number)),
66 : [number] "{x17}" (@intFromEnum(number)),
6767 [arg1] "{x10}" (arg1),
6868 [arg2] "{x11}" (arg2),
6969 [arg3] "{x12}" (arg3),
......@@ -84,7 +84,7 @@ pub fn syscall6(
8484) usize {
8585 return asm volatile ("ecall"
8686 : [ret] "={x10}" (-> usize),
87 : [number] "{x17}" (@enumToInt(number)),
87 : [number] "{x17}" (@intFromEnum(number)),
8888 [arg1] "{x10}" (arg1),
8989 [arg2] "{x11}" (arg2),
9090 [arg3] "{x12}" (arg3),
......@@ -104,7 +104,7 @@ pub const restore = restore_rt;
104104pub fn restore_rt() callconv(.Naked) void {
105105 return asm volatile ("ecall"
106106 :
107 : [number] "{x17}" (@enumToInt(SYS.rt_sigreturn)),
107 : [number] "{x17}" (@intFromEnum(SYS.rt_sigreturn)),
108108 : "memory"
109109 );
110110}
lib/std/os/linux/sparc64.zig+10-10
......@@ -29,7 +29,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
2929 \\ clr %%o0
3030 \\2:
3131 : [ret] "={o0}" (-> usize),
32 : [number] "{g1}" (@enumToInt(SYS.pipe)),
32 : [number] "{g1}" (@intFromEnum(SYS.pipe)),
3333 [arg] "r" (fd),
3434 : "memory", "g3"
3535 );
......@@ -53,7 +53,7 @@ pub fn syscall_fork() usize {
5353 \\ and %%o1, %%o0, %%o0
5454 \\ 2:
5555 : [ret] "={o0}" (-> usize),
56 : [number] "{g1}" (@enumToInt(SYS.fork)),
56 : [number] "{g1}" (@intFromEnum(SYS.fork)),
5757 : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
5858 );
5959}
......@@ -66,7 +66,7 @@ pub fn syscall0(number: SYS) usize {
6666 \\ neg %%o0
6767 \\ 1:
6868 : [ret] "={o0}" (-> usize),
69 : [number] "{g1}" (@enumToInt(number)),
69 : [number] "{g1}" (@intFromEnum(number)),
7070 : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
7171 );
7272}
......@@ -79,7 +79,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
7979 \\ neg %%o0
8080 \\ 1:
8181 : [ret] "={o0}" (-> usize),
82 : [number] "{g1}" (@enumToInt(number)),
82 : [number] "{g1}" (@intFromEnum(number)),
8383 [arg1] "{o0}" (arg1),
8484 : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
8585 );
......@@ -93,7 +93,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
9393 \\ neg %%o0
9494 \\ 1:
9595 : [ret] "={o0}" (-> usize),
96 : [number] "{g1}" (@enumToInt(number)),
96 : [number] "{g1}" (@intFromEnum(number)),
9797 [arg1] "{o0}" (arg1),
9898 [arg2] "{o1}" (arg2),
9999 : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7"
......@@ -108,7 +108,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
108108 \\ neg %%o0
109109 \\ 1:
110110 : [ret] "={o0}" (-> usize),
111 : [number] "{g1}" (@enumToInt(number)),
111 : [number] "{g1}" (@intFromEnum(number)),
112112 [arg1] "{o0}" (arg1),
113113 [arg2] "{o1}" (arg2),
114114 [arg3] "{o2}" (arg3),
......@@ -124,7 +124,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
124124 \\ neg %%o0
125125 \\ 1:
126126 : [ret] "={o0}" (-> usize),
127 : [number] "{g1}" (@enumToInt(number)),
127 : [number] "{g1}" (@intFromEnum(number)),
128128 [arg1] "{o0}" (arg1),
129129 [arg2] "{o1}" (arg2),
130130 [arg3] "{o2}" (arg3),
......@@ -141,7 +141,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
141141 \\ neg %%o0
142142 \\ 1:
143143 : [ret] "={o0}" (-> usize),
144 : [number] "{g1}" (@enumToInt(number)),
144 : [number] "{g1}" (@intFromEnum(number)),
145145 [arg1] "{o0}" (arg1),
146146 [arg2] "{o1}" (arg2),
147147 [arg3] "{o2}" (arg3),
......@@ -167,7 +167,7 @@ pub fn syscall6(
167167 \\ neg %%o0
168168 \\ 1:
169169 : [ret] "={o0}" (-> usize),
170 : [number] "{g1}" (@enumToInt(number)),
170 : [number] "{g1}" (@intFromEnum(number)),
171171 [arg1] "{o0}" (arg1),
172172 [arg2] "{o1}" (arg2),
173173 [arg3] "{o2}" (arg3),
......@@ -190,7 +190,7 @@ pub const restore = restore_rt;
190190pub fn restore_rt() callconv(.C) void {
191191 return asm volatile ("t 0x6d"
192192 :
193 : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)),
193 : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),
194194 : "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7"
195195 );
196196}
lib/std/os/linux/start_pie.zig+5-5
......@@ -78,7 +78,7 @@ pub fn relocate(phdrs: []elf.Phdr) void {
7878 const base_addr = base: {
7979 for (phdrs) |*phdr| {
8080 if (phdr.p_type != elf.PT_DYNAMIC) continue;
81 break :base @ptrToInt(dynv) - phdr.p_vaddr;
81 break :base @intFromPtr(dynv) - phdr.p_vaddr;
8282 }
8383 // This is not supposed to happen for well-formed binaries.
8484 std.os.abort();
......@@ -103,17 +103,17 @@ pub fn relocate(phdrs: []elf.Phdr) void {
103103
104104 // Apply the relocations.
105105 if (rel_addr != 0) {
106 const rel = std.mem.bytesAsSlice(elf.Rel, @intToPtr([*]u8, rel_addr)[0..rel_size]);
106 const rel = std.mem.bytesAsSlice(elf.Rel, @ptrFromInt([*]u8, rel_addr)[0..rel_size]);
107107 for (rel) |r| {
108108 if (r.r_type() != R_RELATIVE) continue;
109 @intToPtr(*usize, base_addr + r.r_offset).* += base_addr;
109 @ptrFromInt(*usize, base_addr + r.r_offset).* += base_addr;
110110 }
111111 }
112112 if (rela_addr != 0) {
113 const rela = std.mem.bytesAsSlice(elf.Rela, @intToPtr([*]u8, rela_addr)[0..rela_size]);
113 const rela = std.mem.bytesAsSlice(elf.Rela, @ptrFromInt([*]u8, rela_addr)[0..rela_size]);
114114 for (rela) |r| {
115115 if (r.r_type() != R_RELATIVE) continue;
116 @intToPtr(*usize, base_addr + r.r_offset).* += base_addr + @bitCast(usize, r.r_addend);
116 @ptrFromInt(*usize, base_addr + r.r_offset).* += base_addr + @bitCast(usize, r.r_addend);
117117 }
118118 }
119119}
lib/std/os/linux/thumb.zig+9-9
......@@ -10,7 +10,7 @@ const SYS = linux.SYS;
1010pub fn syscall0(number: SYS) usize {
1111 @setRuntimeSafety(false);
1212
13 var buf: [2]usize = .{ @enumToInt(number), undefined };
13 var buf: [2]usize = .{ @intFromEnum(number), undefined };
1414 return asm volatile (
1515 \\ str r7, [%[tmp], #4]
1616 \\ ldr r7, [%[tmp]]
......@@ -25,7 +25,7 @@ pub fn syscall0(number: SYS) usize {
2525pub fn syscall1(number: SYS, arg1: usize) usize {
2626 @setRuntimeSafety(false);
2727
28 var buf: [2]usize = .{ @enumToInt(number), undefined };
28 var buf: [2]usize = .{ @intFromEnum(number), undefined };
2929 return asm volatile (
3030 \\ str r7, [%[tmp], #4]
3131 \\ ldr r7, [%[tmp]]
......@@ -41,7 +41,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
4141pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4242 @setRuntimeSafety(false);
4343
44 var buf: [2]usize = .{ @enumToInt(number), undefined };
44 var buf: [2]usize = .{ @intFromEnum(number), undefined };
4545 return asm volatile (
4646 \\ str r7, [%[tmp], #4]
4747 \\ ldr r7, [%[tmp]]
......@@ -58,7 +58,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
5858pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
5959 @setRuntimeSafety(false);
6060
61 var buf: [2]usize = .{ @enumToInt(number), undefined };
61 var buf: [2]usize = .{ @intFromEnum(number), undefined };
6262 return asm volatile (
6363 \\ str r7, [%[tmp], #4]
6464 \\ ldr r7, [%[tmp]]
......@@ -76,7 +76,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
7676pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
7777 @setRuntimeSafety(false);
7878
79 var buf: [2]usize = .{ @enumToInt(number), undefined };
79 var buf: [2]usize = .{ @intFromEnum(number), undefined };
8080 return asm volatile (
8181 \\ str r7, [%[tmp], #4]
8282 \\ ldr r7, [%[tmp]]
......@@ -95,7 +95,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
9595pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
9696 @setRuntimeSafety(false);
9797
98 var buf: [2]usize = .{ @enumToInt(number), undefined };
98 var buf: [2]usize = .{ @intFromEnum(number), undefined };
9999 return asm volatile (
100100 \\ str r7, [%[tmp], #4]
101101 \\ ldr r7, [%[tmp]]
......@@ -123,7 +123,7 @@ pub fn syscall6(
123123) usize {
124124 @setRuntimeSafety(false);
125125
126 var buf: [2]usize = .{ @enumToInt(number), undefined };
126 var buf: [2]usize = .{ @intFromEnum(number), undefined };
127127 return asm volatile (
128128 \\ str r7, [%[tmp], #4]
129129 \\ ldr r7, [%[tmp]]
......@@ -146,7 +146,7 @@ pub fn restore() callconv(.Naked) void {
146146 \\ mov r7, %[number]
147147 \\ svc #0
148148 :
149 : [number] "I" (@enumToInt(SYS.sigreturn)),
149 : [number] "I" (@intFromEnum(SYS.sigreturn)),
150150 );
151151}
152152
......@@ -155,7 +155,7 @@ pub fn restore_rt() callconv(.Naked) void {
155155 \\ mov r7, %[number]
156156 \\ svc #0
157157 :
158 : [number] "I" (@enumToInt(SYS.rt_sigreturn)),
158 : [number] "I" (@intFromEnum(SYS.rt_sigreturn)),
159159 : "memory"
160160 );
161161}
lib/std/os/linux/tls.zig+5-5
......@@ -122,7 +122,7 @@ pub fn setThreadPointer(addr: usize) void {
122122 .seg_not_present = 0,
123123 .useable = 1,
124124 };
125 const rc = std.os.linux.syscall1(.set_thread_area, @ptrToInt(&user_desc));
125 const rc = std.os.linux.syscall1(.set_thread_area, @intFromPtr(&user_desc));
126126 assert(rc == 0);
127127
128128 const gdt_entry_number = user_desc.entry_number;
......@@ -191,7 +191,7 @@ fn initTLS(phdrs: []elf.Phdr) void {
191191
192192 for (phdrs) |*phdr| {
193193 switch (phdr.p_type) {
194 elf.PT_PHDR => img_base = @ptrToInt(phdrs.ptr) - phdr.p_vaddr,
194 elf.PT_PHDR => img_base = @intFromPtr(phdrs.ptr) - phdr.p_vaddr,
195195 elf.PT_TLS => tls_phdr = phdr,
196196 else => {},
197197 }
......@@ -205,7 +205,7 @@ fn initTLS(phdrs: []elf.Phdr) void {
205205 // the data stored in the PT_TLS segment is p_filesz and may be less
206206 // than the former
207207 tls_align_factor = phdr.p_align;
208 tls_data = @intToPtr([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz];
208 tls_data = @ptrFromInt([*]u8, img_base + phdr.p_vaddr)[0..phdr.p_filesz];
209209 tls_data_alloc_size = phdr.p_memsz;
210210 } else {
211211 tls_align_factor = @alignOf(usize);
......@@ -292,7 +292,7 @@ pub fn prepareTLS(area: []u8) usize {
292292 // Return the corrected value (if needed) for the tp register.
293293 // Overflow here is not a problem, the pointer arithmetic involving the tp
294294 // is done with wrapping semantics.
295 return @ptrToInt(area.ptr) +% tls_tp_offset +%
295 return @intFromPtr(area.ptr) +% tls_tp_offset +%
296296 if (tls_tp_points_past_tcb) tls_image.data_offset else tls_image.tcb_offset;
297297}
298298
......@@ -328,7 +328,7 @@ pub fn initStaticTLS(phdrs: []elf.Phdr) void {
328328 ) catch os.abort();
329329
330330 // Make sure the slice is correctly aligned.
331 const begin_addr = @ptrToInt(alloc_tls_area.ptr);
331 const begin_addr = @intFromPtr(alloc_tls_area.ptr);
332332 const begin_aligned_addr = mem.alignForward(usize, begin_addr, tls_image.alloc_align);
333333 const start = begin_aligned_addr - begin_addr;
334334 break :blk alloc_tls_area[start .. start + tls_image.alloc_size];
lib/std/os/linux/vdso.zig+10-10
......@@ -8,7 +8,7 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
88 const vdso_addr = std.os.system.getauxval(std.elf.AT_SYSINFO_EHDR);
99 if (vdso_addr == 0) return 0;
1010
11 const eh = @intToPtr(*elf.Ehdr, vdso_addr);
11 const eh = @ptrFromInt(*elf.Ehdr, vdso_addr);
1212 var ph_addr: usize = vdso_addr + eh.e_phoff;
1313
1414 var maybe_dynv: ?[*]usize = null;
......@@ -19,14 +19,14 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
1919 i += 1;
2020 ph_addr += eh.e_phentsize;
2121 }) {
22 const this_ph = @intToPtr(*elf.Phdr, ph_addr);
22 const this_ph = @ptrFromInt(*elf.Phdr, ph_addr);
2323 switch (this_ph.p_type) {
2424 // On WSL1 as well as older kernels, the VDSO ELF image is pre-linked in the upper half
2525 // of the memory space (e.g. p_vaddr = 0xffffffffff700000 on WSL1).
2626 // Wrapping operations are used on this line as well as subsequent calculations relative to base
2727 // (lines 47, 78) to ensure no overflow check is tripped.
2828 elf.PT_LOAD => base = vdso_addr +% this_ph.p_offset -% this_ph.p_vaddr,
29 elf.PT_DYNAMIC => maybe_dynv = @intToPtr([*]usize, vdso_addr + this_ph.p_offset),
29 elf.PT_DYNAMIC => maybe_dynv = @ptrFromInt([*]usize, vdso_addr + this_ph.p_offset),
3030 else => {},
3131 }
3232 }
......@@ -45,11 +45,11 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
4545 while (dynv[i] != 0) : (i += 2) {
4646 const p = base +% dynv[i + 1];
4747 switch (dynv[i]) {
48 elf.DT_STRTAB => maybe_strings = @intToPtr([*]u8, p),
49 elf.DT_SYMTAB => maybe_syms = @intToPtr([*]elf.Sym, p),
50 elf.DT_HASH => maybe_hashtab = @intToPtr([*]linux.Elf_Symndx, p),
51 elf.DT_VERSYM => maybe_versym = @intToPtr([*]u16, p),
52 elf.DT_VERDEF => maybe_verdef = @intToPtr(*elf.Verdef, p),
48 elf.DT_STRTAB => maybe_strings = @ptrFromInt([*]u8, p),
49 elf.DT_SYMTAB => maybe_syms = @ptrFromInt([*]elf.Sym, p),
50 elf.DT_HASH => maybe_hashtab = @ptrFromInt([*]linux.Elf_Symndx, p),
51 elf.DT_VERSYM => maybe_versym = @ptrFromInt([*]u16, p),
52 elf.DT_VERDEF => maybe_verdef = @ptrFromInt(*elf.Verdef, p),
5353 else => {},
5454 }
5555 }
......@@ -88,9 +88,9 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [
8888 break;
8989 if (def.vd_next == 0)
9090 return false;
91 def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next);
91 def = @ptrFromInt(*elf.Verdef, @intFromPtr(def) + def.vd_next);
9292 }
93 const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux);
93 const aux = @ptrFromInt(*elf.Verdaux, @intFromPtr(def) + def.vd_aux);
9494 const vda_name = @ptrCast([*:0]u8, strings + aux.vda_name);
9595 return mem.eql(u8, vername, mem.sliceTo(vda_name, 0));
9696}
lib/std/os/linux/x86.zig+13-13
......@@ -16,7 +16,7 @@ const timespec = linux.timespec;
1616pub fn syscall0(number: SYS) usize {
1717 return asm volatile ("int $0x80"
1818 : [ret] "={eax}" (-> usize),
19 : [number] "{eax}" (@enumToInt(number)),
19 : [number] "{eax}" (@intFromEnum(number)),
2020 : "memory"
2121 );
2222}
......@@ -24,7 +24,7 @@ pub fn syscall0(number: SYS) usize {
2424pub fn syscall1(number: SYS, arg1: usize) usize {
2525 return asm volatile ("int $0x80"
2626 : [ret] "={eax}" (-> usize),
27 : [number] "{eax}" (@enumToInt(number)),
27 : [number] "{eax}" (@intFromEnum(number)),
2828 [arg1] "{ebx}" (arg1),
2929 : "memory"
3030 );
......@@ -33,7 +33,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3333pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
3434 return asm volatile ("int $0x80"
3535 : [ret] "={eax}" (-> usize),
36 : [number] "{eax}" (@enumToInt(number)),
36 : [number] "{eax}" (@intFromEnum(number)),
3737 [arg1] "{ebx}" (arg1),
3838 [arg2] "{ecx}" (arg2),
3939 : "memory"
......@@ -43,7 +43,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4343pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
4444 return asm volatile ("int $0x80"
4545 : [ret] "={eax}" (-> usize),
46 : [number] "{eax}" (@enumToInt(number)),
46 : [number] "{eax}" (@intFromEnum(number)),
4747 [arg1] "{ebx}" (arg1),
4848 [arg2] "{ecx}" (arg2),
4949 [arg3] "{edx}" (arg3),
......@@ -54,7 +54,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
5454pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
5555 return asm volatile ("int $0x80"
5656 : [ret] "={eax}" (-> usize),
57 : [number] "{eax}" (@enumToInt(number)),
57 : [number] "{eax}" (@intFromEnum(number)),
5858 [arg1] "{ebx}" (arg1),
5959 [arg2] "{ecx}" (arg2),
6060 [arg3] "{edx}" (arg3),
......@@ -66,7 +66,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
6666pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
6767 return asm volatile ("int $0x80"
6868 : [ret] "={eax}" (-> usize),
69 : [number] "{eax}" (@enumToInt(number)),
69 : [number] "{eax}" (@intFromEnum(number)),
7070 [arg1] "{ebx}" (arg1),
7171 [arg2] "{ecx}" (arg2),
7272 [arg3] "{edx}" (arg3),
......@@ -97,7 +97,7 @@ pub fn syscall6(
9797 \\ pop %%ebp
9898 \\ add $4, %%esp
9999 : [ret] "={eax}" (-> usize),
100 : [number] "{eax}" (@enumToInt(number)),
100 : [number] "{eax}" (@intFromEnum(number)),
101101 [arg1] "{ebx}" (arg1),
102102 [arg2] "{ecx}" (arg2),
103103 [arg3] "{edx}" (arg3),
......@@ -111,9 +111,9 @@ pub fn syscall6(
111111pub fn socketcall(call: usize, args: [*]const usize) usize {
112112 return asm volatile ("int $0x80"
113113 : [ret] "={eax}" (-> usize),
114 : [number] "{eax}" (@enumToInt(SYS.socketcall)),
114 : [number] "{eax}" (@intFromEnum(SYS.socketcall)),
115115 [arg1] "{ebx}" (call),
116 [arg2] "{ecx}" (@ptrToInt(args)),
116 [arg2] "{ecx}" (@intFromPtr(args)),
117117 : "memory"
118118 );
119119}
......@@ -130,14 +130,14 @@ pub fn restore() callconv(.Naked) void {
130130 \\ int $0x80
131131 \\ ret
132132 :
133 : [number] "i" (@enumToInt(SYS.sigreturn)),
133 : [number] "i" (@intFromEnum(SYS.sigreturn)),
134134 : "memory"
135135 ),
136136 else => asm volatile (
137137 \\ int $0x80
138138 \\ ret
139139 :
140 : [number] "{eax}" (@enumToInt(SYS.sigreturn)),
140 : [number] "{eax}" (@intFromEnum(SYS.sigreturn)),
141141 : "memory"
142142 ),
143143 }
......@@ -151,14 +151,14 @@ pub fn restore_rt() callconv(.Naked) void {
151151 \\ int $0x80
152152 \\ ret
153153 :
154 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
154 : [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
155155 : "memory"
156156 ),
157157 else => asm volatile (
158158 \\ int $0x80
159159 \\ ret
160160 :
161 : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)),
161 : [number] "{eax}" (@intFromEnum(SYS.rt_sigreturn)),
162162 : "memory"
163163 ),
164164 }
lib/std/os/linux/x86_64.zig+9-9
......@@ -18,7 +18,7 @@ const timespec = linux.timespec;
1818pub fn syscall0(number: SYS) usize {
1919 return asm volatile ("syscall"
2020 : [ret] "={rax}" (-> usize),
21 : [number] "{rax}" (@enumToInt(number)),
21 : [number] "{rax}" (@intFromEnum(number)),
2222 : "rcx", "r11", "memory"
2323 );
2424}
......@@ -26,7 +26,7 @@ pub fn syscall0(number: SYS) usize {
2626pub fn syscall1(number: SYS, arg1: usize) usize {
2727 return asm volatile ("syscall"
2828 : [ret] "={rax}" (-> usize),
29 : [number] "{rax}" (@enumToInt(number)),
29 : [number] "{rax}" (@intFromEnum(number)),
3030 [arg1] "{rdi}" (arg1),
3131 : "rcx", "r11", "memory"
3232 );
......@@ -35,7 +35,7 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
3535pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
3636 return asm volatile ("syscall"
3737 : [ret] "={rax}" (-> usize),
38 : [number] "{rax}" (@enumToInt(number)),
38 : [number] "{rax}" (@intFromEnum(number)),
3939 [arg1] "{rdi}" (arg1),
4040 [arg2] "{rsi}" (arg2),
4141 : "rcx", "r11", "memory"
......@@ -45,7 +45,7 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
4545pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
4646 return asm volatile ("syscall"
4747 : [ret] "={rax}" (-> usize),
48 : [number] "{rax}" (@enumToInt(number)),
48 : [number] "{rax}" (@intFromEnum(number)),
4949 [arg1] "{rdi}" (arg1),
5050 [arg2] "{rsi}" (arg2),
5151 [arg3] "{rdx}" (arg3),
......@@ -56,7 +56,7 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
5656pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
5757 return asm volatile ("syscall"
5858 : [ret] "={rax}" (-> usize),
59 : [number] "{rax}" (@enumToInt(number)),
59 : [number] "{rax}" (@intFromEnum(number)),
6060 [arg1] "{rdi}" (arg1),
6161 [arg2] "{rsi}" (arg2),
6262 [arg3] "{rdx}" (arg3),
......@@ -68,7 +68,7 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
6868pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
6969 return asm volatile ("syscall"
7070 : [ret] "={rax}" (-> usize),
71 : [number] "{rax}" (@enumToInt(number)),
71 : [number] "{rax}" (@intFromEnum(number)),
7272 [arg1] "{rdi}" (arg1),
7373 [arg2] "{rsi}" (arg2),
7474 [arg3] "{rdx}" (arg3),
......@@ -89,7 +89,7 @@ pub fn syscall6(
8989) usize {
9090 return asm volatile ("syscall"
9191 : [ret] "={rax}" (-> usize),
92 : [number] "{rax}" (@enumToInt(number)),
92 : [number] "{rax}" (@intFromEnum(number)),
9393 [arg1] "{rdi}" (arg1),
9494 [arg2] "{rsi}" (arg2),
9595 [arg3] "{rdx}" (arg3),
......@@ -114,14 +114,14 @@ pub fn restore_rt() callconv(.Naked) void {
114114 \\ syscall
115115 \\ retq
116116 :
117 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
117 : [number] "i" (@intFromEnum(SYS.rt_sigreturn)),
118118 : "rcx", "r11", "memory"
119119 ),
120120 else => asm volatile (
121121 \\ syscall
122122 \\ retq
123123 :
124 : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)),
124 : [number] "{rax}" (@intFromEnum(SYS.rt_sigreturn)),
125125 : "rcx", "r11", "memory"
126126 ),
127127 }
lib/std/os/plan9.zig+6-6
......@@ -10,7 +10,7 @@ pub const E = @import("plan9/errno.zig").E;
1010pub fn getErrno(r: usize) E {
1111 const signed_r = @bitCast(isize, r);
1212 const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0;
13 return @intToEnum(E, int);
13 return @enumFromInt(E, int);
1414}
1515pub const SIG = struct {
1616 /// hangup
......@@ -133,19 +133,19 @@ pub const SYS = enum(usize) {
133133};
134134
135135pub fn pwrite(fd: usize, buf: [*]const u8, count: usize, offset: usize) usize {
136 return syscall_bits.syscall4(.PWRITE, fd, @ptrToInt(buf), count, offset);
136 return syscall_bits.syscall4(.PWRITE, fd, @intFromPtr(buf), count, offset);
137137}
138138
139139pub fn pread(fd: usize, buf: [*]const u8, count: usize, offset: usize) usize {
140 return syscall_bits.syscall4(.PREAD, fd, @ptrToInt(buf), count, offset);
140 return syscall_bits.syscall4(.PREAD, fd, @intFromPtr(buf), count, offset);
141141}
142142
143143pub fn open(path: [*:0]const u8, omode: OpenMode) usize {
144 return syscall_bits.syscall2(.OPEN, @ptrToInt(path), @enumToInt(omode));
144 return syscall_bits.syscall2(.OPEN, @intFromPtr(path), @intFromEnum(omode));
145145}
146146
147147pub fn create(path: [*:0]const u8, omode: OpenMode, perms: usize) usize {
148 return syscall_bits.syscall3(.CREATE, @ptrToInt(path), @enumToInt(omode), perms);
148 return syscall_bits.syscall3(.CREATE, @intFromPtr(path), @intFromEnum(omode), perms);
149149}
150150
151151pub fn exit(status: u8) noreturn {
......@@ -159,7 +159,7 @@ pub fn exit(status: u8) noreturn {
159159}
160160
161161pub fn exits(status: ?[*:0]const u8) noreturn {
162 _ = syscall_bits.syscall1(.EXITS, if (status) |s| @ptrToInt(s) else 0);
162 _ = syscall_bits.syscall1(.EXITS, if (status) |s| @intFromPtr(s) else 0);
163163 unreachable;
164164}
165165
lib/std/os/plan9/x86_64.zig+4-4
......@@ -10,7 +10,7 @@ pub fn syscall1(sys: plan9.SYS, arg0: usize) usize {
1010 \\pop %%r11
1111 : [ret] "={rax}" (-> usize),
1212 : [arg0] "{r8}" (arg0),
13 [syscall_number] "{rbp}" (@enumToInt(sys)),
13 [syscall_number] "{rbp}" (@intFromEnum(sys)),
1414 : "rcx", "rax", "rbp", "r11", "memory"
1515 );
1616}
......@@ -26,7 +26,7 @@ pub fn syscall2(sys: plan9.SYS, arg0: usize, arg1: usize) usize {
2626 : [ret] "={rax}" (-> usize),
2727 : [arg0] "{r8}" (arg0),
2828 [arg1] "{r9}" (arg1),
29 [syscall_number] "{rbp}" (@enumToInt(sys)),
29 [syscall_number] "{rbp}" (@intFromEnum(sys)),
3030 : "rcx", "rax", "rbp", "r11", "memory"
3131 );
3232}
......@@ -45,7 +45,7 @@ pub fn syscall3(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize) usize {
4545 : [arg0] "{r8}" (arg0),
4646 [arg1] "{r9}" (arg1),
4747 [arg2] "{r10}" (arg2),
48 [syscall_number] "{rbp}" (@enumToInt(sys)),
48 [syscall_number] "{rbp}" (@intFromEnum(sys)),
4949 : "rcx", "rax", "rbp", "r11", "memory"
5050 );
5151}
......@@ -67,7 +67,7 @@ pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usi
6767 [arg1] "{r9}" (arg1),
6868 [arg2] "{r10}" (arg2),
6969 [arg3] "{r11}" (arg3),
70 [syscall_number] "{rbp}" (@enumToInt(sys)),
70 [syscall_number] "{rbp}" (@intFromEnum(sys)),
7171 : "rcx", "rax", "rbp", "r11", "memory"
7272 );
7373}
lib/std/os/test.zig+10-10
......@@ -488,7 +488,7 @@ fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void {
488488
489489 const reloc_addr = info.dlpi_addr + phdr.p_vaddr;
490490 // Find the ELF header
491 const elf_header = @intToPtr(*elf.Ehdr, reloc_addr - phdr.p_offset);
491 const elf_header = @ptrFromInt(*elf.Ehdr, reloc_addr - phdr.p_offset);
492492 // Validate the magic
493493 if (!mem.eql(u8, elf_header.e_ident[0..4], elf.MAGIC)) return error.BadElfMagic;
494494 // Consistency check
......@@ -751,7 +751,7 @@ test "getrlimit and setrlimit" {
751751 }
752752
753753 inline for (std.meta.fields(os.rlimit_resource)) |field| {
754 const resource = @intToEnum(os.rlimit_resource, field.value);
754 const resource = @enumFromInt(os.rlimit_resource, field.value);
755755 const limit = try os.getrlimit(resource);
756756
757757 // 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" {
931931
932932 // Place an exclusive lock on the first byte, and a shared lock on the second byte:
933933 var struct_flock = std.mem.zeroInit(os.Flock, .{ .type = os.F.WRLCK });
934 _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock));
934 _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock));
935935 struct_flock.start = 1;
936936 struct_flock.type = os.F.RDLCK;
937 _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock));
937 _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock));
938938
939939 // Check the locks in a child process:
940940 const pid = try os.fork();
......@@ -942,15 +942,15 @@ test "POSIX file locking with fcntl" {
942942 // child expects be denied the exclusive lock:
943943 struct_flock.start = 0;
944944 struct_flock.type = os.F.WRLCK;
945 try expectError(error.Locked, os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock)));
945 try expectError(error.Locked, os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock)));
946946 // child expects to get the shared lock:
947947 struct_flock.start = 1;
948948 struct_flock.type = os.F.RDLCK;
949 _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock));
949 _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock));
950950 // child waits for the exclusive lock in order to test deadlock:
951951 struct_flock.start = 0;
952952 struct_flock.type = os.F.WRLCK;
953 _ = try os.fcntl(fd, os.F.SETLKW, @ptrToInt(&struct_flock));
953 _ = try os.fcntl(fd, os.F.SETLKW, @intFromPtr(&struct_flock));
954954 // child exits without continuing:
955955 os.exit(0);
956956 } else {
......@@ -959,15 +959,15 @@ test "POSIX file locking with fcntl" {
959959 // parent expects deadlock when attempting to upgrade the shared lock to exclusive:
960960 struct_flock.start = 1;
961961 struct_flock.type = os.F.WRLCK;
962 try expectError(error.DeadLock, os.fcntl(fd, os.F.SETLKW, @ptrToInt(&struct_flock)));
962 try expectError(error.DeadLock, os.fcntl(fd, os.F.SETLKW, @intFromPtr(&struct_flock)));
963963 // parent releases exclusive lock:
964964 struct_flock.start = 0;
965965 struct_flock.type = os.F.UNLCK;
966 _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock));
966 _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock));
967967 // parent releases shared lock:
968968 struct_flock.start = 1;
969969 struct_flock.type = os.F.UNLCK;
970 _ = try os.fcntl(fd, os.F.SETLK, @ptrToInt(&struct_flock));
970 _ = try os.fcntl(fd, os.F.SETLK, @intFromPtr(&struct_flock));
971971 // parent waits for child:
972972 const result = os.waitpid(pid, 0);
973973 try expect(result.status == 0 * 256);
lib/std/os/uefi/pool_allocator.zig+2-2
......@@ -9,7 +9,7 @@ const Allocator = mem.Allocator;
99
1010const UefiPoolAllocator = struct {
1111 fn getHeader(ptr: [*]u8) *[*]align(8) u8 {
12 return @intToPtr(*[*]align(8) u8, @ptrToInt(ptr) - @sizeOf(usize));
12 return @ptrFromInt(*[*]align(8) u8, @intFromPtr(ptr) - @sizeOf(usize));
1313 }
1414
1515 fn alloc(
......@@ -31,7 +31,7 @@ const UefiPoolAllocator = struct {
3131 var unaligned_ptr: [*]align(8) u8 = undefined;
3232 if (uefi.system_table.boot_services.?.allocatePool(uefi.efi_pool_memory_type, full_len, &unaligned_ptr) != .Success) return null;
3333
34 const unaligned_addr = @ptrToInt(unaligned_ptr);
34 const unaligned_addr = @intFromPtr(unaligned_ptr);
3535 const aligned_addr = mem.alignForward(usize, unaligned_addr + @sizeOf(usize), ptr_align);
3636
3737 var aligned_ptr = unaligned_ptr + (aligned_addr - unaligned_addr);
lib/std/os/uefi/protocols/device_path_protocol.zig+3-3
......@@ -23,7 +23,7 @@ pub const DevicePathProtocol = extern struct {
2323
2424 /// Returns the next DevicePathProtocol node in the sequence, if any.
2525 pub fn next(self: *DevicePathProtocol) ?*DevicePathProtocol {
26 if (self.type == .End and @intToEnum(EndDevicePath.Subtype, self.subtype) == .EndEntire)
26 if (self.type == .End and @enumFromInt(EndDevicePath.Subtype, self.subtype) == .EndEntire)
2727 return null;
2828
2929 return @ptrCast(*DevicePathProtocol, @ptrCast([*]u8, self) + self.length);
......@@ -37,7 +37,7 @@ pub const DevicePathProtocol = extern struct {
3737 node = next_node;
3838 }
3939
40 return (@ptrToInt(node) + node.length) - @ptrToInt(self);
40 return (@intFromPtr(node) + node.length) - @intFromPtr(self);
4141 }
4242
4343 /// Creates a file device path from the existing device path and a file path.
......@@ -99,7 +99,7 @@ pub const DevicePathProtocol = extern struct {
9999
100100 inline for (type_info.fields) |subtype| {
101101 // The tag names match the union names, so just grab that off the enum
102 const tag_val: u8 = @enumToInt(@field(TTag, subtype.name));
102 const tag_val: u8 = @intFromEnum(@field(TTag, subtype.name));
103103
104104 if (self.subtype == tag_val) {
105105 // e.g. expr = .{ .Pci = @ptrCast(...) }
lib/std/os/windows.zig+19-19
......@@ -30,7 +30,7 @@ pub const gdi32 = @import("windows/gdi32.zig");
3030pub const winmm = @import("windows/winmm.zig");
3131pub const crypt32 = @import("windows/crypt32.zig");
3232
33pub const self_process_handle = @intToPtr(HANDLE, maxInt(usize));
33pub const self_process_handle = @ptrFromInt(HANDLE, maxInt(usize));
3434
3535const Self = @This();
3636
......@@ -242,7 +242,7 @@ pub fn DeviceIoControl(
242242
243243pub fn GetOverlappedResult(h: HANDLE, overlapped: *OVERLAPPED, wait: bool) !DWORD {
244244 var bytes: DWORD = undefined;
245 if (kernel32.GetOverlappedResult(h, overlapped, &bytes, @boolToInt(wait)) == 0) {
245 if (kernel32.GetOverlappedResult(h, overlapped, &bytes, @intFromBool(wait)) == 0) {
246246 switch (kernel32.GetLastError()) {
247247 .IO_INCOMPLETE => if (!wait) return error.WouldBlock else unreachable,
248248 else => |err| return unexpectedError(err),
......@@ -294,7 +294,7 @@ pub fn WaitForSingleObject(handle: HANDLE, milliseconds: DWORD) WaitForSingleObj
294294}
295295
296296pub fn WaitForSingleObjectEx(handle: HANDLE, milliseconds: DWORD, alertable: bool) WaitForSingleObjectError!void {
297 switch (kernel32.WaitForSingleObjectEx(handle, milliseconds, @boolToInt(alertable))) {
297 switch (kernel32.WaitForSingleObjectEx(handle, milliseconds, @intFromBool(alertable))) {
298298 WAIT_ABANDONED => return error.WaitAbandoned,
299299 WAIT_OBJECT_0 => return,
300300 WAIT_TIMEOUT => return error.WaitTimeOut,
......@@ -311,9 +311,9 @@ pub fn WaitForMultipleObjectsEx(handles: []const HANDLE, waitAll: bool, millisec
311311 switch (kernel32.WaitForMultipleObjectsEx(
312312 nCount,
313313 handles.ptr,
314 @boolToInt(waitAll),
314 @intFromBool(waitAll),
315315 milliseconds,
316 @boolToInt(alertable),
316 @intFromBool(alertable),
317317 )) {
318318 WAIT_OBJECT_0...WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS => |n| {
319319 const handle_index = n - WAIT_OBJECT_0;
......@@ -422,7 +422,7 @@ pub fn GetQueuedCompletionStatusEx(
422422 @intCast(ULONG, completion_port_entries.len),
423423 &num_entries_removed,
424424 timeout_ms orelse INFINITE,
425 @boolToInt(alertable),
425 @intFromBool(alertable),
426426 );
427427
428428 if (success == FALSE) {
......@@ -1106,7 +1106,7 @@ test "QueryObjectName" {
11061106 var out_buffer: [PATH_MAX_WIDE]u16 = undefined;
11071107
11081108 var result_path = try QueryObjectName(handle, &out_buffer);
1109 const required_len_in_u16 = result_path.len + @divExact(@ptrToInt(result_path.ptr) - @ptrToInt(&out_buffer), 2) + 1;
1109 const required_len_in_u16 = result_path.len + @divExact(@intFromPtr(result_path.ptr) - @intFromPtr(&out_buffer), 2) + 1;
11101110 //insufficient size
11111111 try std.testing.expectError(error.NameTooLong, QueryObjectName(handle, out_buffer[0 .. required_len_in_u16 - 1]));
11121112 //exactly-sufficient size
......@@ -1263,7 +1263,7 @@ test "GetFinalPathNameByHandle" {
12631263 const nt_path = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, &buffer);
12641264 _ = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Dos }, &buffer);
12651265
1266 const required_len_in_u16 = nt_path.len + @divExact(@ptrToInt(nt_path.ptr) - @ptrToInt(&buffer), 2) + 1;
1266 const required_len_in_u16 = nt_path.len + @divExact(@intFromPtr(nt_path.ptr) - @intFromPtr(&buffer), 2) + 1;
12671267 //check with insufficient size
12681268 try std.testing.expectError(error.NameTooLong, GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, buffer[0 .. required_len_in_u16 - 1]));
12691269 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 {
13131313 var wsadata: ws2_32.WSADATA = undefined;
13141314 return switch (ws2_32.WSAStartup((@as(WORD, minorVersion) << 8) | majorVersion, &wsadata)) {
13151315 0 => wsadata,
1316 else => |err_int| switch (@intToEnum(ws2_32.WinsockError, @intCast(u16, err_int))) {
1316 else => |err_int| switch (@enumFromInt(ws2_32.WinsockError, @intCast(u16, err_int))) {
13171317 .WSASYSNOTREADY => return error.SystemNotAvailable,
13181318 .WSAVERNOTSUPPORTED => return error.VersionNotSupported,
13191319 .WSAEINPROGRESS => return error.BlockingOperationInProgress,
......@@ -2286,7 +2286,7 @@ pub fn loadWinsockExtensionFunction(comptime T: type, sock: ws2_32.SOCKET, guid:
22862286 ws2_32.SIO_GET_EXTENSION_FUNCTION_POINTER,
22872287 @ptrCast(*const anyopaque, &guid),
22882288 @sizeOf(GUID),
2289 @intToPtr(?*anyopaque, @ptrToInt(&function)),
2289 @ptrFromInt(?*anyopaque, @intFromPtr(&function)),
22902290 @sizeOf(T),
22912291 &num_bytes,
22922292 null,
......@@ -2325,21 +2325,21 @@ pub fn unexpectedError(err: Win32Error) std.os.UnexpectedError {
23252325 null,
23262326 );
23272327 _ = std.unicode.utf16leToUtf8(&buf_utf8, buf_wstr[0..len]) catch unreachable;
2328 std.debug.print("error.Unexpected: GetLastError({}): {s}\n", .{ @enumToInt(err), buf_utf8[0..len] });
2328 std.debug.print("error.Unexpected: GetLastError({}): {s}\n", .{ @intFromEnum(err), buf_utf8[0..len] });
23292329 std.debug.dumpCurrentStackTrace(@returnAddress());
23302330 }
23312331 return error.Unexpected;
23322332}
23332333
23342334pub fn unexpectedWSAError(err: ws2_32.WinsockError) std.os.UnexpectedError {
2335 return unexpectedError(@intToEnum(Win32Error, @enumToInt(err)));
2335 return unexpectedError(@enumFromInt(Win32Error, @intFromEnum(err)));
23362336}
23372337
23382338/// Call this when you made a windows NtDll call
23392339/// and you get an unexpected status.
23402340pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError {
23412341 if (std.os.unexpected_error_tracing) {
2342 std.debug.print("error.Unexpected NTSTATUS=0x{x}\n", .{@enumToInt(status)});
2342 std.debug.print("error.Unexpected NTSTATUS=0x{x}\n", .{@intFromEnum(status)});
23432343 std.debug.dumpCurrentStackTrace(@returnAddress());
23442344 }
23452345 return error.Unexpected;
......@@ -2527,10 +2527,10 @@ pub fn CTL_CODE(deviceType: u16, function: u12, method: TransferType, access: u2
25272527 return (@as(DWORD, deviceType) << 16) |
25282528 (@as(DWORD, access) << 14) |
25292529 (@as(DWORD, function) << 2) |
2530 @enumToInt(method);
2530 @intFromEnum(method);
25312531}
25322532
2533pub const INVALID_HANDLE_VALUE = @intToPtr(HANDLE, maxInt(usize));
2533pub const INVALID_HANDLE_VALUE = @ptrFromInt(HANDLE, maxInt(usize));
25342534
25352535pub const INVALID_FILE_ATTRIBUTES = @as(DWORD, maxInt(DWORD));
25362536
......@@ -3221,7 +3221,7 @@ pub const LSTATUS = LONG;
32213221
32223222pub const HKEY = *opaque {};
32233223
3224pub const HKEY_LOCAL_MACHINE: HKEY = @intToPtr(HKEY, 0x80000002);
3224pub const HKEY_LOCAL_MACHINE: HKEY = @ptrFromInt(HKEY, 0x80000002);
32253225
32263226/// Combines the STANDARD_RIGHTS_REQUIRED, KEY_QUERY_VALUE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY,
32273227/// KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, and KEY_CREATE_LINK access rights.
......@@ -4685,11 +4685,11 @@ pub const KUSER_SHARED_DATA = extern struct {
46854685/// Read-only user-mode address for the shared data.
46864686/// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
46874687/// https://msrc-blog.microsoft.com/2022/04/05/randomizing-the-kuser_shared_data-structure-on-windows/
4688pub const SharedUserData: *const KUSER_SHARED_DATA = @intToPtr(*const KUSER_SHARED_DATA, 0x7FFE0000);
4688pub const SharedUserData: *const KUSER_SHARED_DATA = @ptrFromInt(*const KUSER_SHARED_DATA, 0x7FFE0000);
46894689
46904690pub fn IsProcessorFeaturePresent(feature: PF) bool {
4691 if (@enumToInt(feature) >= PROCESSOR_FEATURE_MAX) return false;
4692 return SharedUserData.ProcessorFeatures[@enumToInt(feature)] == 1;
4691 if (@intFromEnum(feature) >= PROCESSOR_FEATURE_MAX) return false;
4692 return SharedUserData.ProcessorFeatures[@intFromEnum(feature)] == 1;
46934693}
46944694
46954695pub const TH32CS_SNAPHEAPLIST = 0x00000001;
lib/std/os/windows/user32.zig+1-1
......@@ -1350,7 +1350,7 @@ pub extern "user32" fn AdjustWindowRectEx(lpRect: *RECT, dwStyle: DWORD, bMenu:
13501350pub fn adjustWindowRectEx(lpRect: *RECT, dwStyle: u32, bMenu: bool, dwExStyle: u32) !void {
13511351 assert(dwStyle & WS_OVERLAPPED == 0);
13521352
1353 if (AdjustWindowRectEx(lpRect, dwStyle, @boolToInt(bMenu), dwExStyle) == 0) {
1353 if (AdjustWindowRectEx(lpRect, dwStyle, @intFromBool(bMenu), dwExStyle) == 0) {
13541354 switch (GetLastError()) {
13551355 .INVALID_PARAMETER => unreachable,
13561356 else => |err| return windows.unexpectedError(err),
lib/std/os/windows/ws2_32.zig+1-1
......@@ -21,7 +21,7 @@ const LPARAM = windows.LPARAM;
2121const FARPROC = windows.FARPROC;
2222
2323pub const SOCKET = *opaque {};
24pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
24pub const INVALID_SOCKET = @ptrFromInt(SOCKET, ~@as(usize, 0));
2525
2626pub const GROUP = u32;
2727pub const ADDRESS_FAMILY = u16;
lib/std/pdb.zig+1-1
......@@ -863,7 +863,7 @@ pub const Pdb = struct {
863863 }
864864
865865 pub fn getStream(self: *Pdb, stream: StreamType) ?*MsfStream {
866 const id = @enumToInt(stream);
866 const id = @intFromEnum(stream);
867867 return self.getStreamById(id);
868868 }
869869};
lib/std/process.zig+4-4
......@@ -514,9 +514,9 @@ pub const ArgIteratorWasi = struct {
514514 /// Call to free the internal buffer of the iterator.
515515 pub fn deinit(self: *ArgIteratorWasi) void {
516516 const last_item = self.args[self.args.len - 1];
517 const last_byte_addr = @ptrToInt(last_item.ptr) + last_item.len + 1; // null terminated
517 const last_byte_addr = @intFromPtr(last_item.ptr) + last_item.len + 1; // null terminated
518518 const first_item_ptr = self.args[0].ptr;
519 const len = last_byte_addr - @ptrToInt(first_item_ptr);
519 const len = last_byte_addr - @intFromPtr(first_item_ptr);
520520 self.allocator.free(first_item_ptr[0..len]);
521521 self.allocator.free(self.args);
522522 }
......@@ -1079,9 +1079,9 @@ pub fn getBaseAddress() usize {
10791079 return phdr - @sizeOf(std.elf.Ehdr);
10801080 },
10811081 .macos, .freebsd, .netbsd => {
1082 return @ptrToInt(&std.c._mh_execute_header);
1082 return @intFromPtr(&std.c._mh_execute_header);
10831083 },
1084 .windows => return @ptrToInt(os.windows.kernel32.GetModuleHandleW(null)),
1084 .windows => return @intFromPtr(os.windows.kernel32.GetModuleHandleW(null)),
10851085 else => @compileError("Unsupported OS"),
10861086 }
10871087}
lib/std/rand/benchmark.zig+2-2
......@@ -91,8 +91,8 @@ pub fn benchmark(comptime H: anytype, bytes: usize, comptime block_size: usize)
9191 }
9292 const end = timer.read();
9393
94 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
95 const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s);
94 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
95 const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s);
9696
9797 std.debug.assert(rng.random().int(u64) != 0);
9898
lib/std/rand/test.zig+6-6
......@@ -332,13 +332,13 @@ test "Random float chi-square goodness of fit" {
332332 while (i < num_numbers) : (i += 1) {
333333 const rand_f32 = random.float(f32);
334334 const rand_f64 = random.float(f64);
335 var f32_put = try f32_hist.getOrPut(@floatToInt(u32, rand_f32 * @intToFloat(f32, num_buckets)));
335 var f32_put = try f32_hist.getOrPut(@intFromFloat(u32, rand_f32 * @floatFromInt(f32, num_buckets)));
336336 if (f32_put.found_existing) {
337337 f32_put.value_ptr.* += 1;
338338 } else {
339339 f32_put.value_ptr.* = 1;
340340 }
341 var f64_put = try f64_hist.getOrPut(@floatToInt(u32, rand_f64 * @intToFloat(f64, num_buckets)));
341 var f64_put = try f64_hist.getOrPut(@intFromFloat(u32, rand_f64 * @floatFromInt(f64, num_buckets)));
342342 if (f64_put.found_existing) {
343343 f64_put.value_ptr.* += 1;
344344 } else {
......@@ -352,8 +352,8 @@ test "Random float chi-square goodness of fit" {
352352 {
353353 var j: u32 = 0;
354354 while (j < num_buckets) : (j += 1) {
355 const count = @intToFloat(f64, (if (f32_hist.get(j)) |v| v else 0));
356 const expected = @intToFloat(f64, num_numbers) / @intToFloat(f64, num_buckets);
355 const count = @floatFromInt(f64, (if (f32_hist.get(j)) |v| v else 0));
356 const expected = @floatFromInt(f64, num_numbers) / @floatFromInt(f64, num_buckets);
357357 const delta = count - expected;
358358 const variance = (delta * delta) / expected;
359359 f32_total_variance += variance;
......@@ -363,8 +363,8 @@ test "Random float chi-square goodness of fit" {
363363 {
364364 var j: u64 = 0;
365365 while (j < num_buckets) : (j += 1) {
366 const count = @intToFloat(f64, (if (f64_hist.get(j)) |v| v else 0));
367 const expected = @intToFloat(f64, num_numbers) / @intToFloat(f64, num_buckets);
366 const count = @floatFromInt(f64, (if (f64_hist.get(j)) |v| v else 0));
367 const expected = @floatFromInt(f64, num_numbers) / @floatFromInt(f64, num_buckets);
368368 const delta = count - expected;
369369 const variance = (delta * delta) / expected;
370370 f64_total_variance += variance;
lib/std/simd.zig+2-2
......@@ -61,7 +61,7 @@ pub fn suggestVectorSize(comptime T: type) ?usize {
6161
6262test "suggestVectorSizeForCpu works with signed and unsigned values" {
6363 comptime var cpu = std.Target.Cpu.baseline(std.Target.Cpu.Arch.x86_64);
64 comptime cpu.features.addFeature(@enumToInt(std.Target.x86.Feature.avx512f));
64 comptime cpu.features.addFeature(@intFromEnum(std.Target.x86.Feature.avx512f));
6565 const signed_integer_size = suggestVectorSizeForCpu(i32, cpu).?;
6666 const unsigned_integer_size = suggestVectorSizeForCpu(u32, cpu).?;
6767 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) {
9494 for (&out, 0..) |*element, i| {
9595 element.* = switch (@typeInfo(T)) {
9696 .Int => @intCast(T, i),
97 .Float => @intToFloat(T, i),
97 .Float => @floatFromInt(T, i),
9898 else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."),
9999 };
100100 }
lib/std/sort.zig+1-1
......@@ -96,7 +96,7 @@ fn siftDown(a: usize, root: usize, n: usize, context: anytype) void {
9696 if (child >= n) break;
9797
9898 // choose the greater child.
99 child += @boolToInt(child + 1 < n and context.lessThan(child, child + 1));
99 child += @intFromBool(child + 1 < n and context.lessThan(child, child + 1));
100100
101101 // stop if the invariant holds at `node`.
102102 if (!context.lessThan(node, child)) break;
lib/std/start.zig+3-3
......@@ -248,7 +248,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
248248 return root.main();
249249 },
250250 uefi.Status => {
251 return @enumToInt(root.main());
251 return @intFromEnum(root.main());
252252 },
253253 else => @compileError("expected return type of main to be 'void', 'noreturn', 'usize', or 'std.os.uefi.Status'"),
254254 }
......@@ -419,7 +419,7 @@ fn posixCallMainAndExit() callconv(.C) noreturn {
419419 else => continue,
420420 }
421421 }
422 break :init @intToPtr([*]elf.Phdr, at_phdr)[0..at_phnum];
422 break :init @ptrFromInt([*]elf.Phdr, at_phdr)[0..at_phnum];
423423 };
424424
425425 // 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
500500 if (builtin.os.tag == .linux) {
501501 const at_phdr = std.c.getauxval(elf.AT_PHDR);
502502 const at_phnum = std.c.getauxval(elf.AT_PHNUM);
503 const phdrs = (@intToPtr([*]elf.Phdr, at_phdr))[0..at_phnum];
503 const phdrs = (@ptrFromInt([*]elf.Phdr, at_phdr))[0..at_phnum];
504504 expandStackSize(phdrs);
505505 }
506506
lib/std/start_windows_tls.zig+5-5
......@@ -22,14 +22,14 @@ comptime {
2222// TODO also note, ReactOS has a +1 on StartAddressOfRawData and AddressOfCallBacks. Investigate
2323// why they do that.
2424//export const _tls_used linksection(".rdata$T") = std.os.windows.IMAGE_TLS_DIRECTORY {
25// .StartAddressOfRawData = @ptrToInt(&_tls_start),
26// .EndAddressOfRawData = @ptrToInt(&_tls_end),
27// .AddressOfIndex = @ptrToInt(&_tls_index),
28// .AddressOfCallBacks = @ptrToInt(__xl_a),
25// .StartAddressOfRawData = @intFromPtr(&_tls_start),
26// .EndAddressOfRawData = @intFromPtr(&_tls_end),
27// .AddressOfIndex = @intFromPtr(&_tls_index),
28// .AddressOfCallBacks = @intFromPtr(__xl_a),
2929// .SizeOfZeroFill = 0,
3030// .Characteristics = 0,
3131//};
32// This is the workaround because we can't do @ptrToInt at comptime like that.
32// This is the workaround because we can't do @intFromPtr at comptime like that.
3333pub const IMAGE_TLS_DIRECTORY = extern struct {
3434 StartAddressOfRawData: *anyopaque,
3535 EndAddressOfRawData: *anyopaque,
lib/std/tar.zig+2-2
......@@ -70,8 +70,8 @@ pub const Header = struct {
7070 }
7171
7272 pub fn fileType(header: Header) FileType {
73 const result = @intToEnum(FileType, header.bytes[156]);
74 return if (result == @intToEnum(FileType, 0)) .normal else result;
73 const result = @enumFromInt(FileType, header.bytes[156]);
74 return if (result == @enumFromInt(FileType, 0)) .normal else result;
7575 }
7676
7777 fn str(header: Header, start: usize, end: usize) []const u8 {
lib/std/target.zig+12-12
......@@ -139,7 +139,7 @@ pub const Target = struct {
139139
140140 /// Returns whether the first version `self` is newer (greater) than or equal to the second version `ver`.
141141 pub fn isAtLeast(self: WindowsVersion, ver: WindowsVersion) bool {
142 return @enumToInt(self) >= @enumToInt(ver);
142 return @intFromEnum(self) >= @intFromEnum(ver);
143143 }
144144
145145 pub const Range = struct {
......@@ -147,14 +147,14 @@ pub const Target = struct {
147147 max: WindowsVersion,
148148
149149 pub fn includesVersion(self: Range, ver: WindowsVersion) bool {
150 return @enumToInt(ver) >= @enumToInt(self.min) and @enumToInt(ver) <= @enumToInt(self.max);
150 return @intFromEnum(ver) >= @intFromEnum(self.min) and @intFromEnum(ver) <= @intFromEnum(self.max);
151151 }
152152
153153 /// Checks if system is guaranteed to be at least `version` or older than `version`.
154154 /// Returns `null` if a runtime check is required.
155155 pub fn isAtLeast(self: Range, ver: WindowsVersion) ?bool {
156 if (@enumToInt(self.min) >= @enumToInt(ver)) return true;
157 if (@enumToInt(self.max) < @enumToInt(ver)) return false;
156 if (@intFromEnum(self.min) >= @intFromEnum(ver)) return true;
157 if (@intFromEnum(self.max) < @intFromEnum(ver)) return false;
158158 return null;
159159 }
160160 };
......@@ -168,17 +168,17 @@ pub const Target = struct {
168168 out_stream: anytype,
169169 ) !void {
170170 if (comptime std.mem.eql(u8, fmt, "s")) {
171 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) {
171 if (@intFromEnum(self) >= @intFromEnum(WindowsVersion.nt4) and @intFromEnum(self) <= @intFromEnum(WindowsVersion.latest)) {
172172 try std.fmt.format(out_stream, ".{s}", .{@tagName(self)});
173173 } else {
174174 // TODO this code path breaks zig triples, but it is used in `builtin`
175 try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)});
175 try std.fmt.format(out_stream, "@enumFromInt(Target.Os.WindowsVersion, 0x{X:0>8})", .{@intFromEnum(self)});
176176 }
177177 } else if (fmt.len == 0) {
178 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) {
178 if (@intFromEnum(self) >= @intFromEnum(WindowsVersion.nt4) and @intFromEnum(self) <= @intFromEnum(WindowsVersion.latest)) {
179179 try std.fmt.format(out_stream, "WindowsVersion.{s}", .{@tagName(self)});
180180 } else {
181 try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)});
181 try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@intFromEnum(self)});
182182 }
183183 } else {
184184 std.fmt.invalidFmtError(fmt, self);
......@@ -778,21 +778,21 @@ pub const Target = struct {
778778 pub fn featureSet(features: []const F) Set {
779779 var x = Set.empty;
780780 for (features) |feature| {
781 x.addFeature(@enumToInt(feature));
781 x.addFeature(@intFromEnum(feature));
782782 }
783783 return x;
784784 }
785785
786786 /// Returns true if the specified feature is enabled.
787787 pub fn featureSetHas(set: Set, feature: F) bool {
788 return set.isEnabled(@enumToInt(feature));
788 return set.isEnabled(@intFromEnum(feature));
789789 }
790790
791791 /// Returns true if any specified feature is enabled.
792792 pub fn featureSetHasAny(set: Set, features: anytype) bool {
793793 comptime std.debug.assert(std.meta.trait.isIndexable(@TypeOf(features)));
794794 inline for (features) |feature| {
795 if (set.isEnabled(@enumToInt(@as(F, feature)))) return true;
795 if (set.isEnabled(@intFromEnum(@as(F, feature)))) return true;
796796 }
797797 return false;
798798 }
......@@ -801,7 +801,7 @@ pub const Target = struct {
801801 pub fn featureSetHasAll(set: Set, features: anytype) bool {
802802 comptime std.debug.assert(std.meta.trait.isIndexable(@TypeOf(features)));
803803 inline for (features) |feature| {
804 if (!set.isEnabled(@enumToInt(@as(F, feature)))) return false;
804 if (!set.isEnabled(@intFromEnum(@as(F, feature)))) return false;
805805 }
806806 return true;
807807 }
lib/std/target/aarch64.zig+198-198
......@@ -215,7 +215,7 @@ pub const all_features = blk: {
215215 const len = @typeInfo(Feature).Enum.fields.len;
216216 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
217217 var result: [len]CpuFeature = undefined;
218 result[@enumToInt(Feature.a510)] = .{
218 result[@intFromEnum(Feature.a510)] = .{
219219 .llvm_name = "a510",
220220 .description = "Cortex-A510 ARM processors",
221221 .dependencies = featureSet(&[_]Feature{
......@@ -224,7 +224,7 @@ pub const all_features = blk: {
224224 .use_postra_scheduler,
225225 }),
226226 };
227 result[@enumToInt(Feature.a65)] = .{
227 result[@intFromEnum(Feature.a65)] = .{
228228 .llvm_name = "a65",
229229 .description = "Cortex-A65 ARM processors",
230230 .dependencies = featureSet(&[_]Feature{
......@@ -235,7 +235,7 @@ pub const all_features = blk: {
235235 .fuse_literals,
236236 }),
237237 };
238 result[@enumToInt(Feature.a710)] = .{
238 result[@intFromEnum(Feature.a710)] = .{
239239 .llvm_name = "a710",
240240 .description = "Cortex-A710 ARM processors",
241241 .dependencies = featureSet(&[_]Feature{
......@@ -247,7 +247,7 @@ pub const all_features = blk: {
247247 .use_postra_scheduler,
248248 }),
249249 };
250 result[@enumToInt(Feature.a76)] = .{
250 result[@intFromEnum(Feature.a76)] = .{
251251 .llvm_name = "a76",
252252 .description = "Cortex-A76 ARM processors",
253253 .dependencies = featureSet(&[_]Feature{
......@@ -257,7 +257,7 @@ pub const all_features = blk: {
257257 .lsl_fast,
258258 }),
259259 };
260 result[@enumToInt(Feature.a78)] = .{
260 result[@intFromEnum(Feature.a78)] = .{
261261 .llvm_name = "a78",
262262 .description = "Cortex-A78 ARM processors",
263263 .dependencies = featureSet(&[_]Feature{
......@@ -269,7 +269,7 @@ pub const all_features = blk: {
269269 .use_postra_scheduler,
270270 }),
271271 };
272 result[@enumToInt(Feature.a78c)] = .{
272 result[@intFromEnum(Feature.a78c)] = .{
273273 .llvm_name = "a78c",
274274 .description = "Cortex-A78C ARM processors",
275275 .dependencies = featureSet(&[_]Feature{
......@@ -281,175 +281,175 @@ pub const all_features = blk: {
281281 .use_postra_scheduler,
282282 }),
283283 };
284 result[@enumToInt(Feature.aes)] = .{
284 result[@intFromEnum(Feature.aes)] = .{
285285 .llvm_name = "aes",
286286 .description = "Enable AES support (FEAT_AES, FEAT_PMULL)",
287287 .dependencies = featureSet(&[_]Feature{
288288 .neon,
289289 }),
290290 };
291 result[@enumToInt(Feature.aggressive_fma)] = .{
291 result[@intFromEnum(Feature.aggressive_fma)] = .{
292292 .llvm_name = "aggressive-fma",
293293 .description = "Enable Aggressive FMA for floating-point.",
294294 .dependencies = featureSet(&[_]Feature{}),
295295 };
296 result[@enumToInt(Feature.alternate_sextload_cvt_f32_pattern)] = .{
296 result[@intFromEnum(Feature.alternate_sextload_cvt_f32_pattern)] = .{
297297 .llvm_name = "alternate-sextload-cvt-f32-pattern",
298298 .description = "Use alternative pattern for sextload convert to f32",
299299 .dependencies = featureSet(&[_]Feature{}),
300300 };
301 result[@enumToInt(Feature.altnzcv)] = .{
301 result[@intFromEnum(Feature.altnzcv)] = .{
302302 .llvm_name = "altnzcv",
303303 .description = "Enable alternative NZCV format for floating point comparisons (FEAT_FlagM2)",
304304 .dependencies = featureSet(&[_]Feature{}),
305305 };
306 result[@enumToInt(Feature.am)] = .{
306 result[@intFromEnum(Feature.am)] = .{
307307 .llvm_name = "am",
308308 .description = "Enable v8.4-A Activity Monitors extension (FEAT_AMUv1)",
309309 .dependencies = featureSet(&[_]Feature{}),
310310 };
311 result[@enumToInt(Feature.amvs)] = .{
311 result[@intFromEnum(Feature.amvs)] = .{
312312 .llvm_name = "amvs",
313313 .description = "Enable v8.6-A Activity Monitors Virtualization support (FEAT_AMUv1p1)",
314314 .dependencies = featureSet(&[_]Feature{
315315 .am,
316316 }),
317317 };
318 result[@enumToInt(Feature.arith_bcc_fusion)] = .{
318 result[@intFromEnum(Feature.arith_bcc_fusion)] = .{
319319 .llvm_name = "arith-bcc-fusion",
320320 .description = "CPU fuses arithmetic+bcc operations",
321321 .dependencies = featureSet(&[_]Feature{}),
322322 };
323 result[@enumToInt(Feature.arith_cbz_fusion)] = .{
323 result[@intFromEnum(Feature.arith_cbz_fusion)] = .{
324324 .llvm_name = "arith-cbz-fusion",
325325 .description = "CPU fuses arithmetic + cbz/cbnz operations",
326326 .dependencies = featureSet(&[_]Feature{}),
327327 };
328 result[@enumToInt(Feature.ascend_store_address)] = .{
328 result[@intFromEnum(Feature.ascend_store_address)] = .{
329329 .llvm_name = "ascend-store-address",
330330 .description = "Schedule vector stores by ascending address",
331331 .dependencies = featureSet(&[_]Feature{}),
332332 };
333 result[@enumToInt(Feature.b16b16)] = .{
333 result[@intFromEnum(Feature.b16b16)] = .{
334334 .llvm_name = "b16b16",
335335 .description = "Enable SVE2.1 or SME2.1 non-widening BFloat16 to BFloat16 instructions (FEAT_B16B16)",
336336 .dependencies = featureSet(&[_]Feature{}),
337337 };
338 result[@enumToInt(Feature.balance_fp_ops)] = .{
338 result[@intFromEnum(Feature.balance_fp_ops)] = .{
339339 .llvm_name = "balance-fp-ops",
340340 .description = "balance mix of odd and even D-registers for fp multiply(-accumulate) ops",
341341 .dependencies = featureSet(&[_]Feature{}),
342342 };
343 result[@enumToInt(Feature.bf16)] = .{
343 result[@intFromEnum(Feature.bf16)] = .{
344344 .llvm_name = "bf16",
345345 .description = "Enable BFloat16 Extension (FEAT_BF16)",
346346 .dependencies = featureSet(&[_]Feature{}),
347347 };
348 result[@enumToInt(Feature.brbe)] = .{
348 result[@intFromEnum(Feature.brbe)] = .{
349349 .llvm_name = "brbe",
350350 .description = "Enable Branch Record Buffer Extension (FEAT_BRBE)",
351351 .dependencies = featureSet(&[_]Feature{}),
352352 };
353 result[@enumToInt(Feature.bti)] = .{
353 result[@intFromEnum(Feature.bti)] = .{
354354 .llvm_name = "bti",
355355 .description = "Enable Branch Target Identification (FEAT_BTI)",
356356 .dependencies = featureSet(&[_]Feature{}),
357357 };
358 result[@enumToInt(Feature.call_saved_x10)] = .{
358 result[@intFromEnum(Feature.call_saved_x10)] = .{
359359 .llvm_name = "call-saved-x10",
360360 .description = "Make X10 callee saved.",
361361 .dependencies = featureSet(&[_]Feature{}),
362362 };
363 result[@enumToInt(Feature.call_saved_x11)] = .{
363 result[@intFromEnum(Feature.call_saved_x11)] = .{
364364 .llvm_name = "call-saved-x11",
365365 .description = "Make X11 callee saved.",
366366 .dependencies = featureSet(&[_]Feature{}),
367367 };
368 result[@enumToInt(Feature.call_saved_x12)] = .{
368 result[@intFromEnum(Feature.call_saved_x12)] = .{
369369 .llvm_name = "call-saved-x12",
370370 .description = "Make X12 callee saved.",
371371 .dependencies = featureSet(&[_]Feature{}),
372372 };
373 result[@enumToInt(Feature.call_saved_x13)] = .{
373 result[@intFromEnum(Feature.call_saved_x13)] = .{
374374 .llvm_name = "call-saved-x13",
375375 .description = "Make X13 callee saved.",
376376 .dependencies = featureSet(&[_]Feature{}),
377377 };
378 result[@enumToInt(Feature.call_saved_x14)] = .{
378 result[@intFromEnum(Feature.call_saved_x14)] = .{
379379 .llvm_name = "call-saved-x14",
380380 .description = "Make X14 callee saved.",
381381 .dependencies = featureSet(&[_]Feature{}),
382382 };
383 result[@enumToInt(Feature.call_saved_x15)] = .{
383 result[@intFromEnum(Feature.call_saved_x15)] = .{
384384 .llvm_name = "call-saved-x15",
385385 .description = "Make X15 callee saved.",
386386 .dependencies = featureSet(&[_]Feature{}),
387387 };
388 result[@enumToInt(Feature.call_saved_x18)] = .{
388 result[@intFromEnum(Feature.call_saved_x18)] = .{
389389 .llvm_name = "call-saved-x18",
390390 .description = "Make X18 callee saved.",
391391 .dependencies = featureSet(&[_]Feature{}),
392392 };
393 result[@enumToInt(Feature.call_saved_x8)] = .{
393 result[@intFromEnum(Feature.call_saved_x8)] = .{
394394 .llvm_name = "call-saved-x8",
395395 .description = "Make X8 callee saved.",
396396 .dependencies = featureSet(&[_]Feature{}),
397397 };
398 result[@enumToInt(Feature.call_saved_x9)] = .{
398 result[@intFromEnum(Feature.call_saved_x9)] = .{
399399 .llvm_name = "call-saved-x9",
400400 .description = "Make X9 callee saved.",
401401 .dependencies = featureSet(&[_]Feature{}),
402402 };
403 result[@enumToInt(Feature.ccdp)] = .{
403 result[@intFromEnum(Feature.ccdp)] = .{
404404 .llvm_name = "ccdp",
405405 .description = "Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)",
406406 .dependencies = featureSet(&[_]Feature{}),
407407 };
408 result[@enumToInt(Feature.ccidx)] = .{
408 result[@intFromEnum(Feature.ccidx)] = .{
409409 .llvm_name = "ccidx",
410410 .description = "Enable v8.3-A Extend of the CCSIDR number of sets (FEAT_CCIDX)",
411411 .dependencies = featureSet(&[_]Feature{}),
412412 };
413 result[@enumToInt(Feature.ccpp)] = .{
413 result[@intFromEnum(Feature.ccpp)] = .{
414414 .llvm_name = "ccpp",
415415 .description = "Enable v8.2 data Cache Clean to Point of Persistence (FEAT_DPB)",
416416 .dependencies = featureSet(&[_]Feature{}),
417417 };
418 result[@enumToInt(Feature.clrbhb)] = .{
418 result[@intFromEnum(Feature.clrbhb)] = .{
419419 .llvm_name = "clrbhb",
420420 .description = "Enable Clear BHB instruction (FEAT_CLRBHB)",
421421 .dependencies = featureSet(&[_]Feature{}),
422422 };
423 result[@enumToInt(Feature.cmp_bcc_fusion)] = .{
423 result[@intFromEnum(Feature.cmp_bcc_fusion)] = .{
424424 .llvm_name = "cmp-bcc-fusion",
425425 .description = "CPU fuses cmp+bcc operations",
426426 .dependencies = featureSet(&[_]Feature{}),
427427 };
428 result[@enumToInt(Feature.complxnum)] = .{
428 result[@intFromEnum(Feature.complxnum)] = .{
429429 .llvm_name = "complxnum",
430430 .description = "Enable v8.3-A Floating-point complex number support (FEAT_FCMA)",
431431 .dependencies = featureSet(&[_]Feature{
432432 .neon,
433433 }),
434434 };
435 result[@enumToInt(Feature.contextidr_el2)] = .{
435 result[@intFromEnum(Feature.contextidr_el2)] = .{
436436 .llvm_name = "CONTEXTIDREL2",
437437 .description = "Enable RW operand Context ID Register (EL2)",
438438 .dependencies = featureSet(&[_]Feature{}),
439439 };
440 result[@enumToInt(Feature.cortex_r82)] = .{
440 result[@intFromEnum(Feature.cortex_r82)] = .{
441441 .llvm_name = "cortex-r82",
442442 .description = "Cortex-R82 ARM processors",
443443 .dependencies = featureSet(&[_]Feature{
444444 .use_postra_scheduler,
445445 }),
446446 };
447 result[@enumToInt(Feature.crc)] = .{
447 result[@intFromEnum(Feature.crc)] = .{
448448 .llvm_name = "crc",
449449 .description = "Enable ARMv8 CRC-32 checksum instructions (FEAT_CRC32)",
450450 .dependencies = featureSet(&[_]Feature{}),
451451 };
452 result[@enumToInt(Feature.crypto)] = .{
452 result[@intFromEnum(Feature.crypto)] = .{
453453 .llvm_name = "crypto",
454454 .description = "Enable cryptographic instructions",
455455 .dependencies = featureSet(&[_]Feature{
......@@ -457,560 +457,560 @@ pub const all_features = blk: {
457457 .sha2,
458458 }),
459459 };
460 result[@enumToInt(Feature.cssc)] = .{
460 result[@intFromEnum(Feature.cssc)] = .{
461461 .llvm_name = "cssc",
462462 .description = "Enable Common Short Sequence Compression (CSSC) instructions (FEAT_CSSC)",
463463 .dependencies = featureSet(&[_]Feature{}),
464464 };
465 result[@enumToInt(Feature.custom_cheap_as_move)] = .{
465 result[@intFromEnum(Feature.custom_cheap_as_move)] = .{
466466 .llvm_name = "custom-cheap-as-move",
467467 .description = "Use custom handling of cheap instructions",
468468 .dependencies = featureSet(&[_]Feature{}),
469469 };
470 result[@enumToInt(Feature.d128)] = .{
470 result[@intFromEnum(Feature.d128)] = .{
471471 .llvm_name = "d128",
472472 .description = "Enable Armv9.4-A 128-bit Page Table Descriptors, System Registers and Instructions (FEAT_D128, FEAT_LVA3, FEAT_SYSREG128, FEAT_SYSINSTR128)",
473473 .dependencies = featureSet(&[_]Feature{
474474 .lse128,
475475 }),
476476 };
477 result[@enumToInt(Feature.disable_latency_sched_heuristic)] = .{
477 result[@intFromEnum(Feature.disable_latency_sched_heuristic)] = .{
478478 .llvm_name = "disable-latency-sched-heuristic",
479479 .description = "Disable latency scheduling heuristic",
480480 .dependencies = featureSet(&[_]Feature{}),
481481 };
482 result[@enumToInt(Feature.dit)] = .{
482 result[@intFromEnum(Feature.dit)] = .{
483483 .llvm_name = "dit",
484484 .description = "Enable v8.4-A Data Independent Timing instructions (FEAT_DIT)",
485485 .dependencies = featureSet(&[_]Feature{}),
486486 };
487 result[@enumToInt(Feature.dotprod)] = .{
487 result[@intFromEnum(Feature.dotprod)] = .{
488488 .llvm_name = "dotprod",
489489 .description = "Enable dot product support (FEAT_DotProd)",
490490 .dependencies = featureSet(&[_]Feature{}),
491491 };
492 result[@enumToInt(Feature.ecv)] = .{
492 result[@intFromEnum(Feature.ecv)] = .{
493493 .llvm_name = "ecv",
494494 .description = "Enable enhanced counter virtualization extension (FEAT_ECV)",
495495 .dependencies = featureSet(&[_]Feature{}),
496496 };
497 result[@enumToInt(Feature.el2vmsa)] = .{
497 result[@intFromEnum(Feature.el2vmsa)] = .{
498498 .llvm_name = "el2vmsa",
499499 .description = "Enable Exception Level 2 Virtual Memory System Architecture",
500500 .dependencies = featureSet(&[_]Feature{}),
501501 };
502 result[@enumToInt(Feature.el3)] = .{
502 result[@intFromEnum(Feature.el3)] = .{
503503 .llvm_name = "el3",
504504 .description = "Enable Exception Level 3",
505505 .dependencies = featureSet(&[_]Feature{}),
506506 };
507 result[@enumToInt(Feature.enable_select_opt)] = .{
507 result[@intFromEnum(Feature.enable_select_opt)] = .{
508508 .llvm_name = "enable-select-opt",
509509 .description = "Enable the select optimize pass for select loop heuristics",
510510 .dependencies = featureSet(&[_]Feature{}),
511511 };
512 result[@enumToInt(Feature.ete)] = .{
512 result[@intFromEnum(Feature.ete)] = .{
513513 .llvm_name = "ete",
514514 .description = "Enable Embedded Trace Extension (FEAT_ETE)",
515515 .dependencies = featureSet(&[_]Feature{
516516 .trbe,
517517 }),
518518 };
519 result[@enumToInt(Feature.exynos_cheap_as_move)] = .{
519 result[@intFromEnum(Feature.exynos_cheap_as_move)] = .{
520520 .llvm_name = "exynos-cheap-as-move",
521521 .description = "Use Exynos specific handling of cheap instructions",
522522 .dependencies = featureSet(&[_]Feature{
523523 .custom_cheap_as_move,
524524 }),
525525 };
526 result[@enumToInt(Feature.f32mm)] = .{
526 result[@intFromEnum(Feature.f32mm)] = .{
527527 .llvm_name = "f32mm",
528528 .description = "Enable Matrix Multiply FP32 Extension (FEAT_F32MM)",
529529 .dependencies = featureSet(&[_]Feature{
530530 .sve,
531531 }),
532532 };
533 result[@enumToInt(Feature.f64mm)] = .{
533 result[@intFromEnum(Feature.f64mm)] = .{
534534 .llvm_name = "f64mm",
535535 .description = "Enable Matrix Multiply FP64 Extension (FEAT_F64MM)",
536536 .dependencies = featureSet(&[_]Feature{
537537 .sve,
538538 }),
539539 };
540 result[@enumToInt(Feature.fgt)] = .{
540 result[@intFromEnum(Feature.fgt)] = .{
541541 .llvm_name = "fgt",
542542 .description = "Enable fine grained virtualization traps extension (FEAT_FGT)",
543543 .dependencies = featureSet(&[_]Feature{}),
544544 };
545 result[@enumToInt(Feature.fix_cortex_a53_835769)] = .{
545 result[@intFromEnum(Feature.fix_cortex_a53_835769)] = .{
546546 .llvm_name = "fix-cortex-a53-835769",
547547 .description = "Mitigate Cortex-A53 Erratum 835769",
548548 .dependencies = featureSet(&[_]Feature{}),
549549 };
550 result[@enumToInt(Feature.flagm)] = .{
550 result[@intFromEnum(Feature.flagm)] = .{
551551 .llvm_name = "flagm",
552552 .description = "Enable v8.4-A Flag Manipulation Instructions (FEAT_FlagM)",
553553 .dependencies = featureSet(&[_]Feature{}),
554554 };
555 result[@enumToInt(Feature.fmv)] = .{
555 result[@intFromEnum(Feature.fmv)] = .{
556556 .llvm_name = "fmv",
557557 .description = "Enable Function Multi Versioning support.",
558558 .dependencies = featureSet(&[_]Feature{}),
559559 };
560 result[@enumToInt(Feature.force_32bit_jump_tables)] = .{
560 result[@intFromEnum(Feature.force_32bit_jump_tables)] = .{
561561 .llvm_name = "force-32bit-jump-tables",
562562 .description = "Force jump table entries to be 32-bits wide except at MinSize",
563563 .dependencies = featureSet(&[_]Feature{}),
564564 };
565 result[@enumToInt(Feature.fp16fml)] = .{
565 result[@intFromEnum(Feature.fp16fml)] = .{
566566 .llvm_name = "fp16fml",
567567 .description = "Enable FP16 FML instructions (FEAT_FHM)",
568568 .dependencies = featureSet(&[_]Feature{
569569 .fullfp16,
570570 }),
571571 };
572 result[@enumToInt(Feature.fp_armv8)] = .{
572 result[@intFromEnum(Feature.fp_armv8)] = .{
573573 .llvm_name = "fp-armv8",
574574 .description = "Enable ARMv8 FP (FEAT_FP)",
575575 .dependencies = featureSet(&[_]Feature{}),
576576 };
577 result[@enumToInt(Feature.fptoint)] = .{
577 result[@intFromEnum(Feature.fptoint)] = .{
578578 .llvm_name = "fptoint",
579579 .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)",
580580 .dependencies = featureSet(&[_]Feature{}),
581581 };
582 result[@enumToInt(Feature.fullfp16)] = .{
582 result[@intFromEnum(Feature.fullfp16)] = .{
583583 .llvm_name = "fullfp16",
584584 .description = "Full FP16 (FEAT_FP16)",
585585 .dependencies = featureSet(&[_]Feature{
586586 .fp_armv8,
587587 }),
588588 };
589 result[@enumToInt(Feature.fuse_address)] = .{
589 result[@intFromEnum(Feature.fuse_address)] = .{
590590 .llvm_name = "fuse-address",
591591 .description = "CPU fuses address generation and memory operations",
592592 .dependencies = featureSet(&[_]Feature{}),
593593 };
594 result[@enumToInt(Feature.fuse_adrp_add)] = .{
594 result[@intFromEnum(Feature.fuse_adrp_add)] = .{
595595 .llvm_name = "fuse-adrp-add",
596596 .description = "CPU fuses adrp+add operations",
597597 .dependencies = featureSet(&[_]Feature{}),
598598 };
599 result[@enumToInt(Feature.fuse_aes)] = .{
599 result[@intFromEnum(Feature.fuse_aes)] = .{
600600 .llvm_name = "fuse-aes",
601601 .description = "CPU fuses AES crypto operations",
602602 .dependencies = featureSet(&[_]Feature{}),
603603 };
604 result[@enumToInt(Feature.fuse_arith_logic)] = .{
604 result[@intFromEnum(Feature.fuse_arith_logic)] = .{
605605 .llvm_name = "fuse-arith-logic",
606606 .description = "CPU fuses arithmetic and logic operations",
607607 .dependencies = featureSet(&[_]Feature{}),
608608 };
609 result[@enumToInt(Feature.fuse_crypto_eor)] = .{
609 result[@intFromEnum(Feature.fuse_crypto_eor)] = .{
610610 .llvm_name = "fuse-crypto-eor",
611611 .description = "CPU fuses AES/PMULL and EOR operations",
612612 .dependencies = featureSet(&[_]Feature{}),
613613 };
614 result[@enumToInt(Feature.fuse_csel)] = .{
614 result[@intFromEnum(Feature.fuse_csel)] = .{
615615 .llvm_name = "fuse-csel",
616616 .description = "CPU fuses conditional select operations",
617617 .dependencies = featureSet(&[_]Feature{}),
618618 };
619 result[@enumToInt(Feature.fuse_literals)] = .{
619 result[@intFromEnum(Feature.fuse_literals)] = .{
620620 .llvm_name = "fuse-literals",
621621 .description = "CPU fuses literal generation operations",
622622 .dependencies = featureSet(&[_]Feature{}),
623623 };
624 result[@enumToInt(Feature.harden_sls_blr)] = .{
624 result[@intFromEnum(Feature.harden_sls_blr)] = .{
625625 .llvm_name = "harden-sls-blr",
626626 .description = "Harden against straight line speculation across BLR instructions",
627627 .dependencies = featureSet(&[_]Feature{}),
628628 };
629 result[@enumToInt(Feature.harden_sls_nocomdat)] = .{
629 result[@intFromEnum(Feature.harden_sls_nocomdat)] = .{
630630 .llvm_name = "harden-sls-nocomdat",
631631 .description = "Generate thunk code for SLS mitigation in the normal text section",
632632 .dependencies = featureSet(&[_]Feature{}),
633633 };
634 result[@enumToInt(Feature.harden_sls_retbr)] = .{
634 result[@intFromEnum(Feature.harden_sls_retbr)] = .{
635635 .llvm_name = "harden-sls-retbr",
636636 .description = "Harden against straight line speculation across RET and BR instructions",
637637 .dependencies = featureSet(&[_]Feature{}),
638638 };
639 result[@enumToInt(Feature.hbc)] = .{
639 result[@intFromEnum(Feature.hbc)] = .{
640640 .llvm_name = "hbc",
641641 .description = "Enable Armv8.8-A Hinted Conditional Branches Extension (FEAT_HBC)",
642642 .dependencies = featureSet(&[_]Feature{}),
643643 };
644 result[@enumToInt(Feature.hcx)] = .{
644 result[@intFromEnum(Feature.hcx)] = .{
645645 .llvm_name = "hcx",
646646 .description = "Enable Armv8.7-A HCRX_EL2 system register (FEAT_HCX)",
647647 .dependencies = featureSet(&[_]Feature{}),
648648 };
649 result[@enumToInt(Feature.i8mm)] = .{
649 result[@intFromEnum(Feature.i8mm)] = .{
650650 .llvm_name = "i8mm",
651651 .description = "Enable Matrix Multiply Int8 Extension (FEAT_I8MM)",
652652 .dependencies = featureSet(&[_]Feature{}),
653653 };
654 result[@enumToInt(Feature.ite)] = .{
654 result[@intFromEnum(Feature.ite)] = .{
655655 .llvm_name = "ite",
656656 .description = "Enable Armv9.4-A Instrumentation Extension FEAT_ITE",
657657 .dependencies = featureSet(&[_]Feature{
658658 .ete,
659659 }),
660660 };
661 result[@enumToInt(Feature.jsconv)] = .{
661 result[@intFromEnum(Feature.jsconv)] = .{
662662 .llvm_name = "jsconv",
663663 .description = "Enable v8.3-A JavaScript FP conversion instructions (FEAT_JSCVT)",
664664 .dependencies = featureSet(&[_]Feature{
665665 .fp_armv8,
666666 }),
667667 };
668 result[@enumToInt(Feature.lor)] = .{
668 result[@intFromEnum(Feature.lor)] = .{
669669 .llvm_name = "lor",
670670 .description = "Enables ARM v8.1 Limited Ordering Regions extension (FEAT_LOR)",
671671 .dependencies = featureSet(&[_]Feature{}),
672672 };
673 result[@enumToInt(Feature.ls64)] = .{
673 result[@intFromEnum(Feature.ls64)] = .{
674674 .llvm_name = "ls64",
675675 .description = "Enable Armv8.7-A LD64B/ST64B Accelerator Extension (FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA)",
676676 .dependencies = featureSet(&[_]Feature{}),
677677 };
678 result[@enumToInt(Feature.lse)] = .{
678 result[@intFromEnum(Feature.lse)] = .{
679679 .llvm_name = "lse",
680680 .description = "Enable ARMv8.1 Large System Extension (LSE) atomic instructions (FEAT_LSE)",
681681 .dependencies = featureSet(&[_]Feature{}),
682682 };
683 result[@enumToInt(Feature.lse128)] = .{
683 result[@intFromEnum(Feature.lse128)] = .{
684684 .llvm_name = "lse128",
685685 .description = "Enable Armv9.4-A 128-bit Atomic Instructions (FEAT_LSE128)",
686686 .dependencies = featureSet(&[_]Feature{
687687 .lse,
688688 }),
689689 };
690 result[@enumToInt(Feature.lse2)] = .{
690 result[@intFromEnum(Feature.lse2)] = .{
691691 .llvm_name = "lse2",
692692 .description = "Enable ARMv8.4 Large System Extension 2 (LSE2) atomicity rules (FEAT_LSE2)",
693693 .dependencies = featureSet(&[_]Feature{}),
694694 };
695 result[@enumToInt(Feature.lsl_fast)] = .{
695 result[@intFromEnum(Feature.lsl_fast)] = .{
696696 .llvm_name = "lsl-fast",
697697 .description = "CPU has a fastpath logical shift of up to 3 places",
698698 .dependencies = featureSet(&[_]Feature{}),
699699 };
700 result[@enumToInt(Feature.mec)] = .{
700 result[@intFromEnum(Feature.mec)] = .{
701701 .llvm_name = "mec",
702702 .description = "Enable Memory Encryption Contexts Extension",
703703 .dependencies = featureSet(&[_]Feature{
704704 .rme,
705705 }),
706706 };
707 result[@enumToInt(Feature.mops)] = .{
707 result[@intFromEnum(Feature.mops)] = .{
708708 .llvm_name = "mops",
709709 .description = "Enable Armv8.8-A memcpy and memset acceleration instructions (FEAT_MOPS)",
710710 .dependencies = featureSet(&[_]Feature{}),
711711 };
712 result[@enumToInt(Feature.mpam)] = .{
712 result[@intFromEnum(Feature.mpam)] = .{
713713 .llvm_name = "mpam",
714714 .description = "Enable v8.4-A Memory system Partitioning and Monitoring extension (FEAT_MPAM)",
715715 .dependencies = featureSet(&[_]Feature{}),
716716 };
717 result[@enumToInt(Feature.mte)] = .{
717 result[@intFromEnum(Feature.mte)] = .{
718718 .llvm_name = "mte",
719719 .description = "Enable Memory Tagging Extension (FEAT_MTE, FEAT_MTE2)",
720720 .dependencies = featureSet(&[_]Feature{}),
721721 };
722 result[@enumToInt(Feature.neon)] = .{
722 result[@intFromEnum(Feature.neon)] = .{
723723 .llvm_name = "neon",
724724 .description = "Enable Advanced SIMD instructions (FEAT_AdvSIMD)",
725725 .dependencies = featureSet(&[_]Feature{
726726 .fp_armv8,
727727 }),
728728 };
729 result[@enumToInt(Feature.nmi)] = .{
729 result[@intFromEnum(Feature.nmi)] = .{
730730 .llvm_name = "nmi",
731731 .description = "Enable Armv8.8-A Non-maskable Interrupts (FEAT_NMI, FEAT_GICv3_NMI)",
732732 .dependencies = featureSet(&[_]Feature{}),
733733 };
734 result[@enumToInt(Feature.no_bti_at_return_twice)] = .{
734 result[@intFromEnum(Feature.no_bti_at_return_twice)] = .{
735735 .llvm_name = "no-bti-at-return-twice",
736736 .description = "Don't place a BTI instruction after a return-twice",
737737 .dependencies = featureSet(&[_]Feature{}),
738738 };
739 result[@enumToInt(Feature.no_neg_immediates)] = .{
739 result[@intFromEnum(Feature.no_neg_immediates)] = .{
740740 .llvm_name = "no-neg-immediates",
741741 .description = "Convert immediates and instructions to their negated or complemented equivalent when the immediate does not fit in the encoding.",
742742 .dependencies = featureSet(&[_]Feature{}),
743743 };
744 result[@enumToInt(Feature.no_zcz_fp)] = .{
744 result[@intFromEnum(Feature.no_zcz_fp)] = .{
745745 .llvm_name = "no-zcz-fp",
746746 .description = "Has no zero-cycle zeroing instructions for FP registers",
747747 .dependencies = featureSet(&[_]Feature{}),
748748 };
749 result[@enumToInt(Feature.nv)] = .{
749 result[@intFromEnum(Feature.nv)] = .{
750750 .llvm_name = "nv",
751751 .description = "Enable v8.4-A Nested Virtualization Enchancement (FEAT_NV, FEAT_NV2)",
752752 .dependencies = featureSet(&[_]Feature{}),
753753 };
754 result[@enumToInt(Feature.outline_atomics)] = .{
754 result[@intFromEnum(Feature.outline_atomics)] = .{
755755 .llvm_name = "outline-atomics",
756756 .description = "Enable out of line atomics to support LSE instructions",
757757 .dependencies = featureSet(&[_]Feature{}),
758758 };
759 result[@enumToInt(Feature.pan)] = .{
759 result[@intFromEnum(Feature.pan)] = .{
760760 .llvm_name = "pan",
761761 .description = "Enables ARM v8.1 Privileged Access-Never extension (FEAT_PAN)",
762762 .dependencies = featureSet(&[_]Feature{}),
763763 };
764 result[@enumToInt(Feature.pan_rwv)] = .{
764 result[@intFromEnum(Feature.pan_rwv)] = .{
765765 .llvm_name = "pan-rwv",
766766 .description = "Enable v8.2 PAN s1e1R and s1e1W Variants (FEAT_PAN2)",
767767 .dependencies = featureSet(&[_]Feature{
768768 .pan,
769769 }),
770770 };
771 result[@enumToInt(Feature.pauth)] = .{
771 result[@intFromEnum(Feature.pauth)] = .{
772772 .llvm_name = "pauth",
773773 .description = "Enable v8.3-A Pointer Authentication extension (FEAT_PAuth)",
774774 .dependencies = featureSet(&[_]Feature{}),
775775 };
776 result[@enumToInt(Feature.perfmon)] = .{
776 result[@intFromEnum(Feature.perfmon)] = .{
777777 .llvm_name = "perfmon",
778778 .description = "Enable Code Generation for ARMv8 PMUv3 Performance Monitors extension (FEAT_PMUv3)",
779779 .dependencies = featureSet(&[_]Feature{}),
780780 };
781 result[@enumToInt(Feature.predictable_select_expensive)] = .{
781 result[@intFromEnum(Feature.predictable_select_expensive)] = .{
782782 .llvm_name = "predictable-select-expensive",
783783 .description = "Prefer likely predicted branches over selects",
784784 .dependencies = featureSet(&[_]Feature{}),
785785 };
786 result[@enumToInt(Feature.predres)] = .{
786 result[@intFromEnum(Feature.predres)] = .{
787787 .llvm_name = "predres",
788788 .description = "Enable v8.5a execution and data prediction invalidation instructions (FEAT_SPECRES)",
789789 .dependencies = featureSet(&[_]Feature{}),
790790 };
791 result[@enumToInt(Feature.prfm_slc_target)] = .{
791 result[@intFromEnum(Feature.prfm_slc_target)] = .{
792792 .llvm_name = "prfm-slc-target",
793793 .description = "Enable SLC target for PRFM instruction",
794794 .dependencies = featureSet(&[_]Feature{}),
795795 };
796 result[@enumToInt(Feature.rand)] = .{
796 result[@intFromEnum(Feature.rand)] = .{
797797 .llvm_name = "rand",
798798 .description = "Enable Random Number generation instructions (FEAT_RNG)",
799799 .dependencies = featureSet(&[_]Feature{}),
800800 };
801 result[@enumToInt(Feature.ras)] = .{
801 result[@intFromEnum(Feature.ras)] = .{
802802 .llvm_name = "ras",
803803 .description = "Enable ARMv8 Reliability, Availability and Serviceability Extensions (FEAT_RAS, FEAT_RASv1p1)",
804804 .dependencies = featureSet(&[_]Feature{}),
805805 };
806 result[@enumToInt(Feature.rasv2)] = .{
806 result[@intFromEnum(Feature.rasv2)] = .{
807807 .llvm_name = "rasv2",
808808 .description = "Enable ARMv8.9-A Reliability, Availability and Serviceability Extensions (FEAT_RASv2)",
809809 .dependencies = featureSet(&[_]Feature{
810810 .ras,
811811 }),
812812 };
813 result[@enumToInt(Feature.rcpc)] = .{
813 result[@intFromEnum(Feature.rcpc)] = .{
814814 .llvm_name = "rcpc",
815815 .description = "Enable support for RCPC extension (FEAT_LRCPC)",
816816 .dependencies = featureSet(&[_]Feature{}),
817817 };
818 result[@enumToInt(Feature.rcpc3)] = .{
818 result[@intFromEnum(Feature.rcpc3)] = .{
819819 .llvm_name = "rcpc3",
820820 .description = "Enable Armv8.9-A RCPC instructions for A64 and Advanced SIMD and floating-point instruction set (FEAT_LRCPC3)",
821821 .dependencies = featureSet(&[_]Feature{
822822 .rcpc_immo,
823823 }),
824824 };
825 result[@enumToInt(Feature.rcpc_immo)] = .{
825 result[@intFromEnum(Feature.rcpc_immo)] = .{
826826 .llvm_name = "rcpc-immo",
827827 .description = "Enable v8.4-A RCPC instructions with Immediate Offsets (FEAT_LRCPC2)",
828828 .dependencies = featureSet(&[_]Feature{
829829 .rcpc,
830830 }),
831831 };
832 result[@enumToInt(Feature.rdm)] = .{
832 result[@intFromEnum(Feature.rdm)] = .{
833833 .llvm_name = "rdm",
834834 .description = "Enable ARMv8.1 Rounding Double Multiply Add/Subtract instructions (FEAT_RDM)",
835835 .dependencies = featureSet(&[_]Feature{}),
836836 };
837 result[@enumToInt(Feature.reserve_x1)] = .{
837 result[@intFromEnum(Feature.reserve_x1)] = .{
838838 .llvm_name = "reserve-x1",
839839 .description = "Reserve X1, making it unavailable as a GPR",
840840 .dependencies = featureSet(&[_]Feature{}),
841841 };
842 result[@enumToInt(Feature.reserve_x10)] = .{
842 result[@intFromEnum(Feature.reserve_x10)] = .{
843843 .llvm_name = "reserve-x10",
844844 .description = "Reserve X10, making it unavailable as a GPR",
845845 .dependencies = featureSet(&[_]Feature{}),
846846 };
847 result[@enumToInt(Feature.reserve_x11)] = .{
847 result[@intFromEnum(Feature.reserve_x11)] = .{
848848 .llvm_name = "reserve-x11",
849849 .description = "Reserve X11, making it unavailable as a GPR",
850850 .dependencies = featureSet(&[_]Feature{}),
851851 };
852 result[@enumToInt(Feature.reserve_x12)] = .{
852 result[@intFromEnum(Feature.reserve_x12)] = .{
853853 .llvm_name = "reserve-x12",
854854 .description = "Reserve X12, making it unavailable as a GPR",
855855 .dependencies = featureSet(&[_]Feature{}),
856856 };
857 result[@enumToInt(Feature.reserve_x13)] = .{
857 result[@intFromEnum(Feature.reserve_x13)] = .{
858858 .llvm_name = "reserve-x13",
859859 .description = "Reserve X13, making it unavailable as a GPR",
860860 .dependencies = featureSet(&[_]Feature{}),
861861 };
862 result[@enumToInt(Feature.reserve_x14)] = .{
862 result[@intFromEnum(Feature.reserve_x14)] = .{
863863 .llvm_name = "reserve-x14",
864864 .description = "Reserve X14, making it unavailable as a GPR",
865865 .dependencies = featureSet(&[_]Feature{}),
866866 };
867 result[@enumToInt(Feature.reserve_x15)] = .{
867 result[@intFromEnum(Feature.reserve_x15)] = .{
868868 .llvm_name = "reserve-x15",
869869 .description = "Reserve X15, making it unavailable as a GPR",
870870 .dependencies = featureSet(&[_]Feature{}),
871871 };
872 result[@enumToInt(Feature.reserve_x18)] = .{
872 result[@intFromEnum(Feature.reserve_x18)] = .{
873873 .llvm_name = "reserve-x18",
874874 .description = "Reserve X18, making it unavailable as a GPR",
875875 .dependencies = featureSet(&[_]Feature{}),
876876 };
877 result[@enumToInt(Feature.reserve_x2)] = .{
877 result[@intFromEnum(Feature.reserve_x2)] = .{
878878 .llvm_name = "reserve-x2",
879879 .description = "Reserve X2, making it unavailable as a GPR",
880880 .dependencies = featureSet(&[_]Feature{}),
881881 };
882 result[@enumToInt(Feature.reserve_x20)] = .{
882 result[@intFromEnum(Feature.reserve_x20)] = .{
883883 .llvm_name = "reserve-x20",
884884 .description = "Reserve X20, making it unavailable as a GPR",
885885 .dependencies = featureSet(&[_]Feature{}),
886886 };
887 result[@enumToInt(Feature.reserve_x21)] = .{
887 result[@intFromEnum(Feature.reserve_x21)] = .{
888888 .llvm_name = "reserve-x21",
889889 .description = "Reserve X21, making it unavailable as a GPR",
890890 .dependencies = featureSet(&[_]Feature{}),
891891 };
892 result[@enumToInt(Feature.reserve_x22)] = .{
892 result[@intFromEnum(Feature.reserve_x22)] = .{
893893 .llvm_name = "reserve-x22",
894894 .description = "Reserve X22, making it unavailable as a GPR",
895895 .dependencies = featureSet(&[_]Feature{}),
896896 };
897 result[@enumToInt(Feature.reserve_x23)] = .{
897 result[@intFromEnum(Feature.reserve_x23)] = .{
898898 .llvm_name = "reserve-x23",
899899 .description = "Reserve X23, making it unavailable as a GPR",
900900 .dependencies = featureSet(&[_]Feature{}),
901901 };
902 result[@enumToInt(Feature.reserve_x24)] = .{
902 result[@intFromEnum(Feature.reserve_x24)] = .{
903903 .llvm_name = "reserve-x24",
904904 .description = "Reserve X24, making it unavailable as a GPR",
905905 .dependencies = featureSet(&[_]Feature{}),
906906 };
907 result[@enumToInt(Feature.reserve_x25)] = .{
907 result[@intFromEnum(Feature.reserve_x25)] = .{
908908 .llvm_name = "reserve-x25",
909909 .description = "Reserve X25, making it unavailable as a GPR",
910910 .dependencies = featureSet(&[_]Feature{}),
911911 };
912 result[@enumToInt(Feature.reserve_x26)] = .{
912 result[@intFromEnum(Feature.reserve_x26)] = .{
913913 .llvm_name = "reserve-x26",
914914 .description = "Reserve X26, making it unavailable as a GPR",
915915 .dependencies = featureSet(&[_]Feature{}),
916916 };
917 result[@enumToInt(Feature.reserve_x27)] = .{
917 result[@intFromEnum(Feature.reserve_x27)] = .{
918918 .llvm_name = "reserve-x27",
919919 .description = "Reserve X27, making it unavailable as a GPR",
920920 .dependencies = featureSet(&[_]Feature{}),
921921 };
922 result[@enumToInt(Feature.reserve_x28)] = .{
922 result[@intFromEnum(Feature.reserve_x28)] = .{
923923 .llvm_name = "reserve-x28",
924924 .description = "Reserve X28, making it unavailable as a GPR",
925925 .dependencies = featureSet(&[_]Feature{}),
926926 };
927 result[@enumToInt(Feature.reserve_x3)] = .{
927 result[@intFromEnum(Feature.reserve_x3)] = .{
928928 .llvm_name = "reserve-x3",
929929 .description = "Reserve X3, making it unavailable as a GPR",
930930 .dependencies = featureSet(&[_]Feature{}),
931931 };
932 result[@enumToInt(Feature.reserve_x30)] = .{
932 result[@intFromEnum(Feature.reserve_x30)] = .{
933933 .llvm_name = "reserve-x30",
934934 .description = "Reserve X30, making it unavailable as a GPR",
935935 .dependencies = featureSet(&[_]Feature{}),
936936 };
937 result[@enumToInt(Feature.reserve_x4)] = .{
937 result[@intFromEnum(Feature.reserve_x4)] = .{
938938 .llvm_name = "reserve-x4",
939939 .description = "Reserve X4, making it unavailable as a GPR",
940940 .dependencies = featureSet(&[_]Feature{}),
941941 };
942 result[@enumToInt(Feature.reserve_x5)] = .{
942 result[@intFromEnum(Feature.reserve_x5)] = .{
943943 .llvm_name = "reserve-x5",
944944 .description = "Reserve X5, making it unavailable as a GPR",
945945 .dependencies = featureSet(&[_]Feature{}),
946946 };
947 result[@enumToInt(Feature.reserve_x6)] = .{
947 result[@intFromEnum(Feature.reserve_x6)] = .{
948948 .llvm_name = "reserve-x6",
949949 .description = "Reserve X6, making it unavailable as a GPR",
950950 .dependencies = featureSet(&[_]Feature{}),
951951 };
952 result[@enumToInt(Feature.reserve_x7)] = .{
952 result[@intFromEnum(Feature.reserve_x7)] = .{
953953 .llvm_name = "reserve-x7",
954954 .description = "Reserve X7, making it unavailable as a GPR",
955955 .dependencies = featureSet(&[_]Feature{}),
956956 };
957 result[@enumToInt(Feature.reserve_x9)] = .{
957 result[@intFromEnum(Feature.reserve_x9)] = .{
958958 .llvm_name = "reserve-x9",
959959 .description = "Reserve X9, making it unavailable as a GPR",
960960 .dependencies = featureSet(&[_]Feature{}),
961961 };
962 result[@enumToInt(Feature.rme)] = .{
962 result[@intFromEnum(Feature.rme)] = .{
963963 .llvm_name = "rme",
964964 .description = "Enable Realm Management Extension (FEAT_RME)",
965965 .dependencies = featureSet(&[_]Feature{}),
966966 };
967 result[@enumToInt(Feature.sb)] = .{
967 result[@intFromEnum(Feature.sb)] = .{
968968 .llvm_name = "sb",
969969 .description = "Enable v8.5 Speculation Barrier (FEAT_SB)",
970970 .dependencies = featureSet(&[_]Feature{}),
971971 };
972 result[@enumToInt(Feature.sel2)] = .{
972 result[@intFromEnum(Feature.sel2)] = .{
973973 .llvm_name = "sel2",
974974 .description = "Enable v8.4-A Secure Exception Level 2 extension (FEAT_SEL2)",
975975 .dependencies = featureSet(&[_]Feature{}),
976976 };
977 result[@enumToInt(Feature.sha2)] = .{
977 result[@intFromEnum(Feature.sha2)] = .{
978978 .llvm_name = "sha2",
979979 .description = "Enable SHA1 and SHA256 support (FEAT_SHA1, FEAT_SHA256)",
980980 .dependencies = featureSet(&[_]Feature{
981981 .neon,
982982 }),
983983 };
984 result[@enumToInt(Feature.sha3)] = .{
984 result[@intFromEnum(Feature.sha3)] = .{
985985 .llvm_name = "sha3",
986986 .description = "Enable SHA512 and SHA3 support (FEAT_SHA3, FEAT_SHA512)",
987987 .dependencies = featureSet(&[_]Feature{
988988 .sha2,
989989 }),
990990 };
991 result[@enumToInt(Feature.slow_misaligned_128store)] = .{
991 result[@intFromEnum(Feature.slow_misaligned_128store)] = .{
992992 .llvm_name = "slow-misaligned-128store",
993993 .description = "Misaligned 128 bit stores are slow",
994994 .dependencies = featureSet(&[_]Feature{}),
995995 };
996 result[@enumToInt(Feature.slow_paired_128)] = .{
996 result[@intFromEnum(Feature.slow_paired_128)] = .{
997997 .llvm_name = "slow-paired-128",
998998 .description = "Paired 128 bit loads and stores are slow",
999999 .dependencies = featureSet(&[_]Feature{}),
10001000 };
1001 result[@enumToInt(Feature.slow_strqro_store)] = .{
1001 result[@intFromEnum(Feature.slow_strqro_store)] = .{
10021002 .llvm_name = "slow-strqro-store",
10031003 .description = "STR of Q register with register offset is slow",
10041004 .dependencies = featureSet(&[_]Feature{}),
10051005 };
1006 result[@enumToInt(Feature.sm4)] = .{
1006 result[@intFromEnum(Feature.sm4)] = .{
10071007 .llvm_name = "sm4",
10081008 .description = "Enable SM3 and SM4 support (FEAT_SM4, FEAT_SM3)",
10091009 .dependencies = featureSet(&[_]Feature{
10101010 .neon,
10111011 }),
10121012 };
1013 result[@enumToInt(Feature.sme)] = .{
1013 result[@intFromEnum(Feature.sme)] = .{
10141014 .llvm_name = "sme",
10151015 .description = "Enable Scalable Matrix Extension (SME) (FEAT_SME)",
10161016 .dependencies = featureSet(&[_]Feature{
......@@ -1018,79 +1018,79 @@ pub const all_features = blk: {
10181018 .use_scalar_inc_vl,
10191019 }),
10201020 };
1021 result[@enumToInt(Feature.sme2)] = .{
1021 result[@intFromEnum(Feature.sme2)] = .{
10221022 .llvm_name = "sme2",
10231023 .description = "Enable Scalable Matrix Extension 2 (SME2) instructions",
10241024 .dependencies = featureSet(&[_]Feature{
10251025 .sme,
10261026 }),
10271027 };
1028 result[@enumToInt(Feature.sme2p1)] = .{
1028 result[@intFromEnum(Feature.sme2p1)] = .{
10291029 .llvm_name = "sme2p1",
10301030 .description = "Enable Scalable Matrix Extension 2.1 (FEAT_SME2p1) instructions",
10311031 .dependencies = featureSet(&[_]Feature{
10321032 .sme2,
10331033 }),
10341034 };
1035 result[@enumToInt(Feature.sme_f16f16)] = .{
1035 result[@intFromEnum(Feature.sme_f16f16)] = .{
10361036 .llvm_name = "sme-f16f16",
10371037 .description = "Enable SME2.1 non-widening Float16 instructions (FEAT_SME_F16F16)",
10381038 .dependencies = featureSet(&[_]Feature{}),
10391039 };
1040 result[@enumToInt(Feature.sme_f64f64)] = .{
1040 result[@intFromEnum(Feature.sme_f64f64)] = .{
10411041 .llvm_name = "sme-f64f64",
10421042 .description = "Enable Scalable Matrix Extension (SME) F64F64 instructions (FEAT_SME_F64F64)",
10431043 .dependencies = featureSet(&[_]Feature{
10441044 .sme,
10451045 }),
10461046 };
1047 result[@enumToInt(Feature.sme_i16i64)] = .{
1047 result[@intFromEnum(Feature.sme_i16i64)] = .{
10481048 .llvm_name = "sme-i16i64",
10491049 .description = "Enable Scalable Matrix Extension (SME) I16I64 instructions (FEAT_SME_I16I64)",
10501050 .dependencies = featureSet(&[_]Feature{
10511051 .sme,
10521052 }),
10531053 };
1054 result[@enumToInt(Feature.spe)] = .{
1054 result[@intFromEnum(Feature.spe)] = .{
10551055 .llvm_name = "spe",
10561056 .description = "Enable Statistical Profiling extension (FEAT_SPE)",
10571057 .dependencies = featureSet(&[_]Feature{}),
10581058 };
1059 result[@enumToInt(Feature.spe_eef)] = .{
1059 result[@intFromEnum(Feature.spe_eef)] = .{
10601060 .llvm_name = "spe-eef",
10611061 .description = "Enable extra register in the Statistical Profiling Extension (FEAT_SPEv1p2)",
10621062 .dependencies = featureSet(&[_]Feature{}),
10631063 };
1064 result[@enumToInt(Feature.specres2)] = .{
1064 result[@intFromEnum(Feature.specres2)] = .{
10651065 .llvm_name = "specres2",
10661066 .description = "Enable Speculation Restriction Instruction (FEAT_SPECRES2)",
10671067 .dependencies = featureSet(&[_]Feature{
10681068 .predres,
10691069 }),
10701070 };
1071 result[@enumToInt(Feature.specrestrict)] = .{
1071 result[@intFromEnum(Feature.specrestrict)] = .{
10721072 .llvm_name = "specrestrict",
10731073 .description = "Enable architectural speculation restriction (FEAT_CSV2_2)",
10741074 .dependencies = featureSet(&[_]Feature{}),
10751075 };
1076 result[@enumToInt(Feature.ssbs)] = .{
1076 result[@intFromEnum(Feature.ssbs)] = .{
10771077 .llvm_name = "ssbs",
10781078 .description = "Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)",
10791079 .dependencies = featureSet(&[_]Feature{}),
10801080 };
1081 result[@enumToInt(Feature.strict_align)] = .{
1081 result[@intFromEnum(Feature.strict_align)] = .{
10821082 .llvm_name = "strict-align",
10831083 .description = "Disallow all unaligned memory access",
10841084 .dependencies = featureSet(&[_]Feature{}),
10851085 };
1086 result[@enumToInt(Feature.sve)] = .{
1086 result[@intFromEnum(Feature.sve)] = .{
10871087 .llvm_name = "sve",
10881088 .description = "Enable Scalable Vector Extension (SVE) instructions (FEAT_SVE)",
10891089 .dependencies = featureSet(&[_]Feature{
10901090 .fullfp16,
10911091 }),
10921092 };
1093 result[@enumToInt(Feature.sve2)] = .{
1093 result[@intFromEnum(Feature.sve2)] = .{
10941094 .llvm_name = "sve2",
10951095 .description = "Enable Scalable Vector Extension 2 (SVE2) instructions (FEAT_SVE2)",
10961096 .dependencies = featureSet(&[_]Feature{
......@@ -1098,7 +1098,7 @@ pub const all_features = blk: {
10981098 .use_scalar_inc_vl,
10991099 }),
11001100 };
1101 result[@enumToInt(Feature.sve2_aes)] = .{
1101 result[@intFromEnum(Feature.sve2_aes)] = .{
11021102 .llvm_name = "sve2-aes",
11031103 .description = "Enable AES SVE2 instructions (FEAT_SVE_AES, FEAT_SVE_PMULL128)",
11041104 .dependencies = featureSet(&[_]Feature{
......@@ -1106,14 +1106,14 @@ pub const all_features = blk: {
11061106 .sve2,
11071107 }),
11081108 };
1109 result[@enumToInt(Feature.sve2_bitperm)] = .{
1109 result[@intFromEnum(Feature.sve2_bitperm)] = .{
11101110 .llvm_name = "sve2-bitperm",
11111111 .description = "Enable bit permutation SVE2 instructions (FEAT_SVE_BitPerm)",
11121112 .dependencies = featureSet(&[_]Feature{
11131113 .sve2,
11141114 }),
11151115 };
1116 result[@enumToInt(Feature.sve2_sha3)] = .{
1116 result[@intFromEnum(Feature.sve2_sha3)] = .{
11171117 .llvm_name = "sve2-sha3",
11181118 .description = "Enable SHA3 SVE2 instructions (FEAT_SVE_SHA3)",
11191119 .dependencies = featureSet(&[_]Feature{
......@@ -1121,7 +1121,7 @@ pub const all_features = blk: {
11211121 .sve2,
11221122 }),
11231123 };
1124 result[@enumToInt(Feature.sve2_sm4)] = .{
1124 result[@intFromEnum(Feature.sve2_sm4)] = .{
11251125 .llvm_name = "sve2-sm4",
11261126 .description = "Enable SM4 SVE2 instructions (FEAT_SVE_SM4)",
11271127 .dependencies = featureSet(&[_]Feature{
......@@ -1129,84 +1129,84 @@ pub const all_features = blk: {
11291129 .sve2,
11301130 }),
11311131 };
1132 result[@enumToInt(Feature.sve2p1)] = .{
1132 result[@intFromEnum(Feature.sve2p1)] = .{
11331133 .llvm_name = "sve2p1",
11341134 .description = "Enable Scalable Vector Extension 2.1 instructions",
11351135 .dependencies = featureSet(&[_]Feature{
11361136 .sve2,
11371137 }),
11381138 };
1139 result[@enumToInt(Feature.tagged_globals)] = .{
1139 result[@intFromEnum(Feature.tagged_globals)] = .{
11401140 .llvm_name = "tagged-globals",
11411141 .description = "Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits",
11421142 .dependencies = featureSet(&[_]Feature{}),
11431143 };
1144 result[@enumToInt(Feature.the)] = .{
1144 result[@intFromEnum(Feature.the)] = .{
11451145 .llvm_name = "the",
11461146 .description = "Enable Armv8.9-A Translation Hardening Extension (FEAT_THE)",
11471147 .dependencies = featureSet(&[_]Feature{}),
11481148 };
1149 result[@enumToInt(Feature.tlb_rmi)] = .{
1149 result[@intFromEnum(Feature.tlb_rmi)] = .{
11501150 .llvm_name = "tlb-rmi",
11511151 .description = "Enable v8.4-A TLB Range and Maintenance Instructions (FEAT_TLBIOS, FEAT_TLBIRANGE)",
11521152 .dependencies = featureSet(&[_]Feature{}),
11531153 };
1154 result[@enumToInt(Feature.tme)] = .{
1154 result[@intFromEnum(Feature.tme)] = .{
11551155 .llvm_name = "tme",
11561156 .description = "Enable Transactional Memory Extension (FEAT_TME)",
11571157 .dependencies = featureSet(&[_]Feature{}),
11581158 };
1159 result[@enumToInt(Feature.tpidr_el1)] = .{
1159 result[@intFromEnum(Feature.tpidr_el1)] = .{
11601160 .llvm_name = "tpidr-el1",
11611161 .description = "Permit use of TPIDR_EL1 for the TLS base",
11621162 .dependencies = featureSet(&[_]Feature{}),
11631163 };
1164 result[@enumToInt(Feature.tpidr_el2)] = .{
1164 result[@intFromEnum(Feature.tpidr_el2)] = .{
11651165 .llvm_name = "tpidr-el2",
11661166 .description = "Permit use of TPIDR_EL2 for the TLS base",
11671167 .dependencies = featureSet(&[_]Feature{}),
11681168 };
1169 result[@enumToInt(Feature.tpidr_el3)] = .{
1169 result[@intFromEnum(Feature.tpidr_el3)] = .{
11701170 .llvm_name = "tpidr-el3",
11711171 .description = "Permit use of TPIDR_EL3 for the TLS base",
11721172 .dependencies = featureSet(&[_]Feature{}),
11731173 };
1174 result[@enumToInt(Feature.tracev8_4)] = .{
1174 result[@intFromEnum(Feature.tracev8_4)] = .{
11751175 .llvm_name = "tracev8.4",
11761176 .description = "Enable v8.4-A Trace extension (FEAT_TRF)",
11771177 .dependencies = featureSet(&[_]Feature{}),
11781178 };
1179 result[@enumToInt(Feature.trbe)] = .{
1179 result[@intFromEnum(Feature.trbe)] = .{
11801180 .llvm_name = "trbe",
11811181 .description = "Enable Trace Buffer Extension (FEAT_TRBE)",
11821182 .dependencies = featureSet(&[_]Feature{}),
11831183 };
1184 result[@enumToInt(Feature.uaops)] = .{
1184 result[@intFromEnum(Feature.uaops)] = .{
11851185 .llvm_name = "uaops",
11861186 .description = "Enable v8.2 UAO PState (FEAT_UAO)",
11871187 .dependencies = featureSet(&[_]Feature{}),
11881188 };
1189 result[@enumToInt(Feature.use_experimental_zeroing_pseudos)] = .{
1189 result[@intFromEnum(Feature.use_experimental_zeroing_pseudos)] = .{
11901190 .llvm_name = "use-experimental-zeroing-pseudos",
11911191 .description = "Hint to the compiler that the MOVPRFX instruction is merged with destructive operations",
11921192 .dependencies = featureSet(&[_]Feature{}),
11931193 };
1194 result[@enumToInt(Feature.use_postra_scheduler)] = .{
1194 result[@intFromEnum(Feature.use_postra_scheduler)] = .{
11951195 .llvm_name = "use-postra-scheduler",
11961196 .description = "Schedule again after register allocation",
11971197 .dependencies = featureSet(&[_]Feature{}),
11981198 };
1199 result[@enumToInt(Feature.use_reciprocal_square_root)] = .{
1199 result[@intFromEnum(Feature.use_reciprocal_square_root)] = .{
12001200 .llvm_name = "use-reciprocal-square-root",
12011201 .description = "Use the reciprocal square root approximation",
12021202 .dependencies = featureSet(&[_]Feature{}),
12031203 };
1204 result[@enumToInt(Feature.use_scalar_inc_vl)] = .{
1204 result[@intFromEnum(Feature.use_scalar_inc_vl)] = .{
12051205 .llvm_name = "use-scalar-inc-vl",
12061206 .description = "Prefer inc/dec over add+cnt",
12071207 .dependencies = featureSet(&[_]Feature{}),
12081208 };
1209 result[@enumToInt(Feature.v8_1a)] = .{
1209 result[@intFromEnum(Feature.v8_1a)] = .{
12101210 .llvm_name = "v8.1a",
12111211 .description = "Support ARM v8.1a instructions",
12121212 .dependencies = featureSet(&[_]Feature{
......@@ -1219,7 +1219,7 @@ pub const all_features = blk: {
12191219 .vh,
12201220 }),
12211221 };
1222 result[@enumToInt(Feature.v8_2a)] = .{
1222 result[@intFromEnum(Feature.v8_2a)] = .{
12231223 .llvm_name = "v8.2a",
12241224 .description = "Support ARM v8.2a instructions",
12251225 .dependencies = featureSet(&[_]Feature{
......@@ -1230,7 +1230,7 @@ pub const all_features = blk: {
12301230 .v8_1a,
12311231 }),
12321232 };
1233 result[@enumToInt(Feature.v8_3a)] = .{
1233 result[@intFromEnum(Feature.v8_3a)] = .{
12341234 .llvm_name = "v8.3a",
12351235 .description = "Support ARM v8.3a instructions",
12361236 .dependencies = featureSet(&[_]Feature{
......@@ -1242,7 +1242,7 @@ pub const all_features = blk: {
12421242 .v8_2a,
12431243 }),
12441244 };
1245 result[@enumToInt(Feature.v8_4a)] = .{
1245 result[@intFromEnum(Feature.v8_4a)] = .{
12461246 .llvm_name = "v8.4a",
12471247 .description = "Support ARM v8.4a instructions",
12481248 .dependencies = featureSet(&[_]Feature{
......@@ -1260,7 +1260,7 @@ pub const all_features = blk: {
12601260 .v8_3a,
12611261 }),
12621262 };
1263 result[@enumToInt(Feature.v8_5a)] = .{
1263 result[@intFromEnum(Feature.v8_5a)] = .{
12641264 .llvm_name = "v8.5a",
12651265 .description = "Support ARM v8.5a instructions",
12661266 .dependencies = featureSet(&[_]Feature{
......@@ -1275,7 +1275,7 @@ pub const all_features = blk: {
12751275 .v8_4a,
12761276 }),
12771277 };
1278 result[@enumToInt(Feature.v8_6a)] = .{
1278 result[@intFromEnum(Feature.v8_6a)] = .{
12791279 .llvm_name = "v8.6a",
12801280 .description = "Support ARM v8.6a instructions",
12811281 .dependencies = featureSet(&[_]Feature{
......@@ -1287,7 +1287,7 @@ pub const all_features = blk: {
12871287 .v8_5a,
12881288 }),
12891289 };
1290 result[@enumToInt(Feature.v8_7a)] = .{
1290 result[@intFromEnum(Feature.v8_7a)] = .{
12911291 .llvm_name = "v8.7a",
12921292 .description = "Support ARM v8.7a instructions",
12931293 .dependencies = featureSet(&[_]Feature{
......@@ -1297,7 +1297,7 @@ pub const all_features = blk: {
12971297 .xs,
12981298 }),
12991299 };
1300 result[@enumToInt(Feature.v8_8a)] = .{
1300 result[@intFromEnum(Feature.v8_8a)] = .{
13011301 .llvm_name = "v8.8a",
13021302 .description = "Support ARM v8.8a instructions",
13031303 .dependencies = featureSet(&[_]Feature{
......@@ -1307,7 +1307,7 @@ pub const all_features = blk: {
13071307 .v8_7a,
13081308 }),
13091309 };
1310 result[@enumToInt(Feature.v8_9a)] = .{
1310 result[@intFromEnum(Feature.v8_9a)] = .{
13111311 .llvm_name = "v8.9a",
13121312 .description = "Support ARM v8.9a instructions",
13131313 .dependencies = featureSet(&[_]Feature{
......@@ -1319,7 +1319,7 @@ pub const all_features = blk: {
13191319 .v8_8a,
13201320 }),
13211321 };
1322 result[@enumToInt(Feature.v8a)] = .{
1322 result[@intFromEnum(Feature.v8a)] = .{
13231323 .llvm_name = "v8a",
13241324 .description = "Support ARM v8.0a instructions",
13251325 .dependencies = featureSet(&[_]Feature{
......@@ -1328,7 +1328,7 @@ pub const all_features = blk: {
13281328 .neon,
13291329 }),
13301330 };
1331 result[@enumToInt(Feature.v8r)] = .{
1331 result[@intFromEnum(Feature.v8r)] = .{
13321332 .llvm_name = "v8r",
13331333 .description = "Support ARM v8r instructions",
13341334 .dependencies = featureSet(&[_]Feature{
......@@ -1354,7 +1354,7 @@ pub const all_features = blk: {
13541354 .uaops,
13551355 }),
13561356 };
1357 result[@enumToInt(Feature.v9_1a)] = .{
1357 result[@intFromEnum(Feature.v9_1a)] = .{
13581358 .llvm_name = "v9.1a",
13591359 .description = "Support ARM v9.1a instructions",
13601360 .dependencies = featureSet(&[_]Feature{
......@@ -1362,7 +1362,7 @@ pub const all_features = blk: {
13621362 .v9a,
13631363 }),
13641364 };
1365 result[@enumToInt(Feature.v9_2a)] = .{
1365 result[@intFromEnum(Feature.v9_2a)] = .{
13661366 .llvm_name = "v9.2a",
13671367 .description = "Support ARM v9.2a instructions",
13681368 .dependencies = featureSet(&[_]Feature{
......@@ -1370,7 +1370,7 @@ pub const all_features = blk: {
13701370 .v9_1a,
13711371 }),
13721372 };
1373 result[@enumToInt(Feature.v9_3a)] = .{
1373 result[@intFromEnum(Feature.v9_3a)] = .{
13741374 .llvm_name = "v9.3a",
13751375 .description = "Support ARM v9.3a instructions",
13761376 .dependencies = featureSet(&[_]Feature{
......@@ -1378,7 +1378,7 @@ pub const all_features = blk: {
13781378 .v9_2a,
13791379 }),
13801380 };
1381 result[@enumToInt(Feature.v9_4a)] = .{
1381 result[@intFromEnum(Feature.v9_4a)] = .{
13821382 .llvm_name = "v9.4a",
13831383 .description = "Support ARM v9.4a instructions",
13841384 .dependencies = featureSet(&[_]Feature{
......@@ -1386,7 +1386,7 @@ pub const all_features = blk: {
13861386 .v9_3a,
13871387 }),
13881388 };
1389 result[@enumToInt(Feature.v9a)] = .{
1389 result[@intFromEnum(Feature.v9a)] = .{
13901390 .llvm_name = "v9a",
13911391 .description = "Support ARM v9a instructions",
13921392 .dependencies = featureSet(&[_]Feature{
......@@ -1395,41 +1395,41 @@ pub const all_features = blk: {
13951395 .v8_5a,
13961396 }),
13971397 };
1398 result[@enumToInt(Feature.vh)] = .{
1398 result[@intFromEnum(Feature.vh)] = .{
13991399 .llvm_name = "vh",
14001400 .description = "Enables ARM v8.1 Virtual Host extension (FEAT_VHE)",
14011401 .dependencies = featureSet(&[_]Feature{
14021402 .contextidr_el2,
14031403 }),
14041404 };
1405 result[@enumToInt(Feature.wfxt)] = .{
1405 result[@intFromEnum(Feature.wfxt)] = .{
14061406 .llvm_name = "wfxt",
14071407 .description = "Enable Armv8.7-A WFET and WFIT instruction (FEAT_WFxT)",
14081408 .dependencies = featureSet(&[_]Feature{}),
14091409 };
1410 result[@enumToInt(Feature.xs)] = .{
1410 result[@intFromEnum(Feature.xs)] = .{
14111411 .llvm_name = "xs",
14121412 .description = "Enable Armv8.7-A limited-TLB-maintenance instruction (FEAT_XS)",
14131413 .dependencies = featureSet(&[_]Feature{}),
14141414 };
1415 result[@enumToInt(Feature.zcm)] = .{
1415 result[@intFromEnum(Feature.zcm)] = .{
14161416 .llvm_name = "zcm",
14171417 .description = "Has zero-cycle register moves",
14181418 .dependencies = featureSet(&[_]Feature{}),
14191419 };
1420 result[@enumToInt(Feature.zcz)] = .{
1420 result[@intFromEnum(Feature.zcz)] = .{
14211421 .llvm_name = "zcz",
14221422 .description = "Has zero-cycle zeroing instructions",
14231423 .dependencies = featureSet(&[_]Feature{
14241424 .zcz_gp,
14251425 }),
14261426 };
1427 result[@enumToInt(Feature.zcz_fp_workaround)] = .{
1427 result[@intFromEnum(Feature.zcz_fp_workaround)] = .{
14281428 .llvm_name = "zcz-fp-workaround",
14291429 .description = "The zero-cycle floating-point zeroing instruction has a bug",
14301430 .dependencies = featureSet(&[_]Feature{}),
14311431 };
1432 result[@enumToInt(Feature.zcz_gp)] = .{
1432 result[@intFromEnum(Feature.zcz_gp)] = .{
14331433 .llvm_name = "zcz-gp",
14341434 .description = "Has zero-cycle zeroing instructions for generic registers",
14351435 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/amdgpu.zig+146-146
......@@ -162,248 +162,248 @@ pub const all_features = blk: {
162162 const len = @typeInfo(Feature).Enum.fields.len;
163163 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
164164 var result: [len]CpuFeature = undefined;
165 result[@enumToInt(Feature.@"16_bit_insts")] = .{
165 result[@intFromEnum(Feature.@"16_bit_insts")] = .{
166166 .llvm_name = "16-bit-insts",
167167 .description = "Has i16/f16 instructions",
168168 .dependencies = featureSet(&[_]Feature{}),
169169 };
170 result[@enumToInt(Feature.a16)] = .{
170 result[@intFromEnum(Feature.a16)] = .{
171171 .llvm_name = "a16",
172172 .description = "Support A16 for 16-bit coordinates/gradients/lod/clamp/mip image operands",
173173 .dependencies = featureSet(&[_]Feature{}),
174174 };
175 result[@enumToInt(Feature.add_no_carry_insts)] = .{
175 result[@intFromEnum(Feature.add_no_carry_insts)] = .{
176176 .llvm_name = "add-no-carry-insts",
177177 .description = "Have VALU add/sub instructions without carry out",
178178 .dependencies = featureSet(&[_]Feature{}),
179179 };
180 result[@enumToInt(Feature.aperture_regs)] = .{
180 result[@intFromEnum(Feature.aperture_regs)] = .{
181181 .llvm_name = "aperture-regs",
182182 .description = "Has Memory Aperture Base and Size Registers",
183183 .dependencies = featureSet(&[_]Feature{}),
184184 };
185 result[@enumToInt(Feature.architected_flat_scratch)] = .{
185 result[@intFromEnum(Feature.architected_flat_scratch)] = .{
186186 .llvm_name = "architected-flat-scratch",
187187 .description = "Flat Scratch register is a readonly SPI initialized architected register",
188188 .dependencies = featureSet(&[_]Feature{}),
189189 };
190 result[@enumToInt(Feature.atomic_fadd_no_rtn_insts)] = .{
190 result[@intFromEnum(Feature.atomic_fadd_no_rtn_insts)] = .{
191191 .llvm_name = "atomic-fadd-no-rtn-insts",
192192 .description = "Has buffer_atomic_add_f32 and global_atomic_add_f32 instructions that don't return original value",
193193 .dependencies = featureSet(&[_]Feature{
194194 .flat_global_insts,
195195 }),
196196 };
197 result[@enumToInt(Feature.atomic_fadd_rtn_insts)] = .{
197 result[@intFromEnum(Feature.atomic_fadd_rtn_insts)] = .{
198198 .llvm_name = "atomic-fadd-rtn-insts",
199199 .description = "Has buffer_atomic_add_f32 and global_atomic_add_f32 instructions that return original value",
200200 .dependencies = featureSet(&[_]Feature{
201201 .flat_global_insts,
202202 }),
203203 };
204 result[@enumToInt(Feature.atomic_pk_fadd_no_rtn_insts)] = .{
204 result[@intFromEnum(Feature.atomic_pk_fadd_no_rtn_insts)] = .{
205205 .llvm_name = "atomic-pk-fadd-no-rtn-insts",
206206 .description = "Has buffer_atomic_pk_add_f16 and global_atomic_pk_add_f16 instructions that don't return original value",
207207 .dependencies = featureSet(&[_]Feature{
208208 .flat_global_insts,
209209 }),
210210 };
211 result[@enumToInt(Feature.auto_waitcnt_before_barrier)] = .{
211 result[@intFromEnum(Feature.auto_waitcnt_before_barrier)] = .{
212212 .llvm_name = "auto-waitcnt-before-barrier",
213213 .description = "Hardware automatically inserts waitcnt before barrier",
214214 .dependencies = featureSet(&[_]Feature{}),
215215 };
216 result[@enumToInt(Feature.back_off_barrier)] = .{
216 result[@intFromEnum(Feature.back_off_barrier)] = .{
217217 .llvm_name = "back-off-barrier",
218218 .description = "Hardware supports backing off s_barrier if an exception occurs",
219219 .dependencies = featureSet(&[_]Feature{}),
220220 };
221 result[@enumToInt(Feature.ci_insts)] = .{
221 result[@intFromEnum(Feature.ci_insts)] = .{
222222 .llvm_name = "ci-insts",
223223 .description = "Additional instructions for CI+",
224224 .dependencies = featureSet(&[_]Feature{}),
225225 };
226 result[@enumToInt(Feature.cumode)] = .{
226 result[@intFromEnum(Feature.cumode)] = .{
227227 .llvm_name = "cumode",
228228 .description = "Enable CU wavefront execution mode",
229229 .dependencies = featureSet(&[_]Feature{}),
230230 };
231 result[@enumToInt(Feature.dl_insts)] = .{
231 result[@intFromEnum(Feature.dl_insts)] = .{
232232 .llvm_name = "dl-insts",
233233 .description = "Has v_fmac_f32 and v_xnor_b32 instructions",
234234 .dependencies = featureSet(&[_]Feature{}),
235235 };
236 result[@enumToInt(Feature.dot1_insts)] = .{
236 result[@intFromEnum(Feature.dot1_insts)] = .{
237237 .llvm_name = "dot1-insts",
238238 .description = "Has v_dot4_i32_i8 and v_dot8_i32_i4 instructions",
239239 .dependencies = featureSet(&[_]Feature{}),
240240 };
241 result[@enumToInt(Feature.dot2_insts)] = .{
241 result[@intFromEnum(Feature.dot2_insts)] = .{
242242 .llvm_name = "dot2-insts",
243243 .description = "Has v_dot2_i32_i16, v_dot2_u32_u16 instructions",
244244 .dependencies = featureSet(&[_]Feature{}),
245245 };
246 result[@enumToInt(Feature.dot3_insts)] = .{
246 result[@intFromEnum(Feature.dot3_insts)] = .{
247247 .llvm_name = "dot3-insts",
248248 .description = "Has v_dot8c_i32_i4 instruction",
249249 .dependencies = featureSet(&[_]Feature{}),
250250 };
251 result[@enumToInt(Feature.dot4_insts)] = .{
251 result[@intFromEnum(Feature.dot4_insts)] = .{
252252 .llvm_name = "dot4-insts",
253253 .description = "Has v_dot2c_i32_i16 instruction",
254254 .dependencies = featureSet(&[_]Feature{}),
255255 };
256 result[@enumToInt(Feature.dot5_insts)] = .{
256 result[@intFromEnum(Feature.dot5_insts)] = .{
257257 .llvm_name = "dot5-insts",
258258 .description = "Has v_dot2c_f32_f16 instruction",
259259 .dependencies = featureSet(&[_]Feature{}),
260260 };
261 result[@enumToInt(Feature.dot6_insts)] = .{
261 result[@intFromEnum(Feature.dot6_insts)] = .{
262262 .llvm_name = "dot6-insts",
263263 .description = "Has v_dot4c_i32_i8 instruction",
264264 .dependencies = featureSet(&[_]Feature{}),
265265 };
266 result[@enumToInt(Feature.dot7_insts)] = .{
266 result[@intFromEnum(Feature.dot7_insts)] = .{
267267 .llvm_name = "dot7-insts",
268268 .description = "Has v_dot2_f32_f16, v_dot4_u32_u8, v_dot8_u32_u4 instructions",
269269 .dependencies = featureSet(&[_]Feature{}),
270270 };
271 result[@enumToInt(Feature.dot8_insts)] = .{
271 result[@intFromEnum(Feature.dot8_insts)] = .{
272272 .llvm_name = "dot8-insts",
273273 .description = "Has v_dot4_i32_iu8, v_dot8_i32_iu4 instructions",
274274 .dependencies = featureSet(&[_]Feature{}),
275275 };
276 result[@enumToInt(Feature.dot9_insts)] = .{
276 result[@intFromEnum(Feature.dot9_insts)] = .{
277277 .llvm_name = "dot9-insts",
278278 .description = "Has v_dot2_f16_f16, v_dot2_bf16_bf16, v_dot2_f32_bf16 instructions",
279279 .dependencies = featureSet(&[_]Feature{}),
280280 };
281 result[@enumToInt(Feature.dpp)] = .{
281 result[@intFromEnum(Feature.dpp)] = .{
282282 .llvm_name = "dpp",
283283 .description = "Support DPP (Data Parallel Primitives) extension",
284284 .dependencies = featureSet(&[_]Feature{}),
285285 };
286 result[@enumToInt(Feature.dpp8)] = .{
286 result[@intFromEnum(Feature.dpp8)] = .{
287287 .llvm_name = "dpp8",
288288 .description = "Support DPP8 (Data Parallel Primitives) extension",
289289 .dependencies = featureSet(&[_]Feature{}),
290290 };
291 result[@enumToInt(Feature.dpp_64bit)] = .{
291 result[@intFromEnum(Feature.dpp_64bit)] = .{
292292 .llvm_name = "dpp-64bit",
293293 .description = "Support DPP (Data Parallel Primitives) extension",
294294 .dependencies = featureSet(&[_]Feature{}),
295295 };
296 result[@enumToInt(Feature.ds128)] = .{
296 result[@intFromEnum(Feature.ds128)] = .{
297297 .llvm_name = "enable-ds128",
298298 .description = "Use ds_{read|write}_b128",
299299 .dependencies = featureSet(&[_]Feature{}),
300300 };
301 result[@enumToInt(Feature.ds_src2_insts)] = .{
301 result[@intFromEnum(Feature.ds_src2_insts)] = .{
302302 .llvm_name = "ds-src2-insts",
303303 .description = "Has ds_*_src2 instructions",
304304 .dependencies = featureSet(&[_]Feature{}),
305305 };
306 result[@enumToInt(Feature.extended_image_insts)] = .{
306 result[@intFromEnum(Feature.extended_image_insts)] = .{
307307 .llvm_name = "extended-image-insts",
308308 .description = "Support mips != 0, lod != 0, gather4, and get_lod",
309309 .dependencies = featureSet(&[_]Feature{}),
310310 };
311 result[@enumToInt(Feature.fast_denormal_f32)] = .{
311 result[@intFromEnum(Feature.fast_denormal_f32)] = .{
312312 .llvm_name = "fast-denormal-f32",
313313 .description = "Enabling denormals does not cause f32 instructions to run at f64 rates",
314314 .dependencies = featureSet(&[_]Feature{}),
315315 };
316 result[@enumToInt(Feature.fast_fmaf)] = .{
316 result[@intFromEnum(Feature.fast_fmaf)] = .{
317317 .llvm_name = "fast-fmaf",
318318 .description = "Assuming f32 fma is at least as fast as mul + add",
319319 .dependencies = featureSet(&[_]Feature{}),
320320 };
321 result[@enumToInt(Feature.flat_address_space)] = .{
321 result[@intFromEnum(Feature.flat_address_space)] = .{
322322 .llvm_name = "flat-address-space",
323323 .description = "Support flat address space",
324324 .dependencies = featureSet(&[_]Feature{}),
325325 };
326 result[@enumToInt(Feature.flat_atomic_fadd_f32_inst)] = .{
326 result[@intFromEnum(Feature.flat_atomic_fadd_f32_inst)] = .{
327327 .llvm_name = "flat-atomic-fadd-f32-inst",
328328 .description = "Has flat_atomic_add_f32 instruction",
329329 .dependencies = featureSet(&[_]Feature{}),
330330 };
331 result[@enumToInt(Feature.flat_for_global)] = .{
331 result[@intFromEnum(Feature.flat_for_global)] = .{
332332 .llvm_name = "flat-for-global",
333333 .description = "Force to generate flat instruction for global",
334334 .dependencies = featureSet(&[_]Feature{}),
335335 };
336 result[@enumToInt(Feature.flat_global_insts)] = .{
336 result[@intFromEnum(Feature.flat_global_insts)] = .{
337337 .llvm_name = "flat-global-insts",
338338 .description = "Have global_* flat memory instructions",
339339 .dependencies = featureSet(&[_]Feature{}),
340340 };
341 result[@enumToInt(Feature.flat_inst_offsets)] = .{
341 result[@intFromEnum(Feature.flat_inst_offsets)] = .{
342342 .llvm_name = "flat-inst-offsets",
343343 .description = "Flat instructions have immediate offset addressing mode",
344344 .dependencies = featureSet(&[_]Feature{}),
345345 };
346 result[@enumToInt(Feature.flat_scratch)] = .{
346 result[@intFromEnum(Feature.flat_scratch)] = .{
347347 .llvm_name = "enable-flat-scratch",
348348 .description = "Use scratch_* flat memory instructions to access scratch",
349349 .dependencies = featureSet(&[_]Feature{}),
350350 };
351 result[@enumToInt(Feature.flat_scratch_insts)] = .{
351 result[@intFromEnum(Feature.flat_scratch_insts)] = .{
352352 .llvm_name = "flat-scratch-insts",
353353 .description = "Have scratch_* flat memory instructions",
354354 .dependencies = featureSet(&[_]Feature{}),
355355 };
356 result[@enumToInt(Feature.flat_segment_offset_bug)] = .{
356 result[@intFromEnum(Feature.flat_segment_offset_bug)] = .{
357357 .llvm_name = "flat-segment-offset-bug",
358358 .description = "GFX10 bug where inst_offset is ignored when flat instructions access global memory",
359359 .dependencies = featureSet(&[_]Feature{}),
360360 };
361 result[@enumToInt(Feature.fma_mix_insts)] = .{
361 result[@intFromEnum(Feature.fma_mix_insts)] = .{
362362 .llvm_name = "fma-mix-insts",
363363 .description = "Has v_fma_mix_f32, v_fma_mixlo_f16, v_fma_mixhi_f16 instructions",
364364 .dependencies = featureSet(&[_]Feature{}),
365365 };
366 result[@enumToInt(Feature.fmacf64_inst)] = .{
366 result[@intFromEnum(Feature.fmacf64_inst)] = .{
367367 .llvm_name = "fmacf64-inst",
368368 .description = "Has v_fmac_f64 instruction",
369369 .dependencies = featureSet(&[_]Feature{}),
370370 };
371 result[@enumToInt(Feature.fmaf)] = .{
371 result[@intFromEnum(Feature.fmaf)] = .{
372372 .llvm_name = "fmaf",
373373 .description = "Enable single precision FMA (not as fast as mul+add, but fused)",
374374 .dependencies = featureSet(&[_]Feature{}),
375375 };
376 result[@enumToInt(Feature.fp64)] = .{
376 result[@intFromEnum(Feature.fp64)] = .{
377377 .llvm_name = "fp64",
378378 .description = "Enable double precision operations",
379379 .dependencies = featureSet(&[_]Feature{}),
380380 };
381 result[@enumToInt(Feature.fp8_insts)] = .{
381 result[@intFromEnum(Feature.fp8_insts)] = .{
382382 .llvm_name = "fp8-insts",
383383 .description = "Has fp8 and bf8 instructions",
384384 .dependencies = featureSet(&[_]Feature{}),
385385 };
386 result[@enumToInt(Feature.full_rate_64_ops)] = .{
386 result[@intFromEnum(Feature.full_rate_64_ops)] = .{
387387 .llvm_name = "full-rate-64-ops",
388388 .description = "Most fp64 instructions are full rate",
389389 .dependencies = featureSet(&[_]Feature{}),
390390 };
391 result[@enumToInt(Feature.g16)] = .{
391 result[@intFromEnum(Feature.g16)] = .{
392392 .llvm_name = "g16",
393393 .description = "Support G16 for 16-bit gradient image operands",
394394 .dependencies = featureSet(&[_]Feature{}),
395395 };
396 result[@enumToInt(Feature.gcn3_encoding)] = .{
396 result[@intFromEnum(Feature.gcn3_encoding)] = .{
397397 .llvm_name = "gcn3-encoding",
398398 .description = "Encoding format for VI",
399399 .dependencies = featureSet(&[_]Feature{}),
400400 };
401 result[@enumToInt(Feature.get_wave_id_inst)] = .{
401 result[@intFromEnum(Feature.get_wave_id_inst)] = .{
402402 .llvm_name = "get-wave-id-inst",
403403 .description = "Has s_get_waveid_in_workgroup instruction",
404404 .dependencies = featureSet(&[_]Feature{}),
405405 };
406 result[@enumToInt(Feature.gfx10)] = .{
406 result[@intFromEnum(Feature.gfx10)] = .{
407407 .llvm_name = "gfx10",
408408 .description = "GFX10 GPU generation",
409409 .dependencies = featureSet(&[_]Feature{
......@@ -449,27 +449,27 @@ pub const all_features = blk: {
449449 .vscnt,
450450 }),
451451 };
452 result[@enumToInt(Feature.gfx10_3_insts)] = .{
452 result[@intFromEnum(Feature.gfx10_3_insts)] = .{
453453 .llvm_name = "gfx10-3-insts",
454454 .description = "Additional instructions for GFX10.3",
455455 .dependencies = featureSet(&[_]Feature{}),
456456 };
457 result[@enumToInt(Feature.gfx10_a_encoding)] = .{
457 result[@intFromEnum(Feature.gfx10_a_encoding)] = .{
458458 .llvm_name = "gfx10_a-encoding",
459459 .description = "Has BVH ray tracing instructions",
460460 .dependencies = featureSet(&[_]Feature{}),
461461 };
462 result[@enumToInt(Feature.gfx10_b_encoding)] = .{
462 result[@intFromEnum(Feature.gfx10_b_encoding)] = .{
463463 .llvm_name = "gfx10_b-encoding",
464464 .description = "Encoding format GFX10_B",
465465 .dependencies = featureSet(&[_]Feature{}),
466466 };
467 result[@enumToInt(Feature.gfx10_insts)] = .{
467 result[@intFromEnum(Feature.gfx10_insts)] = .{
468468 .llvm_name = "gfx10-insts",
469469 .description = "Additional instructions for GFX10+",
470470 .dependencies = featureSet(&[_]Feature{}),
471471 };
472 result[@enumToInt(Feature.gfx11)] = .{
472 result[@intFromEnum(Feature.gfx11)] = .{
473473 .llvm_name = "gfx11",
474474 .description = "GFX11 GPU generation",
475475 .dependencies = featureSet(&[_]Feature{
......@@ -514,27 +514,27 @@ pub const all_features = blk: {
514514 .vscnt,
515515 }),
516516 };
517 result[@enumToInt(Feature.gfx11_full_vgprs)] = .{
517 result[@intFromEnum(Feature.gfx11_full_vgprs)] = .{
518518 .llvm_name = "gfx11-full-vgprs",
519519 .description = "GFX11 with 50% more physical VGPRs and 50% larger allocation granule than GFX10",
520520 .dependencies = featureSet(&[_]Feature{}),
521521 };
522 result[@enumToInt(Feature.gfx11_insts)] = .{
522 result[@intFromEnum(Feature.gfx11_insts)] = .{
523523 .llvm_name = "gfx11-insts",
524524 .description = "Additional instructions for GFX11+",
525525 .dependencies = featureSet(&[_]Feature{}),
526526 };
527 result[@enumToInt(Feature.gfx7_gfx8_gfx9_insts)] = .{
527 result[@intFromEnum(Feature.gfx7_gfx8_gfx9_insts)] = .{
528528 .llvm_name = "gfx7-gfx8-gfx9-insts",
529529 .description = "Instructions shared in GFX7, GFX8, GFX9",
530530 .dependencies = featureSet(&[_]Feature{}),
531531 };
532 result[@enumToInt(Feature.gfx8_insts)] = .{
532 result[@intFromEnum(Feature.gfx8_insts)] = .{
533533 .llvm_name = "gfx8-insts",
534534 .description = "Additional instructions for GFX8+",
535535 .dependencies = featureSet(&[_]Feature{}),
536536 };
537 result[@enumToInt(Feature.gfx9)] = .{
537 result[@intFromEnum(Feature.gfx9)] = .{
538538 .llvm_name = "gfx9",
539539 .description = "GFX9 GPU generation",
540540 .dependencies = featureSet(&[_]Feature{
......@@ -577,277 +577,277 @@ pub const all_features = blk: {
577577 .xnack_support,
578578 }),
579579 };
580 result[@enumToInt(Feature.gfx90a_insts)] = .{
580 result[@intFromEnum(Feature.gfx90a_insts)] = .{
581581 .llvm_name = "gfx90a-insts",
582582 .description = "Additional instructions for GFX90A+",
583583 .dependencies = featureSet(&[_]Feature{}),
584584 };
585 result[@enumToInt(Feature.gfx940_insts)] = .{
585 result[@intFromEnum(Feature.gfx940_insts)] = .{
586586 .llvm_name = "gfx940-insts",
587587 .description = "Additional instructions for GFX940+",
588588 .dependencies = featureSet(&[_]Feature{}),
589589 };
590 result[@enumToInt(Feature.gfx9_insts)] = .{
590 result[@intFromEnum(Feature.gfx9_insts)] = .{
591591 .llvm_name = "gfx9-insts",
592592 .description = "Additional instructions for GFX9+",
593593 .dependencies = featureSet(&[_]Feature{}),
594594 };
595 result[@enumToInt(Feature.half_rate_64_ops)] = .{
595 result[@intFromEnum(Feature.half_rate_64_ops)] = .{
596596 .llvm_name = "half-rate-64-ops",
597597 .description = "Most fp64 instructions are half rate instead of quarter",
598598 .dependencies = featureSet(&[_]Feature{}),
599599 };
600 result[@enumToInt(Feature.image_gather4_d16_bug)] = .{
600 result[@intFromEnum(Feature.image_gather4_d16_bug)] = .{
601601 .llvm_name = "image-gather4-d16-bug",
602602 .description = "Image Gather4 D16 hardware bug",
603603 .dependencies = featureSet(&[_]Feature{}),
604604 };
605 result[@enumToInt(Feature.image_insts)] = .{
605 result[@intFromEnum(Feature.image_insts)] = .{
606606 .llvm_name = "image-insts",
607607 .description = "Support image instructions",
608608 .dependencies = featureSet(&[_]Feature{}),
609609 };
610 result[@enumToInt(Feature.image_store_d16_bug)] = .{
610 result[@intFromEnum(Feature.image_store_d16_bug)] = .{
611611 .llvm_name = "image-store-d16-bug",
612612 .description = "Image Store D16 hardware bug",
613613 .dependencies = featureSet(&[_]Feature{}),
614614 };
615 result[@enumToInt(Feature.inst_fwd_prefetch_bug)] = .{
615 result[@intFromEnum(Feature.inst_fwd_prefetch_bug)] = .{
616616 .llvm_name = "inst-fwd-prefetch-bug",
617617 .description = "S_INST_PREFETCH instruction causes shader to hang",
618618 .dependencies = featureSet(&[_]Feature{}),
619619 };
620 result[@enumToInt(Feature.int_clamp_insts)] = .{
620 result[@intFromEnum(Feature.int_clamp_insts)] = .{
621621 .llvm_name = "int-clamp-insts",
622622 .description = "Support clamp for integer destination",
623623 .dependencies = featureSet(&[_]Feature{}),
624624 };
625 result[@enumToInt(Feature.inv_2pi_inline_imm)] = .{
625 result[@intFromEnum(Feature.inv_2pi_inline_imm)] = .{
626626 .llvm_name = "inv-2pi-inline-imm",
627627 .description = "Has 1 / (2 * pi) as inline immediate",
628628 .dependencies = featureSet(&[_]Feature{}),
629629 };
630 result[@enumToInt(Feature.lds_branch_vmem_war_hazard)] = .{
630 result[@intFromEnum(Feature.lds_branch_vmem_war_hazard)] = .{
631631 .llvm_name = "lds-branch-vmem-war-hazard",
632632 .description = "Switching between LDS and VMEM-tex not waiting VM_VSRC=0",
633633 .dependencies = featureSet(&[_]Feature{}),
634634 };
635 result[@enumToInt(Feature.lds_misaligned_bug)] = .{
635 result[@intFromEnum(Feature.lds_misaligned_bug)] = .{
636636 .llvm_name = "lds-misaligned-bug",
637637 .description = "Some GFX10 bug with multi-dword LDS and flat access that is not naturally aligned in WGP mode",
638638 .dependencies = featureSet(&[_]Feature{}),
639639 };
640 result[@enumToInt(Feature.ldsbankcount16)] = .{
640 result[@intFromEnum(Feature.ldsbankcount16)] = .{
641641 .llvm_name = "ldsbankcount16",
642642 .description = "The number of LDS banks per compute unit.",
643643 .dependencies = featureSet(&[_]Feature{}),
644644 };
645 result[@enumToInt(Feature.ldsbankcount32)] = .{
645 result[@intFromEnum(Feature.ldsbankcount32)] = .{
646646 .llvm_name = "ldsbankcount32",
647647 .description = "The number of LDS banks per compute unit.",
648648 .dependencies = featureSet(&[_]Feature{}),
649649 };
650 result[@enumToInt(Feature.load_store_opt)] = .{
650 result[@intFromEnum(Feature.load_store_opt)] = .{
651651 .llvm_name = "load-store-opt",
652652 .description = "Enable SI load/store optimizer pass",
653653 .dependencies = featureSet(&[_]Feature{}),
654654 };
655 result[@enumToInt(Feature.localmemorysize32768)] = .{
655 result[@intFromEnum(Feature.localmemorysize32768)] = .{
656656 .llvm_name = "localmemorysize32768",
657657 .description = "The size of local memory in bytes",
658658 .dependencies = featureSet(&[_]Feature{}),
659659 };
660 result[@enumToInt(Feature.localmemorysize65536)] = .{
660 result[@intFromEnum(Feature.localmemorysize65536)] = .{
661661 .llvm_name = "localmemorysize65536",
662662 .description = "The size of local memory in bytes",
663663 .dependencies = featureSet(&[_]Feature{}),
664664 };
665 result[@enumToInt(Feature.mad_intra_fwd_bug)] = .{
665 result[@intFromEnum(Feature.mad_intra_fwd_bug)] = .{
666666 .llvm_name = "mad-intra-fwd-bug",
667667 .description = "MAD_U64/I64 intra instruction forwarding bug",
668668 .dependencies = featureSet(&[_]Feature{}),
669669 };
670 result[@enumToInt(Feature.mad_mac_f32_insts)] = .{
670 result[@intFromEnum(Feature.mad_mac_f32_insts)] = .{
671671 .llvm_name = "mad-mac-f32-insts",
672672 .description = "Has v_mad_f32/v_mac_f32/v_madak_f32/v_madmk_f32 instructions",
673673 .dependencies = featureSet(&[_]Feature{}),
674674 };
675 result[@enumToInt(Feature.mad_mix_insts)] = .{
675 result[@intFromEnum(Feature.mad_mix_insts)] = .{
676676 .llvm_name = "mad-mix-insts",
677677 .description = "Has v_mad_mix_f32, v_mad_mixlo_f16, v_mad_mixhi_f16 instructions",
678678 .dependencies = featureSet(&[_]Feature{}),
679679 };
680 result[@enumToInt(Feature.mai_insts)] = .{
680 result[@intFromEnum(Feature.mai_insts)] = .{
681681 .llvm_name = "mai-insts",
682682 .description = "Has mAI instructions",
683683 .dependencies = featureSet(&[_]Feature{}),
684684 };
685 result[@enumToInt(Feature.max_private_element_size_16)] = .{
685 result[@intFromEnum(Feature.max_private_element_size_16)] = .{
686686 .llvm_name = "max-private-element-size-16",
687687 .description = "Maximum private access size may be 16",
688688 .dependencies = featureSet(&[_]Feature{}),
689689 };
690 result[@enumToInt(Feature.max_private_element_size_4)] = .{
690 result[@intFromEnum(Feature.max_private_element_size_4)] = .{
691691 .llvm_name = "max-private-element-size-4",
692692 .description = "Maximum private access size may be 4",
693693 .dependencies = featureSet(&[_]Feature{}),
694694 };
695 result[@enumToInt(Feature.max_private_element_size_8)] = .{
695 result[@intFromEnum(Feature.max_private_element_size_8)] = .{
696696 .llvm_name = "max-private-element-size-8",
697697 .description = "Maximum private access size may be 8",
698698 .dependencies = featureSet(&[_]Feature{}),
699699 };
700 result[@enumToInt(Feature.mfma_inline_literal_bug)] = .{
700 result[@intFromEnum(Feature.mfma_inline_literal_bug)] = .{
701701 .llvm_name = "mfma-inline-literal-bug",
702702 .description = "MFMA cannot use inline literal as SrcC",
703703 .dependencies = featureSet(&[_]Feature{}),
704704 };
705 result[@enumToInt(Feature.mimg_r128)] = .{
705 result[@intFromEnum(Feature.mimg_r128)] = .{
706706 .llvm_name = "mimg-r128",
707707 .description = "Support 128-bit texture resources",
708708 .dependencies = featureSet(&[_]Feature{}),
709709 };
710 result[@enumToInt(Feature.movrel)] = .{
710 result[@intFromEnum(Feature.movrel)] = .{
711711 .llvm_name = "movrel",
712712 .description = "Has v_movrel*_b32 instructions",
713713 .dependencies = featureSet(&[_]Feature{}),
714714 };
715 result[@enumToInt(Feature.negative_scratch_offset_bug)] = .{
715 result[@intFromEnum(Feature.negative_scratch_offset_bug)] = .{
716716 .llvm_name = "negative-scratch-offset-bug",
717717 .description = "Negative immediate offsets in scratch instructions with an SGPR offset page fault on GFX9",
718718 .dependencies = featureSet(&[_]Feature{}),
719719 };
720 result[@enumToInt(Feature.negative_unaligned_scratch_offset_bug)] = .{
720 result[@intFromEnum(Feature.negative_unaligned_scratch_offset_bug)] = .{
721721 .llvm_name = "negative-unaligned-scratch-offset-bug",
722722 .description = "Scratch instructions with a VGPR offset and a negative immediate offset that is not a multiple of 4 read wrong memory on GFX10",
723723 .dependencies = featureSet(&[_]Feature{}),
724724 };
725 result[@enumToInt(Feature.no_data_dep_hazard)] = .{
725 result[@intFromEnum(Feature.no_data_dep_hazard)] = .{
726726 .llvm_name = "no-data-dep-hazard",
727727 .description = "Does not need SW waitstates",
728728 .dependencies = featureSet(&[_]Feature{}),
729729 };
730 result[@enumToInt(Feature.no_sdst_cmpx)] = .{
730 result[@intFromEnum(Feature.no_sdst_cmpx)] = .{
731731 .llvm_name = "no-sdst-cmpx",
732732 .description = "V_CMPX does not write VCC/SGPR in addition to EXEC",
733733 .dependencies = featureSet(&[_]Feature{}),
734734 };
735 result[@enumToInt(Feature.nsa_clause_bug)] = .{
735 result[@intFromEnum(Feature.nsa_clause_bug)] = .{
736736 .llvm_name = "nsa-clause-bug",
737737 .description = "MIMG-NSA in a hard clause has unpredictable results on GFX10.1",
738738 .dependencies = featureSet(&[_]Feature{}),
739739 };
740 result[@enumToInt(Feature.nsa_encoding)] = .{
740 result[@intFromEnum(Feature.nsa_encoding)] = .{
741741 .llvm_name = "nsa-encoding",
742742 .description = "Support NSA encoding for image instructions",
743743 .dependencies = featureSet(&[_]Feature{}),
744744 };
745 result[@enumToInt(Feature.nsa_max_size_13)] = .{
745 result[@intFromEnum(Feature.nsa_max_size_13)] = .{
746746 .llvm_name = "nsa-max-size-13",
747747 .description = "The maximum non-sequential address size in VGPRs.",
748748 .dependencies = featureSet(&[_]Feature{}),
749749 };
750 result[@enumToInt(Feature.nsa_max_size_5)] = .{
750 result[@intFromEnum(Feature.nsa_max_size_5)] = .{
751751 .llvm_name = "nsa-max-size-5",
752752 .description = "The maximum non-sequential address size in VGPRs.",
753753 .dependencies = featureSet(&[_]Feature{}),
754754 };
755 result[@enumToInt(Feature.nsa_to_vmem_bug)] = .{
755 result[@intFromEnum(Feature.nsa_to_vmem_bug)] = .{
756756 .llvm_name = "nsa-to-vmem-bug",
757757 .description = "MIMG-NSA followed by VMEM fail if EXEC_LO or EXEC_HI equals zero",
758758 .dependencies = featureSet(&[_]Feature{}),
759759 };
760 result[@enumToInt(Feature.offset_3f_bug)] = .{
760 result[@intFromEnum(Feature.offset_3f_bug)] = .{
761761 .llvm_name = "offset-3f-bug",
762762 .description = "Branch offset of 3f hardware bug",
763763 .dependencies = featureSet(&[_]Feature{}),
764764 };
765 result[@enumToInt(Feature.packed_fp32_ops)] = .{
765 result[@intFromEnum(Feature.packed_fp32_ops)] = .{
766766 .llvm_name = "packed-fp32-ops",
767767 .description = "Support packed fp32 instructions",
768768 .dependencies = featureSet(&[_]Feature{}),
769769 };
770 result[@enumToInt(Feature.packed_tid)] = .{
770 result[@intFromEnum(Feature.packed_tid)] = .{
771771 .llvm_name = "packed-tid",
772772 .description = "Workitem IDs are packed into v0 at kernel launch",
773773 .dependencies = featureSet(&[_]Feature{}),
774774 };
775 result[@enumToInt(Feature.pk_fmac_f16_inst)] = .{
775 result[@intFromEnum(Feature.pk_fmac_f16_inst)] = .{
776776 .llvm_name = "pk-fmac-f16-inst",
777777 .description = "Has v_pk_fmac_f16 instruction",
778778 .dependencies = featureSet(&[_]Feature{}),
779779 };
780 result[@enumToInt(Feature.promote_alloca)] = .{
780 result[@intFromEnum(Feature.promote_alloca)] = .{
781781 .llvm_name = "promote-alloca",
782782 .description = "Enable promote alloca pass",
783783 .dependencies = featureSet(&[_]Feature{}),
784784 };
785 result[@enumToInt(Feature.prt_strict_null)] = .{
785 result[@intFromEnum(Feature.prt_strict_null)] = .{
786786 .llvm_name = "enable-prt-strict-null",
787787 .description = "Enable zeroing of result registers for sparse texture fetches",
788788 .dependencies = featureSet(&[_]Feature{}),
789789 };
790 result[@enumToInt(Feature.r128_a16)] = .{
790 result[@intFromEnum(Feature.r128_a16)] = .{
791791 .llvm_name = "r128-a16",
792792 .description = "Support gfx9-style A16 for 16-bit coordinates/gradients/lod/clamp/mip image operands, where a16 is aliased with r128",
793793 .dependencies = featureSet(&[_]Feature{}),
794794 };
795 result[@enumToInt(Feature.s_memrealtime)] = .{
795 result[@intFromEnum(Feature.s_memrealtime)] = .{
796796 .llvm_name = "s-memrealtime",
797797 .description = "Has s_memrealtime instruction",
798798 .dependencies = featureSet(&[_]Feature{}),
799799 };
800 result[@enumToInt(Feature.s_memtime_inst)] = .{
800 result[@intFromEnum(Feature.s_memtime_inst)] = .{
801801 .llvm_name = "s-memtime-inst",
802802 .description = "Has s_memtime instruction",
803803 .dependencies = featureSet(&[_]Feature{}),
804804 };
805 result[@enumToInt(Feature.scalar_atomics)] = .{
805 result[@intFromEnum(Feature.scalar_atomics)] = .{
806806 .llvm_name = "scalar-atomics",
807807 .description = "Has atomic scalar memory instructions",
808808 .dependencies = featureSet(&[_]Feature{}),
809809 };
810 result[@enumToInt(Feature.scalar_flat_scratch_insts)] = .{
810 result[@intFromEnum(Feature.scalar_flat_scratch_insts)] = .{
811811 .llvm_name = "scalar-flat-scratch-insts",
812812 .description = "Have s_scratch_* flat memory instructions",
813813 .dependencies = featureSet(&[_]Feature{}),
814814 };
815 result[@enumToInt(Feature.scalar_stores)] = .{
815 result[@intFromEnum(Feature.scalar_stores)] = .{
816816 .llvm_name = "scalar-stores",
817817 .description = "Has store scalar memory instructions",
818818 .dependencies = featureSet(&[_]Feature{}),
819819 };
820 result[@enumToInt(Feature.sdwa)] = .{
820 result[@intFromEnum(Feature.sdwa)] = .{
821821 .llvm_name = "sdwa",
822822 .description = "Support SDWA (Sub-DWORD Addressing) extension",
823823 .dependencies = featureSet(&[_]Feature{}),
824824 };
825 result[@enumToInt(Feature.sdwa_mav)] = .{
825 result[@intFromEnum(Feature.sdwa_mav)] = .{
826826 .llvm_name = "sdwa-mav",
827827 .description = "Support v_mac_f32/f16 with SDWA (Sub-DWORD Addressing) extension",
828828 .dependencies = featureSet(&[_]Feature{}),
829829 };
830 result[@enumToInt(Feature.sdwa_omod)] = .{
830 result[@intFromEnum(Feature.sdwa_omod)] = .{
831831 .llvm_name = "sdwa-omod",
832832 .description = "Support OMod with SDWA (Sub-DWORD Addressing) extension",
833833 .dependencies = featureSet(&[_]Feature{}),
834834 };
835 result[@enumToInt(Feature.sdwa_out_mods_vopc)] = .{
835 result[@intFromEnum(Feature.sdwa_out_mods_vopc)] = .{
836836 .llvm_name = "sdwa-out-mods-vopc",
837837 .description = "Support clamp for VOPC with SDWA (Sub-DWORD Addressing) extension",
838838 .dependencies = featureSet(&[_]Feature{}),
839839 };
840 result[@enumToInt(Feature.sdwa_scalar)] = .{
840 result[@intFromEnum(Feature.sdwa_scalar)] = .{
841841 .llvm_name = "sdwa-scalar",
842842 .description = "Support scalar register with SDWA (Sub-DWORD Addressing) extension",
843843 .dependencies = featureSet(&[_]Feature{}),
844844 };
845 result[@enumToInt(Feature.sdwa_sdst)] = .{
845 result[@intFromEnum(Feature.sdwa_sdst)] = .{
846846 .llvm_name = "sdwa-sdst",
847847 .description = "Support scalar dst for VOPC with SDWA (Sub-DWORD Addressing) extension",
848848 .dependencies = featureSet(&[_]Feature{}),
849849 };
850 result[@enumToInt(Feature.sea_islands)] = .{
850 result[@intFromEnum(Feature.sea_islands)] = .{
851851 .llvm_name = "sea-islands",
852852 .description = "SEA_ISLANDS GPU generation",
853853 .dependencies = featureSet(&[_]Feature{
......@@ -868,27 +868,27 @@ pub const all_features = blk: {
868868 .wavefrontsize64,
869869 }),
870870 };
871 result[@enumToInt(Feature.sgpr_init_bug)] = .{
871 result[@intFromEnum(Feature.sgpr_init_bug)] = .{
872872 .llvm_name = "sgpr-init-bug",
873873 .description = "VI SGPR initialization bug requiring a fixed SGPR allocation size",
874874 .dependencies = featureSet(&[_]Feature{}),
875875 };
876 result[@enumToInt(Feature.shader_cycles_register)] = .{
876 result[@intFromEnum(Feature.shader_cycles_register)] = .{
877877 .llvm_name = "shader-cycles-register",
878878 .description = "Has SHADER_CYCLES hardware register",
879879 .dependencies = featureSet(&[_]Feature{}),
880880 };
881 result[@enumToInt(Feature.si_scheduler)] = .{
881 result[@intFromEnum(Feature.si_scheduler)] = .{
882882 .llvm_name = "si-scheduler",
883883 .description = "Enable SI Machine Scheduler",
884884 .dependencies = featureSet(&[_]Feature{}),
885885 };
886 result[@enumToInt(Feature.smem_to_vector_write_hazard)] = .{
886 result[@intFromEnum(Feature.smem_to_vector_write_hazard)] = .{
887887 .llvm_name = "smem-to-vector-write-hazard",
888888 .description = "s_load_dword followed by v_cmp page faults",
889889 .dependencies = featureSet(&[_]Feature{}),
890890 };
891 result[@enumToInt(Feature.southern_islands)] = .{
891 result[@intFromEnum(Feature.southern_islands)] = .{
892892 .llvm_name = "southern-islands",
893893 .description = "SOUTHERN_ISLANDS GPU generation",
894894 .dependencies = featureSet(&[_]Feature{
......@@ -906,97 +906,97 @@ pub const all_features = blk: {
906906 .wavefrontsize64,
907907 }),
908908 };
909 result[@enumToInt(Feature.sramecc)] = .{
909 result[@intFromEnum(Feature.sramecc)] = .{
910910 .llvm_name = "sramecc",
911911 .description = "Enable SRAMECC",
912912 .dependencies = featureSet(&[_]Feature{}),
913913 };
914 result[@enumToInt(Feature.sramecc_support)] = .{
914 result[@intFromEnum(Feature.sramecc_support)] = .{
915915 .llvm_name = "sramecc-support",
916916 .description = "Hardware supports SRAMECC",
917917 .dependencies = featureSet(&[_]Feature{}),
918918 };
919 result[@enumToInt(Feature.tgsplit)] = .{
919 result[@intFromEnum(Feature.tgsplit)] = .{
920920 .llvm_name = "tgsplit",
921921 .description = "Enable threadgroup split execution",
922922 .dependencies = featureSet(&[_]Feature{}),
923923 };
924 result[@enumToInt(Feature.trap_handler)] = .{
924 result[@intFromEnum(Feature.trap_handler)] = .{
925925 .llvm_name = "trap-handler",
926926 .description = "Trap handler support",
927927 .dependencies = featureSet(&[_]Feature{}),
928928 };
929 result[@enumToInt(Feature.trig_reduced_range)] = .{
929 result[@intFromEnum(Feature.trig_reduced_range)] = .{
930930 .llvm_name = "trig-reduced-range",
931931 .description = "Requires use of fract on arguments to trig instructions",
932932 .dependencies = featureSet(&[_]Feature{}),
933933 };
934 result[@enumToInt(Feature.true16)] = .{
934 result[@intFromEnum(Feature.true16)] = .{
935935 .llvm_name = "true16",
936936 .description = "True 16-bit operand instructions",
937937 .dependencies = featureSet(&[_]Feature{}),
938938 };
939 result[@enumToInt(Feature.unaligned_access_mode)] = .{
939 result[@intFromEnum(Feature.unaligned_access_mode)] = .{
940940 .llvm_name = "unaligned-access-mode",
941941 .description = "Enable unaligned global, local and region loads and stores if the hardware supports it",
942942 .dependencies = featureSet(&[_]Feature{}),
943943 };
944 result[@enumToInt(Feature.unaligned_buffer_access)] = .{
944 result[@intFromEnum(Feature.unaligned_buffer_access)] = .{
945945 .llvm_name = "unaligned-buffer-access",
946946 .description = "Hardware supports unaligned global loads and stores",
947947 .dependencies = featureSet(&[_]Feature{}),
948948 };
949 result[@enumToInt(Feature.unaligned_ds_access)] = .{
949 result[@intFromEnum(Feature.unaligned_ds_access)] = .{
950950 .llvm_name = "unaligned-ds-access",
951951 .description = "Hardware supports unaligned local and region loads and stores",
952952 .dependencies = featureSet(&[_]Feature{}),
953953 };
954 result[@enumToInt(Feature.unaligned_scratch_access)] = .{
954 result[@intFromEnum(Feature.unaligned_scratch_access)] = .{
955955 .llvm_name = "unaligned-scratch-access",
956956 .description = "Support unaligned scratch loads and stores",
957957 .dependencies = featureSet(&[_]Feature{}),
958958 };
959 result[@enumToInt(Feature.unpacked_d16_vmem)] = .{
959 result[@intFromEnum(Feature.unpacked_d16_vmem)] = .{
960960 .llvm_name = "unpacked-d16-vmem",
961961 .description = "Has unpacked d16 vmem instructions",
962962 .dependencies = featureSet(&[_]Feature{}),
963963 };
964 result[@enumToInt(Feature.unsafe_ds_offset_folding)] = .{
964 result[@intFromEnum(Feature.unsafe_ds_offset_folding)] = .{
965965 .llvm_name = "unsafe-ds-offset-folding",
966966 .description = "Force using DS instruction immediate offsets on SI",
967967 .dependencies = featureSet(&[_]Feature{}),
968968 };
969 result[@enumToInt(Feature.user_sgpr_init16_bug)] = .{
969 result[@intFromEnum(Feature.user_sgpr_init16_bug)] = .{
970970 .llvm_name = "user-sgpr-init16-bug",
971971 .description = "Bug requiring at least 16 user+system SGPRs to be enabled",
972972 .dependencies = featureSet(&[_]Feature{}),
973973 };
974 result[@enumToInt(Feature.valu_trans_use_hazard)] = .{
974 result[@intFromEnum(Feature.valu_trans_use_hazard)] = .{
975975 .llvm_name = "valu-trans-use-hazard",
976976 .description = "Hazard when TRANS instructions are closely followed by a use of the result",
977977 .dependencies = featureSet(&[_]Feature{}),
978978 };
979 result[@enumToInt(Feature.vcmpx_exec_war_hazard)] = .{
979 result[@intFromEnum(Feature.vcmpx_exec_war_hazard)] = .{
980980 .llvm_name = "vcmpx-exec-war-hazard",
981981 .description = "V_CMPX WAR hazard on EXEC (V_CMPX issue ONLY)",
982982 .dependencies = featureSet(&[_]Feature{}),
983983 };
984 result[@enumToInt(Feature.vcmpx_permlane_hazard)] = .{
984 result[@intFromEnum(Feature.vcmpx_permlane_hazard)] = .{
985985 .llvm_name = "vcmpx-permlane-hazard",
986986 .description = "TODO: describe me",
987987 .dependencies = featureSet(&[_]Feature{}),
988988 };
989 result[@enumToInt(Feature.vgpr_index_mode)] = .{
989 result[@intFromEnum(Feature.vgpr_index_mode)] = .{
990990 .llvm_name = "vgpr-index-mode",
991991 .description = "Has VGPR mode register indexing",
992992 .dependencies = featureSet(&[_]Feature{}),
993993 };
994 result[@enumToInt(Feature.vmem_to_scalar_write_hazard)] = .{
994 result[@intFromEnum(Feature.vmem_to_scalar_write_hazard)] = .{
995995 .llvm_name = "vmem-to-scalar-write-hazard",
996996 .description = "VMEM instruction followed by scalar writing to EXEC mask, M0 or SGPR leads to incorrect execution.",
997997 .dependencies = featureSet(&[_]Feature{}),
998998 };
999 result[@enumToInt(Feature.volcanic_islands)] = .{
999 result[@intFromEnum(Feature.volcanic_islands)] = .{
10001000 .llvm_name = "volcanic-islands",
10011001 .description = "VOLCANIC_ISLANDS GPU generation",
10021002 .dependencies = featureSet(&[_]Feature{
......@@ -1030,47 +1030,47 @@ pub const all_features = blk: {
10301030 .wavefrontsize64,
10311031 }),
10321032 };
1033 result[@enumToInt(Feature.vop3_literal)] = .{
1033 result[@intFromEnum(Feature.vop3_literal)] = .{
10341034 .llvm_name = "vop3-literal",
10351035 .description = "Can use one literal in VOP3",
10361036 .dependencies = featureSet(&[_]Feature{}),
10371037 };
1038 result[@enumToInt(Feature.vop3p)] = .{
1038 result[@intFromEnum(Feature.vop3p)] = .{
10391039 .llvm_name = "vop3p",
10401040 .description = "Has VOP3P packed instructions",
10411041 .dependencies = featureSet(&[_]Feature{}),
10421042 };
1043 result[@enumToInt(Feature.vopd)] = .{
1043 result[@intFromEnum(Feature.vopd)] = .{
10441044 .llvm_name = "vopd",
10451045 .description = "Has VOPD dual issue wave32 instructions",
10461046 .dependencies = featureSet(&[_]Feature{}),
10471047 };
1048 result[@enumToInt(Feature.vscnt)] = .{
1048 result[@intFromEnum(Feature.vscnt)] = .{
10491049 .llvm_name = "vscnt",
10501050 .description = "Has separate store vscnt counter",
10511051 .dependencies = featureSet(&[_]Feature{}),
10521052 };
1053 result[@enumToInt(Feature.wavefrontsize16)] = .{
1053 result[@intFromEnum(Feature.wavefrontsize16)] = .{
10541054 .llvm_name = "wavefrontsize16",
10551055 .description = "The number of threads per wavefront",
10561056 .dependencies = featureSet(&[_]Feature{}),
10571057 };
1058 result[@enumToInt(Feature.wavefrontsize32)] = .{
1058 result[@intFromEnum(Feature.wavefrontsize32)] = .{
10591059 .llvm_name = "wavefrontsize32",
10601060 .description = "The number of threads per wavefront",
10611061 .dependencies = featureSet(&[_]Feature{}),
10621062 };
1063 result[@enumToInt(Feature.wavefrontsize64)] = .{
1063 result[@intFromEnum(Feature.wavefrontsize64)] = .{
10641064 .llvm_name = "wavefrontsize64",
10651065 .description = "The number of threads per wavefront",
10661066 .dependencies = featureSet(&[_]Feature{}),
10671067 };
1068 result[@enumToInt(Feature.xnack)] = .{
1068 result[@intFromEnum(Feature.xnack)] = .{
10691069 .llvm_name = "xnack",
10701070 .description = "Enable XNACK support",
10711071 .dependencies = featureSet(&[_]Feature{}),
10721072 };
1073 result[@enumToInt(Feature.xnack_support)] = .{
1073 result[@intFromEnum(Feature.xnack_support)] = .{
10741074 .llvm_name = "xnack-support",
10751075 .description = "Hardware supports XNACK",
10761076 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/arc.zig+1-1
......@@ -17,7 +17,7 @@ pub const all_features = blk: {
1717 const len = @typeInfo(Feature).Enum.fields.len;
1818 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
1919 var result: [len]CpuFeature = undefined;
20 result[@enumToInt(Feature.norm)] = .{
20 result[@intFromEnum(Feature.norm)] = .{
2121 .llvm_name = "norm",
2222 .description = "Enable support for norm instruction.",
2323 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/arm.zig+197-197
......@@ -214,156 +214,156 @@ pub const all_features = blk: {
214214 const len = @typeInfo(Feature).Enum.fields.len;
215215 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
216216 var result: [len]CpuFeature = undefined;
217 result[@enumToInt(Feature.@"32bit")] = .{
217 result[@intFromEnum(Feature.@"32bit")] = .{
218218 .llvm_name = "32bit",
219219 .description = "Prefer 32-bit Thumb instrs",
220220 .dependencies = featureSet(&[_]Feature{}),
221221 };
222 result[@enumToInt(Feature.@"8msecext")] = .{
222 result[@intFromEnum(Feature.@"8msecext")] = .{
223223 .llvm_name = "8msecext",
224224 .description = "Enable support for ARMv8-M Security Extensions",
225225 .dependencies = featureSet(&[_]Feature{}),
226226 };
227 result[@enumToInt(Feature.a76)] = .{
227 result[@intFromEnum(Feature.a76)] = .{
228228 .llvm_name = "a76",
229229 .description = "Cortex-A76 ARM processors",
230230 .dependencies = featureSet(&[_]Feature{}),
231231 };
232 result[@enumToInt(Feature.aapcs_frame_chain)] = .{
232 result[@intFromEnum(Feature.aapcs_frame_chain)] = .{
233233 .llvm_name = "aapcs-frame-chain",
234234 .description = "Create an AAPCS compliant frame chain",
235235 .dependencies = featureSet(&[_]Feature{}),
236236 };
237 result[@enumToInt(Feature.aapcs_frame_chain_leaf)] = .{
237 result[@intFromEnum(Feature.aapcs_frame_chain_leaf)] = .{
238238 .llvm_name = "aapcs-frame-chain-leaf",
239239 .description = "Create an AAPCS compliant frame chain for leaf functions",
240240 .dependencies = featureSet(&[_]Feature{
241241 .aapcs_frame_chain,
242242 }),
243243 };
244 result[@enumToInt(Feature.aclass)] = .{
244 result[@intFromEnum(Feature.aclass)] = .{
245245 .llvm_name = "aclass",
246246 .description = "Is application profile ('A' series)",
247247 .dependencies = featureSet(&[_]Feature{}),
248248 };
249 result[@enumToInt(Feature.acquire_release)] = .{
249 result[@intFromEnum(Feature.acquire_release)] = .{
250250 .llvm_name = "acquire-release",
251251 .description = "Has v8 acquire/release (lda/ldaex etc) instructions",
252252 .dependencies = featureSet(&[_]Feature{}),
253253 };
254 result[@enumToInt(Feature.aes)] = .{
254 result[@intFromEnum(Feature.aes)] = .{
255255 .llvm_name = "aes",
256256 .description = "Enable AES support",
257257 .dependencies = featureSet(&[_]Feature{
258258 .neon,
259259 }),
260260 };
261 result[@enumToInt(Feature.atomics_32)] = .{
261 result[@intFromEnum(Feature.atomics_32)] = .{
262262 .llvm_name = "atomics-32",
263263 .description = "Assume that lock-free 32-bit atomics are available",
264264 .dependencies = featureSet(&[_]Feature{}),
265265 };
266 result[@enumToInt(Feature.avoid_movs_shop)] = .{
266 result[@intFromEnum(Feature.avoid_movs_shop)] = .{
267267 .llvm_name = "avoid-movs-shop",
268268 .description = "Avoid movs instructions with shifter operand",
269269 .dependencies = featureSet(&[_]Feature{}),
270270 };
271 result[@enumToInt(Feature.avoid_partial_cpsr)] = .{
271 result[@intFromEnum(Feature.avoid_partial_cpsr)] = .{
272272 .llvm_name = "avoid-partial-cpsr",
273273 .description = "Avoid CPSR partial update for OOO execution",
274274 .dependencies = featureSet(&[_]Feature{}),
275275 };
276 result[@enumToInt(Feature.bf16)] = .{
276 result[@intFromEnum(Feature.bf16)] = .{
277277 .llvm_name = "bf16",
278278 .description = "Enable support for BFloat16 instructions",
279279 .dependencies = featureSet(&[_]Feature{
280280 .neon,
281281 }),
282282 };
283 result[@enumToInt(Feature.big_endian_instructions)] = .{
283 result[@intFromEnum(Feature.big_endian_instructions)] = .{
284284 .llvm_name = "big-endian-instructions",
285285 .description = "Expect instructions to be stored big-endian.",
286286 .dependencies = featureSet(&[_]Feature{}),
287287 };
288 result[@enumToInt(Feature.cde)] = .{
288 result[@intFromEnum(Feature.cde)] = .{
289289 .llvm_name = "cde",
290290 .description = "Support CDE instructions",
291291 .dependencies = featureSet(&[_]Feature{
292292 .has_v8m_main,
293293 }),
294294 };
295 result[@enumToInt(Feature.cdecp0)] = .{
295 result[@intFromEnum(Feature.cdecp0)] = .{
296296 .llvm_name = "cdecp0",
297297 .description = "Coprocessor 0 ISA is CDEv1",
298298 .dependencies = featureSet(&[_]Feature{
299299 .cde,
300300 }),
301301 };
302 result[@enumToInt(Feature.cdecp1)] = .{
302 result[@intFromEnum(Feature.cdecp1)] = .{
303303 .llvm_name = "cdecp1",
304304 .description = "Coprocessor 1 ISA is CDEv1",
305305 .dependencies = featureSet(&[_]Feature{
306306 .cde,
307307 }),
308308 };
309 result[@enumToInt(Feature.cdecp2)] = .{
309 result[@intFromEnum(Feature.cdecp2)] = .{
310310 .llvm_name = "cdecp2",
311311 .description = "Coprocessor 2 ISA is CDEv1",
312312 .dependencies = featureSet(&[_]Feature{
313313 .cde,
314314 }),
315315 };
316 result[@enumToInt(Feature.cdecp3)] = .{
316 result[@intFromEnum(Feature.cdecp3)] = .{
317317 .llvm_name = "cdecp3",
318318 .description = "Coprocessor 3 ISA is CDEv1",
319319 .dependencies = featureSet(&[_]Feature{
320320 .cde,
321321 }),
322322 };
323 result[@enumToInt(Feature.cdecp4)] = .{
323 result[@intFromEnum(Feature.cdecp4)] = .{
324324 .llvm_name = "cdecp4",
325325 .description = "Coprocessor 4 ISA is CDEv1",
326326 .dependencies = featureSet(&[_]Feature{
327327 .cde,
328328 }),
329329 };
330 result[@enumToInt(Feature.cdecp5)] = .{
330 result[@intFromEnum(Feature.cdecp5)] = .{
331331 .llvm_name = "cdecp5",
332332 .description = "Coprocessor 5 ISA is CDEv1",
333333 .dependencies = featureSet(&[_]Feature{
334334 .cde,
335335 }),
336336 };
337 result[@enumToInt(Feature.cdecp6)] = .{
337 result[@intFromEnum(Feature.cdecp6)] = .{
338338 .llvm_name = "cdecp6",
339339 .description = "Coprocessor 6 ISA is CDEv1",
340340 .dependencies = featureSet(&[_]Feature{
341341 .cde,
342342 }),
343343 };
344 result[@enumToInt(Feature.cdecp7)] = .{
344 result[@intFromEnum(Feature.cdecp7)] = .{
345345 .llvm_name = "cdecp7",
346346 .description = "Coprocessor 7 ISA is CDEv1",
347347 .dependencies = featureSet(&[_]Feature{
348348 .cde,
349349 }),
350350 };
351 result[@enumToInt(Feature.cheap_predicable_cpsr)] = .{
351 result[@intFromEnum(Feature.cheap_predicable_cpsr)] = .{
352352 .llvm_name = "cheap-predicable-cpsr",
353353 .description = "Disable +1 predication cost for instructions updating CPSR",
354354 .dependencies = featureSet(&[_]Feature{}),
355355 };
356 result[@enumToInt(Feature.clrbhb)] = .{
356 result[@intFromEnum(Feature.clrbhb)] = .{
357357 .llvm_name = "clrbhb",
358358 .description = "Enable Clear BHB instruction",
359359 .dependencies = featureSet(&[_]Feature{}),
360360 };
361 result[@enumToInt(Feature.crc)] = .{
361 result[@intFromEnum(Feature.crc)] = .{
362362 .llvm_name = "crc",
363363 .description = "Enable support for CRC instructions",
364364 .dependencies = featureSet(&[_]Feature{}),
365365 };
366 result[@enumToInt(Feature.crypto)] = .{
366 result[@intFromEnum(Feature.crypto)] = .{
367367 .llvm_name = "crypto",
368368 .description = "Enable support for Cryptography extensions",
369369 .dependencies = featureSet(&[_]Feature{
......@@ -371,54 +371,54 @@ pub const all_features = blk: {
371371 .sha2,
372372 }),
373373 };
374 result[@enumToInt(Feature.d32)] = .{
374 result[@intFromEnum(Feature.d32)] = .{
375375 .llvm_name = "d32",
376376 .description = "Extend FP to 32 double registers",
377377 .dependencies = featureSet(&[_]Feature{}),
378378 };
379 result[@enumToInt(Feature.db)] = .{
379 result[@intFromEnum(Feature.db)] = .{
380380 .llvm_name = "db",
381381 .description = "Has data barrier (dmb/dsb) instructions",
382382 .dependencies = featureSet(&[_]Feature{}),
383383 };
384 result[@enumToInt(Feature.dfb)] = .{
384 result[@intFromEnum(Feature.dfb)] = .{
385385 .llvm_name = "dfb",
386386 .description = "Has full data barrier (dfb) instruction",
387387 .dependencies = featureSet(&[_]Feature{}),
388388 };
389 result[@enumToInt(Feature.disable_postra_scheduler)] = .{
389 result[@intFromEnum(Feature.disable_postra_scheduler)] = .{
390390 .llvm_name = "disable-postra-scheduler",
391391 .description = "Don't schedule again after register allocation",
392392 .dependencies = featureSet(&[_]Feature{}),
393393 };
394 result[@enumToInt(Feature.dont_widen_vmovs)] = .{
394 result[@intFromEnum(Feature.dont_widen_vmovs)] = .{
395395 .llvm_name = "dont-widen-vmovs",
396396 .description = "Don't widen VMOVS to VMOVD",
397397 .dependencies = featureSet(&[_]Feature{}),
398398 };
399 result[@enumToInt(Feature.dotprod)] = .{
399 result[@intFromEnum(Feature.dotprod)] = .{
400400 .llvm_name = "dotprod",
401401 .description = "Enable support for dot product instructions",
402402 .dependencies = featureSet(&[_]Feature{
403403 .neon,
404404 }),
405405 };
406 result[@enumToInt(Feature.dsp)] = .{
406 result[@intFromEnum(Feature.dsp)] = .{
407407 .llvm_name = "dsp",
408408 .description = "Supports DSP instructions in ARM and/or Thumb2",
409409 .dependencies = featureSet(&[_]Feature{}),
410410 };
411 result[@enumToInt(Feature.execute_only)] = .{
411 result[@intFromEnum(Feature.execute_only)] = .{
412412 .llvm_name = "execute-only",
413413 .description = "Enable the generation of execute only code.",
414414 .dependencies = featureSet(&[_]Feature{}),
415415 };
416 result[@enumToInt(Feature.expand_fp_mlx)] = .{
416 result[@intFromEnum(Feature.expand_fp_mlx)] = .{
417417 .llvm_name = "expand-fp-mlx",
418418 .description = "Expand VFP/NEON MLA/MLS instructions",
419419 .dependencies = featureSet(&[_]Feature{}),
420420 };
421 result[@enumToInt(Feature.exynos)] = .{
421 result[@intFromEnum(Feature.exynos)] = .{
422422 .llvm_name = "exynos",
423423 .description = "Samsung Exynos processors",
424424 .dependencies = featureSet(&[_]Feature{
......@@ -441,36 +441,36 @@ pub const all_features = blk: {
441441 .zcz,
442442 }),
443443 };
444 result[@enumToInt(Feature.fix_cmse_cve_2021_35465)] = .{
444 result[@intFromEnum(Feature.fix_cmse_cve_2021_35465)] = .{
445445 .llvm_name = "fix-cmse-cve-2021-35465",
446446 .description = "Mitigate against the cve-2021-35465 security vulnurability",
447447 .dependencies = featureSet(&[_]Feature{}),
448448 };
449 result[@enumToInt(Feature.fix_cortex_a57_aes_1742098)] = .{
449 result[@intFromEnum(Feature.fix_cortex_a57_aes_1742098)] = .{
450450 .llvm_name = "fix-cortex-a57-aes-1742098",
451451 .description = "Work around Cortex-A57 Erratum 1742098 / Cortex-A72 Erratum 1655431 (AES)",
452452 .dependencies = featureSet(&[_]Feature{}),
453453 };
454 result[@enumToInt(Feature.fp16)] = .{
454 result[@intFromEnum(Feature.fp16)] = .{
455455 .llvm_name = "fp16",
456456 .description = "Enable half-precision floating point",
457457 .dependencies = featureSet(&[_]Feature{}),
458458 };
459 result[@enumToInt(Feature.fp16fml)] = .{
459 result[@intFromEnum(Feature.fp16fml)] = .{
460460 .llvm_name = "fp16fml",
461461 .description = "Enable full half-precision floating point fml instructions",
462462 .dependencies = featureSet(&[_]Feature{
463463 .fullfp16,
464464 }),
465465 };
466 result[@enumToInt(Feature.fp64)] = .{
466 result[@intFromEnum(Feature.fp64)] = .{
467467 .llvm_name = "fp64",
468468 .description = "Floating point unit supports double precision",
469469 .dependencies = featureSet(&[_]Feature{
470470 .fpregs64,
471471 }),
472472 };
473 result[@enumToInt(Feature.fp_armv8)] = .{
473 result[@intFromEnum(Feature.fp_armv8)] = .{
474474 .llvm_name = "fp-armv8",
475475 .description = "Enable ARMv8 FP",
476476 .dependencies = featureSet(&[_]Feature{
......@@ -479,7 +479,7 @@ pub const all_features = blk: {
479479 .vfp4,
480480 }),
481481 };
482 result[@enumToInt(Feature.fp_armv8d16)] = .{
482 result[@intFromEnum(Feature.fp_armv8d16)] = .{
483483 .llvm_name = "fp-armv8d16",
484484 .description = "Enable ARMv8 FP with only 16 d-registers",
485485 .dependencies = featureSet(&[_]Feature{
......@@ -487,14 +487,14 @@ pub const all_features = blk: {
487487 .vfp4d16,
488488 }),
489489 };
490 result[@enumToInt(Feature.fp_armv8d16sp)] = .{
490 result[@intFromEnum(Feature.fp_armv8d16sp)] = .{
491491 .llvm_name = "fp-armv8d16sp",
492492 .description = "Enable ARMv8 FP with only 16 d-registers and no double precision",
493493 .dependencies = featureSet(&[_]Feature{
494494 .vfp4d16sp,
495495 }),
496496 };
497 result[@enumToInt(Feature.fp_armv8sp)] = .{
497 result[@intFromEnum(Feature.fp_armv8sp)] = .{
498498 .llvm_name = "fp-armv8sp",
499499 .description = "Enable ARMv8 FP with no double precision",
500500 .dependencies = featureSet(&[_]Feature{
......@@ -502,31 +502,31 @@ pub const all_features = blk: {
502502 .vfp4sp,
503503 }),
504504 };
505 result[@enumToInt(Feature.fpao)] = .{
505 result[@intFromEnum(Feature.fpao)] = .{
506506 .llvm_name = "fpao",
507507 .description = "Enable fast computation of positive address offsets",
508508 .dependencies = featureSet(&[_]Feature{}),
509509 };
510 result[@enumToInt(Feature.fpregs)] = .{
510 result[@intFromEnum(Feature.fpregs)] = .{
511511 .llvm_name = "fpregs",
512512 .description = "Enable FP registers",
513513 .dependencies = featureSet(&[_]Feature{}),
514514 };
515 result[@enumToInt(Feature.fpregs16)] = .{
515 result[@intFromEnum(Feature.fpregs16)] = .{
516516 .llvm_name = "fpregs16",
517517 .description = "Enable 16-bit FP registers",
518518 .dependencies = featureSet(&[_]Feature{
519519 .fpregs,
520520 }),
521521 };
522 result[@enumToInt(Feature.fpregs64)] = .{
522 result[@intFromEnum(Feature.fpregs64)] = .{
523523 .llvm_name = "fpregs64",
524524 .description = "Enable 64-bit FP registers",
525525 .dependencies = featureSet(&[_]Feature{
526526 .fpregs,
527527 }),
528528 };
529 result[@enumToInt(Feature.fullfp16)] = .{
529 result[@intFromEnum(Feature.fullfp16)] = .{
530530 .llvm_name = "fullfp16",
531531 .description = "Enable full half-precision floating point",
532532 .dependencies = featureSet(&[_]Feature{
......@@ -534,72 +534,72 @@ pub const all_features = blk: {
534534 .fpregs16,
535535 }),
536536 };
537 result[@enumToInt(Feature.fuse_aes)] = .{
537 result[@intFromEnum(Feature.fuse_aes)] = .{
538538 .llvm_name = "fuse-aes",
539539 .description = "CPU fuses AES crypto operations",
540540 .dependencies = featureSet(&[_]Feature{}),
541541 };
542 result[@enumToInt(Feature.fuse_literals)] = .{
542 result[@intFromEnum(Feature.fuse_literals)] = .{
543543 .llvm_name = "fuse-literals",
544544 .description = "CPU fuses literal generation operations",
545545 .dependencies = featureSet(&[_]Feature{}),
546546 };
547 result[@enumToInt(Feature.harden_sls_blr)] = .{
547 result[@intFromEnum(Feature.harden_sls_blr)] = .{
548548 .llvm_name = "harden-sls-blr",
549549 .description = "Harden against straight line speculation across indirect calls",
550550 .dependencies = featureSet(&[_]Feature{}),
551551 };
552 result[@enumToInt(Feature.harden_sls_nocomdat)] = .{
552 result[@intFromEnum(Feature.harden_sls_nocomdat)] = .{
553553 .llvm_name = "harden-sls-nocomdat",
554554 .description = "Generate thunk code for SLS mitigation in the normal text section",
555555 .dependencies = featureSet(&[_]Feature{}),
556556 };
557 result[@enumToInt(Feature.harden_sls_retbr)] = .{
557 result[@intFromEnum(Feature.harden_sls_retbr)] = .{
558558 .llvm_name = "harden-sls-retbr",
559559 .description = "Harden against straight line speculation across RETurn and BranchRegister instructions",
560560 .dependencies = featureSet(&[_]Feature{}),
561561 };
562 result[@enumToInt(Feature.has_v4t)] = .{
562 result[@intFromEnum(Feature.has_v4t)] = .{
563563 .llvm_name = "v4t",
564564 .description = "Support ARM v4T instructions",
565565 .dependencies = featureSet(&[_]Feature{}),
566566 };
567 result[@enumToInt(Feature.has_v5t)] = .{
567 result[@intFromEnum(Feature.has_v5t)] = .{
568568 .llvm_name = "v5t",
569569 .description = "Support ARM v5T instructions",
570570 .dependencies = featureSet(&[_]Feature{
571571 .has_v4t,
572572 }),
573573 };
574 result[@enumToInt(Feature.has_v5te)] = .{
574 result[@intFromEnum(Feature.has_v5te)] = .{
575575 .llvm_name = "v5te",
576576 .description = "Support ARM v5TE, v5TEj, and v5TExp instructions",
577577 .dependencies = featureSet(&[_]Feature{
578578 .has_v5t,
579579 }),
580580 };
581 result[@enumToInt(Feature.has_v6)] = .{
581 result[@intFromEnum(Feature.has_v6)] = .{
582582 .llvm_name = "v6",
583583 .description = "Support ARM v6 instructions",
584584 .dependencies = featureSet(&[_]Feature{
585585 .has_v5te,
586586 }),
587587 };
588 result[@enumToInt(Feature.has_v6k)] = .{
588 result[@intFromEnum(Feature.has_v6k)] = .{
589589 .llvm_name = "v6k",
590590 .description = "Support ARM v6k instructions",
591591 .dependencies = featureSet(&[_]Feature{
592592 .has_v6,
593593 }),
594594 };
595 result[@enumToInt(Feature.has_v6m)] = .{
595 result[@intFromEnum(Feature.has_v6m)] = .{
596596 .llvm_name = "v6m",
597597 .description = "Support ARM v6M instructions",
598598 .dependencies = featureSet(&[_]Feature{
599599 .has_v6,
600600 }),
601601 };
602 result[@enumToInt(Feature.has_v6t2)] = .{
602 result[@intFromEnum(Feature.has_v6t2)] = .{
603603 .llvm_name = "v6t2",
604604 .description = "Support ARM v6t2 instructions",
605605 .dependencies = featureSet(&[_]Feature{
......@@ -608,7 +608,7 @@ pub const all_features = blk: {
608608 .thumb2,
609609 }),
610610 };
611 result[@enumToInt(Feature.has_v7)] = .{
611 result[@intFromEnum(Feature.has_v7)] = .{
612612 .llvm_name = "v7",
613613 .description = "Support ARM v7 instructions",
614614 .dependencies = featureSet(&[_]Feature{
......@@ -616,12 +616,12 @@ pub const all_features = blk: {
616616 .has_v7clrex,
617617 }),
618618 };
619 result[@enumToInt(Feature.has_v7clrex)] = .{
619 result[@intFromEnum(Feature.has_v7clrex)] = .{
620620 .llvm_name = "v7clrex",
621621 .description = "Has v7 clrex instruction",
622622 .dependencies = featureSet(&[_]Feature{}),
623623 };
624 result[@enumToInt(Feature.has_v8)] = .{
624 result[@intFromEnum(Feature.has_v8)] = .{
625625 .llvm_name = "v8",
626626 .description = "Support ARM v8 instructions",
627627 .dependencies = featureSet(&[_]Feature{
......@@ -630,35 +630,35 @@ pub const all_features = blk: {
630630 .perfmon,
631631 }),
632632 };
633 result[@enumToInt(Feature.has_v8_1a)] = .{
633 result[@intFromEnum(Feature.has_v8_1a)] = .{
634634 .llvm_name = "v8.1a",
635635 .description = "Support ARM v8.1a instructions",
636636 .dependencies = featureSet(&[_]Feature{
637637 .has_v8,
638638 }),
639639 };
640 result[@enumToInt(Feature.has_v8_1m_main)] = .{
640 result[@intFromEnum(Feature.has_v8_1m_main)] = .{
641641 .llvm_name = "v8.1m.main",
642642 .description = "Support ARM v8-1M Mainline instructions",
643643 .dependencies = featureSet(&[_]Feature{
644644 .has_v8m_main,
645645 }),
646646 };
647 result[@enumToInt(Feature.has_v8_2a)] = .{
647 result[@intFromEnum(Feature.has_v8_2a)] = .{
648648 .llvm_name = "v8.2a",
649649 .description = "Support ARM v8.2a instructions",
650650 .dependencies = featureSet(&[_]Feature{
651651 .has_v8_1a,
652652 }),
653653 };
654 result[@enumToInt(Feature.has_v8_3a)] = .{
654 result[@intFromEnum(Feature.has_v8_3a)] = .{
655655 .llvm_name = "v8.3a",
656656 .description = "Support ARM v8.3a instructions",
657657 .dependencies = featureSet(&[_]Feature{
658658 .has_v8_2a,
659659 }),
660660 };
661 result[@enumToInt(Feature.has_v8_4a)] = .{
661 result[@intFromEnum(Feature.has_v8_4a)] = .{
662662 .llvm_name = "v8.4a",
663663 .description = "Support ARM v8.4a instructions",
664664 .dependencies = featureSet(&[_]Feature{
......@@ -666,7 +666,7 @@ pub const all_features = blk: {
666666 .has_v8_3a,
667667 }),
668668 };
669 result[@enumToInt(Feature.has_v8_5a)] = .{
669 result[@intFromEnum(Feature.has_v8_5a)] = .{
670670 .llvm_name = "v8.5a",
671671 .description = "Support ARM v8.5a instructions",
672672 .dependencies = featureSet(&[_]Feature{
......@@ -674,7 +674,7 @@ pub const all_features = blk: {
674674 .sb,
675675 }),
676676 };
677 result[@enumToInt(Feature.has_v8_6a)] = .{
677 result[@intFromEnum(Feature.has_v8_6a)] = .{
678678 .llvm_name = "v8.6a",
679679 .description = "Support ARM v8.6a instructions",
680680 .dependencies = featureSet(&[_]Feature{
......@@ -683,21 +683,21 @@ pub const all_features = blk: {
683683 .i8mm,
684684 }),
685685 };
686 result[@enumToInt(Feature.has_v8_7a)] = .{
686 result[@intFromEnum(Feature.has_v8_7a)] = .{
687687 .llvm_name = "v8.7a",
688688 .description = "Support ARM v8.7a instructions",
689689 .dependencies = featureSet(&[_]Feature{
690690 .has_v8_6a,
691691 }),
692692 };
693 result[@enumToInt(Feature.has_v8_8a)] = .{
693 result[@intFromEnum(Feature.has_v8_8a)] = .{
694694 .llvm_name = "v8.8a",
695695 .description = "Support ARM v8.8a instructions",
696696 .dependencies = featureSet(&[_]Feature{
697697 .has_v8_7a,
698698 }),
699699 };
700 result[@enumToInt(Feature.has_v8_9a)] = .{
700 result[@intFromEnum(Feature.has_v8_9a)] = .{
701701 .llvm_name = "v8.9a",
702702 .description = "Support ARM v8.9a instructions",
703703 .dependencies = featureSet(&[_]Feature{
......@@ -705,21 +705,21 @@ pub const all_features = blk: {
705705 .has_v8_8a,
706706 }),
707707 };
708 result[@enumToInt(Feature.has_v8m)] = .{
708 result[@intFromEnum(Feature.has_v8m)] = .{
709709 .llvm_name = "v8m",
710710 .description = "Support ARM v8M Baseline instructions",
711711 .dependencies = featureSet(&[_]Feature{
712712 .has_v6m,
713713 }),
714714 };
715 result[@enumToInt(Feature.has_v8m_main)] = .{
715 result[@intFromEnum(Feature.has_v8m_main)] = .{
716716 .llvm_name = "v8m.main",
717717 .description = "Support ARM v8M Mainline instructions",
718718 .dependencies = featureSet(&[_]Feature{
719719 .has_v7,
720720 }),
721721 };
722 result[@enumToInt(Feature.has_v9_1a)] = .{
722 result[@intFromEnum(Feature.has_v9_1a)] = .{
723723 .llvm_name = "v9.1a",
724724 .description = "Support ARM v9.1a instructions",
725725 .dependencies = featureSet(&[_]Feature{
......@@ -727,7 +727,7 @@ pub const all_features = blk: {
727727 .has_v9a,
728728 }),
729729 };
730 result[@enumToInt(Feature.has_v9_2a)] = .{
730 result[@intFromEnum(Feature.has_v9_2a)] = .{
731731 .llvm_name = "v9.2a",
732732 .description = "Support ARM v9.2a instructions",
733733 .dependencies = featureSet(&[_]Feature{
......@@ -735,7 +735,7 @@ pub const all_features = blk: {
735735 .has_v9_1a,
736736 }),
737737 };
738 result[@enumToInt(Feature.has_v9_3a)] = .{
738 result[@intFromEnum(Feature.has_v9_3a)] = .{
739739 .llvm_name = "v9.3a",
740740 .description = "Support ARM v9.3a instructions",
741741 .dependencies = featureSet(&[_]Feature{
......@@ -743,7 +743,7 @@ pub const all_features = blk: {
743743 .has_v9_2a,
744744 }),
745745 };
746 result[@enumToInt(Feature.has_v9_4a)] = .{
746 result[@intFromEnum(Feature.has_v9_4a)] = .{
747747 .llvm_name = "v9.4a",
748748 .description = "Support ARM v9.4a instructions",
749749 .dependencies = featureSet(&[_]Feature{
......@@ -751,80 +751,80 @@ pub const all_features = blk: {
751751 .has_v9_3a,
752752 }),
753753 };
754 result[@enumToInt(Feature.has_v9a)] = .{
754 result[@intFromEnum(Feature.has_v9a)] = .{
755755 .llvm_name = "v9a",
756756 .description = "Support ARM v9a instructions",
757757 .dependencies = featureSet(&[_]Feature{
758758 .has_v8_5a,
759759 }),
760760 };
761 result[@enumToInt(Feature.hwdiv)] = .{
761 result[@intFromEnum(Feature.hwdiv)] = .{
762762 .llvm_name = "hwdiv",
763763 .description = "Enable divide instructions in Thumb",
764764 .dependencies = featureSet(&[_]Feature{}),
765765 };
766 result[@enumToInt(Feature.hwdiv_arm)] = .{
766 result[@intFromEnum(Feature.hwdiv_arm)] = .{
767767 .llvm_name = "hwdiv-arm",
768768 .description = "Enable divide instructions in ARM mode",
769769 .dependencies = featureSet(&[_]Feature{}),
770770 };
771 result[@enumToInt(Feature.i8mm)] = .{
771 result[@intFromEnum(Feature.i8mm)] = .{
772772 .llvm_name = "i8mm",
773773 .description = "Enable Matrix Multiply Int8 Extension",
774774 .dependencies = featureSet(&[_]Feature{
775775 .neon,
776776 }),
777777 };
778 result[@enumToInt(Feature.iwmmxt)] = .{
778 result[@intFromEnum(Feature.iwmmxt)] = .{
779779 .llvm_name = "iwmmxt",
780780 .description = "ARMv5te architecture",
781781 .dependencies = featureSet(&[_]Feature{
782782 .v5te,
783783 }),
784784 };
785 result[@enumToInt(Feature.iwmmxt2)] = .{
785 result[@intFromEnum(Feature.iwmmxt2)] = .{
786786 .llvm_name = "iwmmxt2",
787787 .description = "ARMv5te architecture",
788788 .dependencies = featureSet(&[_]Feature{
789789 .v5te,
790790 }),
791791 };
792 result[@enumToInt(Feature.lob)] = .{
792 result[@intFromEnum(Feature.lob)] = .{
793793 .llvm_name = "lob",
794794 .description = "Enable Low Overhead Branch extensions",
795795 .dependencies = featureSet(&[_]Feature{}),
796796 };
797 result[@enumToInt(Feature.long_calls)] = .{
797 result[@intFromEnum(Feature.long_calls)] = .{
798798 .llvm_name = "long-calls",
799799 .description = "Generate calls via indirect call instructions",
800800 .dependencies = featureSet(&[_]Feature{}),
801801 };
802 result[@enumToInt(Feature.loop_align)] = .{
802 result[@intFromEnum(Feature.loop_align)] = .{
803803 .llvm_name = "loop-align",
804804 .description = "Prefer 32-bit alignment for loops",
805805 .dependencies = featureSet(&[_]Feature{}),
806806 };
807 result[@enumToInt(Feature.m3)] = .{
807 result[@intFromEnum(Feature.m3)] = .{
808808 .llvm_name = "m3",
809809 .description = "Cortex-M3 ARM processors",
810810 .dependencies = featureSet(&[_]Feature{}),
811811 };
812 result[@enumToInt(Feature.mclass)] = .{
812 result[@intFromEnum(Feature.mclass)] = .{
813813 .llvm_name = "mclass",
814814 .description = "Is microcontroller profile ('M' series)",
815815 .dependencies = featureSet(&[_]Feature{}),
816816 };
817 result[@enumToInt(Feature.mp)] = .{
817 result[@intFromEnum(Feature.mp)] = .{
818818 .llvm_name = "mp",
819819 .description = "Supports Multiprocessing extension",
820820 .dependencies = featureSet(&[_]Feature{}),
821821 };
822 result[@enumToInt(Feature.muxed_units)] = .{
822 result[@intFromEnum(Feature.muxed_units)] = .{
823823 .llvm_name = "muxed-units",
824824 .description = "Has muxed AGU and NEON/FPU",
825825 .dependencies = featureSet(&[_]Feature{}),
826826 };
827 result[@enumToInt(Feature.mve)] = .{
827 result[@intFromEnum(Feature.mve)] = .{
828828 .llvm_name = "mve",
829829 .description = "Support M-Class Vector Extension with integer ops",
830830 .dependencies = featureSet(&[_]Feature{
......@@ -834,22 +834,22 @@ pub const all_features = blk: {
834834 .has_v8_1m_main,
835835 }),
836836 };
837 result[@enumToInt(Feature.mve1beat)] = .{
837 result[@intFromEnum(Feature.mve1beat)] = .{
838838 .llvm_name = "mve1beat",
839839 .description = "Model MVE instructions as a 1 beat per tick architecture",
840840 .dependencies = featureSet(&[_]Feature{}),
841841 };
842 result[@enumToInt(Feature.mve2beat)] = .{
842 result[@intFromEnum(Feature.mve2beat)] = .{
843843 .llvm_name = "mve2beat",
844844 .description = "Model MVE instructions as a 2 beats per tick architecture",
845845 .dependencies = featureSet(&[_]Feature{}),
846846 };
847 result[@enumToInt(Feature.mve4beat)] = .{
847 result[@intFromEnum(Feature.mve4beat)] = .{
848848 .llvm_name = "mve4beat",
849849 .description = "Model MVE instructions as a 4 beats per tick architecture",
850850 .dependencies = featureSet(&[_]Feature{}),
851851 };
852 result[@enumToInt(Feature.mve_fp)] = .{
852 result[@intFromEnum(Feature.mve_fp)] = .{
853853 .llvm_name = "mve.fp",
854854 .description = "Support M-Class Vector Extension with integer and floating ops",
855855 .dependencies = featureSet(&[_]Feature{
......@@ -857,243 +857,243 @@ pub const all_features = blk: {
857857 .mve,
858858 }),
859859 };
860 result[@enumToInt(Feature.nacl_trap)] = .{
860 result[@intFromEnum(Feature.nacl_trap)] = .{
861861 .llvm_name = "nacl-trap",
862862 .description = "NaCl trap",
863863 .dependencies = featureSet(&[_]Feature{}),
864864 };
865 result[@enumToInt(Feature.neon)] = .{
865 result[@intFromEnum(Feature.neon)] = .{
866866 .llvm_name = "neon",
867867 .description = "Enable NEON instructions",
868868 .dependencies = featureSet(&[_]Feature{
869869 .vfp3,
870870 }),
871871 };
872 result[@enumToInt(Feature.neon_fpmovs)] = .{
872 result[@intFromEnum(Feature.neon_fpmovs)] = .{
873873 .llvm_name = "neon-fpmovs",
874874 .description = "Convert VMOVSR, VMOVRS, VMOVS to NEON",
875875 .dependencies = featureSet(&[_]Feature{}),
876876 };
877 result[@enumToInt(Feature.neonfp)] = .{
877 result[@intFromEnum(Feature.neonfp)] = .{
878878 .llvm_name = "neonfp",
879879 .description = "Use NEON for single precision FP",
880880 .dependencies = featureSet(&[_]Feature{}),
881881 };
882 result[@enumToInt(Feature.no_branch_predictor)] = .{
882 result[@intFromEnum(Feature.no_branch_predictor)] = .{
883883 .llvm_name = "no-branch-predictor",
884884 .description = "Has no branch predictor",
885885 .dependencies = featureSet(&[_]Feature{}),
886886 };
887 result[@enumToInt(Feature.no_bti_at_return_twice)] = .{
887 result[@intFromEnum(Feature.no_bti_at_return_twice)] = .{
888888 .llvm_name = "no-bti-at-return-twice",
889889 .description = "Don't place a BTI instruction after a return-twice",
890890 .dependencies = featureSet(&[_]Feature{}),
891891 };
892 result[@enumToInt(Feature.no_movt)] = .{
892 result[@intFromEnum(Feature.no_movt)] = .{
893893 .llvm_name = "no-movt",
894894 .description = "Don't use movt/movw pairs for 32-bit imms",
895895 .dependencies = featureSet(&[_]Feature{}),
896896 };
897 result[@enumToInt(Feature.no_neg_immediates)] = .{
897 result[@intFromEnum(Feature.no_neg_immediates)] = .{
898898 .llvm_name = "no-neg-immediates",
899899 .description = "Convert immediates and instructions to their negated or complemented equivalent when the immediate does not fit in the encoding.",
900900 .dependencies = featureSet(&[_]Feature{}),
901901 };
902 result[@enumToInt(Feature.noarm)] = .{
902 result[@intFromEnum(Feature.noarm)] = .{
903903 .llvm_name = "noarm",
904904 .description = "Does not support ARM mode execution",
905905 .dependencies = featureSet(&[_]Feature{}),
906906 };
907 result[@enumToInt(Feature.nonpipelined_vfp)] = .{
907 result[@intFromEnum(Feature.nonpipelined_vfp)] = .{
908908 .llvm_name = "nonpipelined-vfp",
909909 .description = "VFP instructions are not pipelined",
910910 .dependencies = featureSet(&[_]Feature{}),
911911 };
912 result[@enumToInt(Feature.pacbti)] = .{
912 result[@intFromEnum(Feature.pacbti)] = .{
913913 .llvm_name = "pacbti",
914914 .description = "Enable Pointer Authentication and Branch Target Identification",
915915 .dependencies = featureSet(&[_]Feature{}),
916916 };
917 result[@enumToInt(Feature.perfmon)] = .{
917 result[@intFromEnum(Feature.perfmon)] = .{
918918 .llvm_name = "perfmon",
919919 .description = "Enable support for Performance Monitor extensions",
920920 .dependencies = featureSet(&[_]Feature{}),
921921 };
922 result[@enumToInt(Feature.prefer_ishst)] = .{
922 result[@intFromEnum(Feature.prefer_ishst)] = .{
923923 .llvm_name = "prefer-ishst",
924924 .description = "Prefer ISHST barriers",
925925 .dependencies = featureSet(&[_]Feature{}),
926926 };
927 result[@enumToInt(Feature.prefer_vmovsr)] = .{
927 result[@intFromEnum(Feature.prefer_vmovsr)] = .{
928928 .llvm_name = "prefer-vmovsr",
929929 .description = "Prefer VMOVSR",
930930 .dependencies = featureSet(&[_]Feature{}),
931931 };
932 result[@enumToInt(Feature.prof_unpr)] = .{
932 result[@intFromEnum(Feature.prof_unpr)] = .{
933933 .llvm_name = "prof-unpr",
934934 .description = "Is profitable to unpredicate",
935935 .dependencies = featureSet(&[_]Feature{}),
936936 };
937 result[@enumToInt(Feature.r4)] = .{
937 result[@intFromEnum(Feature.r4)] = .{
938938 .llvm_name = "r4",
939939 .description = "Cortex-R4 ARM processors",
940940 .dependencies = featureSet(&[_]Feature{}),
941941 };
942 result[@enumToInt(Feature.ras)] = .{
942 result[@intFromEnum(Feature.ras)] = .{
943943 .llvm_name = "ras",
944944 .description = "Enable Reliability, Availability and Serviceability extensions",
945945 .dependencies = featureSet(&[_]Feature{}),
946946 };
947 result[@enumToInt(Feature.rclass)] = .{
947 result[@intFromEnum(Feature.rclass)] = .{
948948 .llvm_name = "rclass",
949949 .description = "Is realtime profile ('R' series)",
950950 .dependencies = featureSet(&[_]Feature{}),
951951 };
952 result[@enumToInt(Feature.read_tp_hard)] = .{
952 result[@intFromEnum(Feature.read_tp_hard)] = .{
953953 .llvm_name = "read-tp-hard",
954954 .description = "Reading thread pointer from register",
955955 .dependencies = featureSet(&[_]Feature{}),
956956 };
957 result[@enumToInt(Feature.reserve_r9)] = .{
957 result[@intFromEnum(Feature.reserve_r9)] = .{
958958 .llvm_name = "reserve-r9",
959959 .description = "Reserve R9, making it unavailable as GPR",
960960 .dependencies = featureSet(&[_]Feature{}),
961961 };
962 result[@enumToInt(Feature.ret_addr_stack)] = .{
962 result[@intFromEnum(Feature.ret_addr_stack)] = .{
963963 .llvm_name = "ret-addr-stack",
964964 .description = "Has return address stack",
965965 .dependencies = featureSet(&[_]Feature{}),
966966 };
967 result[@enumToInt(Feature.sb)] = .{
967 result[@intFromEnum(Feature.sb)] = .{
968968 .llvm_name = "sb",
969969 .description = "Enable v8.5a Speculation Barrier",
970970 .dependencies = featureSet(&[_]Feature{}),
971971 };
972 result[@enumToInt(Feature.sha2)] = .{
972 result[@intFromEnum(Feature.sha2)] = .{
973973 .llvm_name = "sha2",
974974 .description = "Enable SHA1 and SHA256 support",
975975 .dependencies = featureSet(&[_]Feature{
976976 .neon,
977977 }),
978978 };
979 result[@enumToInt(Feature.slow_fp_brcc)] = .{
979 result[@intFromEnum(Feature.slow_fp_brcc)] = .{
980980 .llvm_name = "slow-fp-brcc",
981981 .description = "FP compare + branch is slow",
982982 .dependencies = featureSet(&[_]Feature{}),
983983 };
984 result[@enumToInt(Feature.slow_load_D_subreg)] = .{
984 result[@intFromEnum(Feature.slow_load_D_subreg)] = .{
985985 .llvm_name = "slow-load-D-subreg",
986986 .description = "Loading into D subregs is slow",
987987 .dependencies = featureSet(&[_]Feature{}),
988988 };
989 result[@enumToInt(Feature.slow_odd_reg)] = .{
989 result[@intFromEnum(Feature.slow_odd_reg)] = .{
990990 .llvm_name = "slow-odd-reg",
991991 .description = "VLDM/VSTM starting with an odd register is slow",
992992 .dependencies = featureSet(&[_]Feature{}),
993993 };
994 result[@enumToInt(Feature.slow_vdup32)] = .{
994 result[@intFromEnum(Feature.slow_vdup32)] = .{
995995 .llvm_name = "slow-vdup32",
996996 .description = "Has slow VDUP32 - prefer VMOV",
997997 .dependencies = featureSet(&[_]Feature{}),
998998 };
999 result[@enumToInt(Feature.slow_vgetlni32)] = .{
999 result[@intFromEnum(Feature.slow_vgetlni32)] = .{
10001000 .llvm_name = "slow-vgetlni32",
10011001 .description = "Has slow VGETLNi32 - prefer VMOV",
10021002 .dependencies = featureSet(&[_]Feature{}),
10031003 };
1004 result[@enumToInt(Feature.slowfpvfmx)] = .{
1004 result[@intFromEnum(Feature.slowfpvfmx)] = .{
10051005 .llvm_name = "slowfpvfmx",
10061006 .description = "Disable VFP / NEON FMA instructions",
10071007 .dependencies = featureSet(&[_]Feature{}),
10081008 };
1009 result[@enumToInt(Feature.slowfpvmlx)] = .{
1009 result[@intFromEnum(Feature.slowfpvmlx)] = .{
10101010 .llvm_name = "slowfpvmlx",
10111011 .description = "Disable VFP / NEON MAC instructions",
10121012 .dependencies = featureSet(&[_]Feature{}),
10131013 };
1014 result[@enumToInt(Feature.soft_float)] = .{
1014 result[@intFromEnum(Feature.soft_float)] = .{
10151015 .llvm_name = "soft-float",
10161016 .description = "Use software floating point features.",
10171017 .dependencies = featureSet(&[_]Feature{}),
10181018 };
1019 result[@enumToInt(Feature.splat_vfp_neon)] = .{
1019 result[@intFromEnum(Feature.splat_vfp_neon)] = .{
10201020 .llvm_name = "splat-vfp-neon",
10211021 .description = "Splat register from VFP to NEON",
10221022 .dependencies = featureSet(&[_]Feature{
10231023 .dont_widen_vmovs,
10241024 }),
10251025 };
1026 result[@enumToInt(Feature.strict_align)] = .{
1026 result[@intFromEnum(Feature.strict_align)] = .{
10271027 .llvm_name = "strict-align",
10281028 .description = "Disallow all unaligned memory access",
10291029 .dependencies = featureSet(&[_]Feature{}),
10301030 };
1031 result[@enumToInt(Feature.swift)] = .{
1031 result[@intFromEnum(Feature.swift)] = .{
10321032 .llvm_name = "swift",
10331033 .description = "Swift ARM processors",
10341034 .dependencies = featureSet(&[_]Feature{}),
10351035 };
1036 result[@enumToInt(Feature.thumb2)] = .{
1036 result[@intFromEnum(Feature.thumb2)] = .{
10371037 .llvm_name = "thumb2",
10381038 .description = "Enable Thumb2 instructions",
10391039 .dependencies = featureSet(&[_]Feature{}),
10401040 };
1041 result[@enumToInt(Feature.thumb_mode)] = .{
1041 result[@intFromEnum(Feature.thumb_mode)] = .{
10421042 .llvm_name = "thumb-mode",
10431043 .description = "Thumb mode",
10441044 .dependencies = featureSet(&[_]Feature{}),
10451045 };
1046 result[@enumToInt(Feature.trustzone)] = .{
1046 result[@intFromEnum(Feature.trustzone)] = .{
10471047 .llvm_name = "trustzone",
10481048 .description = "Enable support for TrustZone security extensions",
10491049 .dependencies = featureSet(&[_]Feature{}),
10501050 };
1051 result[@enumToInt(Feature.use_mipipeliner)] = .{
1051 result[@intFromEnum(Feature.use_mipipeliner)] = .{
10521052 .llvm_name = "use-mipipeliner",
10531053 .description = "Use the MachinePipeliner",
10541054 .dependencies = featureSet(&[_]Feature{}),
10551055 };
1056 result[@enumToInt(Feature.use_misched)] = .{
1056 result[@intFromEnum(Feature.use_misched)] = .{
10571057 .llvm_name = "use-misched",
10581058 .description = "Use the MachineScheduler",
10591059 .dependencies = featureSet(&[_]Feature{}),
10601060 };
1061 result[@enumToInt(Feature.v2)] = .{
1061 result[@intFromEnum(Feature.v2)] = .{
10621062 .llvm_name = null,
10631063 .description = "ARMv2 architecture",
10641064 .dependencies = featureSet(&[_]Feature{
10651065 .strict_align,
10661066 }),
10671067 };
1068 result[@enumToInt(Feature.v2a)] = .{
1068 result[@intFromEnum(Feature.v2a)] = .{
10691069 .llvm_name = null,
10701070 .description = "ARMv2a architecture",
10711071 .dependencies = featureSet(&[_]Feature{
10721072 .strict_align,
10731073 }),
10741074 };
1075 result[@enumToInt(Feature.v3)] = .{
1075 result[@intFromEnum(Feature.v3)] = .{
10761076 .llvm_name = null,
10771077 .description = "ARMv3 architecture",
10781078 .dependencies = featureSet(&[_]Feature{
10791079 .strict_align,
10801080 }),
10811081 };
1082 result[@enumToInt(Feature.v3m)] = .{
1082 result[@intFromEnum(Feature.v3m)] = .{
10831083 .llvm_name = null,
10841084 .description = "ARMv3m architecture",
10851085 .dependencies = featureSet(&[_]Feature{
10861086 .strict_align,
10871087 }),
10881088 };
1089 result[@enumToInt(Feature.v4)] = .{
1089 result[@intFromEnum(Feature.v4)] = .{
10901090 .llvm_name = "armv4",
10911091 .description = "ARMv4 architecture",
10921092 .dependencies = featureSet(&[_]Feature{
10931093 .strict_align,
10941094 }),
10951095 };
1096 result[@enumToInt(Feature.v4t)] = .{
1096 result[@intFromEnum(Feature.v4t)] = .{
10971097 .llvm_name = "armv4t",
10981098 .description = "ARMv4t architecture",
10991099 .dependencies = featureSet(&[_]Feature{
......@@ -1101,7 +1101,7 @@ pub const all_features = blk: {
11011101 .strict_align,
11021102 }),
11031103 };
1104 result[@enumToInt(Feature.v5t)] = .{
1104 result[@intFromEnum(Feature.v5t)] = .{
11051105 .llvm_name = "armv5t",
11061106 .description = "ARMv5t architecture",
11071107 .dependencies = featureSet(&[_]Feature{
......@@ -1109,7 +1109,7 @@ pub const all_features = blk: {
11091109 .strict_align,
11101110 }),
11111111 };
1112 result[@enumToInt(Feature.v5te)] = .{
1112 result[@intFromEnum(Feature.v5te)] = .{
11131113 .llvm_name = "armv5te",
11141114 .description = "ARMv5te architecture",
11151115 .dependencies = featureSet(&[_]Feature{
......@@ -1117,7 +1117,7 @@ pub const all_features = blk: {
11171117 .strict_align,
11181118 }),
11191119 };
1120 result[@enumToInt(Feature.v5tej)] = .{
1120 result[@intFromEnum(Feature.v5tej)] = .{
11211121 .llvm_name = "armv5tej",
11221122 .description = "ARMv5tej architecture",
11231123 .dependencies = featureSet(&[_]Feature{
......@@ -1125,7 +1125,7 @@ pub const all_features = blk: {
11251125 .strict_align,
11261126 }),
11271127 };
1128 result[@enumToInt(Feature.v6)] = .{
1128 result[@intFromEnum(Feature.v6)] = .{
11291129 .llvm_name = "armv6",
11301130 .description = "ARMv6 architecture",
11311131 .dependencies = featureSet(&[_]Feature{
......@@ -1133,21 +1133,21 @@ pub const all_features = blk: {
11331133 .has_v6,
11341134 }),
11351135 };
1136 result[@enumToInt(Feature.v6j)] = .{
1136 result[@intFromEnum(Feature.v6j)] = .{
11371137 .llvm_name = "armv6j",
11381138 .description = "ARMv7a architecture",
11391139 .dependencies = featureSet(&[_]Feature{
11401140 .v6,
11411141 }),
11421142 };
1143 result[@enumToInt(Feature.v6k)] = .{
1143 result[@intFromEnum(Feature.v6k)] = .{
11441144 .llvm_name = "armv6k",
11451145 .description = "ARMv6k architecture",
11461146 .dependencies = featureSet(&[_]Feature{
11471147 .has_v6k,
11481148 }),
11491149 };
1150 result[@enumToInt(Feature.v6kz)] = .{
1150 result[@intFromEnum(Feature.v6kz)] = .{
11511151 .llvm_name = "armv6kz",
11521152 .description = "ARMv6kz architecture",
11531153 .dependencies = featureSet(&[_]Feature{
......@@ -1155,7 +1155,7 @@ pub const all_features = blk: {
11551155 .trustzone,
11561156 }),
11571157 };
1158 result[@enumToInt(Feature.v6m)] = .{
1158 result[@intFromEnum(Feature.v6m)] = .{
11591159 .llvm_name = "armv6-m",
11601160 .description = "ARMv6m architecture",
11611161 .dependencies = featureSet(&[_]Feature{
......@@ -1167,7 +1167,7 @@ pub const all_features = blk: {
11671167 .thumb_mode,
11681168 }),
11691169 };
1170 result[@enumToInt(Feature.v6sm)] = .{
1170 result[@intFromEnum(Feature.v6sm)] = .{
11711171 .llvm_name = "armv6s-m",
11721172 .description = "ARMv6sm architecture",
11731173 .dependencies = featureSet(&[_]Feature{
......@@ -1179,7 +1179,7 @@ pub const all_features = blk: {
11791179 .thumb_mode,
11801180 }),
11811181 };
1182 result[@enumToInt(Feature.v6t2)] = .{
1182 result[@intFromEnum(Feature.v6t2)] = .{
11831183 .llvm_name = "armv6t2",
11841184 .description = "ARMv6t2 architecture",
11851185 .dependencies = featureSet(&[_]Feature{
......@@ -1187,7 +1187,7 @@ pub const all_features = blk: {
11871187 .has_v6t2,
11881188 }),
11891189 };
1190 result[@enumToInt(Feature.v7a)] = .{
1190 result[@intFromEnum(Feature.v7a)] = .{
11911191 .llvm_name = "armv7-a",
11921192 .description = "ARMv7a architecture",
11931193 .dependencies = featureSet(&[_]Feature{
......@@ -1199,7 +1199,7 @@ pub const all_features = blk: {
11991199 .perfmon,
12001200 }),
12011201 };
1202 result[@enumToInt(Feature.v7em)] = .{
1202 result[@intFromEnum(Feature.v7em)] = .{
12031203 .llvm_name = "armv7e-m",
12041204 .description = "ARMv7em architecture",
12051205 .dependencies = featureSet(&[_]Feature{
......@@ -1212,14 +1212,14 @@ pub const all_features = blk: {
12121212 .thumb_mode,
12131213 }),
12141214 };
1215 result[@enumToInt(Feature.v7k)] = .{
1215 result[@intFromEnum(Feature.v7k)] = .{
12161216 .llvm_name = "armv7k",
12171217 .description = "ARMv7a architecture",
12181218 .dependencies = featureSet(&[_]Feature{
12191219 .v7a,
12201220 }),
12211221 };
1222 result[@enumToInt(Feature.v7m)] = .{
1222 result[@intFromEnum(Feature.v7m)] = .{
12231223 .llvm_name = "armv7-m",
12241224 .description = "ARMv7m architecture",
12251225 .dependencies = featureSet(&[_]Feature{
......@@ -1231,7 +1231,7 @@ pub const all_features = blk: {
12311231 .thumb_mode,
12321232 }),
12331233 };
1234 result[@enumToInt(Feature.v7r)] = .{
1234 result[@intFromEnum(Feature.v7r)] = .{
12351235 .llvm_name = "armv7-r",
12361236 .description = "ARMv7r architecture",
12371237 .dependencies = featureSet(&[_]Feature{
......@@ -1243,14 +1243,14 @@ pub const all_features = blk: {
12431243 .rclass,
12441244 }),
12451245 };
1246 result[@enumToInt(Feature.v7s)] = .{
1246 result[@intFromEnum(Feature.v7s)] = .{
12471247 .llvm_name = "armv7s",
12481248 .description = "ARMv7a architecture",
12491249 .dependencies = featureSet(&[_]Feature{
12501250 .v7a,
12511251 }),
12521252 };
1253 result[@enumToInt(Feature.v7ve)] = .{
1253 result[@intFromEnum(Feature.v7ve)] = .{
12541254 .llvm_name = "armv7ve",
12551255 .description = "ARMv7ve architecture",
12561256 .dependencies = featureSet(&[_]Feature{
......@@ -1265,7 +1265,7 @@ pub const all_features = blk: {
12651265 .virtualization,
12661266 }),
12671267 };
1268 result[@enumToInt(Feature.v8_1a)] = .{
1268 result[@intFromEnum(Feature.v8_1a)] = .{
12691269 .llvm_name = "armv8.1-a",
12701270 .description = "ARMv81a architecture",
12711271 .dependencies = featureSet(&[_]Feature{
......@@ -1281,7 +1281,7 @@ pub const all_features = blk: {
12811281 .virtualization,
12821282 }),
12831283 };
1284 result[@enumToInt(Feature.v8_1m_main)] = .{
1284 result[@intFromEnum(Feature.v8_1m_main)] = .{
12851285 .llvm_name = "armv8.1-m.main",
12861286 .description = "ARMv81mMainline architecture",
12871287 .dependencies = featureSet(&[_]Feature{
......@@ -1297,7 +1297,7 @@ pub const all_features = blk: {
12971297 .thumb_mode,
12981298 }),
12991299 };
1300 result[@enumToInt(Feature.v8_2a)] = .{
1300 result[@intFromEnum(Feature.v8_2a)] = .{
13011301 .llvm_name = "armv8.2-a",
13021302 .description = "ARMv82a architecture",
13031303 .dependencies = featureSet(&[_]Feature{
......@@ -1314,7 +1314,7 @@ pub const all_features = blk: {
13141314 .virtualization,
13151315 }),
13161316 };
1317 result[@enumToInt(Feature.v8_3a)] = .{
1317 result[@intFromEnum(Feature.v8_3a)] = .{
13181318 .llvm_name = "armv8.3-a",
13191319 .description = "ARMv83a architecture",
13201320 .dependencies = featureSet(&[_]Feature{
......@@ -1331,7 +1331,7 @@ pub const all_features = blk: {
13311331 .virtualization,
13321332 }),
13331333 };
1334 result[@enumToInt(Feature.v8_4a)] = .{
1334 result[@intFromEnum(Feature.v8_4a)] = .{
13351335 .llvm_name = "armv8.4-a",
13361336 .description = "ARMv84a architecture",
13371337 .dependencies = featureSet(&[_]Feature{
......@@ -1348,7 +1348,7 @@ pub const all_features = blk: {
13481348 .virtualization,
13491349 }),
13501350 };
1351 result[@enumToInt(Feature.v8_5a)] = .{
1351 result[@intFromEnum(Feature.v8_5a)] = .{
13521352 .llvm_name = "armv8.5-a",
13531353 .description = "ARMv85a architecture",
13541354 .dependencies = featureSet(&[_]Feature{
......@@ -1365,7 +1365,7 @@ pub const all_features = blk: {
13651365 .virtualization,
13661366 }),
13671367 };
1368 result[@enumToInt(Feature.v8_6a)] = .{
1368 result[@intFromEnum(Feature.v8_6a)] = .{
13691369 .llvm_name = "armv8.6-a",
13701370 .description = "ARMv86a architecture",
13711371 .dependencies = featureSet(&[_]Feature{
......@@ -1382,7 +1382,7 @@ pub const all_features = blk: {
13821382 .virtualization,
13831383 }),
13841384 };
1385 result[@enumToInt(Feature.v8_7a)] = .{
1385 result[@intFromEnum(Feature.v8_7a)] = .{
13861386 .llvm_name = "armv8.7-a",
13871387 .description = "ARMv87a architecture",
13881388 .dependencies = featureSet(&[_]Feature{
......@@ -1399,7 +1399,7 @@ pub const all_features = blk: {
13991399 .virtualization,
14001400 }),
14011401 };
1402 result[@enumToInt(Feature.v8_8a)] = .{
1402 result[@intFromEnum(Feature.v8_8a)] = .{
14031403 .llvm_name = "armv8.8-a",
14041404 .description = "ARMv88a architecture",
14051405 .dependencies = featureSet(&[_]Feature{
......@@ -1416,7 +1416,7 @@ pub const all_features = blk: {
14161416 .virtualization,
14171417 }),
14181418 };
1419 result[@enumToInt(Feature.v8_9a)] = .{
1419 result[@intFromEnum(Feature.v8_9a)] = .{
14201420 .llvm_name = "armv8.9-a",
14211421 .description = "ARMv89a architecture",
14221422 .dependencies = featureSet(&[_]Feature{
......@@ -1433,7 +1433,7 @@ pub const all_features = blk: {
14331433 .virtualization,
14341434 }),
14351435 };
1436 result[@enumToInt(Feature.v8a)] = .{
1436 result[@intFromEnum(Feature.v8a)] = .{
14371437 .llvm_name = "armv8-a",
14381438 .description = "ARMv8a architecture",
14391439 .dependencies = featureSet(&[_]Feature{
......@@ -1449,7 +1449,7 @@ pub const all_features = blk: {
14491449 .virtualization,
14501450 }),
14511451 };
1452 result[@enumToInt(Feature.v8m)] = .{
1452 result[@intFromEnum(Feature.v8m)] = .{
14531453 .llvm_name = "armv8-m.base",
14541454 .description = "ARMv8mBaseline architecture",
14551455 .dependencies = featureSet(&[_]Feature{
......@@ -1465,7 +1465,7 @@ pub const all_features = blk: {
14651465 .thumb_mode,
14661466 }),
14671467 };
1468 result[@enumToInt(Feature.v8m_main)] = .{
1468 result[@intFromEnum(Feature.v8m_main)] = .{
14691469 .llvm_name = "armv8-m.main",
14701470 .description = "ARMv8mMainline architecture",
14711471 .dependencies = featureSet(&[_]Feature{
......@@ -1479,7 +1479,7 @@ pub const all_features = blk: {
14791479 .thumb_mode,
14801480 }),
14811481 };
1482 result[@enumToInt(Feature.v8r)] = .{
1482 result[@intFromEnum(Feature.v8r)] = .{
14831483 .llvm_name = "armv8-r",
14841484 .description = "ARMv8r architecture",
14851485 .dependencies = featureSet(&[_]Feature{
......@@ -1495,7 +1495,7 @@ pub const all_features = blk: {
14951495 .virtualization,
14961496 }),
14971497 };
1498 result[@enumToInt(Feature.v9_1a)] = .{
1498 result[@intFromEnum(Feature.v9_1a)] = .{
14991499 .llvm_name = "armv9.1-a",
15001500 .description = "ARMv91a architecture",
15011501 .dependencies = featureSet(&[_]Feature{
......@@ -1511,7 +1511,7 @@ pub const all_features = blk: {
15111511 .virtualization,
15121512 }),
15131513 };
1514 result[@enumToInt(Feature.v9_2a)] = .{
1514 result[@intFromEnum(Feature.v9_2a)] = .{
15151515 .llvm_name = "armv9.2-a",
15161516 .description = "ARMv92a architecture",
15171517 .dependencies = featureSet(&[_]Feature{
......@@ -1527,7 +1527,7 @@ pub const all_features = blk: {
15271527 .virtualization,
15281528 }),
15291529 };
1530 result[@enumToInt(Feature.v9_3a)] = .{
1530 result[@intFromEnum(Feature.v9_3a)] = .{
15311531 .llvm_name = "armv9.3-a",
15321532 .description = "ARMv93a architecture",
15331533 .dependencies = featureSet(&[_]Feature{
......@@ -1544,7 +1544,7 @@ pub const all_features = blk: {
15441544 .virtualization,
15451545 }),
15461546 };
1547 result[@enumToInt(Feature.v9_4a)] = .{
1547 result[@intFromEnum(Feature.v9_4a)] = .{
15481548 .llvm_name = "armv9.4-a",
15491549 .description = "ARMv94a architecture",
15501550 .dependencies = featureSet(&[_]Feature{
......@@ -1560,7 +1560,7 @@ pub const all_features = blk: {
15601560 .virtualization,
15611561 }),
15621562 };
1563 result[@enumToInt(Feature.v9a)] = .{
1563 result[@intFromEnum(Feature.v9a)] = .{
15641564 .llvm_name = "armv9-a",
15651565 .description = "ARMv9a architecture",
15661566 .dependencies = featureSet(&[_]Feature{
......@@ -1576,7 +1576,7 @@ pub const all_features = blk: {
15761576 .virtualization,
15771577 }),
15781578 };
1579 result[@enumToInt(Feature.vfp2)] = .{
1579 result[@intFromEnum(Feature.vfp2)] = .{
15801580 .llvm_name = "vfp2",
15811581 .description = "Enable VFP2 instructions",
15821582 .dependencies = featureSet(&[_]Feature{
......@@ -1584,14 +1584,14 @@ pub const all_features = blk: {
15841584 .vfp2sp,
15851585 }),
15861586 };
1587 result[@enumToInt(Feature.vfp2sp)] = .{
1587 result[@intFromEnum(Feature.vfp2sp)] = .{
15881588 .llvm_name = "vfp2sp",
15891589 .description = "Enable VFP2 instructions with no double precision",
15901590 .dependencies = featureSet(&[_]Feature{
15911591 .fpregs,
15921592 }),
15931593 };
1594 result[@enumToInt(Feature.vfp3)] = .{
1594 result[@intFromEnum(Feature.vfp3)] = .{
15951595 .llvm_name = "vfp3",
15961596 .description = "Enable VFP3 instructions",
15971597 .dependencies = featureSet(&[_]Feature{
......@@ -1599,7 +1599,7 @@ pub const all_features = blk: {
15991599 .vfp3sp,
16001600 }),
16011601 };
1602 result[@enumToInt(Feature.vfp3d16)] = .{
1602 result[@intFromEnum(Feature.vfp3d16)] = .{
16031603 .llvm_name = "vfp3d16",
16041604 .description = "Enable VFP3 instructions with only 16 d-registers",
16051605 .dependencies = featureSet(&[_]Feature{
......@@ -1607,14 +1607,14 @@ pub const all_features = blk: {
16071607 .vfp3d16sp,
16081608 }),
16091609 };
1610 result[@enumToInt(Feature.vfp3d16sp)] = .{
1610 result[@intFromEnum(Feature.vfp3d16sp)] = .{
16111611 .llvm_name = "vfp3d16sp",
16121612 .description = "Enable VFP3 instructions with only 16 d-registers and no double precision",
16131613 .dependencies = featureSet(&[_]Feature{
16141614 .vfp2sp,
16151615 }),
16161616 };
1617 result[@enumToInt(Feature.vfp3sp)] = .{
1617 result[@intFromEnum(Feature.vfp3sp)] = .{
16181618 .llvm_name = "vfp3sp",
16191619 .description = "Enable VFP3 instructions with no double precision",
16201620 .dependencies = featureSet(&[_]Feature{
......@@ -1622,7 +1622,7 @@ pub const all_features = blk: {
16221622 .vfp3d16sp,
16231623 }),
16241624 };
1625 result[@enumToInt(Feature.vfp4)] = .{
1625 result[@intFromEnum(Feature.vfp4)] = .{
16261626 .llvm_name = "vfp4",
16271627 .description = "Enable VFP4 instructions",
16281628 .dependencies = featureSet(&[_]Feature{
......@@ -1631,7 +1631,7 @@ pub const all_features = blk: {
16311631 .vfp4sp,
16321632 }),
16331633 };
1634 result[@enumToInt(Feature.vfp4d16)] = .{
1634 result[@intFromEnum(Feature.vfp4d16)] = .{
16351635 .llvm_name = "vfp4d16",
16361636 .description = "Enable VFP4 instructions with only 16 d-registers",
16371637 .dependencies = featureSet(&[_]Feature{
......@@ -1639,7 +1639,7 @@ pub const all_features = blk: {
16391639 .vfp4d16sp,
16401640 }),
16411641 };
1642 result[@enumToInt(Feature.vfp4d16sp)] = .{
1642 result[@intFromEnum(Feature.vfp4d16sp)] = .{
16431643 .llvm_name = "vfp4d16sp",
16441644 .description = "Enable VFP4 instructions with only 16 d-registers and no double precision",
16451645 .dependencies = featureSet(&[_]Feature{
......@@ -1647,7 +1647,7 @@ pub const all_features = blk: {
16471647 .vfp3d16sp,
16481648 }),
16491649 };
1650 result[@enumToInt(Feature.vfp4sp)] = .{
1650 result[@intFromEnum(Feature.vfp4sp)] = .{
16511651 .llvm_name = "vfp4sp",
16521652 .description = "Enable VFP4 instructions with no double precision",
16531653 .dependencies = featureSet(&[_]Feature{
......@@ -1655,7 +1655,7 @@ pub const all_features = blk: {
16551655 .vfp4d16sp,
16561656 }),
16571657 };
1658 result[@enumToInt(Feature.virtualization)] = .{
1658 result[@intFromEnum(Feature.virtualization)] = .{
16591659 .llvm_name = "virtualization",
16601660 .description = "Supports Virtualization extension",
16611661 .dependencies = featureSet(&[_]Feature{
......@@ -1663,34 +1663,34 @@ pub const all_features = blk: {
16631663 .hwdiv_arm,
16641664 }),
16651665 };
1666 result[@enumToInt(Feature.vldn_align)] = .{
1666 result[@intFromEnum(Feature.vldn_align)] = .{
16671667 .llvm_name = "vldn-align",
16681668 .description = "Check for VLDn unaligned access",
16691669 .dependencies = featureSet(&[_]Feature{}),
16701670 };
1671 result[@enumToInt(Feature.vmlx_forwarding)] = .{
1671 result[@intFromEnum(Feature.vmlx_forwarding)] = .{
16721672 .llvm_name = "vmlx-forwarding",
16731673 .description = "Has multiplier accumulator forwarding",
16741674 .dependencies = featureSet(&[_]Feature{}),
16751675 };
1676 result[@enumToInt(Feature.vmlx_hazards)] = .{
1676 result[@intFromEnum(Feature.vmlx_hazards)] = .{
16771677 .llvm_name = "vmlx-hazards",
16781678 .description = "Has VMLx hazards",
16791679 .dependencies = featureSet(&[_]Feature{}),
16801680 };
1681 result[@enumToInt(Feature.wide_stride_vfp)] = .{
1681 result[@intFromEnum(Feature.wide_stride_vfp)] = .{
16821682 .llvm_name = "wide-stride-vfp",
16831683 .description = "Use a wide stride when allocating VFP registers",
16841684 .dependencies = featureSet(&[_]Feature{}),
16851685 };
1686 result[@enumToInt(Feature.xscale)] = .{
1686 result[@intFromEnum(Feature.xscale)] = .{
16871687 .llvm_name = "xscale",
16881688 .description = "ARMv5te architecture",
16891689 .dependencies = featureSet(&[_]Feature{
16901690 .v5te,
16911691 }),
16921692 };
1693 result[@enumToInt(Feature.zcz)] = .{
1693 result[@intFromEnum(Feature.zcz)] = .{
16941694 .llvm_name = "zcz",
16951695 .description = "Has zero-cycle zeroing instructions",
16961696 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/avr.zig+36-36
......@@ -52,17 +52,17 @@ pub const all_features = blk: {
5252 const len = @typeInfo(Feature).Enum.fields.len;
5353 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
5454 var result: [len]CpuFeature = undefined;
55 result[@enumToInt(Feature.addsubiw)] = .{
55 result[@intFromEnum(Feature.addsubiw)] = .{
5656 .llvm_name = "addsubiw",
5757 .description = "Enable 16-bit register-immediate addition and subtraction instructions",
5858 .dependencies = featureSet(&[_]Feature{}),
5959 };
60 result[@enumToInt(Feature.avr0)] = .{
60 result[@intFromEnum(Feature.avr0)] = .{
6161 .llvm_name = "avr0",
6262 .description = "The device is a part of the avr0 family",
6363 .dependencies = featureSet(&[_]Feature{}),
6464 };
65 result[@enumToInt(Feature.avr1)] = .{
65 result[@intFromEnum(Feature.avr1)] = .{
6666 .llvm_name = "avr1",
6767 .description = "The device is a part of the avr1 family",
6868 .dependencies = featureSet(&[_]Feature{
......@@ -72,7 +72,7 @@ pub const all_features = blk: {
7272 .progmem,
7373 }),
7474 };
75 result[@enumToInt(Feature.avr2)] = .{
75 result[@intFromEnum(Feature.avr2)] = .{
7676 .llvm_name = "avr2",
7777 .description = "The device is a part of the avr2 family",
7878 .dependencies = featureSet(&[_]Feature{
......@@ -82,7 +82,7 @@ pub const all_features = blk: {
8282 .sram,
8383 }),
8484 };
85 result[@enumToInt(Feature.avr25)] = .{
85 result[@intFromEnum(Feature.avr25)] = .{
8686 .llvm_name = "avr25",
8787 .description = "The device is a part of the avr25 family",
8888 .dependencies = featureSet(&[_]Feature{
......@@ -93,7 +93,7 @@ pub const all_features = blk: {
9393 .spm,
9494 }),
9595 };
96 result[@enumToInt(Feature.avr3)] = .{
96 result[@intFromEnum(Feature.avr3)] = .{
9797 .llvm_name = "avr3",
9898 .description = "The device is a part of the avr3 family",
9999 .dependencies = featureSet(&[_]Feature{
......@@ -101,7 +101,7 @@ pub const all_features = blk: {
101101 .jmpcall,
102102 }),
103103 };
104 result[@enumToInt(Feature.avr31)] = .{
104 result[@intFromEnum(Feature.avr31)] = .{
105105 .llvm_name = "avr31",
106106 .description = "The device is a part of the avr31 family",
107107 .dependencies = featureSet(&[_]Feature{
......@@ -109,7 +109,7 @@ pub const all_features = blk: {
109109 .elpm,
110110 }),
111111 };
112 result[@enumToInt(Feature.avr35)] = .{
112 result[@intFromEnum(Feature.avr35)] = .{
113113 .llvm_name = "avr35",
114114 .description = "The device is a part of the avr35 family",
115115 .dependencies = featureSet(&[_]Feature{
......@@ -120,7 +120,7 @@ pub const all_features = blk: {
120120 .spm,
121121 }),
122122 };
123 result[@enumToInt(Feature.avr4)] = .{
123 result[@intFromEnum(Feature.avr4)] = .{
124124 .llvm_name = "avr4",
125125 .description = "The device is a part of the avr4 family",
126126 .dependencies = featureSet(&[_]Feature{
......@@ -132,7 +132,7 @@ pub const all_features = blk: {
132132 .spm,
133133 }),
134134 };
135 result[@enumToInt(Feature.avr5)] = .{
135 result[@intFromEnum(Feature.avr5)] = .{
136136 .llvm_name = "avr5",
137137 .description = "The device is a part of the avr5 family",
138138 .dependencies = featureSet(&[_]Feature{
......@@ -144,7 +144,7 @@ pub const all_features = blk: {
144144 .spm,
145145 }),
146146 };
147 result[@enumToInt(Feature.avr51)] = .{
147 result[@intFromEnum(Feature.avr51)] = .{
148148 .llvm_name = "avr51",
149149 .description = "The device is a part of the avr51 family",
150150 .dependencies = featureSet(&[_]Feature{
......@@ -153,7 +153,7 @@ pub const all_features = blk: {
153153 .elpmx,
154154 }),
155155 };
156 result[@enumToInt(Feature.avr6)] = .{
156 result[@intFromEnum(Feature.avr6)] = .{
157157 .llvm_name = "avr6",
158158 .description = "The device is a part of the avr6 family",
159159 .dependencies = featureSet(&[_]Feature{
......@@ -161,7 +161,7 @@ pub const all_features = blk: {
161161 .eijmpcall,
162162 }),
163163 };
164 result[@enumToInt(Feature.avrtiny)] = .{
164 result[@intFromEnum(Feature.avrtiny)] = .{
165165 .llvm_name = "avrtiny",
166166 .description = "The device is a part of the avrtiny family",
167167 .dependencies = featureSet(&[_]Feature{
......@@ -172,82 +172,82 @@ pub const all_features = blk: {
172172 .tinyencoding,
173173 }),
174174 };
175 result[@enumToInt(Feature.@"break")] = .{
175 result[@intFromEnum(Feature.@"break")] = .{
176176 .llvm_name = "break",
177177 .description = "The device supports the `BREAK` debugging instruction",
178178 .dependencies = featureSet(&[_]Feature{}),
179179 };
180 result[@enumToInt(Feature.des)] = .{
180 result[@intFromEnum(Feature.des)] = .{
181181 .llvm_name = "des",
182182 .description = "The device supports the `DES k` encryption instruction",
183183 .dependencies = featureSet(&[_]Feature{}),
184184 };
185 result[@enumToInt(Feature.eijmpcall)] = .{
185 result[@intFromEnum(Feature.eijmpcall)] = .{
186186 .llvm_name = "eijmpcall",
187187 .description = "The device supports the `EIJMP`/`EICALL` instructions",
188188 .dependencies = featureSet(&[_]Feature{}),
189189 };
190 result[@enumToInt(Feature.elpm)] = .{
190 result[@intFromEnum(Feature.elpm)] = .{
191191 .llvm_name = "elpm",
192192 .description = "The device supports the ELPM instruction",
193193 .dependencies = featureSet(&[_]Feature{}),
194194 };
195 result[@enumToInt(Feature.elpmx)] = .{
195 result[@intFromEnum(Feature.elpmx)] = .{
196196 .llvm_name = "elpmx",
197197 .description = "The device supports the `ELPM Rd, Z[+]` instructions",
198198 .dependencies = featureSet(&[_]Feature{}),
199199 };
200 result[@enumToInt(Feature.ijmpcall)] = .{
200 result[@intFromEnum(Feature.ijmpcall)] = .{
201201 .llvm_name = "ijmpcall",
202202 .description = "The device supports `IJMP`/`ICALL`instructions",
203203 .dependencies = featureSet(&[_]Feature{}),
204204 };
205 result[@enumToInt(Feature.jmpcall)] = .{
205 result[@intFromEnum(Feature.jmpcall)] = .{
206206 .llvm_name = "jmpcall",
207207 .description = "The device supports the `JMP` and `CALL` instructions",
208208 .dependencies = featureSet(&[_]Feature{}),
209209 };
210 result[@enumToInt(Feature.lpm)] = .{
210 result[@intFromEnum(Feature.lpm)] = .{
211211 .llvm_name = "lpm",
212212 .description = "The device supports the `LPM` instruction",
213213 .dependencies = featureSet(&[_]Feature{}),
214214 };
215 result[@enumToInt(Feature.lpmx)] = .{
215 result[@intFromEnum(Feature.lpmx)] = .{
216216 .llvm_name = "lpmx",
217217 .description = "The device supports the `LPM Rd, Z[+]` instruction",
218218 .dependencies = featureSet(&[_]Feature{}),
219219 };
220 result[@enumToInt(Feature.memmappedregs)] = .{
220 result[@intFromEnum(Feature.memmappedregs)] = .{
221221 .llvm_name = "memmappedregs",
222222 .description = "The device has CPU registers mapped in data address space",
223223 .dependencies = featureSet(&[_]Feature{}),
224224 };
225 result[@enumToInt(Feature.movw)] = .{
225 result[@intFromEnum(Feature.movw)] = .{
226226 .llvm_name = "movw",
227227 .description = "The device supports the 16-bit MOVW instruction",
228228 .dependencies = featureSet(&[_]Feature{}),
229229 };
230 result[@enumToInt(Feature.mul)] = .{
230 result[@intFromEnum(Feature.mul)] = .{
231231 .llvm_name = "mul",
232232 .description = "The device supports the multiplication instructions",
233233 .dependencies = featureSet(&[_]Feature{}),
234234 };
235 result[@enumToInt(Feature.progmem)] = .{
235 result[@intFromEnum(Feature.progmem)] = .{
236236 .llvm_name = "progmem",
237237 .description = "The device has a separate flash namespace",
238238 .dependencies = featureSet(&[_]Feature{}),
239239 };
240 result[@enumToInt(Feature.rmw)] = .{
240 result[@intFromEnum(Feature.rmw)] = .{
241241 .llvm_name = "rmw",
242242 .description = "The device supports the read-write-modify instructions: XCH, LAS, LAC, LAT",
243243 .dependencies = featureSet(&[_]Feature{}),
244244 };
245 result[@enumToInt(Feature.smallstack)] = .{
245 result[@intFromEnum(Feature.smallstack)] = .{
246246 .llvm_name = "smallstack",
247247 .description = "The device has an 8-bit stack pointer",
248248 .dependencies = featureSet(&[_]Feature{}),
249249 };
250 result[@enumToInt(Feature.special)] = .{
250 result[@intFromEnum(Feature.special)] = .{
251251 .llvm_name = "special",
252252 .description = "Enable use of the entire instruction set - used for debugging",
253253 .dependencies = featureSet(&[_]Feature{
......@@ -270,27 +270,27 @@ pub const all_features = blk: {
270270 .sram,
271271 }),
272272 };
273 result[@enumToInt(Feature.spm)] = .{
273 result[@intFromEnum(Feature.spm)] = .{
274274 .llvm_name = "spm",
275275 .description = "The device supports the `SPM` instruction",
276276 .dependencies = featureSet(&[_]Feature{}),
277277 };
278 result[@enumToInt(Feature.spmx)] = .{
278 result[@intFromEnum(Feature.spmx)] = .{
279279 .llvm_name = "spmx",
280280 .description = "The device supports the `SPM Z+` instruction",
281281 .dependencies = featureSet(&[_]Feature{}),
282282 };
283 result[@enumToInt(Feature.sram)] = .{
283 result[@intFromEnum(Feature.sram)] = .{
284284 .llvm_name = "sram",
285285 .description = "The device has random access memory",
286286 .dependencies = featureSet(&[_]Feature{}),
287287 };
288 result[@enumToInt(Feature.tinyencoding)] = .{
288 result[@intFromEnum(Feature.tinyencoding)] = .{
289289 .llvm_name = "tinyencoding",
290290 .description = "The device has Tiny core specific instruction encodings",
291291 .dependencies = featureSet(&[_]Feature{}),
292292 };
293 result[@enumToInt(Feature.xmega)] = .{
293 result[@intFromEnum(Feature.xmega)] = .{
294294 .llvm_name = "xmega",
295295 .description = "The device is a part of the xmega family",
296296 .dependencies = featureSet(&[_]Feature{
......@@ -313,7 +313,7 @@ pub const all_features = blk: {
313313 .sram,
314314 }),
315315 };
316 result[@enumToInt(Feature.xmega3)] = .{
316 result[@intFromEnum(Feature.xmega3)] = .{
317317 .llvm_name = "xmega3",
318318 .description = "The device is a part of the xmega3 family",
319319 .dependencies = featureSet(&[_]Feature{
......@@ -330,7 +330,7 @@ pub const all_features = blk: {
330330 .sram,
331331 }),
332332 };
333 result[@enumToInt(Feature.xmegau)] = .{
333 result[@intFromEnum(Feature.xmegau)] = .{
334334 .llvm_name = "xmegau",
335335 .description = "The device is a part of the xmegau family",
336336 .dependencies = featureSet(&[_]Feature{
lib/std/target/bpf.zig+3-3
......@@ -19,17 +19,17 @@ pub const all_features = blk: {
1919 const len = @typeInfo(Feature).Enum.fields.len;
2020 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
2121 var result: [len]CpuFeature = undefined;
22 result[@enumToInt(Feature.alu32)] = .{
22 result[@intFromEnum(Feature.alu32)] = .{
2323 .llvm_name = "alu32",
2424 .description = "Enable ALU32 instructions",
2525 .dependencies = featureSet(&[_]Feature{}),
2626 };
27 result[@enumToInt(Feature.dummy)] = .{
27 result[@intFromEnum(Feature.dummy)] = .{
2828 .llvm_name = "dummy",
2929 .description = "unused feature",
3030 .dependencies = featureSet(&[_]Feature{}),
3131 };
32 result[@enumToInt(Feature.dwarfris)] = .{
32 result[@intFromEnum(Feature.dwarfris)] = .{
3333 .llvm_name = "dwarfris",
3434 .description = "Disable MCAsmInfo DwarfUsesRelocationsAcrossSections",
3535 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/csky.zig+63-63
......@@ -79,26 +79,26 @@ pub const all_features = blk: {
7979 const len = @typeInfo(Feature).Enum.fields.len;
8080 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
8181 var result: [len]CpuFeature = undefined;
82 result[@enumToInt(Feature.@"10e60")] = .{
82 result[@intFromEnum(Feature.@"10e60")] = .{
8383 .llvm_name = "10e60",
8484 .description = "Support CSKY 10e60 instructions",
8585 .dependencies = featureSet(&[_]Feature{
8686 .@"7e10",
8787 }),
8888 };
89 result[@enumToInt(Feature.@"2e3")] = .{
89 result[@intFromEnum(Feature.@"2e3")] = .{
9090 .llvm_name = "2e3",
9191 .description = "Support CSKY 2e3 instructions",
9292 .dependencies = featureSet(&[_]Feature{
9393 .e2,
9494 }),
9595 };
96 result[@enumToInt(Feature.@"3e3r1")] = .{
96 result[@intFromEnum(Feature.@"3e3r1")] = .{
9797 .llvm_name = "3e3r1",
9898 .description = "Support CSKY 3e3r1 instructions",
9999 .dependencies = featureSet(&[_]Feature{}),
100100 };
101 result[@enumToInt(Feature.@"3e3r2")] = .{
101 result[@intFromEnum(Feature.@"3e3r2")] = .{
102102 .llvm_name = "3e3r2",
103103 .description = "Support CSKY 3e3r2 instructions",
104104 .dependencies = featureSet(&[_]Feature{
......@@ -106,311 +106,311 @@ pub const all_features = blk: {
106106 .doloop,
107107 }),
108108 };
109 result[@enumToInt(Feature.@"3e3r3")] = .{
109 result[@intFromEnum(Feature.@"3e3r3")] = .{
110110 .llvm_name = "3e3r3",
111111 .description = "Support CSKY 3e3r3 instructions",
112112 .dependencies = featureSet(&[_]Feature{
113113 .doloop,
114114 }),
115115 };
116 result[@enumToInt(Feature.@"3e7")] = .{
116 result[@intFromEnum(Feature.@"3e7")] = .{
117117 .llvm_name = "3e7",
118118 .description = "Support CSKY 3e7 instructions",
119119 .dependencies = featureSet(&[_]Feature{
120120 .@"2e3",
121121 }),
122122 };
123 result[@enumToInt(Feature.@"7e10")] = .{
123 result[@intFromEnum(Feature.@"7e10")] = .{
124124 .llvm_name = "7e10",
125125 .description = "Support CSKY 7e10 instructions",
126126 .dependencies = featureSet(&[_]Feature{
127127 .@"3e7",
128128 }),
129129 };
130 result[@enumToInt(Feature.btst16)] = .{
130 result[@intFromEnum(Feature.btst16)] = .{
131131 .llvm_name = "btst16",
132132 .description = "Use the 16-bit btsti instruction",
133133 .dependencies = featureSet(&[_]Feature{}),
134134 };
135 result[@enumToInt(Feature.cache)] = .{
135 result[@intFromEnum(Feature.cache)] = .{
136136 .llvm_name = "cache",
137137 .description = "Enable cache",
138138 .dependencies = featureSet(&[_]Feature{}),
139139 };
140 result[@enumToInt(Feature.ccrt)] = .{
140 result[@intFromEnum(Feature.ccrt)] = .{
141141 .llvm_name = "ccrt",
142142 .description = "Use CSKY compiler runtime",
143143 .dependencies = featureSet(&[_]Feature{}),
144144 };
145 result[@enumToInt(Feature.ck801)] = .{
145 result[@intFromEnum(Feature.ck801)] = .{
146146 .llvm_name = "ck801",
147147 .description = "CSKY ck801 processors",
148148 .dependencies = featureSet(&[_]Feature{}),
149149 };
150 result[@enumToInt(Feature.ck802)] = .{
150 result[@intFromEnum(Feature.ck802)] = .{
151151 .llvm_name = "ck802",
152152 .description = "CSKY ck802 processors",
153153 .dependencies = featureSet(&[_]Feature{}),
154154 };
155 result[@enumToInt(Feature.ck803)] = .{
155 result[@intFromEnum(Feature.ck803)] = .{
156156 .llvm_name = "ck803",
157157 .description = "CSKY ck803 processors",
158158 .dependencies = featureSet(&[_]Feature{}),
159159 };
160 result[@enumToInt(Feature.ck803s)] = .{
160 result[@intFromEnum(Feature.ck803s)] = .{
161161 .llvm_name = "ck803s",
162162 .description = "CSKY ck803s processors",
163163 .dependencies = featureSet(&[_]Feature{}),
164164 };
165 result[@enumToInt(Feature.ck804)] = .{
165 result[@intFromEnum(Feature.ck804)] = .{
166166 .llvm_name = "ck804",
167167 .description = "CSKY ck804 processors",
168168 .dependencies = featureSet(&[_]Feature{}),
169169 };
170 result[@enumToInt(Feature.ck805)] = .{
170 result[@intFromEnum(Feature.ck805)] = .{
171171 .llvm_name = "ck805",
172172 .description = "CSKY ck805 processors",
173173 .dependencies = featureSet(&[_]Feature{}),
174174 };
175 result[@enumToInt(Feature.ck807)] = .{
175 result[@intFromEnum(Feature.ck807)] = .{
176176 .llvm_name = "ck807",
177177 .description = "CSKY ck807 processors",
178178 .dependencies = featureSet(&[_]Feature{}),
179179 };
180 result[@enumToInt(Feature.ck810)] = .{
180 result[@intFromEnum(Feature.ck810)] = .{
181181 .llvm_name = "ck810",
182182 .description = "CSKY ck810 processors",
183183 .dependencies = featureSet(&[_]Feature{}),
184184 };
185 result[@enumToInt(Feature.ck810v)] = .{
185 result[@intFromEnum(Feature.ck810v)] = .{
186186 .llvm_name = "ck810v",
187187 .description = "CSKY ck810v processors",
188188 .dependencies = featureSet(&[_]Feature{}),
189189 };
190 result[@enumToInt(Feature.ck860)] = .{
190 result[@intFromEnum(Feature.ck860)] = .{
191191 .llvm_name = "ck860",
192192 .description = "CSKY ck860 processors",
193193 .dependencies = featureSet(&[_]Feature{}),
194194 };
195 result[@enumToInt(Feature.ck860v)] = .{
195 result[@intFromEnum(Feature.ck860v)] = .{
196196 .llvm_name = "ck860v",
197197 .description = "CSKY ck860v processors",
198198 .dependencies = featureSet(&[_]Feature{}),
199199 };
200 result[@enumToInt(Feature.constpool)] = .{
200 result[@intFromEnum(Feature.constpool)] = .{
201201 .llvm_name = "constpool",
202202 .description = "Dump the constant pool by compiler",
203203 .dependencies = featureSet(&[_]Feature{}),
204204 };
205 result[@enumToInt(Feature.doloop)] = .{
205 result[@intFromEnum(Feature.doloop)] = .{
206206 .llvm_name = "doloop",
207207 .description = "Enable doloop instructions",
208208 .dependencies = featureSet(&[_]Feature{}),
209209 };
210 result[@enumToInt(Feature.dsp1e2)] = .{
210 result[@intFromEnum(Feature.dsp1e2)] = .{
211211 .llvm_name = "dsp1e2",
212212 .description = "Support CSKY dsp1e2 instructions",
213213 .dependencies = featureSet(&[_]Feature{}),
214214 };
215 result[@enumToInt(Feature.dsp_silan)] = .{
215 result[@intFromEnum(Feature.dsp_silan)] = .{
216216 .llvm_name = "dsp_silan",
217217 .description = "Enable DSP Silan instructions",
218218 .dependencies = featureSet(&[_]Feature{}),
219219 };
220 result[@enumToInt(Feature.dspe60)] = .{
220 result[@intFromEnum(Feature.dspe60)] = .{
221221 .llvm_name = "dspe60",
222222 .description = "Support CSKY dspe60 instructions",
223223 .dependencies = featureSet(&[_]Feature{}),
224224 };
225 result[@enumToInt(Feature.dspv2)] = .{
225 result[@intFromEnum(Feature.dspv2)] = .{
226226 .llvm_name = "dspv2",
227227 .description = "Enable DSP V2.0 instructions",
228228 .dependencies = featureSet(&[_]Feature{}),
229229 };
230 result[@enumToInt(Feature.e1)] = .{
230 result[@intFromEnum(Feature.e1)] = .{
231231 .llvm_name = "e1",
232232 .description = "Support CSKY e1 instructions",
233233 .dependencies = featureSet(&[_]Feature{
234234 .elrw,
235235 }),
236236 };
237 result[@enumToInt(Feature.e2)] = .{
237 result[@intFromEnum(Feature.e2)] = .{
238238 .llvm_name = "e2",
239239 .description = "Support CSKY e2 instructions",
240240 .dependencies = featureSet(&[_]Feature{
241241 .e1,
242242 }),
243243 };
244 result[@enumToInt(Feature.edsp)] = .{
244 result[@intFromEnum(Feature.edsp)] = .{
245245 .llvm_name = "edsp",
246246 .description = "Enable DSP instructions",
247247 .dependencies = featureSet(&[_]Feature{}),
248248 };
249 result[@enumToInt(Feature.elrw)] = .{
249 result[@intFromEnum(Feature.elrw)] = .{
250250 .llvm_name = "elrw",
251251 .description = "Use the extend LRW instruction",
252252 .dependencies = featureSet(&[_]Feature{}),
253253 };
254 result[@enumToInt(Feature.fdivdu)] = .{
254 result[@intFromEnum(Feature.fdivdu)] = .{
255255 .llvm_name = "fdivdu",
256256 .description = "Enable float divide instructions",
257257 .dependencies = featureSet(&[_]Feature{}),
258258 };
259 result[@enumToInt(Feature.float1e2)] = .{
259 result[@intFromEnum(Feature.float1e2)] = .{
260260 .llvm_name = "float1e2",
261261 .description = "Support CSKY float1e2 instructions",
262262 .dependencies = featureSet(&[_]Feature{}),
263263 };
264 result[@enumToInt(Feature.float1e3)] = .{
264 result[@intFromEnum(Feature.float1e3)] = .{
265265 .llvm_name = "float1e3",
266266 .description = "Support CSKY float1e3 instructions",
267267 .dependencies = featureSet(&[_]Feature{}),
268268 };
269 result[@enumToInt(Feature.float3e4)] = .{
269 result[@intFromEnum(Feature.float3e4)] = .{
270270 .llvm_name = "float3e4",
271271 .description = "Support CSKY float3e4 instructions",
272272 .dependencies = featureSet(&[_]Feature{}),
273273 };
274 result[@enumToInt(Feature.float7e60)] = .{
274 result[@intFromEnum(Feature.float7e60)] = .{
275275 .llvm_name = "float7e60",
276276 .description = "Support CSKY float7e60 instructions",
277277 .dependencies = featureSet(&[_]Feature{}),
278278 };
279 result[@enumToInt(Feature.floate1)] = .{
279 result[@intFromEnum(Feature.floate1)] = .{
280280 .llvm_name = "floate1",
281281 .description = "Support CSKY floate1 instructions",
282282 .dependencies = featureSet(&[_]Feature{}),
283283 };
284 result[@enumToInt(Feature.fpuv2_df)] = .{
284 result[@intFromEnum(Feature.fpuv2_df)] = .{
285285 .llvm_name = "fpuv2_df",
286286 .description = "Enable FPUv2 double float instructions",
287287 .dependencies = featureSet(&[_]Feature{}),
288288 };
289 result[@enumToInt(Feature.fpuv2_sf)] = .{
289 result[@intFromEnum(Feature.fpuv2_sf)] = .{
290290 .llvm_name = "fpuv2_sf",
291291 .description = "Enable FPUv2 single float instructions",
292292 .dependencies = featureSet(&[_]Feature{}),
293293 };
294 result[@enumToInt(Feature.fpuv3_df)] = .{
294 result[@intFromEnum(Feature.fpuv3_df)] = .{
295295 .llvm_name = "fpuv3_df",
296296 .description = "Enable FPUv3 double float instructions",
297297 .dependencies = featureSet(&[_]Feature{}),
298298 };
299 result[@enumToInt(Feature.fpuv3_hf)] = .{
299 result[@intFromEnum(Feature.fpuv3_hf)] = .{
300300 .llvm_name = "fpuv3_hf",
301301 .description = "Enable FPUv3 harf precision operate instructions",
302302 .dependencies = featureSet(&[_]Feature{}),
303303 };
304 result[@enumToInt(Feature.fpuv3_hi)] = .{
304 result[@intFromEnum(Feature.fpuv3_hi)] = .{
305305 .llvm_name = "fpuv3_hi",
306306 .description = "Enable FPUv3 harf word converting instructions",
307307 .dependencies = featureSet(&[_]Feature{}),
308308 };
309 result[@enumToInt(Feature.fpuv3_sf)] = .{
309 result[@intFromEnum(Feature.fpuv3_sf)] = .{
310310 .llvm_name = "fpuv3_sf",
311311 .description = "Enable FPUv3 single float instructions",
312312 .dependencies = featureSet(&[_]Feature{}),
313313 };
314 result[@enumToInt(Feature.hard_float)] = .{
314 result[@intFromEnum(Feature.hard_float)] = .{
315315 .llvm_name = "hard-float",
316316 .description = "Use hard floating point features",
317317 .dependencies = featureSet(&[_]Feature{}),
318318 };
319 result[@enumToInt(Feature.hard_float_abi)] = .{
319 result[@intFromEnum(Feature.hard_float_abi)] = .{
320320 .llvm_name = "hard-float-abi",
321321 .description = "Use hard floating point ABI to pass args",
322322 .dependencies = featureSet(&[_]Feature{}),
323323 };
324 result[@enumToInt(Feature.hard_tp)] = .{
324 result[@intFromEnum(Feature.hard_tp)] = .{
325325 .llvm_name = "hard-tp",
326326 .description = "Enable TLS Pointer register",
327327 .dependencies = featureSet(&[_]Feature{}),
328328 };
329 result[@enumToInt(Feature.high_registers)] = .{
329 result[@intFromEnum(Feature.high_registers)] = .{
330330 .llvm_name = "high-registers",
331331 .description = "Enable r16-r31 registers",
332332 .dependencies = featureSet(&[_]Feature{}),
333333 };
334 result[@enumToInt(Feature.hwdiv)] = .{
334 result[@intFromEnum(Feature.hwdiv)] = .{
335335 .llvm_name = "hwdiv",
336336 .description = "Enable divide instructions",
337337 .dependencies = featureSet(&[_]Feature{}),
338338 };
339 result[@enumToInt(Feature.istack)] = .{
339 result[@intFromEnum(Feature.istack)] = .{
340340 .llvm_name = "istack",
341341 .description = "Enable interrupt attribute",
342342 .dependencies = featureSet(&[_]Feature{}),
343343 };
344 result[@enumToInt(Feature.java)] = .{
344 result[@intFromEnum(Feature.java)] = .{
345345 .llvm_name = "java",
346346 .description = "Enable java instructions",
347347 .dependencies = featureSet(&[_]Feature{}),
348348 };
349 result[@enumToInt(Feature.mp)] = .{
349 result[@intFromEnum(Feature.mp)] = .{
350350 .llvm_name = "mp",
351351 .description = "Support CSKY mp instructions",
352352 .dependencies = featureSet(&[_]Feature{
353353 .@"2e3",
354354 }),
355355 };
356 result[@enumToInt(Feature.mp1e2)] = .{
356 result[@intFromEnum(Feature.mp1e2)] = .{
357357 .llvm_name = "mp1e2",
358358 .description = "Support CSKY mp1e2 instructions",
359359 .dependencies = featureSet(&[_]Feature{
360360 .@"3e7",
361361 }),
362362 };
363 result[@enumToInt(Feature.multiple_stld)] = .{
363 result[@intFromEnum(Feature.multiple_stld)] = .{
364364 .llvm_name = "multiple_stld",
365365 .description = "Enable multiple load/store instructions",
366366 .dependencies = featureSet(&[_]Feature{}),
367367 };
368 result[@enumToInt(Feature.nvic)] = .{
368 result[@intFromEnum(Feature.nvic)] = .{
369369 .llvm_name = "nvic",
370370 .description = "Enable NVIC",
371371 .dependencies = featureSet(&[_]Feature{}),
372372 };
373 result[@enumToInt(Feature.pushpop)] = .{
373 result[@intFromEnum(Feature.pushpop)] = .{
374374 .llvm_name = "pushpop",
375375 .description = "Enable push/pop instructions",
376376 .dependencies = featureSet(&[_]Feature{}),
377377 };
378 result[@enumToInt(Feature.smart)] = .{
378 result[@intFromEnum(Feature.smart)] = .{
379379 .llvm_name = "smart",
380380 .description = "Let CPU work in Smart Mode",
381381 .dependencies = featureSet(&[_]Feature{}),
382382 };
383 result[@enumToInt(Feature.soft_tp)] = .{
383 result[@intFromEnum(Feature.soft_tp)] = .{
384384 .llvm_name = "soft-tp",
385385 .description = "Disable TLS Pointer register",
386386 .dependencies = featureSet(&[_]Feature{}),
387387 };
388 result[@enumToInt(Feature.stack_size)] = .{
388 result[@intFromEnum(Feature.stack_size)] = .{
389389 .llvm_name = "stack-size",
390390 .description = "Output stack size information",
391391 .dependencies = featureSet(&[_]Feature{}),
392392 };
393 result[@enumToInt(Feature.trust)] = .{
393 result[@intFromEnum(Feature.trust)] = .{
394394 .llvm_name = "trust",
395395 .description = "Enable trust instructions",
396396 .dependencies = featureSet(&[_]Feature{}),
397397 };
398 result[@enumToInt(Feature.vdsp2e3)] = .{
398 result[@intFromEnum(Feature.vdsp2e3)] = .{
399399 .llvm_name = "vdsp2e3",
400400 .description = "Support CSKY vdsp2e3 instructions",
401401 .dependencies = featureSet(&[_]Feature{}),
402402 };
403 result[@enumToInt(Feature.vdsp2e60f)] = .{
403 result[@intFromEnum(Feature.vdsp2e60f)] = .{
404404 .llvm_name = "vdsp2e60f",
405405 .description = "Support CSKY vdsp2e60f instructions",
406406 .dependencies = featureSet(&[_]Feature{}),
407407 };
408 result[@enumToInt(Feature.vdspv1)] = .{
408 result[@intFromEnum(Feature.vdspv1)] = .{
409409 .llvm_name = "vdspv1",
410410 .description = "Enable 128bit vdsp-v1 instructions",
411411 .dependencies = featureSet(&[_]Feature{}),
412412 };
413 result[@enumToInt(Feature.vdspv2)] = .{
413 result[@intFromEnum(Feature.vdspv2)] = .{
414414 .llvm_name = "vdspv2",
415415 .description = "Enable vdsp-v2 instructions",
416416 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/hexagon.zig+42-42
......@@ -58,77 +58,77 @@ pub const all_features = blk: {
5858 const len = @typeInfo(Feature).Enum.fields.len;
5959 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
6060 var result: [len]CpuFeature = undefined;
61 result[@enumToInt(Feature.audio)] = .{
61 result[@intFromEnum(Feature.audio)] = .{
6262 .llvm_name = "audio",
6363 .description = "Hexagon Audio extension instructions",
6464 .dependencies = featureSet(&[_]Feature{}),
6565 };
66 result[@enumToInt(Feature.cabac)] = .{
66 result[@intFromEnum(Feature.cabac)] = .{
6767 .llvm_name = "cabac",
6868 .description = "Emit the CABAC instruction",
6969 .dependencies = featureSet(&[_]Feature{}),
7070 };
71 result[@enumToInt(Feature.compound)] = .{
71 result[@intFromEnum(Feature.compound)] = .{
7272 .llvm_name = "compound",
7373 .description = "Use compound instructions",
7474 .dependencies = featureSet(&[_]Feature{}),
7575 };
76 result[@enumToInt(Feature.duplex)] = .{
76 result[@intFromEnum(Feature.duplex)] = .{
7777 .llvm_name = "duplex",
7878 .description = "Enable generation of duplex instruction",
7979 .dependencies = featureSet(&[_]Feature{}),
8080 };
81 result[@enumToInt(Feature.hvx)] = .{
81 result[@intFromEnum(Feature.hvx)] = .{
8282 .llvm_name = "hvx",
8383 .description = "Hexagon HVX instructions",
8484 .dependencies = featureSet(&[_]Feature{}),
8585 };
86 result[@enumToInt(Feature.hvx_ieee_fp)] = .{
86 result[@intFromEnum(Feature.hvx_ieee_fp)] = .{
8787 .llvm_name = "hvx-ieee-fp",
8888 .description = "Hexagon HVX IEEE floating point instructions",
8989 .dependencies = featureSet(&[_]Feature{}),
9090 };
91 result[@enumToInt(Feature.hvx_length128b)] = .{
91 result[@intFromEnum(Feature.hvx_length128b)] = .{
9292 .llvm_name = "hvx-length128b",
9393 .description = "Hexagon HVX 128B instructions",
9494 .dependencies = featureSet(&[_]Feature{
9595 .hvx,
9696 }),
9797 };
98 result[@enumToInt(Feature.hvx_length64b)] = .{
98 result[@intFromEnum(Feature.hvx_length64b)] = .{
9999 .llvm_name = "hvx-length64b",
100100 .description = "Hexagon HVX 64B instructions",
101101 .dependencies = featureSet(&[_]Feature{
102102 .hvx,
103103 }),
104104 };
105 result[@enumToInt(Feature.hvx_qfloat)] = .{
105 result[@intFromEnum(Feature.hvx_qfloat)] = .{
106106 .llvm_name = "hvx-qfloat",
107107 .description = "Hexagon HVX QFloating point instructions",
108108 .dependencies = featureSet(&[_]Feature{}),
109109 };
110 result[@enumToInt(Feature.hvxv60)] = .{
110 result[@intFromEnum(Feature.hvxv60)] = .{
111111 .llvm_name = "hvxv60",
112112 .description = "Hexagon HVX instructions",
113113 .dependencies = featureSet(&[_]Feature{
114114 .hvx,
115115 }),
116116 };
117 result[@enumToInt(Feature.hvxv62)] = .{
117 result[@intFromEnum(Feature.hvxv62)] = .{
118118 .llvm_name = "hvxv62",
119119 .description = "Hexagon HVX instructions",
120120 .dependencies = featureSet(&[_]Feature{
121121 .hvxv60,
122122 }),
123123 };
124 result[@enumToInt(Feature.hvxv65)] = .{
124 result[@intFromEnum(Feature.hvxv65)] = .{
125125 .llvm_name = "hvxv65",
126126 .description = "Hexagon HVX instructions",
127127 .dependencies = featureSet(&[_]Feature{
128128 .hvxv62,
129129 }),
130130 };
131 result[@enumToInt(Feature.hvxv66)] = .{
131 result[@intFromEnum(Feature.hvxv66)] = .{
132132 .llvm_name = "hvxv66",
133133 .description = "Hexagon HVX instructions",
134134 .dependencies = featureSet(&[_]Feature{
......@@ -136,161 +136,161 @@ pub const all_features = blk: {
136136 .zreg,
137137 }),
138138 };
139 result[@enumToInt(Feature.hvxv67)] = .{
139 result[@intFromEnum(Feature.hvxv67)] = .{
140140 .llvm_name = "hvxv67",
141141 .description = "Hexagon HVX instructions",
142142 .dependencies = featureSet(&[_]Feature{
143143 .hvxv66,
144144 }),
145145 };
146 result[@enumToInt(Feature.hvxv68)] = .{
146 result[@intFromEnum(Feature.hvxv68)] = .{
147147 .llvm_name = "hvxv68",
148148 .description = "Hexagon HVX instructions",
149149 .dependencies = featureSet(&[_]Feature{
150150 .hvxv67,
151151 }),
152152 };
153 result[@enumToInt(Feature.hvxv69)] = .{
153 result[@intFromEnum(Feature.hvxv69)] = .{
154154 .llvm_name = "hvxv69",
155155 .description = "Hexagon HVX instructions",
156156 .dependencies = featureSet(&[_]Feature{
157157 .hvxv68,
158158 }),
159159 };
160 result[@enumToInt(Feature.hvxv71)] = .{
160 result[@intFromEnum(Feature.hvxv71)] = .{
161161 .llvm_name = "hvxv71",
162162 .description = "Hexagon HVX instructions",
163163 .dependencies = featureSet(&[_]Feature{
164164 .hvxv69,
165165 }),
166166 };
167 result[@enumToInt(Feature.hvxv73)] = .{
167 result[@intFromEnum(Feature.hvxv73)] = .{
168168 .llvm_name = "hvxv73",
169169 .description = "Hexagon HVX instructions",
170170 .dependencies = featureSet(&[_]Feature{
171171 .hvxv71,
172172 }),
173173 };
174 result[@enumToInt(Feature.long_calls)] = .{
174 result[@intFromEnum(Feature.long_calls)] = .{
175175 .llvm_name = "long-calls",
176176 .description = "Use constant-extended calls",
177177 .dependencies = featureSet(&[_]Feature{}),
178178 };
179 result[@enumToInt(Feature.mem_noshuf)] = .{
179 result[@intFromEnum(Feature.mem_noshuf)] = .{
180180 .llvm_name = "mem_noshuf",
181181 .description = "Supports mem_noshuf feature",
182182 .dependencies = featureSet(&[_]Feature{}),
183183 };
184 result[@enumToInt(Feature.memops)] = .{
184 result[@intFromEnum(Feature.memops)] = .{
185185 .llvm_name = "memops",
186186 .description = "Use memop instructions",
187187 .dependencies = featureSet(&[_]Feature{}),
188188 };
189 result[@enumToInt(Feature.noreturn_stack_elim)] = .{
189 result[@intFromEnum(Feature.noreturn_stack_elim)] = .{
190190 .llvm_name = "noreturn-stack-elim",
191191 .description = "Eliminate stack allocation in a noreturn function when possible",
192192 .dependencies = featureSet(&[_]Feature{}),
193193 };
194 result[@enumToInt(Feature.nvj)] = .{
194 result[@intFromEnum(Feature.nvj)] = .{
195195 .llvm_name = "nvj",
196196 .description = "Support for new-value jumps",
197197 .dependencies = featureSet(&[_]Feature{
198198 .packets,
199199 }),
200200 };
201 result[@enumToInt(Feature.nvs)] = .{
201 result[@intFromEnum(Feature.nvs)] = .{
202202 .llvm_name = "nvs",
203203 .description = "Support for new-value stores",
204204 .dependencies = featureSet(&[_]Feature{
205205 .packets,
206206 }),
207207 };
208 result[@enumToInt(Feature.packets)] = .{
208 result[@intFromEnum(Feature.packets)] = .{
209209 .llvm_name = "packets",
210210 .description = "Support for instruction packets",
211211 .dependencies = featureSet(&[_]Feature{}),
212212 };
213 result[@enumToInt(Feature.prev65)] = .{
213 result[@intFromEnum(Feature.prev65)] = .{
214214 .llvm_name = "prev65",
215215 .description = "Support features deprecated in v65",
216216 .dependencies = featureSet(&[_]Feature{}),
217217 };
218 result[@enumToInt(Feature.reserved_r19)] = .{
218 result[@intFromEnum(Feature.reserved_r19)] = .{
219219 .llvm_name = "reserved-r19",
220220 .description = "Reserve register R19",
221221 .dependencies = featureSet(&[_]Feature{}),
222222 };
223 result[@enumToInt(Feature.small_data)] = .{
223 result[@intFromEnum(Feature.small_data)] = .{
224224 .llvm_name = "small-data",
225225 .description = "Allow GP-relative addressing of global variables",
226226 .dependencies = featureSet(&[_]Feature{}),
227227 };
228 result[@enumToInt(Feature.tinycore)] = .{
228 result[@intFromEnum(Feature.tinycore)] = .{
229229 .llvm_name = "tinycore",
230230 .description = "Hexagon Tiny Core",
231231 .dependencies = featureSet(&[_]Feature{}),
232232 };
233 result[@enumToInt(Feature.unsafe_fp)] = .{
233 result[@intFromEnum(Feature.unsafe_fp)] = .{
234234 .llvm_name = "unsafe-fp",
235235 .description = "Use unsafe FP math",
236236 .dependencies = featureSet(&[_]Feature{}),
237237 };
238 result[@enumToInt(Feature.v5)] = .{
238 result[@intFromEnum(Feature.v5)] = .{
239239 .llvm_name = "v5",
240240 .description = "Enable Hexagon V5 architecture",
241241 .dependencies = featureSet(&[_]Feature{}),
242242 };
243 result[@enumToInt(Feature.v55)] = .{
243 result[@intFromEnum(Feature.v55)] = .{
244244 .llvm_name = "v55",
245245 .description = "Enable Hexagon V55 architecture",
246246 .dependencies = featureSet(&[_]Feature{}),
247247 };
248 result[@enumToInt(Feature.v60)] = .{
248 result[@intFromEnum(Feature.v60)] = .{
249249 .llvm_name = "v60",
250250 .description = "Enable Hexagon V60 architecture",
251251 .dependencies = featureSet(&[_]Feature{}),
252252 };
253 result[@enumToInt(Feature.v62)] = .{
253 result[@intFromEnum(Feature.v62)] = .{
254254 .llvm_name = "v62",
255255 .description = "Enable Hexagon V62 architecture",
256256 .dependencies = featureSet(&[_]Feature{}),
257257 };
258 result[@enumToInt(Feature.v65)] = .{
258 result[@intFromEnum(Feature.v65)] = .{
259259 .llvm_name = "v65",
260260 .description = "Enable Hexagon V65 architecture",
261261 .dependencies = featureSet(&[_]Feature{}),
262262 };
263 result[@enumToInt(Feature.v66)] = .{
263 result[@intFromEnum(Feature.v66)] = .{
264264 .llvm_name = "v66",
265265 .description = "Enable Hexagon V66 architecture",
266266 .dependencies = featureSet(&[_]Feature{}),
267267 };
268 result[@enumToInt(Feature.v67)] = .{
268 result[@intFromEnum(Feature.v67)] = .{
269269 .llvm_name = "v67",
270270 .description = "Enable Hexagon V67 architecture",
271271 .dependencies = featureSet(&[_]Feature{}),
272272 };
273 result[@enumToInt(Feature.v68)] = .{
273 result[@intFromEnum(Feature.v68)] = .{
274274 .llvm_name = "v68",
275275 .description = "Enable Hexagon V68 architecture",
276276 .dependencies = featureSet(&[_]Feature{}),
277277 };
278 result[@enumToInt(Feature.v69)] = .{
278 result[@intFromEnum(Feature.v69)] = .{
279279 .llvm_name = "v69",
280280 .description = "Enable Hexagon V69 architecture",
281281 .dependencies = featureSet(&[_]Feature{}),
282282 };
283 result[@enumToInt(Feature.v71)] = .{
283 result[@intFromEnum(Feature.v71)] = .{
284284 .llvm_name = "v71",
285285 .description = "Enable Hexagon V71 architecture",
286286 .dependencies = featureSet(&[_]Feature{}),
287287 };
288 result[@enumToInt(Feature.v73)] = .{
288 result[@intFromEnum(Feature.v73)] = .{
289289 .llvm_name = "v73",
290290 .description = "Enable Hexagon V73 architecture",
291291 .dependencies = featureSet(&[_]Feature{}),
292292 };
293 result[@enumToInt(Feature.zreg)] = .{
293 result[@intFromEnum(Feature.zreg)] = .{
294294 .llvm_name = "zreg",
295295 .description = "Hexagon ZReg extension instructions",
296296 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/loongarch.zig+11-11
......@@ -27,63 +27,63 @@ pub const all_features = blk: {
2727 const len = @typeInfo(Feature).Enum.fields.len;
2828 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
2929 var result: [len]CpuFeature = undefined;
30 result[@enumToInt(Feature.@"32bit")] = .{
30 result[@intFromEnum(Feature.@"32bit")] = .{
3131 .llvm_name = "32bit",
3232 .description = "LA32 Basic Integer and Privilege Instruction Set",
3333 .dependencies = featureSet(&[_]Feature{}),
3434 };
35 result[@enumToInt(Feature.@"64bit")] = .{
35 result[@intFromEnum(Feature.@"64bit")] = .{
3636 .llvm_name = "64bit",
3737 .description = "LA64 Basic Integer and Privilege Instruction Set",
3838 .dependencies = featureSet(&[_]Feature{}),
3939 };
40 result[@enumToInt(Feature.d)] = .{
40 result[@intFromEnum(Feature.d)] = .{
4141 .llvm_name = "d",
4242 .description = "'D' (Double-Precision Floating-Point)",
4343 .dependencies = featureSet(&[_]Feature{
4444 .f,
4545 }),
4646 };
47 result[@enumToInt(Feature.f)] = .{
47 result[@intFromEnum(Feature.f)] = .{
4848 .llvm_name = "f",
4949 .description = "'F' (Single-Precision Floating-Point)",
5050 .dependencies = featureSet(&[_]Feature{}),
5151 };
52 result[@enumToInt(Feature.la_global_with_abs)] = .{
52 result[@intFromEnum(Feature.la_global_with_abs)] = .{
5353 .llvm_name = "la-global-with-abs",
5454 .description = "Expand la.global as la.abs",
5555 .dependencies = featureSet(&[_]Feature{}),
5656 };
57 result[@enumToInt(Feature.la_global_with_pcrel)] = .{
57 result[@intFromEnum(Feature.la_global_with_pcrel)] = .{
5858 .llvm_name = "la-global-with-pcrel",
5959 .description = "Expand la.global as la.pcrel",
6060 .dependencies = featureSet(&[_]Feature{}),
6161 };
62 result[@enumToInt(Feature.la_local_with_abs)] = .{
62 result[@intFromEnum(Feature.la_local_with_abs)] = .{
6363 .llvm_name = "la-local-with-abs",
6464 .description = "Expand la.local as la.abs",
6565 .dependencies = featureSet(&[_]Feature{}),
6666 };
67 result[@enumToInt(Feature.lasx)] = .{
67 result[@intFromEnum(Feature.lasx)] = .{
6868 .llvm_name = "lasx",
6969 .description = "'LASX' (Loongson Advanced SIMD Extension)",
7070 .dependencies = featureSet(&[_]Feature{
7171 .lsx,
7272 }),
7373 };
74 result[@enumToInt(Feature.lbt)] = .{
74 result[@intFromEnum(Feature.lbt)] = .{
7575 .llvm_name = "lbt",
7676 .description = "'LBT' (Loongson Binary Translation Extension)",
7777 .dependencies = featureSet(&[_]Feature{}),
7878 };
79 result[@enumToInt(Feature.lsx)] = .{
79 result[@intFromEnum(Feature.lsx)] = .{
8080 .llvm_name = "lsx",
8181 .description = "'LSX' (Loongson SIMD Extension)",
8282 .dependencies = featureSet(&[_]Feature{
8383 .d,
8484 }),
8585 };
86 result[@enumToInt(Feature.lvz)] = .{
86 result[@intFromEnum(Feature.lvz)] = .{
8787 .llvm_name = "lvz",
8888 .description = "'LVZ' (Loongson Virtualization Extension)",
8989 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/m68k.zig+21-21
......@@ -37,117 +37,117 @@ pub const all_features = blk: {
3737 const len = @typeInfo(Feature).Enum.fields.len;
3838 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
3939 var result: [len]CpuFeature = undefined;
40 result[@enumToInt(Feature.isa_68000)] = .{
40 result[@intFromEnum(Feature.isa_68000)] = .{
4141 .llvm_name = "isa-68000",
4242 .description = "Is M68000 ISA supported",
4343 .dependencies = featureSet(&[_]Feature{}),
4444 };
45 result[@enumToInt(Feature.isa_68010)] = .{
45 result[@intFromEnum(Feature.isa_68010)] = .{
4646 .llvm_name = "isa-68010",
4747 .description = "Is M68010 ISA supported",
4848 .dependencies = featureSet(&[_]Feature{
4949 .isa_68000,
5050 }),
5151 };
52 result[@enumToInt(Feature.isa_68020)] = .{
52 result[@intFromEnum(Feature.isa_68020)] = .{
5353 .llvm_name = "isa-68020",
5454 .description = "Is M68020 ISA supported",
5555 .dependencies = featureSet(&[_]Feature{
5656 .isa_68010,
5757 }),
5858 };
59 result[@enumToInt(Feature.isa_68030)] = .{
59 result[@intFromEnum(Feature.isa_68030)] = .{
6060 .llvm_name = "isa-68030",
6161 .description = "Is M68030 ISA supported",
6262 .dependencies = featureSet(&[_]Feature{
6363 .isa_68020,
6464 }),
6565 };
66 result[@enumToInt(Feature.isa_68040)] = .{
66 result[@intFromEnum(Feature.isa_68040)] = .{
6767 .llvm_name = "isa-68040",
6868 .description = "Is M68040 ISA supported",
6969 .dependencies = featureSet(&[_]Feature{
7070 .isa_68030,
7171 }),
7272 };
73 result[@enumToInt(Feature.isa_68060)] = .{
73 result[@intFromEnum(Feature.isa_68060)] = .{
7474 .llvm_name = "isa-68060",
7575 .description = "Is M68060 ISA supported",
7676 .dependencies = featureSet(&[_]Feature{
7777 .isa_68040,
7878 }),
7979 };
80 result[@enumToInt(Feature.reserve_a0)] = .{
80 result[@intFromEnum(Feature.reserve_a0)] = .{
8181 .llvm_name = "reserve-a0",
8282 .description = "Reserve A0 register",
8383 .dependencies = featureSet(&[_]Feature{}),
8484 };
85 result[@enumToInt(Feature.reserve_a1)] = .{
85 result[@intFromEnum(Feature.reserve_a1)] = .{
8686 .llvm_name = "reserve-a1",
8787 .description = "Reserve A1 register",
8888 .dependencies = featureSet(&[_]Feature{}),
8989 };
90 result[@enumToInt(Feature.reserve_a2)] = .{
90 result[@intFromEnum(Feature.reserve_a2)] = .{
9191 .llvm_name = "reserve-a2",
9292 .description = "Reserve A2 register",
9393 .dependencies = featureSet(&[_]Feature{}),
9494 };
95 result[@enumToInt(Feature.reserve_a3)] = .{
95 result[@intFromEnum(Feature.reserve_a3)] = .{
9696 .llvm_name = "reserve-a3",
9797 .description = "Reserve A3 register",
9898 .dependencies = featureSet(&[_]Feature{}),
9999 };
100 result[@enumToInt(Feature.reserve_a4)] = .{
100 result[@intFromEnum(Feature.reserve_a4)] = .{
101101 .llvm_name = "reserve-a4",
102102 .description = "Reserve A4 register",
103103 .dependencies = featureSet(&[_]Feature{}),
104104 };
105 result[@enumToInt(Feature.reserve_a5)] = .{
105 result[@intFromEnum(Feature.reserve_a5)] = .{
106106 .llvm_name = "reserve-a5",
107107 .description = "Reserve A5 register",
108108 .dependencies = featureSet(&[_]Feature{}),
109109 };
110 result[@enumToInt(Feature.reserve_a6)] = .{
110 result[@intFromEnum(Feature.reserve_a6)] = .{
111111 .llvm_name = "reserve-a6",
112112 .description = "Reserve A6 register",
113113 .dependencies = featureSet(&[_]Feature{}),
114114 };
115 result[@enumToInt(Feature.reserve_d0)] = .{
115 result[@intFromEnum(Feature.reserve_d0)] = .{
116116 .llvm_name = "reserve-d0",
117117 .description = "Reserve D0 register",
118118 .dependencies = featureSet(&[_]Feature{}),
119119 };
120 result[@enumToInt(Feature.reserve_d1)] = .{
120 result[@intFromEnum(Feature.reserve_d1)] = .{
121121 .llvm_name = "reserve-d1",
122122 .description = "Reserve D1 register",
123123 .dependencies = featureSet(&[_]Feature{}),
124124 };
125 result[@enumToInt(Feature.reserve_d2)] = .{
125 result[@intFromEnum(Feature.reserve_d2)] = .{
126126 .llvm_name = "reserve-d2",
127127 .description = "Reserve D2 register",
128128 .dependencies = featureSet(&[_]Feature{}),
129129 };
130 result[@enumToInt(Feature.reserve_d3)] = .{
130 result[@intFromEnum(Feature.reserve_d3)] = .{
131131 .llvm_name = "reserve-d3",
132132 .description = "Reserve D3 register",
133133 .dependencies = featureSet(&[_]Feature{}),
134134 };
135 result[@enumToInt(Feature.reserve_d4)] = .{
135 result[@intFromEnum(Feature.reserve_d4)] = .{
136136 .llvm_name = "reserve-d4",
137137 .description = "Reserve D4 register",
138138 .dependencies = featureSet(&[_]Feature{}),
139139 };
140 result[@enumToInt(Feature.reserve_d5)] = .{
140 result[@intFromEnum(Feature.reserve_d5)] = .{
141141 .llvm_name = "reserve-d5",
142142 .description = "Reserve D5 register",
143143 .dependencies = featureSet(&[_]Feature{}),
144144 };
145 result[@enumToInt(Feature.reserve_d6)] = .{
145 result[@intFromEnum(Feature.reserve_d6)] = .{
146146 .llvm_name = "reserve-d6",
147147 .description = "Reserve D6 register",
148148 .dependencies = featureSet(&[_]Feature{}),
149149 };
150 result[@enumToInt(Feature.reserve_d7)] = .{
150 result[@intFromEnum(Feature.reserve_d7)] = .{
151151 .llvm_name = "reserve-d7",
152152 .description = "Reserve D7 register",
153153 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/mips.zig+52-52
......@@ -68,102 +68,102 @@ pub const all_features = blk: {
6868 const len = @typeInfo(Feature).Enum.fields.len;
6969 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
7070 var result: [len]CpuFeature = undefined;
71 result[@enumToInt(Feature.abs2008)] = .{
71 result[@intFromEnum(Feature.abs2008)] = .{
7272 .llvm_name = "abs2008",
7373 .description = "Disable IEEE 754-2008 abs.fmt mode",
7474 .dependencies = featureSet(&[_]Feature{}),
7575 };
76 result[@enumToInt(Feature.cnmips)] = .{
76 result[@intFromEnum(Feature.cnmips)] = .{
7777 .llvm_name = "cnmips",
7878 .description = "Octeon cnMIPS Support",
7979 .dependencies = featureSet(&[_]Feature{
8080 .mips64r2,
8181 }),
8282 };
83 result[@enumToInt(Feature.cnmipsp)] = .{
83 result[@intFromEnum(Feature.cnmipsp)] = .{
8484 .llvm_name = "cnmipsp",
8585 .description = "Octeon+ cnMIPS Support",
8686 .dependencies = featureSet(&[_]Feature{
8787 .cnmips,
8888 }),
8989 };
90 result[@enumToInt(Feature.crc)] = .{
90 result[@intFromEnum(Feature.crc)] = .{
9191 .llvm_name = "crc",
9292 .description = "Mips R6 CRC ASE",
9393 .dependencies = featureSet(&[_]Feature{}),
9494 };
95 result[@enumToInt(Feature.dsp)] = .{
95 result[@intFromEnum(Feature.dsp)] = .{
9696 .llvm_name = "dsp",
9797 .description = "Mips DSP ASE",
9898 .dependencies = featureSet(&[_]Feature{}),
9999 };
100 result[@enumToInt(Feature.dspr2)] = .{
100 result[@intFromEnum(Feature.dspr2)] = .{
101101 .llvm_name = "dspr2",
102102 .description = "Mips DSP-R2 ASE",
103103 .dependencies = featureSet(&[_]Feature{
104104 .dsp,
105105 }),
106106 };
107 result[@enumToInt(Feature.dspr3)] = .{
107 result[@intFromEnum(Feature.dspr3)] = .{
108108 .llvm_name = "dspr3",
109109 .description = "Mips DSP-R3 ASE",
110110 .dependencies = featureSet(&[_]Feature{
111111 .dspr2,
112112 }),
113113 };
114 result[@enumToInt(Feature.eva)] = .{
114 result[@intFromEnum(Feature.eva)] = .{
115115 .llvm_name = "eva",
116116 .description = "Mips EVA ASE",
117117 .dependencies = featureSet(&[_]Feature{}),
118118 };
119 result[@enumToInt(Feature.fp64)] = .{
119 result[@intFromEnum(Feature.fp64)] = .{
120120 .llvm_name = "fp64",
121121 .description = "Support 64-bit FP registers",
122122 .dependencies = featureSet(&[_]Feature{}),
123123 };
124 result[@enumToInt(Feature.fpxx)] = .{
124 result[@intFromEnum(Feature.fpxx)] = .{
125125 .llvm_name = "fpxx",
126126 .description = "Support for FPXX",
127127 .dependencies = featureSet(&[_]Feature{}),
128128 };
129 result[@enumToInt(Feature.ginv)] = .{
129 result[@intFromEnum(Feature.ginv)] = .{
130130 .llvm_name = "ginv",
131131 .description = "Mips Global Invalidate ASE",
132132 .dependencies = featureSet(&[_]Feature{}),
133133 };
134 result[@enumToInt(Feature.gp64)] = .{
134 result[@intFromEnum(Feature.gp64)] = .{
135135 .llvm_name = "gp64",
136136 .description = "General Purpose Registers are 64-bit wide",
137137 .dependencies = featureSet(&[_]Feature{}),
138138 };
139 result[@enumToInt(Feature.long_calls)] = .{
139 result[@intFromEnum(Feature.long_calls)] = .{
140140 .llvm_name = "long-calls",
141141 .description = "Disable use of the jal instruction",
142142 .dependencies = featureSet(&[_]Feature{}),
143143 };
144 result[@enumToInt(Feature.micromips)] = .{
144 result[@intFromEnum(Feature.micromips)] = .{
145145 .llvm_name = "micromips",
146146 .description = "microMips mode",
147147 .dependencies = featureSet(&[_]Feature{}),
148148 };
149 result[@enumToInt(Feature.mips1)] = .{
149 result[@intFromEnum(Feature.mips1)] = .{
150150 .llvm_name = "mips1",
151151 .description = "Mips I ISA Support [highly experimental]",
152152 .dependencies = featureSet(&[_]Feature{}),
153153 };
154 result[@enumToInt(Feature.mips16)] = .{
154 result[@intFromEnum(Feature.mips16)] = .{
155155 .llvm_name = "mips16",
156156 .description = "Mips16 mode",
157157 .dependencies = featureSet(&[_]Feature{}),
158158 };
159 result[@enumToInt(Feature.mips2)] = .{
159 result[@intFromEnum(Feature.mips2)] = .{
160160 .llvm_name = "mips2",
161161 .description = "Mips II ISA Support [highly experimental]",
162162 .dependencies = featureSet(&[_]Feature{
163163 .mips1,
164164 }),
165165 };
166 result[@enumToInt(Feature.mips3)] = .{
166 result[@intFromEnum(Feature.mips3)] = .{
167167 .llvm_name = "mips3",
168168 .description = "MIPS III ISA Support [highly experimental]",
169169 .dependencies = featureSet(&[_]Feature{
......@@ -174,7 +174,7 @@ pub const all_features = blk: {
174174 .mips3_32r2,
175175 }),
176176 };
177 result[@enumToInt(Feature.mips32)] = .{
177 result[@intFromEnum(Feature.mips32)] = .{
178178 .llvm_name = "mips32",
179179 .description = "Mips32 ISA Support",
180180 .dependencies = featureSet(&[_]Feature{
......@@ -183,7 +183,7 @@ pub const all_features = blk: {
183183 .mips4_32,
184184 }),
185185 };
186 result[@enumToInt(Feature.mips32r2)] = .{
186 result[@intFromEnum(Feature.mips32r2)] = .{
187187 .llvm_name = "mips32r2",
188188 .description = "Mips32r2 ISA Support",
189189 .dependencies = featureSet(&[_]Feature{
......@@ -193,21 +193,21 @@ pub const all_features = blk: {
193193 .mips5_32r2,
194194 }),
195195 };
196 result[@enumToInt(Feature.mips32r3)] = .{
196 result[@intFromEnum(Feature.mips32r3)] = .{
197197 .llvm_name = "mips32r3",
198198 .description = "Mips32r3 ISA Support",
199199 .dependencies = featureSet(&[_]Feature{
200200 .mips32r2,
201201 }),
202202 };
203 result[@enumToInt(Feature.mips32r5)] = .{
203 result[@intFromEnum(Feature.mips32r5)] = .{
204204 .llvm_name = "mips32r5",
205205 .description = "Mips32r5 ISA Support",
206206 .dependencies = featureSet(&[_]Feature{
207207 .mips32r3,
208208 }),
209209 };
210 result[@enumToInt(Feature.mips32r6)] = .{
210 result[@intFromEnum(Feature.mips32r6)] = .{
211211 .llvm_name = "mips32r6",
212212 .description = "Mips32r6 ISA Support [experimental]",
213213 .dependencies = featureSet(&[_]Feature{
......@@ -217,22 +217,22 @@ pub const all_features = blk: {
217217 .nan2008,
218218 }),
219219 };
220 result[@enumToInt(Feature.mips3_32)] = .{
220 result[@intFromEnum(Feature.mips3_32)] = .{
221221 .llvm_name = "mips3_32",
222222 .description = "Subset of MIPS-III that is also in MIPS32 [highly experimental]",
223223 .dependencies = featureSet(&[_]Feature{}),
224224 };
225 result[@enumToInt(Feature.mips3_32r2)] = .{
225 result[@intFromEnum(Feature.mips3_32r2)] = .{
226226 .llvm_name = "mips3_32r2",
227227 .description = "Subset of MIPS-III that is also in MIPS32r2 [highly experimental]",
228228 .dependencies = featureSet(&[_]Feature{}),
229229 };
230 result[@enumToInt(Feature.mips3d)] = .{
230 result[@intFromEnum(Feature.mips3d)] = .{
231231 .llvm_name = "mips3d",
232232 .description = "Mips 3D ASE",
233233 .dependencies = featureSet(&[_]Feature{}),
234234 };
235 result[@enumToInt(Feature.mips4)] = .{
235 result[@intFromEnum(Feature.mips4)] = .{
236236 .llvm_name = "mips4",
237237 .description = "MIPS IV ISA Support",
238238 .dependencies = featureSet(&[_]Feature{
......@@ -241,17 +241,17 @@ pub const all_features = blk: {
241241 .mips4_32r2,
242242 }),
243243 };
244 result[@enumToInt(Feature.mips4_32)] = .{
244 result[@intFromEnum(Feature.mips4_32)] = .{
245245 .llvm_name = "mips4_32",
246246 .description = "Subset of MIPS-IV that is also in MIPS32 [highly experimental]",
247247 .dependencies = featureSet(&[_]Feature{}),
248248 };
249 result[@enumToInt(Feature.mips4_32r2)] = .{
249 result[@intFromEnum(Feature.mips4_32r2)] = .{
250250 .llvm_name = "mips4_32r2",
251251 .description = "Subset of MIPS-IV that is also in MIPS32r2 [highly experimental]",
252252 .dependencies = featureSet(&[_]Feature{}),
253253 };
254 result[@enumToInt(Feature.mips5)] = .{
254 result[@intFromEnum(Feature.mips5)] = .{
255255 .llvm_name = "mips5",
256256 .description = "MIPS V ISA Support [highly experimental]",
257257 .dependencies = featureSet(&[_]Feature{
......@@ -259,12 +259,12 @@ pub const all_features = blk: {
259259 .mips5_32r2,
260260 }),
261261 };
262 result[@enumToInt(Feature.mips5_32r2)] = .{
262 result[@intFromEnum(Feature.mips5_32r2)] = .{
263263 .llvm_name = "mips5_32r2",
264264 .description = "Subset of MIPS-V that is also in MIPS32r2 [highly experimental]",
265265 .dependencies = featureSet(&[_]Feature{}),
266266 };
267 result[@enumToInt(Feature.mips64)] = .{
267 result[@intFromEnum(Feature.mips64)] = .{
268268 .llvm_name = "mips64",
269269 .description = "Mips64 ISA Support",
270270 .dependencies = featureSet(&[_]Feature{
......@@ -272,7 +272,7 @@ pub const all_features = blk: {
272272 .mips5,
273273 }),
274274 };
275 result[@enumToInt(Feature.mips64r2)] = .{
275 result[@intFromEnum(Feature.mips64r2)] = .{
276276 .llvm_name = "mips64r2",
277277 .description = "Mips64r2 ISA Support",
278278 .dependencies = featureSet(&[_]Feature{
......@@ -280,7 +280,7 @@ pub const all_features = blk: {
280280 .mips64,
281281 }),
282282 };
283 result[@enumToInt(Feature.mips64r3)] = .{
283 result[@intFromEnum(Feature.mips64r3)] = .{
284284 .llvm_name = "mips64r3",
285285 .description = "Mips64r3 ISA Support",
286286 .dependencies = featureSet(&[_]Feature{
......@@ -288,7 +288,7 @@ pub const all_features = blk: {
288288 .mips64r2,
289289 }),
290290 };
291 result[@enumToInt(Feature.mips64r5)] = .{
291 result[@intFromEnum(Feature.mips64r5)] = .{
292292 .llvm_name = "mips64r5",
293293 .description = "Mips64r5 ISA Support",
294294 .dependencies = featureSet(&[_]Feature{
......@@ -296,7 +296,7 @@ pub const all_features = blk: {
296296 .mips64r3,
297297 }),
298298 };
299 result[@enumToInt(Feature.mips64r6)] = .{
299 result[@intFromEnum(Feature.mips64r6)] = .{
300300 .llvm_name = "mips64r6",
301301 .description = "Mips64r6 ISA Support [experimental]",
302302 .dependencies = featureSet(&[_]Feature{
......@@ -304,84 +304,84 @@ pub const all_features = blk: {
304304 .mips64r5,
305305 }),
306306 };
307 result[@enumToInt(Feature.msa)] = .{
307 result[@intFromEnum(Feature.msa)] = .{
308308 .llvm_name = "msa",
309309 .description = "Mips MSA ASE",
310310 .dependencies = featureSet(&[_]Feature{}),
311311 };
312 result[@enumToInt(Feature.mt)] = .{
312 result[@intFromEnum(Feature.mt)] = .{
313313 .llvm_name = "mt",
314314 .description = "Mips MT ASE",
315315 .dependencies = featureSet(&[_]Feature{}),
316316 };
317 result[@enumToInt(Feature.nan2008)] = .{
317 result[@intFromEnum(Feature.nan2008)] = .{
318318 .llvm_name = "nan2008",
319319 .description = "IEEE 754-2008 NaN encoding",
320320 .dependencies = featureSet(&[_]Feature{}),
321321 };
322 result[@enumToInt(Feature.noabicalls)] = .{
322 result[@intFromEnum(Feature.noabicalls)] = .{
323323 .llvm_name = "noabicalls",
324324 .description = "Disable SVR4-style position-independent code",
325325 .dependencies = featureSet(&[_]Feature{}),
326326 };
327 result[@enumToInt(Feature.nomadd4)] = .{
327 result[@intFromEnum(Feature.nomadd4)] = .{
328328 .llvm_name = "nomadd4",
329329 .description = "Disable 4-operand madd.fmt and related instructions",
330330 .dependencies = featureSet(&[_]Feature{}),
331331 };
332 result[@enumToInt(Feature.nooddspreg)] = .{
332 result[@intFromEnum(Feature.nooddspreg)] = .{
333333 .llvm_name = "nooddspreg",
334334 .description = "Disable odd numbered single-precision registers",
335335 .dependencies = featureSet(&[_]Feature{}),
336336 };
337 result[@enumToInt(Feature.p5600)] = .{
337 result[@intFromEnum(Feature.p5600)] = .{
338338 .llvm_name = "p5600",
339339 .description = "The P5600 Processor",
340340 .dependencies = featureSet(&[_]Feature{
341341 .mips32r5,
342342 }),
343343 };
344 result[@enumToInt(Feature.ptr64)] = .{
344 result[@intFromEnum(Feature.ptr64)] = .{
345345 .llvm_name = "ptr64",
346346 .description = "Pointers are 64-bit wide",
347347 .dependencies = featureSet(&[_]Feature{}),
348348 };
349 result[@enumToInt(Feature.single_float)] = .{
349 result[@intFromEnum(Feature.single_float)] = .{
350350 .llvm_name = "single-float",
351351 .description = "Only supports single precision float",
352352 .dependencies = featureSet(&[_]Feature{}),
353353 };
354 result[@enumToInt(Feature.soft_float)] = .{
354 result[@intFromEnum(Feature.soft_float)] = .{
355355 .llvm_name = "soft-float",
356356 .description = "Does not support floating point instructions",
357357 .dependencies = featureSet(&[_]Feature{}),
358358 };
359 result[@enumToInt(Feature.sym32)] = .{
359 result[@intFromEnum(Feature.sym32)] = .{
360360 .llvm_name = "sym32",
361361 .description = "Symbols are 32 bit on Mips64",
362362 .dependencies = featureSet(&[_]Feature{}),
363363 };
364 result[@enumToInt(Feature.use_indirect_jump_hazard)] = .{
364 result[@intFromEnum(Feature.use_indirect_jump_hazard)] = .{
365365 .llvm_name = "use-indirect-jump-hazard",
366366 .description = "Use indirect jump guards to prevent certain speculation based attacks",
367367 .dependencies = featureSet(&[_]Feature{}),
368368 };
369 result[@enumToInt(Feature.use_tcc_in_div)] = .{
369 result[@intFromEnum(Feature.use_tcc_in_div)] = .{
370370 .llvm_name = "use-tcc-in-div",
371371 .description = "Force the assembler to use trapping",
372372 .dependencies = featureSet(&[_]Feature{}),
373373 };
374 result[@enumToInt(Feature.vfpu)] = .{
374 result[@intFromEnum(Feature.vfpu)] = .{
375375 .llvm_name = "vfpu",
376376 .description = "Enable vector FPU instructions",
377377 .dependencies = featureSet(&[_]Feature{}),
378378 };
379 result[@enumToInt(Feature.virt)] = .{
379 result[@intFromEnum(Feature.virt)] = .{
380380 .llvm_name = "virt",
381381 .description = "Mips Virtualization ASE",
382382 .dependencies = featureSet(&[_]Feature{}),
383383 };
384 result[@enumToInt(Feature.xgot)] = .{
384 result[@intFromEnum(Feature.xgot)] = .{
385385 .llvm_name = "xgot",
386386 .description = "Assume 32-bit GOT",
387387 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/msp430.zig+4-4
......@@ -20,22 +20,22 @@ pub const all_features = blk: {
2020 const len = @typeInfo(Feature).Enum.fields.len;
2121 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
2222 var result: [len]CpuFeature = undefined;
23 result[@enumToInt(Feature.ext)] = .{
23 result[@intFromEnum(Feature.ext)] = .{
2424 .llvm_name = "ext",
2525 .description = "Enable MSP430-X extensions",
2626 .dependencies = featureSet(&[_]Feature{}),
2727 };
28 result[@enumToInt(Feature.hwmult16)] = .{
28 result[@intFromEnum(Feature.hwmult16)] = .{
2929 .llvm_name = "hwmult16",
3030 .description = "Enable 16-bit hardware multiplier",
3131 .dependencies = featureSet(&[_]Feature{}),
3232 };
33 result[@enumToInt(Feature.hwmult32)] = .{
33 result[@intFromEnum(Feature.hwmult32)] = .{
3434 .llvm_name = "hwmult32",
3535 .description = "Enable 32-bit hardware multiplier",
3636 .dependencies = featureSet(&[_]Feature{}),
3737 };
38 result[@enumToInt(Feature.hwmultf5)] = .{
38 result[@intFromEnum(Feature.hwmultf5)] = .{
3939 .llvm_name = "hwmultf5",
4040 .description = "Enable F5 series hardware multiplier",
4141 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/nvptx.zig+40-40
......@@ -56,202 +56,202 @@ pub const all_features = blk: {
5656 const len = @typeInfo(Feature).Enum.fields.len;
5757 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
5858 var result: [len]CpuFeature = undefined;
59 result[@enumToInt(Feature.ptx32)] = .{
59 result[@intFromEnum(Feature.ptx32)] = .{
6060 .llvm_name = "ptx32",
6161 .description = "Use PTX version 3.2",
6262 .dependencies = featureSet(&[_]Feature{}),
6363 };
64 result[@enumToInt(Feature.ptx40)] = .{
64 result[@intFromEnum(Feature.ptx40)] = .{
6565 .llvm_name = "ptx40",
6666 .description = "Use PTX version 4.0",
6767 .dependencies = featureSet(&[_]Feature{}),
6868 };
69 result[@enumToInt(Feature.ptx41)] = .{
69 result[@intFromEnum(Feature.ptx41)] = .{
7070 .llvm_name = "ptx41",
7171 .description = "Use PTX version 4.1",
7272 .dependencies = featureSet(&[_]Feature{}),
7373 };
74 result[@enumToInt(Feature.ptx42)] = .{
74 result[@intFromEnum(Feature.ptx42)] = .{
7575 .llvm_name = "ptx42",
7676 .description = "Use PTX version 4.2",
7777 .dependencies = featureSet(&[_]Feature{}),
7878 };
79 result[@enumToInt(Feature.ptx43)] = .{
79 result[@intFromEnum(Feature.ptx43)] = .{
8080 .llvm_name = "ptx43",
8181 .description = "Use PTX version 4.3",
8282 .dependencies = featureSet(&[_]Feature{}),
8383 };
84 result[@enumToInt(Feature.ptx50)] = .{
84 result[@intFromEnum(Feature.ptx50)] = .{
8585 .llvm_name = "ptx50",
8686 .description = "Use PTX version 5.0",
8787 .dependencies = featureSet(&[_]Feature{}),
8888 };
89 result[@enumToInt(Feature.ptx60)] = .{
89 result[@intFromEnum(Feature.ptx60)] = .{
9090 .llvm_name = "ptx60",
9191 .description = "Use PTX version 6.0",
9292 .dependencies = featureSet(&[_]Feature{}),
9393 };
94 result[@enumToInt(Feature.ptx61)] = .{
94 result[@intFromEnum(Feature.ptx61)] = .{
9595 .llvm_name = "ptx61",
9696 .description = "Use PTX version 6.1",
9797 .dependencies = featureSet(&[_]Feature{}),
9898 };
99 result[@enumToInt(Feature.ptx63)] = .{
99 result[@intFromEnum(Feature.ptx63)] = .{
100100 .llvm_name = "ptx63",
101101 .description = "Use PTX version 6.3",
102102 .dependencies = featureSet(&[_]Feature{}),
103103 };
104 result[@enumToInt(Feature.ptx64)] = .{
104 result[@intFromEnum(Feature.ptx64)] = .{
105105 .llvm_name = "ptx64",
106106 .description = "Use PTX version 6.4",
107107 .dependencies = featureSet(&[_]Feature{}),
108108 };
109 result[@enumToInt(Feature.ptx65)] = .{
109 result[@intFromEnum(Feature.ptx65)] = .{
110110 .llvm_name = "ptx65",
111111 .description = "Use PTX version 6.5",
112112 .dependencies = featureSet(&[_]Feature{}),
113113 };
114 result[@enumToInt(Feature.ptx70)] = .{
114 result[@intFromEnum(Feature.ptx70)] = .{
115115 .llvm_name = "ptx70",
116116 .description = "Use PTX version 7.0",
117117 .dependencies = featureSet(&[_]Feature{}),
118118 };
119 result[@enumToInt(Feature.ptx71)] = .{
119 result[@intFromEnum(Feature.ptx71)] = .{
120120 .llvm_name = "ptx71",
121121 .description = "Use PTX version 7.1",
122122 .dependencies = featureSet(&[_]Feature{}),
123123 };
124 result[@enumToInt(Feature.ptx72)] = .{
124 result[@intFromEnum(Feature.ptx72)] = .{
125125 .llvm_name = "ptx72",
126126 .description = "Use PTX version 7.2",
127127 .dependencies = featureSet(&[_]Feature{}),
128128 };
129 result[@enumToInt(Feature.ptx73)] = .{
129 result[@intFromEnum(Feature.ptx73)] = .{
130130 .llvm_name = "ptx73",
131131 .description = "Use PTX version 7.3",
132132 .dependencies = featureSet(&[_]Feature{}),
133133 };
134 result[@enumToInt(Feature.ptx74)] = .{
134 result[@intFromEnum(Feature.ptx74)] = .{
135135 .llvm_name = "ptx74",
136136 .description = "Use PTX version 7.4",
137137 .dependencies = featureSet(&[_]Feature{}),
138138 };
139 result[@enumToInt(Feature.ptx75)] = .{
139 result[@intFromEnum(Feature.ptx75)] = .{
140140 .llvm_name = "ptx75",
141141 .description = "Use PTX version 7.5",
142142 .dependencies = featureSet(&[_]Feature{}),
143143 };
144 result[@enumToInt(Feature.ptx76)] = .{
144 result[@intFromEnum(Feature.ptx76)] = .{
145145 .llvm_name = "ptx76",
146146 .description = "Use PTX version 7.6",
147147 .dependencies = featureSet(&[_]Feature{}),
148148 };
149 result[@enumToInt(Feature.ptx77)] = .{
149 result[@intFromEnum(Feature.ptx77)] = .{
150150 .llvm_name = "ptx77",
151151 .description = "Use PTX version 7.7",
152152 .dependencies = featureSet(&[_]Feature{}),
153153 };
154 result[@enumToInt(Feature.ptx78)] = .{
154 result[@intFromEnum(Feature.ptx78)] = .{
155155 .llvm_name = "ptx78",
156156 .description = "Use PTX version 7.8",
157157 .dependencies = featureSet(&[_]Feature{}),
158158 };
159 result[@enumToInt(Feature.sm_20)] = .{
159 result[@intFromEnum(Feature.sm_20)] = .{
160160 .llvm_name = "sm_20",
161161 .description = "Target SM 2.0",
162162 .dependencies = featureSet(&[_]Feature{}),
163163 };
164 result[@enumToInt(Feature.sm_21)] = .{
164 result[@intFromEnum(Feature.sm_21)] = .{
165165 .llvm_name = "sm_21",
166166 .description = "Target SM 2.1",
167167 .dependencies = featureSet(&[_]Feature{}),
168168 };
169 result[@enumToInt(Feature.sm_30)] = .{
169 result[@intFromEnum(Feature.sm_30)] = .{
170170 .llvm_name = "sm_30",
171171 .description = "Target SM 3.0",
172172 .dependencies = featureSet(&[_]Feature{}),
173173 };
174 result[@enumToInt(Feature.sm_32)] = .{
174 result[@intFromEnum(Feature.sm_32)] = .{
175175 .llvm_name = "sm_32",
176176 .description = "Target SM 3.2",
177177 .dependencies = featureSet(&[_]Feature{}),
178178 };
179 result[@enumToInt(Feature.sm_35)] = .{
179 result[@intFromEnum(Feature.sm_35)] = .{
180180 .llvm_name = "sm_35",
181181 .description = "Target SM 3.5",
182182 .dependencies = featureSet(&[_]Feature{}),
183183 };
184 result[@enumToInt(Feature.sm_37)] = .{
184 result[@intFromEnum(Feature.sm_37)] = .{
185185 .llvm_name = "sm_37",
186186 .description = "Target SM 3.7",
187187 .dependencies = featureSet(&[_]Feature{}),
188188 };
189 result[@enumToInt(Feature.sm_50)] = .{
189 result[@intFromEnum(Feature.sm_50)] = .{
190190 .llvm_name = "sm_50",
191191 .description = "Target SM 5.0",
192192 .dependencies = featureSet(&[_]Feature{}),
193193 };
194 result[@enumToInt(Feature.sm_52)] = .{
194 result[@intFromEnum(Feature.sm_52)] = .{
195195 .llvm_name = "sm_52",
196196 .description = "Target SM 5.2",
197197 .dependencies = featureSet(&[_]Feature{}),
198198 };
199 result[@enumToInt(Feature.sm_53)] = .{
199 result[@intFromEnum(Feature.sm_53)] = .{
200200 .llvm_name = "sm_53",
201201 .description = "Target SM 5.3",
202202 .dependencies = featureSet(&[_]Feature{}),
203203 };
204 result[@enumToInt(Feature.sm_60)] = .{
204 result[@intFromEnum(Feature.sm_60)] = .{
205205 .llvm_name = "sm_60",
206206 .description = "Target SM 6.0",
207207 .dependencies = featureSet(&[_]Feature{}),
208208 };
209 result[@enumToInt(Feature.sm_61)] = .{
209 result[@intFromEnum(Feature.sm_61)] = .{
210210 .llvm_name = "sm_61",
211211 .description = "Target SM 6.1",
212212 .dependencies = featureSet(&[_]Feature{}),
213213 };
214 result[@enumToInt(Feature.sm_62)] = .{
214 result[@intFromEnum(Feature.sm_62)] = .{
215215 .llvm_name = "sm_62",
216216 .description = "Target SM 6.2",
217217 .dependencies = featureSet(&[_]Feature{}),
218218 };
219 result[@enumToInt(Feature.sm_70)] = .{
219 result[@intFromEnum(Feature.sm_70)] = .{
220220 .llvm_name = "sm_70",
221221 .description = "Target SM 7.0",
222222 .dependencies = featureSet(&[_]Feature{}),
223223 };
224 result[@enumToInt(Feature.sm_72)] = .{
224 result[@intFromEnum(Feature.sm_72)] = .{
225225 .llvm_name = "sm_72",
226226 .description = "Target SM 7.2",
227227 .dependencies = featureSet(&[_]Feature{}),
228228 };
229 result[@enumToInt(Feature.sm_75)] = .{
229 result[@intFromEnum(Feature.sm_75)] = .{
230230 .llvm_name = "sm_75",
231231 .description = "Target SM 7.5",
232232 .dependencies = featureSet(&[_]Feature{}),
233233 };
234 result[@enumToInt(Feature.sm_80)] = .{
234 result[@intFromEnum(Feature.sm_80)] = .{
235235 .llvm_name = "sm_80",
236236 .description = "Target SM 8.0",
237237 .dependencies = featureSet(&[_]Feature{}),
238238 };
239 result[@enumToInt(Feature.sm_86)] = .{
239 result[@intFromEnum(Feature.sm_86)] = .{
240240 .llvm_name = "sm_86",
241241 .description = "Target SM 8.6",
242242 .dependencies = featureSet(&[_]Feature{}),
243243 };
244 result[@enumToInt(Feature.sm_87)] = .{
244 result[@intFromEnum(Feature.sm_87)] = .{
245245 .llvm_name = "sm_87",
246246 .description = "Target SM 8.7",
247247 .dependencies = featureSet(&[_]Feature{}),
248248 };
249 result[@enumToInt(Feature.sm_89)] = .{
249 result[@intFromEnum(Feature.sm_89)] = .{
250250 .llvm_name = "sm_89",
251251 .description = "Target SM 8.9",
252252 .dependencies = featureSet(&[_]Feature{}),
253253 };
254 result[@enumToInt(Feature.sm_90)] = .{
254 result[@intFromEnum(Feature.sm_90)] = .{
255255 .llvm_name = "sm_90",
256256 .description = "Target SM 9.0",
257257 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/powerpc.zig+81-81
......@@ -97,329 +97,329 @@ pub const all_features = blk: {
9797 const len = @typeInfo(Feature).Enum.fields.len;
9898 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
9999 var result: [len]CpuFeature = undefined;
100 result[@enumToInt(Feature.@"64bit")] = .{
100 result[@intFromEnum(Feature.@"64bit")] = .{
101101 .llvm_name = "64bit",
102102 .description = "Enable 64-bit instructions",
103103 .dependencies = featureSet(&[_]Feature{}),
104104 };
105 result[@enumToInt(Feature.@"64bitregs")] = .{
105 result[@intFromEnum(Feature.@"64bitregs")] = .{
106106 .llvm_name = "64bitregs",
107107 .description = "Enable 64-bit registers usage for ppc32 [beta]",
108108 .dependencies = featureSet(&[_]Feature{}),
109109 };
110 result[@enumToInt(Feature.aix)] = .{
110 result[@intFromEnum(Feature.aix)] = .{
111111 .llvm_name = "aix",
112112 .description = "AIX OS",
113113 .dependencies = featureSet(&[_]Feature{}),
114114 };
115 result[@enumToInt(Feature.allow_unaligned_fp_access)] = .{
115 result[@intFromEnum(Feature.allow_unaligned_fp_access)] = .{
116116 .llvm_name = "allow-unaligned-fp-access",
117117 .description = "CPU does not trap on unaligned FP access",
118118 .dependencies = featureSet(&[_]Feature{}),
119119 };
120 result[@enumToInt(Feature.altivec)] = .{
120 result[@intFromEnum(Feature.altivec)] = .{
121121 .llvm_name = "altivec",
122122 .description = "Enable Altivec instructions",
123123 .dependencies = featureSet(&[_]Feature{
124124 .fpu,
125125 }),
126126 };
127 result[@enumToInt(Feature.booke)] = .{
127 result[@intFromEnum(Feature.booke)] = .{
128128 .llvm_name = "booke",
129129 .description = "Enable Book E instructions",
130130 .dependencies = featureSet(&[_]Feature{
131131 .icbt,
132132 }),
133133 };
134 result[@enumToInt(Feature.bpermd)] = .{
134 result[@intFromEnum(Feature.bpermd)] = .{
135135 .llvm_name = "bpermd",
136136 .description = "Enable the bpermd instruction",
137137 .dependencies = featureSet(&[_]Feature{}),
138138 };
139 result[@enumToInt(Feature.cmpb)] = .{
139 result[@intFromEnum(Feature.cmpb)] = .{
140140 .llvm_name = "cmpb",
141141 .description = "Enable the cmpb instruction",
142142 .dependencies = featureSet(&[_]Feature{}),
143143 };
144 result[@enumToInt(Feature.crbits)] = .{
144 result[@intFromEnum(Feature.crbits)] = .{
145145 .llvm_name = "crbits",
146146 .description = "Use condition-register bits individually",
147147 .dependencies = featureSet(&[_]Feature{}),
148148 };
149 result[@enumToInt(Feature.crypto)] = .{
149 result[@intFromEnum(Feature.crypto)] = .{
150150 .llvm_name = "crypto",
151151 .description = "Enable POWER8 Crypto instructions",
152152 .dependencies = featureSet(&[_]Feature{
153153 .power8_altivec,
154154 }),
155155 };
156 result[@enumToInt(Feature.direct_move)] = .{
156 result[@intFromEnum(Feature.direct_move)] = .{
157157 .llvm_name = "direct-move",
158158 .description = "Enable Power8 direct move instructions",
159159 .dependencies = featureSet(&[_]Feature{
160160 .vsx,
161161 }),
162162 };
163 result[@enumToInt(Feature.e500)] = .{
163 result[@intFromEnum(Feature.e500)] = .{
164164 .llvm_name = "e500",
165165 .description = "Enable E500/E500mc instructions",
166166 .dependencies = featureSet(&[_]Feature{}),
167167 };
168 result[@enumToInt(Feature.efpu2)] = .{
168 result[@intFromEnum(Feature.efpu2)] = .{
169169 .llvm_name = "efpu2",
170170 .description = "Enable Embedded Floating-Point APU 2 instructions",
171171 .dependencies = featureSet(&[_]Feature{
172172 .spe,
173173 }),
174174 };
175 result[@enumToInt(Feature.extdiv)] = .{
175 result[@intFromEnum(Feature.extdiv)] = .{
176176 .llvm_name = "extdiv",
177177 .description = "Enable extended divide instructions",
178178 .dependencies = featureSet(&[_]Feature{}),
179179 };
180 result[@enumToInt(Feature.fast_MFLR)] = .{
180 result[@intFromEnum(Feature.fast_MFLR)] = .{
181181 .llvm_name = "fast-MFLR",
182182 .description = "MFLR is a fast instruction",
183183 .dependencies = featureSet(&[_]Feature{}),
184184 };
185 result[@enumToInt(Feature.fcpsgn)] = .{
185 result[@intFromEnum(Feature.fcpsgn)] = .{
186186 .llvm_name = "fcpsgn",
187187 .description = "Enable the fcpsgn instruction",
188188 .dependencies = featureSet(&[_]Feature{
189189 .fpu,
190190 }),
191191 };
192 result[@enumToInt(Feature.float128)] = .{
192 result[@intFromEnum(Feature.float128)] = .{
193193 .llvm_name = "float128",
194194 .description = "Enable the __float128 data type for IEEE-754R Binary128.",
195195 .dependencies = featureSet(&[_]Feature{
196196 .vsx,
197197 }),
198198 };
199 result[@enumToInt(Feature.fpcvt)] = .{
199 result[@intFromEnum(Feature.fpcvt)] = .{
200200 .llvm_name = "fpcvt",
201201 .description = "Enable fc[ft]* (unsigned and single-precision) and lfiwzx instructions",
202202 .dependencies = featureSet(&[_]Feature{
203203 .fpu,
204204 }),
205205 };
206 result[@enumToInt(Feature.fprnd)] = .{
206 result[@intFromEnum(Feature.fprnd)] = .{
207207 .llvm_name = "fprnd",
208208 .description = "Enable the fri[mnpz] instructions",
209209 .dependencies = featureSet(&[_]Feature{
210210 .fpu,
211211 }),
212212 };
213 result[@enumToInt(Feature.fpu)] = .{
213 result[@intFromEnum(Feature.fpu)] = .{
214214 .llvm_name = "fpu",
215215 .description = "Enable classic FPU instructions",
216216 .dependencies = featureSet(&[_]Feature{
217217 .hard_float,
218218 }),
219219 };
220 result[@enumToInt(Feature.fre)] = .{
220 result[@intFromEnum(Feature.fre)] = .{
221221 .llvm_name = "fre",
222222 .description = "Enable the fre instruction",
223223 .dependencies = featureSet(&[_]Feature{
224224 .fpu,
225225 }),
226226 };
227 result[@enumToInt(Feature.fres)] = .{
227 result[@intFromEnum(Feature.fres)] = .{
228228 .llvm_name = "fres",
229229 .description = "Enable the fres instruction",
230230 .dependencies = featureSet(&[_]Feature{
231231 .fpu,
232232 }),
233233 };
234 result[@enumToInt(Feature.frsqrte)] = .{
234 result[@intFromEnum(Feature.frsqrte)] = .{
235235 .llvm_name = "frsqrte",
236236 .description = "Enable the frsqrte instruction",
237237 .dependencies = featureSet(&[_]Feature{
238238 .fpu,
239239 }),
240240 };
241 result[@enumToInt(Feature.frsqrtes)] = .{
241 result[@intFromEnum(Feature.frsqrtes)] = .{
242242 .llvm_name = "frsqrtes",
243243 .description = "Enable the frsqrtes instruction",
244244 .dependencies = featureSet(&[_]Feature{
245245 .fpu,
246246 }),
247247 };
248 result[@enumToInt(Feature.fsqrt)] = .{
248 result[@intFromEnum(Feature.fsqrt)] = .{
249249 .llvm_name = "fsqrt",
250250 .description = "Enable the fsqrt instruction",
251251 .dependencies = featureSet(&[_]Feature{
252252 .fpu,
253253 }),
254254 };
255 result[@enumToInt(Feature.fuse_add_logical)] = .{
255 result[@intFromEnum(Feature.fuse_add_logical)] = .{
256256 .llvm_name = "fuse-add-logical",
257257 .description = "Target supports Add with Logical Operations fusion",
258258 .dependencies = featureSet(&[_]Feature{
259259 .fusion,
260260 }),
261261 };
262 result[@enumToInt(Feature.fuse_addi_load)] = .{
262 result[@intFromEnum(Feature.fuse_addi_load)] = .{
263263 .llvm_name = "fuse-addi-load",
264264 .description = "Power8 Addi-Load fusion",
265265 .dependencies = featureSet(&[_]Feature{
266266 .fusion,
267267 }),
268268 };
269 result[@enumToInt(Feature.fuse_addis_load)] = .{
269 result[@intFromEnum(Feature.fuse_addis_load)] = .{
270270 .llvm_name = "fuse-addis-load",
271271 .description = "Power8 Addis-Load fusion",
272272 .dependencies = featureSet(&[_]Feature{
273273 .fusion,
274274 }),
275275 };
276 result[@enumToInt(Feature.fuse_arith_add)] = .{
276 result[@intFromEnum(Feature.fuse_arith_add)] = .{
277277 .llvm_name = "fuse-arith-add",
278278 .description = "Target supports Arithmetic Operations with Add fusion",
279279 .dependencies = featureSet(&[_]Feature{
280280 .fusion,
281281 }),
282282 };
283 result[@enumToInt(Feature.fuse_back2back)] = .{
283 result[@intFromEnum(Feature.fuse_back2back)] = .{
284284 .llvm_name = "fuse-back2back",
285285 .description = "Target supports general back to back fusion",
286286 .dependencies = featureSet(&[_]Feature{
287287 .fusion,
288288 }),
289289 };
290 result[@enumToInt(Feature.fuse_cmp)] = .{
290 result[@intFromEnum(Feature.fuse_cmp)] = .{
291291 .llvm_name = "fuse-cmp",
292292 .description = "Target supports Comparison Operations fusion",
293293 .dependencies = featureSet(&[_]Feature{
294294 .fusion,
295295 }),
296296 };
297 result[@enumToInt(Feature.fuse_logical)] = .{
297 result[@intFromEnum(Feature.fuse_logical)] = .{
298298 .llvm_name = "fuse-logical",
299299 .description = "Target supports Logical Operations fusion",
300300 .dependencies = featureSet(&[_]Feature{
301301 .fusion,
302302 }),
303303 };
304 result[@enumToInt(Feature.fuse_logical_add)] = .{
304 result[@intFromEnum(Feature.fuse_logical_add)] = .{
305305 .llvm_name = "fuse-logical-add",
306306 .description = "Target supports Logical with Add Operations fusion",
307307 .dependencies = featureSet(&[_]Feature{
308308 .fusion,
309309 }),
310310 };
311 result[@enumToInt(Feature.fuse_sha3)] = .{
311 result[@intFromEnum(Feature.fuse_sha3)] = .{
312312 .llvm_name = "fuse-sha3",
313313 .description = "Target supports SHA3 assist fusion",
314314 .dependencies = featureSet(&[_]Feature{
315315 .fusion,
316316 }),
317317 };
318 result[@enumToInt(Feature.fuse_store)] = .{
318 result[@intFromEnum(Feature.fuse_store)] = .{
319319 .llvm_name = "fuse-store",
320320 .description = "Target supports store clustering",
321321 .dependencies = featureSet(&[_]Feature{
322322 .fusion,
323323 }),
324324 };
325 result[@enumToInt(Feature.fuse_wideimm)] = .{
325 result[@intFromEnum(Feature.fuse_wideimm)] = .{
326326 .llvm_name = "fuse-wideimm",
327327 .description = "Target supports Wide-Immediate fusion",
328328 .dependencies = featureSet(&[_]Feature{
329329 .fusion,
330330 }),
331331 };
332 result[@enumToInt(Feature.fuse_zeromove)] = .{
332 result[@intFromEnum(Feature.fuse_zeromove)] = .{
333333 .llvm_name = "fuse-zeromove",
334334 .description = "Target supports move to SPR with branch fusion",
335335 .dependencies = featureSet(&[_]Feature{
336336 .fusion,
337337 }),
338338 };
339 result[@enumToInt(Feature.fusion)] = .{
339 result[@intFromEnum(Feature.fusion)] = .{
340340 .llvm_name = "fusion",
341341 .description = "Target supports instruction fusion",
342342 .dependencies = featureSet(&[_]Feature{}),
343343 };
344 result[@enumToInt(Feature.hard_float)] = .{
344 result[@intFromEnum(Feature.hard_float)] = .{
345345 .llvm_name = "hard-float",
346346 .description = "Enable floating-point instructions",
347347 .dependencies = featureSet(&[_]Feature{}),
348348 };
349 result[@enumToInt(Feature.htm)] = .{
349 result[@intFromEnum(Feature.htm)] = .{
350350 .llvm_name = "htm",
351351 .description = "Enable Hardware Transactional Memory instructions",
352352 .dependencies = featureSet(&[_]Feature{}),
353353 };
354 result[@enumToInt(Feature.icbt)] = .{
354 result[@intFromEnum(Feature.icbt)] = .{
355355 .llvm_name = "icbt",
356356 .description = "Enable icbt instruction",
357357 .dependencies = featureSet(&[_]Feature{}),
358358 };
359 result[@enumToInt(Feature.invariant_function_descriptors)] = .{
359 result[@intFromEnum(Feature.invariant_function_descriptors)] = .{
360360 .llvm_name = "invariant-function-descriptors",
361361 .description = "Assume function descriptors are invariant",
362362 .dependencies = featureSet(&[_]Feature{}),
363363 };
364 result[@enumToInt(Feature.isa_future_instructions)] = .{
364 result[@intFromEnum(Feature.isa_future_instructions)] = .{
365365 .llvm_name = "isa-future-instructions",
366366 .description = "Enable instructions for Future ISA.",
367367 .dependencies = featureSet(&[_]Feature{
368368 .isa_v31_instructions,
369369 }),
370370 };
371 result[@enumToInt(Feature.isa_v206_instructions)] = .{
371 result[@intFromEnum(Feature.isa_v206_instructions)] = .{
372372 .llvm_name = "isa-v206-instructions",
373373 .description = "Enable instructions in ISA 2.06.",
374374 .dependencies = featureSet(&[_]Feature{}),
375375 };
376 result[@enumToInt(Feature.isa_v207_instructions)] = .{
376 result[@intFromEnum(Feature.isa_v207_instructions)] = .{
377377 .llvm_name = "isa-v207-instructions",
378378 .description = "Enable instructions in ISA 2.07.",
379379 .dependencies = featureSet(&[_]Feature{}),
380380 };
381 result[@enumToInt(Feature.isa_v30_instructions)] = .{
381 result[@intFromEnum(Feature.isa_v30_instructions)] = .{
382382 .llvm_name = "isa-v30-instructions",
383383 .description = "Enable instructions in ISA 3.0.",
384384 .dependencies = featureSet(&[_]Feature{
385385 .isa_v207_instructions,
386386 }),
387387 };
388 result[@enumToInt(Feature.isa_v31_instructions)] = .{
388 result[@intFromEnum(Feature.isa_v31_instructions)] = .{
389389 .llvm_name = "isa-v31-instructions",
390390 .description = "Enable instructions in ISA 3.1.",
391391 .dependencies = featureSet(&[_]Feature{
392392 .isa_v30_instructions,
393393 }),
394394 };
395 result[@enumToInt(Feature.isel)] = .{
395 result[@intFromEnum(Feature.isel)] = .{
396396 .llvm_name = "isel",
397397 .description = "Enable the isel instruction",
398398 .dependencies = featureSet(&[_]Feature{}),
399399 };
400 result[@enumToInt(Feature.ldbrx)] = .{
400 result[@intFromEnum(Feature.ldbrx)] = .{
401401 .llvm_name = "ldbrx",
402402 .description = "Enable the ldbrx instruction",
403403 .dependencies = featureSet(&[_]Feature{}),
404404 };
405 result[@enumToInt(Feature.lfiwax)] = .{
405 result[@intFromEnum(Feature.lfiwax)] = .{
406406 .llvm_name = "lfiwax",
407407 .description = "Enable the lfiwax instruction",
408408 .dependencies = featureSet(&[_]Feature{
409409 .fpu,
410410 }),
411411 };
412 result[@enumToInt(Feature.longcall)] = .{
412 result[@intFromEnum(Feature.longcall)] = .{
413413 .llvm_name = "longcall",
414414 .description = "Always use indirect calls",
415415 .dependencies = featureSet(&[_]Feature{}),
416416 };
417 result[@enumToInt(Feature.mfocrf)] = .{
417 result[@intFromEnum(Feature.mfocrf)] = .{
418418 .llvm_name = "mfocrf",
419419 .description = "Enable the MFOCRF instruction",
420420 .dependencies = featureSet(&[_]Feature{}),
421421 };
422 result[@enumToInt(Feature.mma)] = .{
422 result[@intFromEnum(Feature.mma)] = .{
423423 .llvm_name = "mma",
424424 .description = "Enable MMA instructions",
425425 .dependencies = featureSet(&[_]Feature{
......@@ -428,43 +428,43 @@ pub const all_features = blk: {
428428 .power9_altivec,
429429 }),
430430 };
431 result[@enumToInt(Feature.modern_aix_as)] = .{
431 result[@intFromEnum(Feature.modern_aix_as)] = .{
432432 .llvm_name = "modern-aix-as",
433433 .description = "AIX system assembler is modern enough to support new mnes",
434434 .dependencies = featureSet(&[_]Feature{}),
435435 };
436 result[@enumToInt(Feature.msync)] = .{
436 result[@intFromEnum(Feature.msync)] = .{
437437 .llvm_name = "msync",
438438 .description = "Has only the msync instruction instead of sync",
439439 .dependencies = featureSet(&[_]Feature{
440440 .booke,
441441 }),
442442 };
443 result[@enumToInt(Feature.paired_vector_memops)] = .{
443 result[@intFromEnum(Feature.paired_vector_memops)] = .{
444444 .llvm_name = "paired-vector-memops",
445445 .description = "32Byte load and store instructions",
446446 .dependencies = featureSet(&[_]Feature{
447447 .isa_v30_instructions,
448448 }),
449449 };
450 result[@enumToInt(Feature.partword_atomics)] = .{
450 result[@intFromEnum(Feature.partword_atomics)] = .{
451451 .llvm_name = "partword-atomics",
452452 .description = "Enable l[bh]arx and st[bh]cx.",
453453 .dependencies = featureSet(&[_]Feature{}),
454454 };
455 result[@enumToInt(Feature.pcrelative_memops)] = .{
455 result[@intFromEnum(Feature.pcrelative_memops)] = .{
456456 .llvm_name = "pcrelative-memops",
457457 .description = "Enable PC relative Memory Ops",
458458 .dependencies = featureSet(&[_]Feature{
459459 .prefix_instrs,
460460 }),
461461 };
462 result[@enumToInt(Feature.popcntd)] = .{
462 result[@intFromEnum(Feature.popcntd)] = .{
463463 .llvm_name = "popcntd",
464464 .description = "Enable the popcnt[dw] instructions",
465465 .dependencies = featureSet(&[_]Feature{}),
466466 };
467 result[@enumToInt(Feature.power10_vector)] = .{
467 result[@intFromEnum(Feature.power10_vector)] = .{
468468 .llvm_name = "power10-vector",
469469 .description = "Enable POWER10 vector instructions",
470470 .dependencies = featureSet(&[_]Feature{
......@@ -472,14 +472,14 @@ pub const all_features = blk: {
472472 .power9_vector,
473473 }),
474474 };
475 result[@enumToInt(Feature.power8_altivec)] = .{
475 result[@intFromEnum(Feature.power8_altivec)] = .{
476476 .llvm_name = "power8-altivec",
477477 .description = "Enable POWER8 Altivec instructions",
478478 .dependencies = featureSet(&[_]Feature{
479479 .altivec,
480480 }),
481481 };
482 result[@enumToInt(Feature.power8_vector)] = .{
482 result[@intFromEnum(Feature.power8_vector)] = .{
483483 .llvm_name = "power8-vector",
484484 .description = "Enable POWER8 vector instructions",
485485 .dependencies = featureSet(&[_]Feature{
......@@ -487,7 +487,7 @@ pub const all_features = blk: {
487487 .vsx,
488488 }),
489489 };
490 result[@enumToInt(Feature.power9_altivec)] = .{
490 result[@intFromEnum(Feature.power9_altivec)] = .{
491491 .llvm_name = "power9-altivec",
492492 .description = "Enable POWER9 Altivec instructions",
493493 .dependencies = featureSet(&[_]Feature{
......@@ -495,7 +495,7 @@ pub const all_features = blk: {
495495 .power8_altivec,
496496 }),
497497 };
498 result[@enumToInt(Feature.power9_vector)] = .{
498 result[@intFromEnum(Feature.power9_vector)] = .{
499499 .llvm_name = "power9-vector",
500500 .description = "Enable POWER9 vector instructions",
501501 .dependencies = featureSet(&[_]Feature{
......@@ -503,32 +503,32 @@ pub const all_features = blk: {
503503 .power9_altivec,
504504 }),
505505 };
506 result[@enumToInt(Feature.ppc4xx)] = .{
506 result[@intFromEnum(Feature.ppc4xx)] = .{
507507 .llvm_name = "ppc4xx",
508508 .description = "Enable PPC 4xx instructions",
509509 .dependencies = featureSet(&[_]Feature{}),
510510 };
511 result[@enumToInt(Feature.ppc6xx)] = .{
511 result[@intFromEnum(Feature.ppc6xx)] = .{
512512 .llvm_name = "ppc6xx",
513513 .description = "Enable PPC 6xx instructions",
514514 .dependencies = featureSet(&[_]Feature{}),
515515 };
516 result[@enumToInt(Feature.ppc_postra_sched)] = .{
516 result[@intFromEnum(Feature.ppc_postra_sched)] = .{
517517 .llvm_name = "ppc-postra-sched",
518518 .description = "Use PowerPC post-RA scheduling strategy",
519519 .dependencies = featureSet(&[_]Feature{}),
520520 };
521 result[@enumToInt(Feature.ppc_prera_sched)] = .{
521 result[@intFromEnum(Feature.ppc_prera_sched)] = .{
522522 .llvm_name = "ppc-prera-sched",
523523 .description = "Use PowerPC pre-RA scheduling strategy",
524524 .dependencies = featureSet(&[_]Feature{}),
525525 };
526 result[@enumToInt(Feature.predictable_select_expensive)] = .{
526 result[@intFromEnum(Feature.predictable_select_expensive)] = .{
527527 .llvm_name = "predictable-select-expensive",
528528 .description = "Prefer likely predicted branches over selects",
529529 .dependencies = featureSet(&[_]Feature{}),
530530 };
531 result[@enumToInt(Feature.prefix_instrs)] = .{
531 result[@intFromEnum(Feature.prefix_instrs)] = .{
532532 .llvm_name = "prefix-instrs",
533533 .description = "Enable prefixed instructions",
534534 .dependencies = featureSet(&[_]Feature{
......@@ -536,61 +536,61 @@ pub const all_features = blk: {
536536 .power9_altivec,
537537 }),
538538 };
539 result[@enumToInt(Feature.privileged)] = .{
539 result[@intFromEnum(Feature.privileged)] = .{
540540 .llvm_name = "privileged",
541541 .description = "Add privileged instructions",
542542 .dependencies = featureSet(&[_]Feature{}),
543543 };
544 result[@enumToInt(Feature.quadword_atomics)] = .{
544 result[@intFromEnum(Feature.quadword_atomics)] = .{
545545 .llvm_name = "quadword-atomics",
546546 .description = "Enable lqarx and stqcx.",
547547 .dependencies = featureSet(&[_]Feature{}),
548548 };
549 result[@enumToInt(Feature.recipprec)] = .{
549 result[@intFromEnum(Feature.recipprec)] = .{
550550 .llvm_name = "recipprec",
551551 .description = "Assume higher precision reciprocal estimates",
552552 .dependencies = featureSet(&[_]Feature{}),
553553 };
554 result[@enumToInt(Feature.rop_protect)] = .{
554 result[@intFromEnum(Feature.rop_protect)] = .{
555555 .llvm_name = "rop-protect",
556556 .description = "Add ROP protect",
557557 .dependencies = featureSet(&[_]Feature{}),
558558 };
559 result[@enumToInt(Feature.secure_plt)] = .{
559 result[@intFromEnum(Feature.secure_plt)] = .{
560560 .llvm_name = "secure-plt",
561561 .description = "Enable secure plt mode",
562562 .dependencies = featureSet(&[_]Feature{}),
563563 };
564 result[@enumToInt(Feature.slow_popcntd)] = .{
564 result[@intFromEnum(Feature.slow_popcntd)] = .{
565565 .llvm_name = "slow-popcntd",
566566 .description = "Has slow popcnt[dw] instructions",
567567 .dependencies = featureSet(&[_]Feature{}),
568568 };
569 result[@enumToInt(Feature.spe)] = .{
569 result[@intFromEnum(Feature.spe)] = .{
570570 .llvm_name = "spe",
571571 .description = "Enable SPE instructions",
572572 .dependencies = featureSet(&[_]Feature{
573573 .hard_float,
574574 }),
575575 };
576 result[@enumToInt(Feature.stfiwx)] = .{
576 result[@intFromEnum(Feature.stfiwx)] = .{
577577 .llvm_name = "stfiwx",
578578 .description = "Enable the stfiwx instruction",
579579 .dependencies = featureSet(&[_]Feature{
580580 .fpu,
581581 }),
582582 };
583 result[@enumToInt(Feature.two_const_nr)] = .{
583 result[@intFromEnum(Feature.two_const_nr)] = .{
584584 .llvm_name = "two-const-nr",
585585 .description = "Requires two constant Newton-Raphson computation",
586586 .dependencies = featureSet(&[_]Feature{}),
587587 };
588 result[@enumToInt(Feature.vectors_use_two_units)] = .{
588 result[@intFromEnum(Feature.vectors_use_two_units)] = .{
589589 .llvm_name = "vectors-use-two-units",
590590 .description = "Vectors use two units",
591591 .dependencies = featureSet(&[_]Feature{}),
592592 };
593 result[@enumToInt(Feature.vsx)] = .{
593 result[@intFromEnum(Feature.vsx)] = .{
594594 .llvm_name = "vsx",
595595 .description = "Enable VSX instructions",
596596 .dependencies = featureSet(&[_]Feature{
lib/std/target/riscv.zig+108-108
......@@ -124,311 +124,311 @@ pub const all_features = blk: {
124124 const len = @typeInfo(Feature).Enum.fields.len;
125125 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
126126 var result: [len]CpuFeature = undefined;
127 result[@enumToInt(Feature.@"32bit")] = .{
127 result[@intFromEnum(Feature.@"32bit")] = .{
128128 .llvm_name = "32bit",
129129 .description = "Implements RV32",
130130 .dependencies = featureSet(&[_]Feature{}),
131131 };
132 result[@enumToInt(Feature.@"64bit")] = .{
132 result[@intFromEnum(Feature.@"64bit")] = .{
133133 .llvm_name = "64bit",
134134 .description = "Implements RV64",
135135 .dependencies = featureSet(&[_]Feature{}),
136136 };
137 result[@enumToInt(Feature.a)] = .{
137 result[@intFromEnum(Feature.a)] = .{
138138 .llvm_name = "a",
139139 .description = "'A' (Atomic Instructions)",
140140 .dependencies = featureSet(&[_]Feature{}),
141141 };
142 result[@enumToInt(Feature.c)] = .{
142 result[@intFromEnum(Feature.c)] = .{
143143 .llvm_name = "c",
144144 .description = "'C' (Compressed Instructions)",
145145 .dependencies = featureSet(&[_]Feature{}),
146146 };
147 result[@enumToInt(Feature.d)] = .{
147 result[@intFromEnum(Feature.d)] = .{
148148 .llvm_name = "d",
149149 .description = "'D' (Double-Precision Floating-Point)",
150150 .dependencies = featureSet(&[_]Feature{
151151 .f,
152152 }),
153153 };
154 result[@enumToInt(Feature.e)] = .{
154 result[@intFromEnum(Feature.e)] = .{
155155 .llvm_name = "e",
156156 .description = "Implements RV32E (provides 16 rather than 32 GPRs)",
157157 .dependencies = featureSet(&[_]Feature{}),
158158 };
159 result[@enumToInt(Feature.experimental_zawrs)] = .{
159 result[@intFromEnum(Feature.experimental_zawrs)] = .{
160160 .llvm_name = "experimental-zawrs",
161161 .description = "'Zawrs' (Wait on Reservation Set)",
162162 .dependencies = featureSet(&[_]Feature{}),
163163 };
164 result[@enumToInt(Feature.experimental_zca)] = .{
164 result[@intFromEnum(Feature.experimental_zca)] = .{
165165 .llvm_name = "experimental-zca",
166166 .description = "'Zca' (part of the C extension, excluding compressed floating point loads/stores)",
167167 .dependencies = featureSet(&[_]Feature{}),
168168 };
169 result[@enumToInt(Feature.experimental_zcd)] = .{
169 result[@intFromEnum(Feature.experimental_zcd)] = .{
170170 .llvm_name = "experimental-zcd",
171171 .description = "'Zcd' (Compressed Double-Precision Floating-Point Instructions)",
172172 .dependencies = featureSet(&[_]Feature{}),
173173 };
174 result[@enumToInt(Feature.experimental_zcf)] = .{
174 result[@intFromEnum(Feature.experimental_zcf)] = .{
175175 .llvm_name = "experimental-zcf",
176176 .description = "'Zcf' (Compressed Single-Precision Floating-Point Instructions)",
177177 .dependencies = featureSet(&[_]Feature{}),
178178 };
179 result[@enumToInt(Feature.experimental_zihintntl)] = .{
179 result[@intFromEnum(Feature.experimental_zihintntl)] = .{
180180 .llvm_name = "experimental-zihintntl",
181181 .description = "'zihintntl' (Non-Temporal Locality Hints)",
182182 .dependencies = featureSet(&[_]Feature{}),
183183 };
184 result[@enumToInt(Feature.experimental_ztso)] = .{
184 result[@intFromEnum(Feature.experimental_ztso)] = .{
185185 .llvm_name = "experimental-ztso",
186186 .description = "'Ztso' (Memory Model - Total Store Order)",
187187 .dependencies = featureSet(&[_]Feature{}),
188188 };
189 result[@enumToInt(Feature.experimental_zvfh)] = .{
189 result[@intFromEnum(Feature.experimental_zvfh)] = .{
190190 .llvm_name = "experimental-zvfh",
191191 .description = "'Zvfh' (Vector Half-Precision Floating-Point)",
192192 .dependencies = featureSet(&[_]Feature{
193193 .zve32f,
194194 }),
195195 };
196 result[@enumToInt(Feature.f)] = .{
196 result[@intFromEnum(Feature.f)] = .{
197197 .llvm_name = "f",
198198 .description = "'F' (Single-Precision Floating-Point)",
199199 .dependencies = featureSet(&[_]Feature{}),
200200 };
201 result[@enumToInt(Feature.forced_atomics)] = .{
201 result[@intFromEnum(Feature.forced_atomics)] = .{
202202 .llvm_name = "forced-atomics",
203203 .description = "Assume that lock-free native-width atomics are available",
204204 .dependencies = featureSet(&[_]Feature{}),
205205 };
206 result[@enumToInt(Feature.h)] = .{
206 result[@intFromEnum(Feature.h)] = .{
207207 .llvm_name = "h",
208208 .description = "'H' (Hypervisor)",
209209 .dependencies = featureSet(&[_]Feature{}),
210210 };
211 result[@enumToInt(Feature.lui_addi_fusion)] = .{
211 result[@intFromEnum(Feature.lui_addi_fusion)] = .{
212212 .llvm_name = "lui-addi-fusion",
213213 .description = "Enable LUI+ADDI macrofusion",
214214 .dependencies = featureSet(&[_]Feature{}),
215215 };
216 result[@enumToInt(Feature.m)] = .{
216 result[@intFromEnum(Feature.m)] = .{
217217 .llvm_name = "m",
218218 .description = "'M' (Integer Multiplication and Division)",
219219 .dependencies = featureSet(&[_]Feature{}),
220220 };
221 result[@enumToInt(Feature.no_default_unroll)] = .{
221 result[@intFromEnum(Feature.no_default_unroll)] = .{
222222 .llvm_name = "no-default-unroll",
223223 .description = "Disable default unroll preference.",
224224 .dependencies = featureSet(&[_]Feature{}),
225225 };
226 result[@enumToInt(Feature.no_optimized_zero_stride_load)] = .{
226 result[@intFromEnum(Feature.no_optimized_zero_stride_load)] = .{
227227 .llvm_name = "no-optimized-zero-stride-load",
228228 .description = "Hasn't optimized (perform fewer memory operations)zero-stride vector load",
229229 .dependencies = featureSet(&[_]Feature{}),
230230 };
231 result[@enumToInt(Feature.no_rvc_hints)] = .{
231 result[@intFromEnum(Feature.no_rvc_hints)] = .{
232232 .llvm_name = "no-rvc-hints",
233233 .description = "Disable RVC Hint Instructions.",
234234 .dependencies = featureSet(&[_]Feature{}),
235235 };
236 result[@enumToInt(Feature.relax)] = .{
236 result[@intFromEnum(Feature.relax)] = .{
237237 .llvm_name = "relax",
238238 .description = "Enable Linker relaxation.",
239239 .dependencies = featureSet(&[_]Feature{}),
240240 };
241 result[@enumToInt(Feature.reserve_x1)] = .{
241 result[@intFromEnum(Feature.reserve_x1)] = .{
242242 .llvm_name = "reserve-x1",
243243 .description = "Reserve X1",
244244 .dependencies = featureSet(&[_]Feature{}),
245245 };
246 result[@enumToInt(Feature.reserve_x10)] = .{
246 result[@intFromEnum(Feature.reserve_x10)] = .{
247247 .llvm_name = "reserve-x10",
248248 .description = "Reserve X10",
249249 .dependencies = featureSet(&[_]Feature{}),
250250 };
251 result[@enumToInt(Feature.reserve_x11)] = .{
251 result[@intFromEnum(Feature.reserve_x11)] = .{
252252 .llvm_name = "reserve-x11",
253253 .description = "Reserve X11",
254254 .dependencies = featureSet(&[_]Feature{}),
255255 };
256 result[@enumToInt(Feature.reserve_x12)] = .{
256 result[@intFromEnum(Feature.reserve_x12)] = .{
257257 .llvm_name = "reserve-x12",
258258 .description = "Reserve X12",
259259 .dependencies = featureSet(&[_]Feature{}),
260260 };
261 result[@enumToInt(Feature.reserve_x13)] = .{
261 result[@intFromEnum(Feature.reserve_x13)] = .{
262262 .llvm_name = "reserve-x13",
263263 .description = "Reserve X13",
264264 .dependencies = featureSet(&[_]Feature{}),
265265 };
266 result[@enumToInt(Feature.reserve_x14)] = .{
266 result[@intFromEnum(Feature.reserve_x14)] = .{
267267 .llvm_name = "reserve-x14",
268268 .description = "Reserve X14",
269269 .dependencies = featureSet(&[_]Feature{}),
270270 };
271 result[@enumToInt(Feature.reserve_x15)] = .{
271 result[@intFromEnum(Feature.reserve_x15)] = .{
272272 .llvm_name = "reserve-x15",
273273 .description = "Reserve X15",
274274 .dependencies = featureSet(&[_]Feature{}),
275275 };
276 result[@enumToInt(Feature.reserve_x16)] = .{
276 result[@intFromEnum(Feature.reserve_x16)] = .{
277277 .llvm_name = "reserve-x16",
278278 .description = "Reserve X16",
279279 .dependencies = featureSet(&[_]Feature{}),
280280 };
281 result[@enumToInt(Feature.reserve_x17)] = .{
281 result[@intFromEnum(Feature.reserve_x17)] = .{
282282 .llvm_name = "reserve-x17",
283283 .description = "Reserve X17",
284284 .dependencies = featureSet(&[_]Feature{}),
285285 };
286 result[@enumToInt(Feature.reserve_x18)] = .{
286 result[@intFromEnum(Feature.reserve_x18)] = .{
287287 .llvm_name = "reserve-x18",
288288 .description = "Reserve X18",
289289 .dependencies = featureSet(&[_]Feature{}),
290290 };
291 result[@enumToInt(Feature.reserve_x19)] = .{
291 result[@intFromEnum(Feature.reserve_x19)] = .{
292292 .llvm_name = "reserve-x19",
293293 .description = "Reserve X19",
294294 .dependencies = featureSet(&[_]Feature{}),
295295 };
296 result[@enumToInt(Feature.reserve_x2)] = .{
296 result[@intFromEnum(Feature.reserve_x2)] = .{
297297 .llvm_name = "reserve-x2",
298298 .description = "Reserve X2",
299299 .dependencies = featureSet(&[_]Feature{}),
300300 };
301 result[@enumToInt(Feature.reserve_x20)] = .{
301 result[@intFromEnum(Feature.reserve_x20)] = .{
302302 .llvm_name = "reserve-x20",
303303 .description = "Reserve X20",
304304 .dependencies = featureSet(&[_]Feature{}),
305305 };
306 result[@enumToInt(Feature.reserve_x21)] = .{
306 result[@intFromEnum(Feature.reserve_x21)] = .{
307307 .llvm_name = "reserve-x21",
308308 .description = "Reserve X21",
309309 .dependencies = featureSet(&[_]Feature{}),
310310 };
311 result[@enumToInt(Feature.reserve_x22)] = .{
311 result[@intFromEnum(Feature.reserve_x22)] = .{
312312 .llvm_name = "reserve-x22",
313313 .description = "Reserve X22",
314314 .dependencies = featureSet(&[_]Feature{}),
315315 };
316 result[@enumToInt(Feature.reserve_x23)] = .{
316 result[@intFromEnum(Feature.reserve_x23)] = .{
317317 .llvm_name = "reserve-x23",
318318 .description = "Reserve X23",
319319 .dependencies = featureSet(&[_]Feature{}),
320320 };
321 result[@enumToInt(Feature.reserve_x24)] = .{
321 result[@intFromEnum(Feature.reserve_x24)] = .{
322322 .llvm_name = "reserve-x24",
323323 .description = "Reserve X24",
324324 .dependencies = featureSet(&[_]Feature{}),
325325 };
326 result[@enumToInt(Feature.reserve_x25)] = .{
326 result[@intFromEnum(Feature.reserve_x25)] = .{
327327 .llvm_name = "reserve-x25",
328328 .description = "Reserve X25",
329329 .dependencies = featureSet(&[_]Feature{}),
330330 };
331 result[@enumToInt(Feature.reserve_x26)] = .{
331 result[@intFromEnum(Feature.reserve_x26)] = .{
332332 .llvm_name = "reserve-x26",
333333 .description = "Reserve X26",
334334 .dependencies = featureSet(&[_]Feature{}),
335335 };
336 result[@enumToInt(Feature.reserve_x27)] = .{
336 result[@intFromEnum(Feature.reserve_x27)] = .{
337337 .llvm_name = "reserve-x27",
338338 .description = "Reserve X27",
339339 .dependencies = featureSet(&[_]Feature{}),
340340 };
341 result[@enumToInt(Feature.reserve_x28)] = .{
341 result[@intFromEnum(Feature.reserve_x28)] = .{
342342 .llvm_name = "reserve-x28",
343343 .description = "Reserve X28",
344344 .dependencies = featureSet(&[_]Feature{}),
345345 };
346 result[@enumToInt(Feature.reserve_x29)] = .{
346 result[@intFromEnum(Feature.reserve_x29)] = .{
347347 .llvm_name = "reserve-x29",
348348 .description = "Reserve X29",
349349 .dependencies = featureSet(&[_]Feature{}),
350350 };
351 result[@enumToInt(Feature.reserve_x3)] = .{
351 result[@intFromEnum(Feature.reserve_x3)] = .{
352352 .llvm_name = "reserve-x3",
353353 .description = "Reserve X3",
354354 .dependencies = featureSet(&[_]Feature{}),
355355 };
356 result[@enumToInt(Feature.reserve_x30)] = .{
356 result[@intFromEnum(Feature.reserve_x30)] = .{
357357 .llvm_name = "reserve-x30",
358358 .description = "Reserve X30",
359359 .dependencies = featureSet(&[_]Feature{}),
360360 };
361 result[@enumToInt(Feature.reserve_x31)] = .{
361 result[@intFromEnum(Feature.reserve_x31)] = .{
362362 .llvm_name = "reserve-x31",
363363 .description = "Reserve X31",
364364 .dependencies = featureSet(&[_]Feature{}),
365365 };
366 result[@enumToInt(Feature.reserve_x4)] = .{
366 result[@intFromEnum(Feature.reserve_x4)] = .{
367367 .llvm_name = "reserve-x4",
368368 .description = "Reserve X4",
369369 .dependencies = featureSet(&[_]Feature{}),
370370 };
371 result[@enumToInt(Feature.reserve_x5)] = .{
371 result[@intFromEnum(Feature.reserve_x5)] = .{
372372 .llvm_name = "reserve-x5",
373373 .description = "Reserve X5",
374374 .dependencies = featureSet(&[_]Feature{}),
375375 };
376 result[@enumToInt(Feature.reserve_x6)] = .{
376 result[@intFromEnum(Feature.reserve_x6)] = .{
377377 .llvm_name = "reserve-x6",
378378 .description = "Reserve X6",
379379 .dependencies = featureSet(&[_]Feature{}),
380380 };
381 result[@enumToInt(Feature.reserve_x7)] = .{
381 result[@intFromEnum(Feature.reserve_x7)] = .{
382382 .llvm_name = "reserve-x7",
383383 .description = "Reserve X7",
384384 .dependencies = featureSet(&[_]Feature{}),
385385 };
386 result[@enumToInt(Feature.reserve_x8)] = .{
386 result[@intFromEnum(Feature.reserve_x8)] = .{
387387 .llvm_name = "reserve-x8",
388388 .description = "Reserve X8",
389389 .dependencies = featureSet(&[_]Feature{}),
390390 };
391 result[@enumToInt(Feature.reserve_x9)] = .{
391 result[@intFromEnum(Feature.reserve_x9)] = .{
392392 .llvm_name = "reserve-x9",
393393 .description = "Reserve X9",
394394 .dependencies = featureSet(&[_]Feature{}),
395395 };
396 result[@enumToInt(Feature.save_restore)] = .{
396 result[@intFromEnum(Feature.save_restore)] = .{
397397 .llvm_name = "save-restore",
398398 .description = "Enable save/restore.",
399399 .dependencies = featureSet(&[_]Feature{}),
400400 };
401 result[@enumToInt(Feature.short_forward_branch_opt)] = .{
401 result[@intFromEnum(Feature.short_forward_branch_opt)] = .{
402402 .llvm_name = "short-forward-branch-opt",
403403 .description = "Enable short forward branch optimization",
404404 .dependencies = featureSet(&[_]Feature{}),
405405 };
406 result[@enumToInt(Feature.svinval)] = .{
406 result[@intFromEnum(Feature.svinval)] = .{
407407 .llvm_name = "svinval",
408408 .description = "'Svinval' (Fine-Grained Address-Translation Cache Invalidation)",
409409 .dependencies = featureSet(&[_]Feature{}),
410410 };
411 result[@enumToInt(Feature.svnapot)] = .{
411 result[@intFromEnum(Feature.svnapot)] = .{
412412 .llvm_name = "svnapot",
413413 .description = "'Svnapot' (NAPOT Translation Contiguity)",
414414 .dependencies = featureSet(&[_]Feature{}),
415415 };
416 result[@enumToInt(Feature.svpbmt)] = .{
416 result[@intFromEnum(Feature.svpbmt)] = .{
417417 .llvm_name = "svpbmt",
418418 .description = "'Svpbmt' (Page-Based Memory Types)",
419419 .dependencies = featureSet(&[_]Feature{}),
420420 };
421 result[@enumToInt(Feature.tagged_globals)] = .{
421 result[@intFromEnum(Feature.tagged_globals)] = .{
422422 .llvm_name = "tagged-globals",
423423 .description = "Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits",
424424 .dependencies = featureSet(&[_]Feature{}),
425425 };
426 result[@enumToInt(Feature.unaligned_scalar_mem)] = .{
426 result[@intFromEnum(Feature.unaligned_scalar_mem)] = .{
427427 .llvm_name = "unaligned-scalar-mem",
428428 .description = "Has reasonably performant unaligned scalar loads and stores",
429429 .dependencies = featureSet(&[_]Feature{}),
430430 };
431 result[@enumToInt(Feature.v)] = .{
431 result[@intFromEnum(Feature.v)] = .{
432432 .llvm_name = "v",
433433 .description = "'V' (Vector Extension for Application Processors)",
434434 .dependencies = featureSet(&[_]Feature{
......@@ -437,114 +437,114 @@ pub const all_features = blk: {
437437 .zvl128b,
438438 }),
439439 };
440 result[@enumToInt(Feature.xtheadvdot)] = .{
440 result[@intFromEnum(Feature.xtheadvdot)] = .{
441441 .llvm_name = "xtheadvdot",
442442 .description = "'xtheadvdot' (T-Head Vector Extensions for Dot)",
443443 .dependencies = featureSet(&[_]Feature{
444444 .v,
445445 }),
446446 };
447 result[@enumToInt(Feature.xventanacondops)] = .{
447 result[@intFromEnum(Feature.xventanacondops)] = .{
448448 .llvm_name = "xventanacondops",
449449 .description = "'XVentanaCondOps' (Ventana Conditional Ops)",
450450 .dependencies = featureSet(&[_]Feature{}),
451451 };
452 result[@enumToInt(Feature.zba)] = .{
452 result[@intFromEnum(Feature.zba)] = .{
453453 .llvm_name = "zba",
454454 .description = "'Zba' (Address Generation Instructions)",
455455 .dependencies = featureSet(&[_]Feature{}),
456456 };
457 result[@enumToInt(Feature.zbb)] = .{
457 result[@intFromEnum(Feature.zbb)] = .{
458458 .llvm_name = "zbb",
459459 .description = "'Zbb' (Basic Bit-Manipulation)",
460460 .dependencies = featureSet(&[_]Feature{}),
461461 };
462 result[@enumToInt(Feature.zbc)] = .{
462 result[@intFromEnum(Feature.zbc)] = .{
463463 .llvm_name = "zbc",
464464 .description = "'Zbc' (Carry-Less Multiplication)",
465465 .dependencies = featureSet(&[_]Feature{}),
466466 };
467 result[@enumToInt(Feature.zbkb)] = .{
467 result[@intFromEnum(Feature.zbkb)] = .{
468468 .llvm_name = "zbkb",
469469 .description = "'Zbkb' (Bitmanip instructions for Cryptography)",
470470 .dependencies = featureSet(&[_]Feature{}),
471471 };
472 result[@enumToInt(Feature.zbkc)] = .{
472 result[@intFromEnum(Feature.zbkc)] = .{
473473 .llvm_name = "zbkc",
474474 .description = "'Zbkc' (Carry-less multiply instructions for Cryptography)",
475475 .dependencies = featureSet(&[_]Feature{}),
476476 };
477 result[@enumToInt(Feature.zbkx)] = .{
477 result[@intFromEnum(Feature.zbkx)] = .{
478478 .llvm_name = "zbkx",
479479 .description = "'Zbkx' (Crossbar permutation instructions)",
480480 .dependencies = featureSet(&[_]Feature{}),
481481 };
482 result[@enumToInt(Feature.zbs)] = .{
482 result[@intFromEnum(Feature.zbs)] = .{
483483 .llvm_name = "zbs",
484484 .description = "'Zbs' (Single-Bit Instructions)",
485485 .dependencies = featureSet(&[_]Feature{}),
486486 };
487 result[@enumToInt(Feature.zdinx)] = .{
487 result[@intFromEnum(Feature.zdinx)] = .{
488488 .llvm_name = "zdinx",
489489 .description = "'Zdinx' (Double in Integer)",
490490 .dependencies = featureSet(&[_]Feature{
491491 .zfinx,
492492 }),
493493 };
494 result[@enumToInt(Feature.zfh)] = .{
494 result[@intFromEnum(Feature.zfh)] = .{
495495 .llvm_name = "zfh",
496496 .description = "'Zfh' (Half-Precision Floating-Point)",
497497 .dependencies = featureSet(&[_]Feature{
498498 .f,
499499 }),
500500 };
501 result[@enumToInt(Feature.zfhmin)] = .{
501 result[@intFromEnum(Feature.zfhmin)] = .{
502502 .llvm_name = "zfhmin",
503503 .description = "'Zfhmin' (Half-Precision Floating-Point Minimal)",
504504 .dependencies = featureSet(&[_]Feature{
505505 .f,
506506 }),
507507 };
508 result[@enumToInt(Feature.zfinx)] = .{
508 result[@intFromEnum(Feature.zfinx)] = .{
509509 .llvm_name = "zfinx",
510510 .description = "'Zfinx' (Float in Integer)",
511511 .dependencies = featureSet(&[_]Feature{}),
512512 };
513 result[@enumToInt(Feature.zhinx)] = .{
513 result[@intFromEnum(Feature.zhinx)] = .{
514514 .llvm_name = "zhinx",
515515 .description = "'Zhinx' (Half Float in Integer)",
516516 .dependencies = featureSet(&[_]Feature{
517517 .zfinx,
518518 }),
519519 };
520 result[@enumToInt(Feature.zhinxmin)] = .{
520 result[@intFromEnum(Feature.zhinxmin)] = .{
521521 .llvm_name = "zhinxmin",
522522 .description = "'Zhinxmin' (Half Float in Integer Minimal)",
523523 .dependencies = featureSet(&[_]Feature{
524524 .zfinx,
525525 }),
526526 };
527 result[@enumToInt(Feature.zicbom)] = .{
527 result[@intFromEnum(Feature.zicbom)] = .{
528528 .llvm_name = "zicbom",
529529 .description = "'Zicbom' (Cache-Block Management Instructions)",
530530 .dependencies = featureSet(&[_]Feature{}),
531531 };
532 result[@enumToInt(Feature.zicbop)] = .{
532 result[@intFromEnum(Feature.zicbop)] = .{
533533 .llvm_name = "zicbop",
534534 .description = "'Zicbop' (Cache-Block Prefetch Instructions)",
535535 .dependencies = featureSet(&[_]Feature{}),
536536 };
537 result[@enumToInt(Feature.zicboz)] = .{
537 result[@intFromEnum(Feature.zicboz)] = .{
538538 .llvm_name = "zicboz",
539539 .description = "'Zicboz' (Cache-Block Zero Instructions)",
540540 .dependencies = featureSet(&[_]Feature{}),
541541 };
542 result[@enumToInt(Feature.zihintpause)] = .{
542 result[@intFromEnum(Feature.zihintpause)] = .{
543543 .llvm_name = "zihintpause",
544544 .description = "'zihintpause' (Pause Hint)",
545545 .dependencies = featureSet(&[_]Feature{}),
546546 };
547 result[@enumToInt(Feature.zk)] = .{
547 result[@intFromEnum(Feature.zk)] = .{
548548 .llvm_name = "zk",
549549 .description = "'Zk' (Standard scalar cryptography extension)",
550550 .dependencies = featureSet(&[_]Feature{
......@@ -553,7 +553,7 @@ pub const all_features = blk: {
553553 .zkt,
554554 }),
555555 };
556 result[@enumToInt(Feature.zkn)] = .{
556 result[@intFromEnum(Feature.zkn)] = .{
557557 .llvm_name = "zkn",
558558 .description = "'Zkn' (NIST Algorithm Suite)",
559559 .dependencies = featureSet(&[_]Feature{
......@@ -565,27 +565,27 @@ pub const all_features = blk: {
565565 .zknh,
566566 }),
567567 };
568 result[@enumToInt(Feature.zknd)] = .{
568 result[@intFromEnum(Feature.zknd)] = .{
569569 .llvm_name = "zknd",
570570 .description = "'Zknd' (NIST Suite: AES Decryption)",
571571 .dependencies = featureSet(&[_]Feature{}),
572572 };
573 result[@enumToInt(Feature.zkne)] = .{
573 result[@intFromEnum(Feature.zkne)] = .{
574574 .llvm_name = "zkne",
575575 .description = "'Zkne' (NIST Suite: AES Encryption)",
576576 .dependencies = featureSet(&[_]Feature{}),
577577 };
578 result[@enumToInt(Feature.zknh)] = .{
578 result[@intFromEnum(Feature.zknh)] = .{
579579 .llvm_name = "zknh",
580580 .description = "'Zknh' (NIST Suite: Hash Function Instructions)",
581581 .dependencies = featureSet(&[_]Feature{}),
582582 };
583 result[@enumToInt(Feature.zkr)] = .{
583 result[@intFromEnum(Feature.zkr)] = .{
584584 .llvm_name = "zkr",
585585 .description = "'Zkr' (Entropy Source Extension)",
586586 .dependencies = featureSet(&[_]Feature{}),
587587 };
588 result[@enumToInt(Feature.zks)] = .{
588 result[@intFromEnum(Feature.zks)] = .{
589589 .llvm_name = "zks",
590590 .description = "'Zks' (ShangMi Algorithm Suite)",
591591 .dependencies = featureSet(&[_]Feature{
......@@ -596,48 +596,48 @@ pub const all_features = blk: {
596596 .zksh,
597597 }),
598598 };
599 result[@enumToInt(Feature.zksed)] = .{
599 result[@intFromEnum(Feature.zksed)] = .{
600600 .llvm_name = "zksed",
601601 .description = "'Zksed' (ShangMi Suite: SM4 Block Cipher Instructions)",
602602 .dependencies = featureSet(&[_]Feature{}),
603603 };
604 result[@enumToInt(Feature.zksh)] = .{
604 result[@intFromEnum(Feature.zksh)] = .{
605605 .llvm_name = "zksh",
606606 .description = "'Zksh' (ShangMi Suite: SM3 Hash Function Instructions)",
607607 .dependencies = featureSet(&[_]Feature{}),
608608 };
609 result[@enumToInt(Feature.zkt)] = .{
609 result[@intFromEnum(Feature.zkt)] = .{
610610 .llvm_name = "zkt",
611611 .description = "'Zkt' (Data Independent Execution Latency)",
612612 .dependencies = featureSet(&[_]Feature{}),
613613 };
614 result[@enumToInt(Feature.zmmul)] = .{
614 result[@intFromEnum(Feature.zmmul)] = .{
615615 .llvm_name = "zmmul",
616616 .description = "'Zmmul' (Integer Multiplication)",
617617 .dependencies = featureSet(&[_]Feature{}),
618618 };
619 result[@enumToInt(Feature.zve32f)] = .{
619 result[@intFromEnum(Feature.zve32f)] = .{
620620 .llvm_name = "zve32f",
621621 .description = "'Zve32f' (Vector Extensions for Embedded Processors with maximal 32 EEW and F extension)",
622622 .dependencies = featureSet(&[_]Feature{
623623 .zve32x,
624624 }),
625625 };
626 result[@enumToInt(Feature.zve32x)] = .{
626 result[@intFromEnum(Feature.zve32x)] = .{
627627 .llvm_name = "zve32x",
628628 .description = "'Zve32x' (Vector Extensions for Embedded Processors with maximal 32 EEW)",
629629 .dependencies = featureSet(&[_]Feature{
630630 .zvl32b,
631631 }),
632632 };
633 result[@enumToInt(Feature.zve64d)] = .{
633 result[@intFromEnum(Feature.zve64d)] = .{
634634 .llvm_name = "zve64d",
635635 .description = "'Zve64d' (Vector Extensions for Embedded Processors with maximal 64 EEW, F and D extension)",
636636 .dependencies = featureSet(&[_]Feature{
637637 .zve64f,
638638 }),
639639 };
640 result[@enumToInt(Feature.zve64f)] = .{
640 result[@intFromEnum(Feature.zve64f)] = .{
641641 .llvm_name = "zve64f",
642642 .description = "'Zve64f' (Vector Extensions for Embedded Processors with maximal 64 EEW and F extension)",
643643 .dependencies = featureSet(&[_]Feature{
......@@ -645,7 +645,7 @@ pub const all_features = blk: {
645645 .zve64x,
646646 }),
647647 };
648 result[@enumToInt(Feature.zve64x)] = .{
648 result[@intFromEnum(Feature.zve64x)] = .{
649649 .llvm_name = "zve64x",
650650 .description = "'Zve64x' (Vector Extensions for Embedded Processors with maximal 64 EEW)",
651651 .dependencies = featureSet(&[_]Feature{
......@@ -653,82 +653,82 @@ pub const all_features = blk: {
653653 .zvl64b,
654654 }),
655655 };
656 result[@enumToInt(Feature.zvl1024b)] = .{
656 result[@intFromEnum(Feature.zvl1024b)] = .{
657657 .llvm_name = "zvl1024b",
658658 .description = "'Zvl' (Minimum Vector Length) 1024",
659659 .dependencies = featureSet(&[_]Feature{
660660 .zvl512b,
661661 }),
662662 };
663 result[@enumToInt(Feature.zvl128b)] = .{
663 result[@intFromEnum(Feature.zvl128b)] = .{
664664 .llvm_name = "zvl128b",
665665 .description = "'Zvl' (Minimum Vector Length) 128",
666666 .dependencies = featureSet(&[_]Feature{
667667 .zvl64b,
668668 }),
669669 };
670 result[@enumToInt(Feature.zvl16384b)] = .{
670 result[@intFromEnum(Feature.zvl16384b)] = .{
671671 .llvm_name = "zvl16384b",
672672 .description = "'Zvl' (Minimum Vector Length) 16384",
673673 .dependencies = featureSet(&[_]Feature{
674674 .zvl8192b,
675675 }),
676676 };
677 result[@enumToInt(Feature.zvl2048b)] = .{
677 result[@intFromEnum(Feature.zvl2048b)] = .{
678678 .llvm_name = "zvl2048b",
679679 .description = "'Zvl' (Minimum Vector Length) 2048",
680680 .dependencies = featureSet(&[_]Feature{
681681 .zvl1024b,
682682 }),
683683 };
684 result[@enumToInt(Feature.zvl256b)] = .{
684 result[@intFromEnum(Feature.zvl256b)] = .{
685685 .llvm_name = "zvl256b",
686686 .description = "'Zvl' (Minimum Vector Length) 256",
687687 .dependencies = featureSet(&[_]Feature{
688688 .zvl128b,
689689 }),
690690 };
691 result[@enumToInt(Feature.zvl32768b)] = .{
691 result[@intFromEnum(Feature.zvl32768b)] = .{
692692 .llvm_name = "zvl32768b",
693693 .description = "'Zvl' (Minimum Vector Length) 32768",
694694 .dependencies = featureSet(&[_]Feature{
695695 .zvl16384b,
696696 }),
697697 };
698 result[@enumToInt(Feature.zvl32b)] = .{
698 result[@intFromEnum(Feature.zvl32b)] = .{
699699 .llvm_name = "zvl32b",
700700 .description = "'Zvl' (Minimum Vector Length) 32",
701701 .dependencies = featureSet(&[_]Feature{}),
702702 };
703 result[@enumToInt(Feature.zvl4096b)] = .{
703 result[@intFromEnum(Feature.zvl4096b)] = .{
704704 .llvm_name = "zvl4096b",
705705 .description = "'Zvl' (Minimum Vector Length) 4096",
706706 .dependencies = featureSet(&[_]Feature{
707707 .zvl2048b,
708708 }),
709709 };
710 result[@enumToInt(Feature.zvl512b)] = .{
710 result[@intFromEnum(Feature.zvl512b)] = .{
711711 .llvm_name = "zvl512b",
712712 .description = "'Zvl' (Minimum Vector Length) 512",
713713 .dependencies = featureSet(&[_]Feature{
714714 .zvl256b,
715715 }),
716716 };
717 result[@enumToInt(Feature.zvl64b)] = .{
717 result[@intFromEnum(Feature.zvl64b)] = .{
718718 .llvm_name = "zvl64b",
719719 .description = "'Zvl' (Minimum Vector Length) 64",
720720 .dependencies = featureSet(&[_]Feature{
721721 .zvl32b,
722722 }),
723723 };
724 result[@enumToInt(Feature.zvl65536b)] = .{
724 result[@intFromEnum(Feature.zvl65536b)] = .{
725725 .llvm_name = "zvl65536b",
726726 .description = "'Zvl' (Minimum Vector Length) 65536",
727727 .dependencies = featureSet(&[_]Feature{
728728 .zvl32768b,
729729 }),
730730 };
731 result[@enumToInt(Feature.zvl8192b)] = .{
731 result[@intFromEnum(Feature.zvl8192b)] = .{
732732 .llvm_name = "zvl8192b",
733733 .description = "'Zvl' (Minimum Vector Length) 8192",
734734 .dependencies = featureSet(&[_]Feature{
lib/std/target/s390x.zig+41-41
......@@ -57,207 +57,207 @@ pub const all_features = blk: {
5757 const len = @typeInfo(Feature).Enum.fields.len;
5858 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
5959 var result: [len]CpuFeature = undefined;
60 result[@enumToInt(Feature.bear_enhancement)] = .{
60 result[@intFromEnum(Feature.bear_enhancement)] = .{
6161 .llvm_name = "bear-enhancement",
6262 .description = "Assume that the BEAR-enhancement facility is installed",
6363 .dependencies = featureSet(&[_]Feature{}),
6464 };
65 result[@enumToInt(Feature.deflate_conversion)] = .{
65 result[@intFromEnum(Feature.deflate_conversion)] = .{
6666 .llvm_name = "deflate-conversion",
6767 .description = "Assume that the deflate-conversion facility is installed",
6868 .dependencies = featureSet(&[_]Feature{}),
6969 };
70 result[@enumToInt(Feature.dfp_packed_conversion)] = .{
70 result[@intFromEnum(Feature.dfp_packed_conversion)] = .{
7171 .llvm_name = "dfp-packed-conversion",
7272 .description = "Assume that the DFP packed-conversion facility is installed",
7373 .dependencies = featureSet(&[_]Feature{}),
7474 };
75 result[@enumToInt(Feature.dfp_zoned_conversion)] = .{
75 result[@intFromEnum(Feature.dfp_zoned_conversion)] = .{
7676 .llvm_name = "dfp-zoned-conversion",
7777 .description = "Assume that the DFP zoned-conversion facility is installed",
7878 .dependencies = featureSet(&[_]Feature{}),
7979 };
80 result[@enumToInt(Feature.distinct_ops)] = .{
80 result[@intFromEnum(Feature.distinct_ops)] = .{
8181 .llvm_name = "distinct-ops",
8282 .description = "Assume that the distinct-operands facility is installed",
8383 .dependencies = featureSet(&[_]Feature{}),
8484 };
85 result[@enumToInt(Feature.enhanced_dat_2)] = .{
85 result[@intFromEnum(Feature.enhanced_dat_2)] = .{
8686 .llvm_name = "enhanced-dat-2",
8787 .description = "Assume that the enhanced-DAT facility 2 is installed",
8888 .dependencies = featureSet(&[_]Feature{}),
8989 };
90 result[@enumToInt(Feature.enhanced_sort)] = .{
90 result[@intFromEnum(Feature.enhanced_sort)] = .{
9191 .llvm_name = "enhanced-sort",
9292 .description = "Assume that the enhanced-sort facility is installed",
9393 .dependencies = featureSet(&[_]Feature{}),
9494 };
95 result[@enumToInt(Feature.execution_hint)] = .{
95 result[@intFromEnum(Feature.execution_hint)] = .{
9696 .llvm_name = "execution-hint",
9797 .description = "Assume that the execution-hint facility is installed",
9898 .dependencies = featureSet(&[_]Feature{}),
9999 };
100 result[@enumToInt(Feature.fast_serialization)] = .{
100 result[@intFromEnum(Feature.fast_serialization)] = .{
101101 .llvm_name = "fast-serialization",
102102 .description = "Assume that the fast-serialization facility is installed",
103103 .dependencies = featureSet(&[_]Feature{}),
104104 };
105 result[@enumToInt(Feature.fp_extension)] = .{
105 result[@intFromEnum(Feature.fp_extension)] = .{
106106 .llvm_name = "fp-extension",
107107 .description = "Assume that the floating-point extension facility is installed",
108108 .dependencies = featureSet(&[_]Feature{}),
109109 };
110 result[@enumToInt(Feature.guarded_storage)] = .{
110 result[@intFromEnum(Feature.guarded_storage)] = .{
111111 .llvm_name = "guarded-storage",
112112 .description = "Assume that the guarded-storage facility is installed",
113113 .dependencies = featureSet(&[_]Feature{}),
114114 };
115 result[@enumToInt(Feature.high_word)] = .{
115 result[@intFromEnum(Feature.high_word)] = .{
116116 .llvm_name = "high-word",
117117 .description = "Assume that the high-word facility is installed",
118118 .dependencies = featureSet(&[_]Feature{}),
119119 };
120 result[@enumToInt(Feature.insert_reference_bits_multiple)] = .{
120 result[@intFromEnum(Feature.insert_reference_bits_multiple)] = .{
121121 .llvm_name = "insert-reference-bits-multiple",
122122 .description = "Assume that the insert-reference-bits-multiple facility is installed",
123123 .dependencies = featureSet(&[_]Feature{}),
124124 };
125 result[@enumToInt(Feature.interlocked_access1)] = .{
125 result[@intFromEnum(Feature.interlocked_access1)] = .{
126126 .llvm_name = "interlocked-access1",
127127 .description = "Assume that interlocked-access facility 1 is installed",
128128 .dependencies = featureSet(&[_]Feature{}),
129129 };
130 result[@enumToInt(Feature.load_and_trap)] = .{
130 result[@intFromEnum(Feature.load_and_trap)] = .{
131131 .llvm_name = "load-and-trap",
132132 .description = "Assume that the load-and-trap facility is installed",
133133 .dependencies = featureSet(&[_]Feature{}),
134134 };
135 result[@enumToInt(Feature.load_and_zero_rightmost_byte)] = .{
135 result[@intFromEnum(Feature.load_and_zero_rightmost_byte)] = .{
136136 .llvm_name = "load-and-zero-rightmost-byte",
137137 .description = "Assume that the load-and-zero-rightmost-byte facility is installed",
138138 .dependencies = featureSet(&[_]Feature{}),
139139 };
140 result[@enumToInt(Feature.load_store_on_cond)] = .{
140 result[@intFromEnum(Feature.load_store_on_cond)] = .{
141141 .llvm_name = "load-store-on-cond",
142142 .description = "Assume that the load/store-on-condition facility is installed",
143143 .dependencies = featureSet(&[_]Feature{}),
144144 };
145 result[@enumToInt(Feature.load_store_on_cond_2)] = .{
145 result[@intFromEnum(Feature.load_store_on_cond_2)] = .{
146146 .llvm_name = "load-store-on-cond-2",
147147 .description = "Assume that the load/store-on-condition facility 2 is installed",
148148 .dependencies = featureSet(&[_]Feature{}),
149149 };
150 result[@enumToInt(Feature.message_security_assist_extension3)] = .{
150 result[@intFromEnum(Feature.message_security_assist_extension3)] = .{
151151 .llvm_name = "message-security-assist-extension3",
152152 .description = "Assume that the message-security-assist extension facility 3 is installed",
153153 .dependencies = featureSet(&[_]Feature{}),
154154 };
155 result[@enumToInt(Feature.message_security_assist_extension4)] = .{
155 result[@intFromEnum(Feature.message_security_assist_extension4)] = .{
156156 .llvm_name = "message-security-assist-extension4",
157157 .description = "Assume that the message-security-assist extension facility 4 is installed",
158158 .dependencies = featureSet(&[_]Feature{}),
159159 };
160 result[@enumToInt(Feature.message_security_assist_extension5)] = .{
160 result[@intFromEnum(Feature.message_security_assist_extension5)] = .{
161161 .llvm_name = "message-security-assist-extension5",
162162 .description = "Assume that the message-security-assist extension facility 5 is installed",
163163 .dependencies = featureSet(&[_]Feature{}),
164164 };
165 result[@enumToInt(Feature.message_security_assist_extension7)] = .{
165 result[@intFromEnum(Feature.message_security_assist_extension7)] = .{
166166 .llvm_name = "message-security-assist-extension7",
167167 .description = "Assume that the message-security-assist extension facility 7 is installed",
168168 .dependencies = featureSet(&[_]Feature{}),
169169 };
170 result[@enumToInt(Feature.message_security_assist_extension8)] = .{
170 result[@intFromEnum(Feature.message_security_assist_extension8)] = .{
171171 .llvm_name = "message-security-assist-extension8",
172172 .description = "Assume that the message-security-assist extension facility 8 is installed",
173173 .dependencies = featureSet(&[_]Feature{}),
174174 };
175 result[@enumToInt(Feature.message_security_assist_extension9)] = .{
175 result[@intFromEnum(Feature.message_security_assist_extension9)] = .{
176176 .llvm_name = "message-security-assist-extension9",
177177 .description = "Assume that the message-security-assist extension facility 9 is installed",
178178 .dependencies = featureSet(&[_]Feature{}),
179179 };
180 result[@enumToInt(Feature.miscellaneous_extensions)] = .{
180 result[@intFromEnum(Feature.miscellaneous_extensions)] = .{
181181 .llvm_name = "miscellaneous-extensions",
182182 .description = "Assume that the miscellaneous-extensions facility is installed",
183183 .dependencies = featureSet(&[_]Feature{}),
184184 };
185 result[@enumToInt(Feature.miscellaneous_extensions_2)] = .{
185 result[@intFromEnum(Feature.miscellaneous_extensions_2)] = .{
186186 .llvm_name = "miscellaneous-extensions-2",
187187 .description = "Assume that the miscellaneous-extensions facility 2 is installed",
188188 .dependencies = featureSet(&[_]Feature{}),
189189 };
190 result[@enumToInt(Feature.miscellaneous_extensions_3)] = .{
190 result[@intFromEnum(Feature.miscellaneous_extensions_3)] = .{
191191 .llvm_name = "miscellaneous-extensions-3",
192192 .description = "Assume that the miscellaneous-extensions facility 3 is installed",
193193 .dependencies = featureSet(&[_]Feature{}),
194194 };
195 result[@enumToInt(Feature.nnp_assist)] = .{
195 result[@intFromEnum(Feature.nnp_assist)] = .{
196196 .llvm_name = "nnp-assist",
197197 .description = "Assume that the NNP-assist facility is installed",
198198 .dependencies = featureSet(&[_]Feature{}),
199199 };
200 result[@enumToInt(Feature.population_count)] = .{
200 result[@intFromEnum(Feature.population_count)] = .{
201201 .llvm_name = "population-count",
202202 .description = "Assume that the population-count facility is installed",
203203 .dependencies = featureSet(&[_]Feature{}),
204204 };
205 result[@enumToInt(Feature.processor_activity_instrumentation)] = .{
205 result[@intFromEnum(Feature.processor_activity_instrumentation)] = .{
206206 .llvm_name = "processor-activity-instrumentation",
207207 .description = "Assume that the processor-activity-instrumentation facility is installed",
208208 .dependencies = featureSet(&[_]Feature{}),
209209 };
210 result[@enumToInt(Feature.processor_assist)] = .{
210 result[@intFromEnum(Feature.processor_assist)] = .{
211211 .llvm_name = "processor-assist",
212212 .description = "Assume that the processor-assist facility is installed",
213213 .dependencies = featureSet(&[_]Feature{}),
214214 };
215 result[@enumToInt(Feature.reset_dat_protection)] = .{
215 result[@intFromEnum(Feature.reset_dat_protection)] = .{
216216 .llvm_name = "reset-dat-protection",
217217 .description = "Assume that the reset-DAT-protection facility is installed",
218218 .dependencies = featureSet(&[_]Feature{}),
219219 };
220 result[@enumToInt(Feature.reset_reference_bits_multiple)] = .{
220 result[@intFromEnum(Feature.reset_reference_bits_multiple)] = .{
221221 .llvm_name = "reset-reference-bits-multiple",
222222 .description = "Assume that the reset-reference-bits-multiple facility is installed",
223223 .dependencies = featureSet(&[_]Feature{}),
224224 };
225 result[@enumToInt(Feature.soft_float)] = .{
225 result[@intFromEnum(Feature.soft_float)] = .{
226226 .llvm_name = "soft-float",
227227 .description = "Use software emulation for floating point",
228228 .dependencies = featureSet(&[_]Feature{}),
229229 };
230 result[@enumToInt(Feature.transactional_execution)] = .{
230 result[@intFromEnum(Feature.transactional_execution)] = .{
231231 .llvm_name = "transactional-execution",
232232 .description = "Assume that the transactional-execution facility is installed",
233233 .dependencies = featureSet(&[_]Feature{}),
234234 };
235 result[@enumToInt(Feature.vector)] = .{
235 result[@intFromEnum(Feature.vector)] = .{
236236 .llvm_name = "vector",
237237 .description = "Assume that the vectory facility is installed",
238238 .dependencies = featureSet(&[_]Feature{}),
239239 };
240 result[@enumToInt(Feature.vector_enhancements_1)] = .{
240 result[@intFromEnum(Feature.vector_enhancements_1)] = .{
241241 .llvm_name = "vector-enhancements-1",
242242 .description = "Assume that the vector enhancements facility 1 is installed",
243243 .dependencies = featureSet(&[_]Feature{}),
244244 };
245 result[@enumToInt(Feature.vector_enhancements_2)] = .{
245 result[@intFromEnum(Feature.vector_enhancements_2)] = .{
246246 .llvm_name = "vector-enhancements-2",
247247 .description = "Assume that the vector enhancements facility 2 is installed",
248248 .dependencies = featureSet(&[_]Feature{}),
249249 };
250 result[@enumToInt(Feature.vector_packed_decimal)] = .{
250 result[@intFromEnum(Feature.vector_packed_decimal)] = .{
251251 .llvm_name = "vector-packed-decimal",
252252 .description = "Assume that the vector packed decimal facility is installed",
253253 .dependencies = featureSet(&[_]Feature{}),
254254 };
255 result[@enumToInt(Feature.vector_packed_decimal_enhancement)] = .{
255 result[@intFromEnum(Feature.vector_packed_decimal_enhancement)] = .{
256256 .llvm_name = "vector-packed-decimal-enhancement",
257257 .description = "Assume that the vector packed decimal enhancement facility is installed",
258258 .dependencies = featureSet(&[_]Feature{}),
259259 };
260 result[@enumToInt(Feature.vector_packed_decimal_enhancement_2)] = .{
260 result[@intFromEnum(Feature.vector_packed_decimal_enhancement_2)] = .{
261261 .llvm_name = "vector-packed-decimal-enhancement-2",
262262 .description = "Assume that the vector packed decimal enhancement facility 2 is installed",
263263 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/sparc.zig+19-19
......@@ -35,97 +35,97 @@ pub const all_features = blk: {
3535 const len = @typeInfo(Feature).Enum.fields.len;
3636 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
3737 var result: [len]CpuFeature = undefined;
38 result[@enumToInt(Feature.deprecated_v8)] = .{
38 result[@intFromEnum(Feature.deprecated_v8)] = .{
3939 .llvm_name = "deprecated-v8",
4040 .description = "Enable deprecated V8 instructions in V9 mode",
4141 .dependencies = featureSet(&[_]Feature{}),
4242 };
43 result[@enumToInt(Feature.detectroundchange)] = .{
43 result[@intFromEnum(Feature.detectroundchange)] = .{
4444 .llvm_name = "detectroundchange",
4545 .description = "LEON3 erratum detection: Detects any rounding mode change request: use only the round-to-nearest rounding mode",
4646 .dependencies = featureSet(&[_]Feature{}),
4747 };
48 result[@enumToInt(Feature.fixallfdivsqrt)] = .{
48 result[@intFromEnum(Feature.fixallfdivsqrt)] = .{
4949 .llvm_name = "fixallfdivsqrt",
5050 .description = "LEON erratum fix: Fix FDIVS/FDIVD/FSQRTS/FSQRTD instructions with NOPs and floating-point store",
5151 .dependencies = featureSet(&[_]Feature{}),
5252 };
53 result[@enumToInt(Feature.hard_quad_float)] = .{
53 result[@intFromEnum(Feature.hard_quad_float)] = .{
5454 .llvm_name = "hard-quad-float",
5555 .description = "Enable quad-word floating point instructions",
5656 .dependencies = featureSet(&[_]Feature{}),
5757 };
58 result[@enumToInt(Feature.hasleoncasa)] = .{
58 result[@intFromEnum(Feature.hasleoncasa)] = .{
5959 .llvm_name = "hasleoncasa",
6060 .description = "Enable CASA instruction for LEON3 and LEON4 processors",
6161 .dependencies = featureSet(&[_]Feature{}),
6262 };
63 result[@enumToInt(Feature.hasumacsmac)] = .{
63 result[@intFromEnum(Feature.hasumacsmac)] = .{
6464 .llvm_name = "hasumacsmac",
6565 .description = "Enable UMAC and SMAC for LEON3 and LEON4 processors",
6666 .dependencies = featureSet(&[_]Feature{}),
6767 };
68 result[@enumToInt(Feature.insertnopload)] = .{
68 result[@intFromEnum(Feature.insertnopload)] = .{
6969 .llvm_name = "insertnopload",
7070 .description = "LEON3 erratum fix: Insert a NOP instruction after every single-cycle load instruction when the next instruction is another load/store instruction",
7171 .dependencies = featureSet(&[_]Feature{}),
7272 };
73 result[@enumToInt(Feature.leon)] = .{
73 result[@intFromEnum(Feature.leon)] = .{
7474 .llvm_name = "leon",
7575 .description = "Enable LEON extensions",
7676 .dependencies = featureSet(&[_]Feature{}),
7777 };
78 result[@enumToInt(Feature.leoncyclecounter)] = .{
78 result[@intFromEnum(Feature.leoncyclecounter)] = .{
7979 .llvm_name = "leoncyclecounter",
8080 .description = "Use the Leon cycle counter register",
8181 .dependencies = featureSet(&[_]Feature{}),
8282 };
83 result[@enumToInt(Feature.leonpwrpsr)] = .{
83 result[@intFromEnum(Feature.leonpwrpsr)] = .{
8484 .llvm_name = "leonpwrpsr",
8585 .description = "Enable the PWRPSR instruction",
8686 .dependencies = featureSet(&[_]Feature{}),
8787 };
88 result[@enumToInt(Feature.no_fmuls)] = .{
88 result[@intFromEnum(Feature.no_fmuls)] = .{
8989 .llvm_name = "no-fmuls",
9090 .description = "Disable the fmuls instruction.",
9191 .dependencies = featureSet(&[_]Feature{}),
9292 };
93 result[@enumToInt(Feature.no_fsmuld)] = .{
93 result[@intFromEnum(Feature.no_fsmuld)] = .{
9494 .llvm_name = "no-fsmuld",
9595 .description = "Disable the fsmuld instruction.",
9696 .dependencies = featureSet(&[_]Feature{}),
9797 };
98 result[@enumToInt(Feature.popc)] = .{
98 result[@intFromEnum(Feature.popc)] = .{
9999 .llvm_name = "popc",
100100 .description = "Use the popc (population count) instruction",
101101 .dependencies = featureSet(&[_]Feature{}),
102102 };
103 result[@enumToInt(Feature.soft_float)] = .{
103 result[@intFromEnum(Feature.soft_float)] = .{
104104 .llvm_name = "soft-float",
105105 .description = "Use software emulation for floating point",
106106 .dependencies = featureSet(&[_]Feature{}),
107107 };
108 result[@enumToInt(Feature.soft_mul_div)] = .{
108 result[@intFromEnum(Feature.soft_mul_div)] = .{
109109 .llvm_name = "soft-mul-div",
110110 .description = "Use software emulation for integer multiply and divide",
111111 .dependencies = featureSet(&[_]Feature{}),
112112 };
113 result[@enumToInt(Feature.v9)] = .{
113 result[@intFromEnum(Feature.v9)] = .{
114114 .llvm_name = "v9",
115115 .description = "Enable SPARC-V9 instructions",
116116 .dependencies = featureSet(&[_]Feature{}),
117117 };
118 result[@enumToInt(Feature.vis)] = .{
118 result[@intFromEnum(Feature.vis)] = .{
119119 .llvm_name = "vis",
120120 .description = "Enable UltraSPARC Visual Instruction Set extensions",
121121 .dependencies = featureSet(&[_]Feature{}),
122122 };
123 result[@enumToInt(Feature.vis2)] = .{
123 result[@intFromEnum(Feature.vis2)] = .{
124124 .llvm_name = "vis2",
125125 .description = "Enable Visual Instruction Set extensions II",
126126 .dependencies = featureSet(&[_]Feature{}),
127127 };
128 result[@enumToInt(Feature.vis3)] = .{
128 result[@intFromEnum(Feature.vis3)] = .{
129129 .llvm_name = "vis3",
130130 .description = "Enable Visual Instruction Set extensions III",
131131 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/spirv.zig+284-284
......@@ -304,803 +304,803 @@ pub const all_features = blk: {
304304 const len = @typeInfo(Feature).Enum.fields.len;
305305 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
306306 var result: [len]CpuFeature = undefined;
307 result[@enumToInt(Feature.v1_1)] = .{
307 result[@intFromEnum(Feature.v1_1)] = .{
308308 .llvm_name = null,
309309 .description = "SPIR-V version 1.1",
310310 .dependencies = featureSet(&[_]Feature{}),
311311 };
312 result[@enumToInt(Feature.v1_2)] = .{
312 result[@intFromEnum(Feature.v1_2)] = .{
313313 .llvm_name = null,
314314 .description = "SPIR-V version 1.2",
315315 .dependencies = featureSet(&[_]Feature{
316316 .v1_1,
317317 }),
318318 };
319 result[@enumToInt(Feature.v1_3)] = .{
319 result[@intFromEnum(Feature.v1_3)] = .{
320320 .llvm_name = null,
321321 .description = "SPIR-V version 1.3",
322322 .dependencies = featureSet(&[_]Feature{
323323 .v1_2,
324324 }),
325325 };
326 result[@enumToInt(Feature.v1_4)] = .{
326 result[@intFromEnum(Feature.v1_4)] = .{
327327 .llvm_name = null,
328328 .description = "SPIR-V version 1.4",
329329 .dependencies = featureSet(&[_]Feature{
330330 .v1_3,
331331 }),
332332 };
333 result[@enumToInt(Feature.v1_5)] = .{
333 result[@intFromEnum(Feature.v1_5)] = .{
334334 .llvm_name = null,
335335 .description = "SPIR-V version 1.5",
336336 .dependencies = featureSet(&[_]Feature{
337337 .v1_4,
338338 }),
339339 };
340 result[@enumToInt(Feature.SPV_AMD_shader_fragment_mask)] = .{
340 result[@intFromEnum(Feature.SPV_AMD_shader_fragment_mask)] = .{
341341 .llvm_name = null,
342342 .description = "SPIR-V extension SPV_AMD_shader_fragment_mask",
343343 .dependencies = featureSet(&[_]Feature{}),
344344 };
345 result[@enumToInt(Feature.SPV_AMD_gpu_shader_int16)] = .{
345 result[@intFromEnum(Feature.SPV_AMD_gpu_shader_int16)] = .{
346346 .llvm_name = null,
347347 .description = "SPIR-V extension SPV_AMD_gpu_shader_int16",
348348 .dependencies = featureSet(&[_]Feature{}),
349349 };
350 result[@enumToInt(Feature.SPV_AMD_gpu_shader_half_float)] = .{
350 result[@intFromEnum(Feature.SPV_AMD_gpu_shader_half_float)] = .{
351351 .llvm_name = null,
352352 .description = "SPIR-V extension SPV_AMD_gpu_shader_half_float",
353353 .dependencies = featureSet(&[_]Feature{}),
354354 };
355 result[@enumToInt(Feature.SPV_AMD_texture_gather_bias_lod)] = .{
355 result[@intFromEnum(Feature.SPV_AMD_texture_gather_bias_lod)] = .{
356356 .llvm_name = null,
357357 .description = "SPIR-V extension SPV_AMD_texture_gather_bias_lod",
358358 .dependencies = featureSet(&[_]Feature{}),
359359 };
360 result[@enumToInt(Feature.SPV_AMD_shader_ballot)] = .{
360 result[@intFromEnum(Feature.SPV_AMD_shader_ballot)] = .{
361361 .llvm_name = null,
362362 .description = "SPIR-V extension SPV_AMD_shader_ballot",
363363 .dependencies = featureSet(&[_]Feature{}),
364364 };
365 result[@enumToInt(Feature.SPV_AMD_gcn_shader)] = .{
365 result[@intFromEnum(Feature.SPV_AMD_gcn_shader)] = .{
366366 .llvm_name = null,
367367 .description = "SPIR-V extension SPV_AMD_gcn_shader",
368368 .dependencies = featureSet(&[_]Feature{}),
369369 };
370 result[@enumToInt(Feature.SPV_AMD_shader_image_load_store_lod)] = .{
370 result[@intFromEnum(Feature.SPV_AMD_shader_image_load_store_lod)] = .{
371371 .llvm_name = null,
372372 .description = "SPIR-V extension SPV_AMD_shader_image_load_store_lod",
373373 .dependencies = featureSet(&[_]Feature{}),
374374 };
375 result[@enumToInt(Feature.SPV_AMD_shader_explicit_vertex_parameter)] = .{
375 result[@intFromEnum(Feature.SPV_AMD_shader_explicit_vertex_parameter)] = .{
376376 .llvm_name = null,
377377 .description = "SPIR-V extension SPV_AMD_shader_explicit_vertex_parameter",
378378 .dependencies = featureSet(&[_]Feature{}),
379379 };
380 result[@enumToInt(Feature.SPV_AMD_shader_trinary_minmax)] = .{
380 result[@intFromEnum(Feature.SPV_AMD_shader_trinary_minmax)] = .{
381381 .llvm_name = null,
382382 .description = "SPIR-V extension SPV_AMD_shader_trinary_minmax",
383383 .dependencies = featureSet(&[_]Feature{}),
384384 };
385 result[@enumToInt(Feature.SPV_AMD_gpu_shader_half_float_fetch)] = .{
385 result[@intFromEnum(Feature.SPV_AMD_gpu_shader_half_float_fetch)] = .{
386386 .llvm_name = null,
387387 .description = "SPIR-V extension SPV_AMD_gpu_shader_half_float_fetch",
388388 .dependencies = featureSet(&[_]Feature{}),
389389 };
390 result[@enumToInt(Feature.SPV_GOOGLE_hlsl_functionality1)] = .{
390 result[@intFromEnum(Feature.SPV_GOOGLE_hlsl_functionality1)] = .{
391391 .llvm_name = null,
392392 .description = "SPIR-V extension SPV_GOOGLE_hlsl_functionality1",
393393 .dependencies = featureSet(&[_]Feature{}),
394394 };
395 result[@enumToInt(Feature.SPV_GOOGLE_user_type)] = .{
395 result[@intFromEnum(Feature.SPV_GOOGLE_user_type)] = .{
396396 .llvm_name = null,
397397 .description = "SPIR-V extension SPV_GOOGLE_user_type",
398398 .dependencies = featureSet(&[_]Feature{}),
399399 };
400 result[@enumToInt(Feature.SPV_GOOGLE_decorate_string)] = .{
400 result[@intFromEnum(Feature.SPV_GOOGLE_decorate_string)] = .{
401401 .llvm_name = null,
402402 .description = "SPIR-V extension SPV_GOOGLE_decorate_string",
403403 .dependencies = featureSet(&[_]Feature{}),
404404 };
405 result[@enumToInt(Feature.SPV_EXT_demote_to_helper_invocation)] = .{
405 result[@intFromEnum(Feature.SPV_EXT_demote_to_helper_invocation)] = .{
406406 .llvm_name = null,
407407 .description = "SPIR-V extension SPV_EXT_demote_to_helper_invocation",
408408 .dependencies = featureSet(&[_]Feature{}),
409409 };
410 result[@enumToInt(Feature.SPV_EXT_descriptor_indexing)] = .{
410 result[@intFromEnum(Feature.SPV_EXT_descriptor_indexing)] = .{
411411 .llvm_name = null,
412412 .description = "SPIR-V extension SPV_EXT_descriptor_indexing",
413413 .dependencies = featureSet(&[_]Feature{}),
414414 };
415 result[@enumToInt(Feature.SPV_EXT_fragment_fully_covered)] = .{
415 result[@intFromEnum(Feature.SPV_EXT_fragment_fully_covered)] = .{
416416 .llvm_name = null,
417417 .description = "SPIR-V extension SPV_EXT_fragment_fully_covered",
418418 .dependencies = featureSet(&[_]Feature{}),
419419 };
420 result[@enumToInt(Feature.SPV_EXT_shader_stencil_export)] = .{
420 result[@intFromEnum(Feature.SPV_EXT_shader_stencil_export)] = .{
421421 .llvm_name = null,
422422 .description = "SPIR-V extension SPV_EXT_shader_stencil_export",
423423 .dependencies = featureSet(&[_]Feature{}),
424424 };
425 result[@enumToInt(Feature.SPV_EXT_physical_storage_buffer)] = .{
425 result[@intFromEnum(Feature.SPV_EXT_physical_storage_buffer)] = .{
426426 .llvm_name = null,
427427 .description = "SPIR-V extension SPV_EXT_physical_storage_buffer",
428428 .dependencies = featureSet(&[_]Feature{}),
429429 };
430 result[@enumToInt(Feature.SPV_EXT_shader_atomic_float_add)] = .{
430 result[@intFromEnum(Feature.SPV_EXT_shader_atomic_float_add)] = .{
431431 .llvm_name = null,
432432 .description = "SPIR-V extension SPV_EXT_shader_atomic_float_add",
433433 .dependencies = featureSet(&[_]Feature{}),
434434 };
435 result[@enumToInt(Feature.SPV_EXT_shader_atomic_float_min_max)] = .{
435 result[@intFromEnum(Feature.SPV_EXT_shader_atomic_float_min_max)] = .{
436436 .llvm_name = null,
437437 .description = "SPIR-V extension SPV_EXT_shader_atomic_float_min_max",
438438 .dependencies = featureSet(&[_]Feature{}),
439439 };
440 result[@enumToInt(Feature.SPV_EXT_shader_image_int64)] = .{
440 result[@intFromEnum(Feature.SPV_EXT_shader_image_int64)] = .{
441441 .llvm_name = null,
442442 .description = "SPIR-V extension SPV_EXT_shader_image_int64",
443443 .dependencies = featureSet(&[_]Feature{}),
444444 };
445 result[@enumToInt(Feature.SPV_EXT_fragment_shader_interlock)] = .{
445 result[@intFromEnum(Feature.SPV_EXT_fragment_shader_interlock)] = .{
446446 .llvm_name = null,
447447 .description = "SPIR-V extension SPV_EXT_fragment_shader_interlock",
448448 .dependencies = featureSet(&[_]Feature{}),
449449 };
450 result[@enumToInt(Feature.SPV_EXT_fragment_invocation_density)] = .{
450 result[@intFromEnum(Feature.SPV_EXT_fragment_invocation_density)] = .{
451451 .llvm_name = null,
452452 .description = "SPIR-V extension SPV_EXT_fragment_invocation_density",
453453 .dependencies = featureSet(&[_]Feature{}),
454454 };
455 result[@enumToInt(Feature.SPV_EXT_shader_viewport_index_layer)] = .{
455 result[@intFromEnum(Feature.SPV_EXT_shader_viewport_index_layer)] = .{
456456 .llvm_name = null,
457457 .description = "SPIR-V extension SPV_EXT_shader_viewport_index_layer",
458458 .dependencies = featureSet(&[_]Feature{}),
459459 };
460 result[@enumToInt(Feature.SPV_INTEL_loop_fuse)] = .{
460 result[@intFromEnum(Feature.SPV_INTEL_loop_fuse)] = .{
461461 .llvm_name = null,
462462 .description = "SPIR-V extension SPV_INTEL_loop_fuse",
463463 .dependencies = featureSet(&[_]Feature{}),
464464 };
465 result[@enumToInt(Feature.SPV_INTEL_fpga_dsp_control)] = .{
465 result[@intFromEnum(Feature.SPV_INTEL_fpga_dsp_control)] = .{
466466 .llvm_name = null,
467467 .description = "SPIR-V extension SPV_INTEL_fpga_dsp_control",
468468 .dependencies = featureSet(&[_]Feature{}),
469469 };
470 result[@enumToInt(Feature.SPV_INTEL_fpga_reg)] = .{
470 result[@intFromEnum(Feature.SPV_INTEL_fpga_reg)] = .{
471471 .llvm_name = null,
472472 .description = "SPIR-V extension SPV_INTEL_fpga_reg",
473473 .dependencies = featureSet(&[_]Feature{}),
474474 };
475 result[@enumToInt(Feature.SPV_INTEL_fpga_memory_accesses)] = .{
475 result[@intFromEnum(Feature.SPV_INTEL_fpga_memory_accesses)] = .{
476476 .llvm_name = null,
477477 .description = "SPIR-V extension SPV_INTEL_fpga_memory_accesses",
478478 .dependencies = featureSet(&[_]Feature{}),
479479 };
480 result[@enumToInt(Feature.SPV_INTEL_fpga_loop_controls)] = .{
480 result[@intFromEnum(Feature.SPV_INTEL_fpga_loop_controls)] = .{
481481 .llvm_name = null,
482482 .description = "SPIR-V extension SPV_INTEL_fpga_loop_controls",
483483 .dependencies = featureSet(&[_]Feature{}),
484484 };
485 result[@enumToInt(Feature.SPV_INTEL_io_pipes)] = .{
485 result[@intFromEnum(Feature.SPV_INTEL_io_pipes)] = .{
486486 .llvm_name = null,
487487 .description = "SPIR-V extension SPV_INTEL_io_pipes",
488488 .dependencies = featureSet(&[_]Feature{}),
489489 };
490 result[@enumToInt(Feature.SPV_INTEL_unstructured_loop_controls)] = .{
490 result[@intFromEnum(Feature.SPV_INTEL_unstructured_loop_controls)] = .{
491491 .llvm_name = null,
492492 .description = "SPIR-V extension SPV_INTEL_unstructured_loop_controls",
493493 .dependencies = featureSet(&[_]Feature{}),
494494 };
495 result[@enumToInt(Feature.SPV_INTEL_blocking_pipes)] = .{
495 result[@intFromEnum(Feature.SPV_INTEL_blocking_pipes)] = .{
496496 .llvm_name = null,
497497 .description = "SPIR-V extension SPV_INTEL_blocking_pipes",
498498 .dependencies = featureSet(&[_]Feature{}),
499499 };
500 result[@enumToInt(Feature.SPV_INTEL_device_side_avc_motion_estimation)] = .{
500 result[@intFromEnum(Feature.SPV_INTEL_device_side_avc_motion_estimation)] = .{
501501 .llvm_name = null,
502502 .description = "SPIR-V extension SPV_INTEL_device_side_avc_motion_estimation",
503503 .dependencies = featureSet(&[_]Feature{}),
504504 };
505 result[@enumToInt(Feature.SPV_INTEL_fpga_memory_attributes)] = .{
505 result[@intFromEnum(Feature.SPV_INTEL_fpga_memory_attributes)] = .{
506506 .llvm_name = null,
507507 .description = "SPIR-V extension SPV_INTEL_fpga_memory_attributes",
508508 .dependencies = featureSet(&[_]Feature{}),
509509 };
510 result[@enumToInt(Feature.SPV_INTEL_fp_fast_math_mode)] = .{
510 result[@intFromEnum(Feature.SPV_INTEL_fp_fast_math_mode)] = .{
511511 .llvm_name = null,
512512 .description = "SPIR-V extension SPV_INTEL_fp_fast_math_mode",
513513 .dependencies = featureSet(&[_]Feature{}),
514514 };
515 result[@enumToInt(Feature.SPV_INTEL_media_block_io)] = .{
515 result[@intFromEnum(Feature.SPV_INTEL_media_block_io)] = .{
516516 .llvm_name = null,
517517 .description = "SPIR-V extension SPV_INTEL_media_block_io",
518518 .dependencies = featureSet(&[_]Feature{}),
519519 };
520 result[@enumToInt(Feature.SPV_INTEL_shader_integer_functions2)] = .{
520 result[@intFromEnum(Feature.SPV_INTEL_shader_integer_functions2)] = .{
521521 .llvm_name = null,
522522 .description = "SPIR-V extension SPV_INTEL_shader_integer_functions2",
523523 .dependencies = featureSet(&[_]Feature{}),
524524 };
525 result[@enumToInt(Feature.SPV_INTEL_subgroups)] = .{
525 result[@intFromEnum(Feature.SPV_INTEL_subgroups)] = .{
526526 .llvm_name = null,
527527 .description = "SPIR-V extension SPV_INTEL_subgroups",
528528 .dependencies = featureSet(&[_]Feature{}),
529529 };
530 result[@enumToInt(Feature.SPV_INTEL_fpga_cluster_attributes)] = .{
530 result[@intFromEnum(Feature.SPV_INTEL_fpga_cluster_attributes)] = .{
531531 .llvm_name = null,
532532 .description = "SPIR-V extension SPV_INTEL_fpga_cluster_attributes",
533533 .dependencies = featureSet(&[_]Feature{}),
534534 };
535 result[@enumToInt(Feature.SPV_INTEL_kernel_attributes)] = .{
535 result[@intFromEnum(Feature.SPV_INTEL_kernel_attributes)] = .{
536536 .llvm_name = null,
537537 .description = "SPIR-V extension SPV_INTEL_kernel_attributes",
538538 .dependencies = featureSet(&[_]Feature{}),
539539 };
540 result[@enumToInt(Feature.SPV_INTEL_arbitrary_precision_integers)] = .{
540 result[@intFromEnum(Feature.SPV_INTEL_arbitrary_precision_integers)] = .{
541541 .llvm_name = null,
542542 .description = "SPIR-V extension SPV_INTEL_arbitrary_precision_integers",
543543 .dependencies = featureSet(&[_]Feature{}),
544544 };
545 result[@enumToInt(Feature.SPV_KHR_8bit_storage)] = .{
545 result[@intFromEnum(Feature.SPV_KHR_8bit_storage)] = .{
546546 .llvm_name = null,
547547 .description = "SPIR-V extension SPV_KHR_8bit_storage",
548548 .dependencies = featureSet(&[_]Feature{}),
549549 };
550 result[@enumToInt(Feature.SPV_KHR_shader_clock)] = .{
550 result[@intFromEnum(Feature.SPV_KHR_shader_clock)] = .{
551551 .llvm_name = null,
552552 .description = "SPIR-V extension SPV_KHR_shader_clock",
553553 .dependencies = featureSet(&[_]Feature{}),
554554 };
555 result[@enumToInt(Feature.SPV_KHR_device_group)] = .{
555 result[@intFromEnum(Feature.SPV_KHR_device_group)] = .{
556556 .llvm_name = null,
557557 .description = "SPIR-V extension SPV_KHR_device_group",
558558 .dependencies = featureSet(&[_]Feature{}),
559559 };
560 result[@enumToInt(Feature.SPV_KHR_16bit_storage)] = .{
560 result[@intFromEnum(Feature.SPV_KHR_16bit_storage)] = .{
561561 .llvm_name = null,
562562 .description = "SPIR-V extension SPV_KHR_16bit_storage",
563563 .dependencies = featureSet(&[_]Feature{}),
564564 };
565 result[@enumToInt(Feature.SPV_KHR_variable_pointers)] = .{
565 result[@intFromEnum(Feature.SPV_KHR_variable_pointers)] = .{
566566 .llvm_name = null,
567567 .description = "SPIR-V extension SPV_KHR_variable_pointers",
568568 .dependencies = featureSet(&[_]Feature{}),
569569 };
570 result[@enumToInt(Feature.SPV_KHR_no_integer_wrap_decoration)] = .{
570 result[@intFromEnum(Feature.SPV_KHR_no_integer_wrap_decoration)] = .{
571571 .llvm_name = null,
572572 .description = "SPIR-V extension SPV_KHR_no_integer_wrap_decoration",
573573 .dependencies = featureSet(&[_]Feature{}),
574574 };
575 result[@enumToInt(Feature.SPV_KHR_subgroup_vote)] = .{
575 result[@intFromEnum(Feature.SPV_KHR_subgroup_vote)] = .{
576576 .llvm_name = null,
577577 .description = "SPIR-V extension SPV_KHR_subgroup_vote",
578578 .dependencies = featureSet(&[_]Feature{}),
579579 };
580 result[@enumToInt(Feature.SPV_KHR_multiview)] = .{
580 result[@intFromEnum(Feature.SPV_KHR_multiview)] = .{
581581 .llvm_name = null,
582582 .description = "SPIR-V extension SPV_KHR_multiview",
583583 .dependencies = featureSet(&[_]Feature{}),
584584 };
585 result[@enumToInt(Feature.SPV_KHR_shader_ballot)] = .{
585 result[@intFromEnum(Feature.SPV_KHR_shader_ballot)] = .{
586586 .llvm_name = null,
587587 .description = "SPIR-V extension SPV_KHR_shader_ballot",
588588 .dependencies = featureSet(&[_]Feature{}),
589589 };
590 result[@enumToInt(Feature.SPV_KHR_vulkan_memory_model)] = .{
590 result[@intFromEnum(Feature.SPV_KHR_vulkan_memory_model)] = .{
591591 .llvm_name = null,
592592 .description = "SPIR-V extension SPV_KHR_vulkan_memory_model",
593593 .dependencies = featureSet(&[_]Feature{}),
594594 };
595 result[@enumToInt(Feature.SPV_KHR_physical_storage_buffer)] = .{
595 result[@intFromEnum(Feature.SPV_KHR_physical_storage_buffer)] = .{
596596 .llvm_name = null,
597597 .description = "SPIR-V extension SPV_KHR_physical_storage_buffer",
598598 .dependencies = featureSet(&[_]Feature{}),
599599 };
600 result[@enumToInt(Feature.SPV_KHR_workgroup_memory_explicit_layout)] = .{
600 result[@intFromEnum(Feature.SPV_KHR_workgroup_memory_explicit_layout)] = .{
601601 .llvm_name = null,
602602 .description = "SPIR-V extension SPV_KHR_workgroup_memory_explicit_layout",
603603 .dependencies = featureSet(&[_]Feature{}),
604604 };
605 result[@enumToInt(Feature.SPV_KHR_fragment_shading_rate)] = .{
605 result[@intFromEnum(Feature.SPV_KHR_fragment_shading_rate)] = .{
606606 .llvm_name = null,
607607 .description = "SPIR-V extension SPV_KHR_fragment_shading_rate",
608608 .dependencies = featureSet(&[_]Feature{}),
609609 };
610 result[@enumToInt(Feature.SPV_KHR_shader_atomic_counter_ops)] = .{
610 result[@intFromEnum(Feature.SPV_KHR_shader_atomic_counter_ops)] = .{
611611 .llvm_name = null,
612612 .description = "SPIR-V extension SPV_KHR_shader_atomic_counter_ops",
613613 .dependencies = featureSet(&[_]Feature{}),
614614 };
615 result[@enumToInt(Feature.SPV_KHR_shader_draw_parameters)] = .{
615 result[@intFromEnum(Feature.SPV_KHR_shader_draw_parameters)] = .{
616616 .llvm_name = null,
617617 .description = "SPIR-V extension SPV_KHR_shader_draw_parameters",
618618 .dependencies = featureSet(&[_]Feature{}),
619619 };
620 result[@enumToInt(Feature.SPV_KHR_storage_buffer_storage_class)] = .{
620 result[@intFromEnum(Feature.SPV_KHR_storage_buffer_storage_class)] = .{
621621 .llvm_name = null,
622622 .description = "SPIR-V extension SPV_KHR_storage_buffer_storage_class",
623623 .dependencies = featureSet(&[_]Feature{}),
624624 };
625 result[@enumToInt(Feature.SPV_KHR_linkonce_odr)] = .{
625 result[@intFromEnum(Feature.SPV_KHR_linkonce_odr)] = .{
626626 .llvm_name = null,
627627 .description = "SPIR-V extension SPV_KHR_linkonce_odr",
628628 .dependencies = featureSet(&[_]Feature{}),
629629 };
630 result[@enumToInt(Feature.SPV_KHR_terminate_invocation)] = .{
630 result[@intFromEnum(Feature.SPV_KHR_terminate_invocation)] = .{
631631 .llvm_name = null,
632632 .description = "SPIR-V extension SPV_KHR_terminate_invocation",
633633 .dependencies = featureSet(&[_]Feature{}),
634634 };
635 result[@enumToInt(Feature.SPV_KHR_non_semantic_info)] = .{
635 result[@intFromEnum(Feature.SPV_KHR_non_semantic_info)] = .{
636636 .llvm_name = null,
637637 .description = "SPIR-V extension SPV_KHR_non_semantic_info",
638638 .dependencies = featureSet(&[_]Feature{}),
639639 };
640 result[@enumToInt(Feature.SPV_KHR_post_depth_coverage)] = .{
640 result[@intFromEnum(Feature.SPV_KHR_post_depth_coverage)] = .{
641641 .llvm_name = null,
642642 .description = "SPIR-V extension SPV_KHR_post_depth_coverage",
643643 .dependencies = featureSet(&[_]Feature{}),
644644 };
645 result[@enumToInt(Feature.SPV_KHR_expect_assume)] = .{
645 result[@intFromEnum(Feature.SPV_KHR_expect_assume)] = .{
646646 .llvm_name = null,
647647 .description = "SPIR-V extension SPV_KHR_expect_assume",
648648 .dependencies = featureSet(&[_]Feature{}),
649649 };
650 result[@enumToInt(Feature.SPV_KHR_ray_tracing)] = .{
650 result[@intFromEnum(Feature.SPV_KHR_ray_tracing)] = .{
651651 .llvm_name = null,
652652 .description = "SPIR-V extension SPV_KHR_ray_tracing",
653653 .dependencies = featureSet(&[_]Feature{}),
654654 };
655 result[@enumToInt(Feature.SPV_KHR_ray_query)] = .{
655 result[@intFromEnum(Feature.SPV_KHR_ray_query)] = .{
656656 .llvm_name = null,
657657 .description = "SPIR-V extension SPV_KHR_ray_query",
658658 .dependencies = featureSet(&[_]Feature{}),
659659 };
660 result[@enumToInt(Feature.SPV_KHR_float_controls)] = .{
660 result[@intFromEnum(Feature.SPV_KHR_float_controls)] = .{
661661 .llvm_name = null,
662662 .description = "SPIR-V extension SPV_KHR_float_controls",
663663 .dependencies = featureSet(&[_]Feature{}),
664664 };
665 result[@enumToInt(Feature.SPV_NV_viewport_array2)] = .{
665 result[@intFromEnum(Feature.SPV_NV_viewport_array2)] = .{
666666 .llvm_name = null,
667667 .description = "SPIR-V extension SPV_NV_viewport_array2",
668668 .dependencies = featureSet(&[_]Feature{}),
669669 };
670 result[@enumToInt(Feature.SPV_NV_shader_subgroup_partitioned)] = .{
670 result[@intFromEnum(Feature.SPV_NV_shader_subgroup_partitioned)] = .{
671671 .llvm_name = null,
672672 .description = "SPIR-V extension SPV_NV_shader_subgroup_partitioned",
673673 .dependencies = featureSet(&[_]Feature{}),
674674 };
675 result[@enumToInt(Feature.SPV_NVX_multiview_per_view_attributes)] = .{
675 result[@intFromEnum(Feature.SPV_NVX_multiview_per_view_attributes)] = .{
676676 .llvm_name = null,
677677 .description = "SPIR-V extension SPV_NVX_multiview_per_view_attributes",
678678 .dependencies = featureSet(&[_]Feature{}),
679679 };
680 result[@enumToInt(Feature.SPV_NV_ray_tracing)] = .{
680 result[@intFromEnum(Feature.SPV_NV_ray_tracing)] = .{
681681 .llvm_name = null,
682682 .description = "SPIR-V extension SPV_NV_ray_tracing",
683683 .dependencies = featureSet(&[_]Feature{}),
684684 };
685 result[@enumToInt(Feature.SPV_NV_shader_image_footprint)] = .{
685 result[@intFromEnum(Feature.SPV_NV_shader_image_footprint)] = .{
686686 .llvm_name = null,
687687 .description = "SPIR-V extension SPV_NV_shader_image_footprint",
688688 .dependencies = featureSet(&[_]Feature{}),
689689 };
690 result[@enumToInt(Feature.SPV_NV_shading_rate)] = .{
690 result[@intFromEnum(Feature.SPV_NV_shading_rate)] = .{
691691 .llvm_name = null,
692692 .description = "SPIR-V extension SPV_NV_shading_rate",
693693 .dependencies = featureSet(&[_]Feature{}),
694694 };
695 result[@enumToInt(Feature.SPV_NV_stereo_view_rendering)] = .{
695 result[@intFromEnum(Feature.SPV_NV_stereo_view_rendering)] = .{
696696 .llvm_name = null,
697697 .description = "SPIR-V extension SPV_NV_stereo_view_rendering",
698698 .dependencies = featureSet(&[_]Feature{}),
699699 };
700 result[@enumToInt(Feature.SPV_NV_compute_shader_derivatives)] = .{
700 result[@intFromEnum(Feature.SPV_NV_compute_shader_derivatives)] = .{
701701 .llvm_name = null,
702702 .description = "SPIR-V extension SPV_NV_compute_shader_derivatives",
703703 .dependencies = featureSet(&[_]Feature{}),
704704 };
705 result[@enumToInt(Feature.SPV_NV_shader_sm_builtins)] = .{
705 result[@intFromEnum(Feature.SPV_NV_shader_sm_builtins)] = .{
706706 .llvm_name = null,
707707 .description = "SPIR-V extension SPV_NV_shader_sm_builtins",
708708 .dependencies = featureSet(&[_]Feature{}),
709709 };
710 result[@enumToInt(Feature.SPV_NV_mesh_shader)] = .{
710 result[@intFromEnum(Feature.SPV_NV_mesh_shader)] = .{
711711 .llvm_name = null,
712712 .description = "SPIR-V extension SPV_NV_mesh_shader",
713713 .dependencies = featureSet(&[_]Feature{}),
714714 };
715 result[@enumToInt(Feature.SPV_NV_geometry_shader_passthrough)] = .{
715 result[@intFromEnum(Feature.SPV_NV_geometry_shader_passthrough)] = .{
716716 .llvm_name = null,
717717 .description = "SPIR-V extension SPV_NV_geometry_shader_passthrough",
718718 .dependencies = featureSet(&[_]Feature{}),
719719 };
720 result[@enumToInt(Feature.SPV_NV_fragment_shader_barycentric)] = .{
720 result[@intFromEnum(Feature.SPV_NV_fragment_shader_barycentric)] = .{
721721 .llvm_name = null,
722722 .description = "SPIR-V extension SPV_NV_fragment_shader_barycentric",
723723 .dependencies = featureSet(&[_]Feature{}),
724724 };
725 result[@enumToInt(Feature.SPV_NV_cooperative_matrix)] = .{
725 result[@intFromEnum(Feature.SPV_NV_cooperative_matrix)] = .{
726726 .llvm_name = null,
727727 .description = "SPIR-V extension SPV_NV_cooperative_matrix",
728728 .dependencies = featureSet(&[_]Feature{}),
729729 };
730 result[@enumToInt(Feature.SPV_NV_sample_mask_override_coverage)] = .{
730 result[@intFromEnum(Feature.SPV_NV_sample_mask_override_coverage)] = .{
731731 .llvm_name = null,
732732 .description = "SPIR-V extension SPV_NV_sample_mask_override_coverage",
733733 .dependencies = featureSet(&[_]Feature{}),
734734 };
735 result[@enumToInt(Feature.Matrix)] = .{
735 result[@intFromEnum(Feature.Matrix)] = .{
736736 .llvm_name = null,
737737 .description = "Enable SPIR-V capability Matrix",
738738 .dependencies = featureSet(&[_]Feature{}),
739739 };
740 result[@enumToInt(Feature.Shader)] = .{
740 result[@intFromEnum(Feature.Shader)] = .{
741741 .llvm_name = null,
742742 .description = "Enable SPIR-V capability Shader",
743743 .dependencies = featureSet(&[_]Feature{
744744 .Matrix,
745745 }),
746746 };
747 result[@enumToInt(Feature.Geometry)] = .{
747 result[@intFromEnum(Feature.Geometry)] = .{
748748 .llvm_name = null,
749749 .description = "Enable SPIR-V capability Geometry",
750750 .dependencies = featureSet(&[_]Feature{
751751 .Shader,
752752 }),
753753 };
754 result[@enumToInt(Feature.Tessellation)] = .{
754 result[@intFromEnum(Feature.Tessellation)] = .{
755755 .llvm_name = null,
756756 .description = "Enable SPIR-V capability Tessellation",
757757 .dependencies = featureSet(&[_]Feature{
758758 .Shader,
759759 }),
760760 };
761 result[@enumToInt(Feature.Addresses)] = .{
761 result[@intFromEnum(Feature.Addresses)] = .{
762762 .llvm_name = null,
763763 .description = "Enable SPIR-V capability Addresses",
764764 .dependencies = featureSet(&[_]Feature{}),
765765 };
766 result[@enumToInt(Feature.Linkage)] = .{
766 result[@intFromEnum(Feature.Linkage)] = .{
767767 .llvm_name = null,
768768 .description = "Enable SPIR-V capability Linkage",
769769 .dependencies = featureSet(&[_]Feature{}),
770770 };
771 result[@enumToInt(Feature.Kernel)] = .{
771 result[@intFromEnum(Feature.Kernel)] = .{
772772 .llvm_name = null,
773773 .description = "Enable SPIR-V capability Kernel",
774774 .dependencies = featureSet(&[_]Feature{}),
775775 };
776 result[@enumToInt(Feature.Vector16)] = .{
776 result[@intFromEnum(Feature.Vector16)] = .{
777777 .llvm_name = null,
778778 .description = "Enable SPIR-V capability Vector16",
779779 .dependencies = featureSet(&[_]Feature{
780780 .Kernel,
781781 }),
782782 };
783 result[@enumToInt(Feature.Float16Buffer)] = .{
783 result[@intFromEnum(Feature.Float16Buffer)] = .{
784784 .llvm_name = null,
785785 .description = "Enable SPIR-V capability Float16Buffer",
786786 .dependencies = featureSet(&[_]Feature{
787787 .Kernel,
788788 }),
789789 };
790 result[@enumToInt(Feature.Float16)] = .{
790 result[@intFromEnum(Feature.Float16)] = .{
791791 .llvm_name = null,
792792 .description = "Enable SPIR-V capability Float16",
793793 .dependencies = featureSet(&[_]Feature{}),
794794 };
795 result[@enumToInt(Feature.Float64)] = .{
795 result[@intFromEnum(Feature.Float64)] = .{
796796 .llvm_name = null,
797797 .description = "Enable SPIR-V capability Float64",
798798 .dependencies = featureSet(&[_]Feature{}),
799799 };
800 result[@enumToInt(Feature.Int64)] = .{
800 result[@intFromEnum(Feature.Int64)] = .{
801801 .llvm_name = null,
802802 .description = "Enable SPIR-V capability Int64",
803803 .dependencies = featureSet(&[_]Feature{}),
804804 };
805 result[@enumToInt(Feature.Int64Atomics)] = .{
805 result[@intFromEnum(Feature.Int64Atomics)] = .{
806806 .llvm_name = null,
807807 .description = "Enable SPIR-V capability Int64Atomics",
808808 .dependencies = featureSet(&[_]Feature{
809809 .Int64,
810810 }),
811811 };
812 result[@enumToInt(Feature.ImageBasic)] = .{
812 result[@intFromEnum(Feature.ImageBasic)] = .{
813813 .llvm_name = null,
814814 .description = "Enable SPIR-V capability ImageBasic",
815815 .dependencies = featureSet(&[_]Feature{
816816 .Kernel,
817817 }),
818818 };
819 result[@enumToInt(Feature.ImageReadWrite)] = .{
819 result[@intFromEnum(Feature.ImageReadWrite)] = .{
820820 .llvm_name = null,
821821 .description = "Enable SPIR-V capability ImageReadWrite",
822822 .dependencies = featureSet(&[_]Feature{
823823 .ImageBasic,
824824 }),
825825 };
826 result[@enumToInt(Feature.ImageMipmap)] = .{
826 result[@intFromEnum(Feature.ImageMipmap)] = .{
827827 .llvm_name = null,
828828 .description = "Enable SPIR-V capability ImageMipmap",
829829 .dependencies = featureSet(&[_]Feature{
830830 .ImageBasic,
831831 }),
832832 };
833 result[@enumToInt(Feature.Pipes)] = .{
833 result[@intFromEnum(Feature.Pipes)] = .{
834834 .llvm_name = null,
835835 .description = "Enable SPIR-V capability Pipes",
836836 .dependencies = featureSet(&[_]Feature{
837837 .Kernel,
838838 }),
839839 };
840 result[@enumToInt(Feature.Groups)] = .{
840 result[@intFromEnum(Feature.Groups)] = .{
841841 .llvm_name = null,
842842 .description = "Enable SPIR-V capability Groups",
843843 .dependencies = featureSet(&[_]Feature{}),
844844 };
845 result[@enumToInt(Feature.DeviceEnqueue)] = .{
845 result[@intFromEnum(Feature.DeviceEnqueue)] = .{
846846 .llvm_name = null,
847847 .description = "Enable SPIR-V capability DeviceEnqueue",
848848 .dependencies = featureSet(&[_]Feature{
849849 .Kernel,
850850 }),
851851 };
852 result[@enumToInt(Feature.LiteralSampler)] = .{
852 result[@intFromEnum(Feature.LiteralSampler)] = .{
853853 .llvm_name = null,
854854 .description = "Enable SPIR-V capability LiteralSampler",
855855 .dependencies = featureSet(&[_]Feature{
856856 .Kernel,
857857 }),
858858 };
859 result[@enumToInt(Feature.AtomicStorage)] = .{
859 result[@intFromEnum(Feature.AtomicStorage)] = .{
860860 .llvm_name = null,
861861 .description = "Enable SPIR-V capability AtomicStorage",
862862 .dependencies = featureSet(&[_]Feature{
863863 .Shader,
864864 }),
865865 };
866 result[@enumToInt(Feature.Int16)] = .{
866 result[@intFromEnum(Feature.Int16)] = .{
867867 .llvm_name = null,
868868 .description = "Enable SPIR-V capability Int16",
869869 .dependencies = featureSet(&[_]Feature{}),
870870 };
871 result[@enumToInt(Feature.TessellationPointSize)] = .{
871 result[@intFromEnum(Feature.TessellationPointSize)] = .{
872872 .llvm_name = null,
873873 .description = "Enable SPIR-V capability TessellationPointSize",
874874 .dependencies = featureSet(&[_]Feature{
875875 .Tessellation,
876876 }),
877877 };
878 result[@enumToInt(Feature.GeometryPointSize)] = .{
878 result[@intFromEnum(Feature.GeometryPointSize)] = .{
879879 .llvm_name = null,
880880 .description = "Enable SPIR-V capability GeometryPointSize",
881881 .dependencies = featureSet(&[_]Feature{
882882 .Geometry,
883883 }),
884884 };
885 result[@enumToInt(Feature.ImageGatherExtended)] = .{
885 result[@intFromEnum(Feature.ImageGatherExtended)] = .{
886886 .llvm_name = null,
887887 .description = "Enable SPIR-V capability ImageGatherExtended",
888888 .dependencies = featureSet(&[_]Feature{
889889 .Shader,
890890 }),
891891 };
892 result[@enumToInt(Feature.StorageImageMultisample)] = .{
892 result[@intFromEnum(Feature.StorageImageMultisample)] = .{
893893 .llvm_name = null,
894894 .description = "Enable SPIR-V capability StorageImageMultisample",
895895 .dependencies = featureSet(&[_]Feature{
896896 .Shader,
897897 }),
898898 };
899 result[@enumToInt(Feature.UniformBufferArrayDynamicIndexing)] = .{
899 result[@intFromEnum(Feature.UniformBufferArrayDynamicIndexing)] = .{
900900 .llvm_name = null,
901901 .description = "Enable SPIR-V capability UniformBufferArrayDynamicIndexing",
902902 .dependencies = featureSet(&[_]Feature{
903903 .Shader,
904904 }),
905905 };
906 result[@enumToInt(Feature.SampledImageArrayDynamicIndexing)] = .{
906 result[@intFromEnum(Feature.SampledImageArrayDynamicIndexing)] = .{
907907 .llvm_name = null,
908908 .description = "Enable SPIR-V capability SampledImageArrayDynamicIndexing",
909909 .dependencies = featureSet(&[_]Feature{
910910 .Shader,
911911 }),
912912 };
913 result[@enumToInt(Feature.StorageBufferArrayDynamicIndexing)] = .{
913 result[@intFromEnum(Feature.StorageBufferArrayDynamicIndexing)] = .{
914914 .llvm_name = null,
915915 .description = "Enable SPIR-V capability StorageBufferArrayDynamicIndexing",
916916 .dependencies = featureSet(&[_]Feature{
917917 .Shader,
918918 }),
919919 };
920 result[@enumToInt(Feature.StorageImageArrayDynamicIndexing)] = .{
920 result[@intFromEnum(Feature.StorageImageArrayDynamicIndexing)] = .{
921921 .llvm_name = null,
922922 .description = "Enable SPIR-V capability StorageImageArrayDynamicIndexing",
923923 .dependencies = featureSet(&[_]Feature{
924924 .Shader,
925925 }),
926926 };
927 result[@enumToInt(Feature.ClipDistance)] = .{
927 result[@intFromEnum(Feature.ClipDistance)] = .{
928928 .llvm_name = null,
929929 .description = "Enable SPIR-V capability ClipDistance",
930930 .dependencies = featureSet(&[_]Feature{
931931 .Shader,
932932 }),
933933 };
934 result[@enumToInt(Feature.CullDistance)] = .{
934 result[@intFromEnum(Feature.CullDistance)] = .{
935935 .llvm_name = null,
936936 .description = "Enable SPIR-V capability CullDistance",
937937 .dependencies = featureSet(&[_]Feature{
938938 .Shader,
939939 }),
940940 };
941 result[@enumToInt(Feature.ImageCubeArray)] = .{
941 result[@intFromEnum(Feature.ImageCubeArray)] = .{
942942 .llvm_name = null,
943943 .description = "Enable SPIR-V capability ImageCubeArray",
944944 .dependencies = featureSet(&[_]Feature{
945945 .SampledCubeArray,
946946 }),
947947 };
948 result[@enumToInt(Feature.SampleRateShading)] = .{
948 result[@intFromEnum(Feature.SampleRateShading)] = .{
949949 .llvm_name = null,
950950 .description = "Enable SPIR-V capability SampleRateShading",
951951 .dependencies = featureSet(&[_]Feature{
952952 .Shader,
953953 }),
954954 };
955 result[@enumToInt(Feature.ImageRect)] = .{
955 result[@intFromEnum(Feature.ImageRect)] = .{
956956 .llvm_name = null,
957957 .description = "Enable SPIR-V capability ImageRect",
958958 .dependencies = featureSet(&[_]Feature{
959959 .SampledRect,
960960 }),
961961 };
962 result[@enumToInt(Feature.SampledRect)] = .{
962 result[@intFromEnum(Feature.SampledRect)] = .{
963963 .llvm_name = null,
964964 .description = "Enable SPIR-V capability SampledRect",
965965 .dependencies = featureSet(&[_]Feature{
966966 .Shader,
967967 }),
968968 };
969 result[@enumToInt(Feature.GenericPointer)] = .{
969 result[@intFromEnum(Feature.GenericPointer)] = .{
970970 .llvm_name = null,
971971 .description = "Enable SPIR-V capability GenericPointer",
972972 .dependencies = featureSet(&[_]Feature{
973973 .Addresses,
974974 }),
975975 };
976 result[@enumToInt(Feature.Int8)] = .{
976 result[@intFromEnum(Feature.Int8)] = .{
977977 .llvm_name = null,
978978 .description = "Enable SPIR-V capability Int8",
979979 .dependencies = featureSet(&[_]Feature{}),
980980 };
981 result[@enumToInt(Feature.InputAttachment)] = .{
981 result[@intFromEnum(Feature.InputAttachment)] = .{
982982 .llvm_name = null,
983983 .description = "Enable SPIR-V capability InputAttachment",
984984 .dependencies = featureSet(&[_]Feature{
985985 .Shader,
986986 }),
987987 };
988 result[@enumToInt(Feature.SparseResidency)] = .{
988 result[@intFromEnum(Feature.SparseResidency)] = .{
989989 .llvm_name = null,
990990 .description = "Enable SPIR-V capability SparseResidency",
991991 .dependencies = featureSet(&[_]Feature{
992992 .Shader,
993993 }),
994994 };
995 result[@enumToInt(Feature.MinLod)] = .{
995 result[@intFromEnum(Feature.MinLod)] = .{
996996 .llvm_name = null,
997997 .description = "Enable SPIR-V capability MinLod",
998998 .dependencies = featureSet(&[_]Feature{
999999 .Shader,
10001000 }),
10011001 };
1002 result[@enumToInt(Feature.Sampled1D)] = .{
1002 result[@intFromEnum(Feature.Sampled1D)] = .{
10031003 .llvm_name = null,
10041004 .description = "Enable SPIR-V capability Sampled1D",
10051005 .dependencies = featureSet(&[_]Feature{}),
10061006 };
1007 result[@enumToInt(Feature.Image1D)] = .{
1007 result[@intFromEnum(Feature.Image1D)] = .{
10081008 .llvm_name = null,
10091009 .description = "Enable SPIR-V capability Image1D",
10101010 .dependencies = featureSet(&[_]Feature{
10111011 .Sampled1D,
10121012 }),
10131013 };
1014 result[@enumToInt(Feature.SampledCubeArray)] = .{
1014 result[@intFromEnum(Feature.SampledCubeArray)] = .{
10151015 .llvm_name = null,
10161016 .description = "Enable SPIR-V capability SampledCubeArray",
10171017 .dependencies = featureSet(&[_]Feature{
10181018 .Shader,
10191019 }),
10201020 };
1021 result[@enumToInt(Feature.SampledBuffer)] = .{
1021 result[@intFromEnum(Feature.SampledBuffer)] = .{
10221022 .llvm_name = null,
10231023 .description = "Enable SPIR-V capability SampledBuffer",
10241024 .dependencies = featureSet(&[_]Feature{}),
10251025 };
1026 result[@enumToInt(Feature.ImageBuffer)] = .{
1026 result[@intFromEnum(Feature.ImageBuffer)] = .{
10271027 .llvm_name = null,
10281028 .description = "Enable SPIR-V capability ImageBuffer",
10291029 .dependencies = featureSet(&[_]Feature{
10301030 .SampledBuffer,
10311031 }),
10321032 };
1033 result[@enumToInt(Feature.ImageMSArray)] = .{
1033 result[@intFromEnum(Feature.ImageMSArray)] = .{
10341034 .llvm_name = null,
10351035 .description = "Enable SPIR-V capability ImageMSArray",
10361036 .dependencies = featureSet(&[_]Feature{
10371037 .Shader,
10381038 }),
10391039 };
1040 result[@enumToInt(Feature.StorageImageExtendedFormats)] = .{
1040 result[@intFromEnum(Feature.StorageImageExtendedFormats)] = .{
10411041 .llvm_name = null,
10421042 .description = "Enable SPIR-V capability StorageImageExtendedFormats",
10431043 .dependencies = featureSet(&[_]Feature{
10441044 .Shader,
10451045 }),
10461046 };
1047 result[@enumToInt(Feature.ImageQuery)] = .{
1047 result[@intFromEnum(Feature.ImageQuery)] = .{
10481048 .llvm_name = null,
10491049 .description = "Enable SPIR-V capability ImageQuery",
10501050 .dependencies = featureSet(&[_]Feature{
10511051 .Shader,
10521052 }),
10531053 };
1054 result[@enumToInt(Feature.DerivativeControl)] = .{
1054 result[@intFromEnum(Feature.DerivativeControl)] = .{
10551055 .llvm_name = null,
10561056 .description = "Enable SPIR-V capability DerivativeControl",
10571057 .dependencies = featureSet(&[_]Feature{
10581058 .Shader,
10591059 }),
10601060 };
1061 result[@enumToInt(Feature.InterpolationFunction)] = .{
1061 result[@intFromEnum(Feature.InterpolationFunction)] = .{
10621062 .llvm_name = null,
10631063 .description = "Enable SPIR-V capability InterpolationFunction",
10641064 .dependencies = featureSet(&[_]Feature{
10651065 .Shader,
10661066 }),
10671067 };
1068 result[@enumToInt(Feature.TransformFeedback)] = .{
1068 result[@intFromEnum(Feature.TransformFeedback)] = .{
10691069 .llvm_name = null,
10701070 .description = "Enable SPIR-V capability TransformFeedback",
10711071 .dependencies = featureSet(&[_]Feature{
10721072 .Shader,
10731073 }),
10741074 };
1075 result[@enumToInt(Feature.GeometryStreams)] = .{
1075 result[@intFromEnum(Feature.GeometryStreams)] = .{
10761076 .llvm_name = null,
10771077 .description = "Enable SPIR-V capability GeometryStreams",
10781078 .dependencies = featureSet(&[_]Feature{
10791079 .Geometry,
10801080 }),
10811081 };
1082 result[@enumToInt(Feature.StorageImageReadWithoutFormat)] = .{
1082 result[@intFromEnum(Feature.StorageImageReadWithoutFormat)] = .{
10831083 .llvm_name = null,
10841084 .description = "Enable SPIR-V capability StorageImageReadWithoutFormat",
10851085 .dependencies = featureSet(&[_]Feature{
10861086 .Shader,
10871087 }),
10881088 };
1089 result[@enumToInt(Feature.StorageImageWriteWithoutFormat)] = .{
1089 result[@intFromEnum(Feature.StorageImageWriteWithoutFormat)] = .{
10901090 .llvm_name = null,
10911091 .description = "Enable SPIR-V capability StorageImageWriteWithoutFormat",
10921092 .dependencies = featureSet(&[_]Feature{
10931093 .Shader,
10941094 }),
10951095 };
1096 result[@enumToInt(Feature.MultiViewport)] = .{
1096 result[@intFromEnum(Feature.MultiViewport)] = .{
10971097 .llvm_name = null,
10981098 .description = "Enable SPIR-V capability MultiViewport",
10991099 .dependencies = featureSet(&[_]Feature{
11001100 .Geometry,
11011101 }),
11021102 };
1103 result[@enumToInt(Feature.SubgroupDispatch)] = .{
1103 result[@intFromEnum(Feature.SubgroupDispatch)] = .{
11041104 .llvm_name = null,
11051105 .description = "Enable SPIR-V capability SubgroupDispatch",
11061106 .dependencies = featureSet(&[_]Feature{
......@@ -1108,7 +1108,7 @@ pub const all_features = blk: {
11081108 .DeviceEnqueue,
11091109 }),
11101110 };
1111 result[@enumToInt(Feature.NamedBarrier)] = .{
1111 result[@intFromEnum(Feature.NamedBarrier)] = .{
11121112 .llvm_name = null,
11131113 .description = "Enable SPIR-V capability NamedBarrier",
11141114 .dependencies = featureSet(&[_]Feature{
......@@ -1116,7 +1116,7 @@ pub const all_features = blk: {
11161116 .Kernel,
11171117 }),
11181118 };
1119 result[@enumToInt(Feature.PipeStorage)] = .{
1119 result[@intFromEnum(Feature.PipeStorage)] = .{
11201120 .llvm_name = null,
11211121 .description = "Enable SPIR-V capability PipeStorage",
11221122 .dependencies = featureSet(&[_]Feature{
......@@ -1124,14 +1124,14 @@ pub const all_features = blk: {
11241124 .Pipes,
11251125 }),
11261126 };
1127 result[@enumToInt(Feature.GroupNonUniform)] = .{
1127 result[@intFromEnum(Feature.GroupNonUniform)] = .{
11281128 .llvm_name = null,
11291129 .description = "Enable SPIR-V capability GroupNonUniform",
11301130 .dependencies = featureSet(&[_]Feature{
11311131 .v1_3,
11321132 }),
11331133 };
1134 result[@enumToInt(Feature.GroupNonUniformVote)] = .{
1134 result[@intFromEnum(Feature.GroupNonUniformVote)] = .{
11351135 .llvm_name = null,
11361136 .description = "Enable SPIR-V capability GroupNonUniformVote",
11371137 .dependencies = featureSet(&[_]Feature{
......@@ -1139,7 +1139,7 @@ pub const all_features = blk: {
11391139 .GroupNonUniform,
11401140 }),
11411141 };
1142 result[@enumToInt(Feature.GroupNonUniformArithmetic)] = .{
1142 result[@intFromEnum(Feature.GroupNonUniformArithmetic)] = .{
11431143 .llvm_name = null,
11441144 .description = "Enable SPIR-V capability GroupNonUniformArithmetic",
11451145 .dependencies = featureSet(&[_]Feature{
......@@ -1147,7 +1147,7 @@ pub const all_features = blk: {
11471147 .GroupNonUniform,
11481148 }),
11491149 };
1150 result[@enumToInt(Feature.GroupNonUniformBallot)] = .{
1150 result[@intFromEnum(Feature.GroupNonUniformBallot)] = .{
11511151 .llvm_name = null,
11521152 .description = "Enable SPIR-V capability GroupNonUniformBallot",
11531153 .dependencies = featureSet(&[_]Feature{
......@@ -1155,7 +1155,7 @@ pub const all_features = blk: {
11551155 .GroupNonUniform,
11561156 }),
11571157 };
1158 result[@enumToInt(Feature.GroupNonUniformShuffle)] = .{
1158 result[@intFromEnum(Feature.GroupNonUniformShuffle)] = .{
11591159 .llvm_name = null,
11601160 .description = "Enable SPIR-V capability GroupNonUniformShuffle",
11611161 .dependencies = featureSet(&[_]Feature{
......@@ -1163,7 +1163,7 @@ pub const all_features = blk: {
11631163 .GroupNonUniform,
11641164 }),
11651165 };
1166 result[@enumToInt(Feature.GroupNonUniformShuffleRelative)] = .{
1166 result[@intFromEnum(Feature.GroupNonUniformShuffleRelative)] = .{
11671167 .llvm_name = null,
11681168 .description = "Enable SPIR-V capability GroupNonUniformShuffleRelative",
11691169 .dependencies = featureSet(&[_]Feature{
......@@ -1171,7 +1171,7 @@ pub const all_features = blk: {
11711171 .GroupNonUniform,
11721172 }),
11731173 };
1174 result[@enumToInt(Feature.GroupNonUniformClustered)] = .{
1174 result[@intFromEnum(Feature.GroupNonUniformClustered)] = .{
11751175 .llvm_name = null,
11761176 .description = "Enable SPIR-V capability GroupNonUniformClustered",
11771177 .dependencies = featureSet(&[_]Feature{
......@@ -1179,7 +1179,7 @@ pub const all_features = blk: {
11791179 .GroupNonUniform,
11801180 }),
11811181 };
1182 result[@enumToInt(Feature.GroupNonUniformQuad)] = .{
1182 result[@intFromEnum(Feature.GroupNonUniformQuad)] = .{
11831183 .llvm_name = null,
11841184 .description = "Enable SPIR-V capability GroupNonUniformQuad",
11851185 .dependencies = featureSet(&[_]Feature{
......@@ -1187,33 +1187,33 @@ pub const all_features = blk: {
11871187 .GroupNonUniform,
11881188 }),
11891189 };
1190 result[@enumToInt(Feature.ShaderLayer)] = .{
1190 result[@intFromEnum(Feature.ShaderLayer)] = .{
11911191 .llvm_name = null,
11921192 .description = "Enable SPIR-V capability ShaderLayer",
11931193 .dependencies = featureSet(&[_]Feature{
11941194 .v1_5,
11951195 }),
11961196 };
1197 result[@enumToInt(Feature.ShaderViewportIndex)] = .{
1197 result[@intFromEnum(Feature.ShaderViewportIndex)] = .{
11981198 .llvm_name = null,
11991199 .description = "Enable SPIR-V capability ShaderViewportIndex",
12001200 .dependencies = featureSet(&[_]Feature{
12011201 .v1_5,
12021202 }),
12031203 };
1204 result[@enumToInt(Feature.FragmentShadingRateKHR)] = .{
1204 result[@intFromEnum(Feature.FragmentShadingRateKHR)] = .{
12051205 .llvm_name = null,
12061206 .description = "Enable SPIR-V capability FragmentShadingRateKHR",
12071207 .dependencies = featureSet(&[_]Feature{
12081208 .Shader,
12091209 }),
12101210 };
1211 result[@enumToInt(Feature.SubgroupBallotKHR)] = .{
1211 result[@intFromEnum(Feature.SubgroupBallotKHR)] = .{
12121212 .llvm_name = null,
12131213 .description = "Enable SPIR-V capability SubgroupBallotKHR",
12141214 .dependencies = featureSet(&[_]Feature{}),
12151215 };
1216 result[@enumToInt(Feature.DrawParameters)] = .{
1216 result[@intFromEnum(Feature.DrawParameters)] = .{
12171217 .llvm_name = null,
12181218 .description = "Enable SPIR-V capability DrawParameters",
12191219 .dependencies = featureSet(&[_]Feature{
......@@ -1221,47 +1221,47 @@ pub const all_features = blk: {
12211221 .Shader,
12221222 }),
12231223 };
1224 result[@enumToInt(Feature.WorkgroupMemoryExplicitLayoutKHR)] = .{
1224 result[@intFromEnum(Feature.WorkgroupMemoryExplicitLayoutKHR)] = .{
12251225 .llvm_name = null,
12261226 .description = "Enable SPIR-V capability WorkgroupMemoryExplicitLayoutKHR",
12271227 .dependencies = featureSet(&[_]Feature{
12281228 .Shader,
12291229 }),
12301230 };
1231 result[@enumToInt(Feature.WorkgroupMemoryExplicitLayout8BitAccessKHR)] = .{
1231 result[@intFromEnum(Feature.WorkgroupMemoryExplicitLayout8BitAccessKHR)] = .{
12321232 .llvm_name = null,
12331233 .description = "Enable SPIR-V capability WorkgroupMemoryExplicitLayout8BitAccessKHR",
12341234 .dependencies = featureSet(&[_]Feature{
12351235 .WorkgroupMemoryExplicitLayoutKHR,
12361236 }),
12371237 };
1238 result[@enumToInt(Feature.WorkgroupMemoryExplicitLayout16BitAccessKHR)] = .{
1238 result[@intFromEnum(Feature.WorkgroupMemoryExplicitLayout16BitAccessKHR)] = .{
12391239 .llvm_name = null,
12401240 .description = "Enable SPIR-V capability WorkgroupMemoryExplicitLayout16BitAccessKHR",
12411241 .dependencies = featureSet(&[_]Feature{
12421242 .Shader,
12431243 }),
12441244 };
1245 result[@enumToInt(Feature.SubgroupVoteKHR)] = .{
1245 result[@intFromEnum(Feature.SubgroupVoteKHR)] = .{
12461246 .llvm_name = null,
12471247 .description = "Enable SPIR-V capability SubgroupVoteKHR",
12481248 .dependencies = featureSet(&[_]Feature{}),
12491249 };
1250 result[@enumToInt(Feature.StorageBuffer16BitAccess)] = .{
1250 result[@intFromEnum(Feature.StorageBuffer16BitAccess)] = .{
12511251 .llvm_name = null,
12521252 .description = "Enable SPIR-V capability StorageBuffer16BitAccess",
12531253 .dependencies = featureSet(&[_]Feature{
12541254 .v1_3,
12551255 }),
12561256 };
1257 result[@enumToInt(Feature.StorageUniformBufferBlock16)] = .{
1257 result[@intFromEnum(Feature.StorageUniformBufferBlock16)] = .{
12581258 .llvm_name = null,
12591259 .description = "Enable SPIR-V capability StorageUniformBufferBlock16",
12601260 .dependencies = featureSet(&[_]Feature{
12611261 .v1_3,
12621262 }),
12631263 };
1264 result[@enumToInt(Feature.UniformAndStorageBuffer16BitAccess)] = .{
1264 result[@intFromEnum(Feature.UniformAndStorageBuffer16BitAccess)] = .{
12651265 .llvm_name = null,
12661266 .description = "Enable SPIR-V capability UniformAndStorageBuffer16BitAccess",
12671267 .dependencies = featureSet(&[_]Feature{
......@@ -1270,7 +1270,7 @@ pub const all_features = blk: {
12701270 .StorageUniformBufferBlock16,
12711271 }),
12721272 };
1273 result[@enumToInt(Feature.StorageUniform16)] = .{
1273 result[@intFromEnum(Feature.StorageUniform16)] = .{
12741274 .llvm_name = null,
12751275 .description = "Enable SPIR-V capability StorageUniform16",
12761276 .dependencies = featureSet(&[_]Feature{
......@@ -1279,28 +1279,28 @@ pub const all_features = blk: {
12791279 .StorageUniformBufferBlock16,
12801280 }),
12811281 };
1282 result[@enumToInt(Feature.StoragePushConstant16)] = .{
1282 result[@intFromEnum(Feature.StoragePushConstant16)] = .{
12831283 .llvm_name = null,
12841284 .description = "Enable SPIR-V capability StoragePushConstant16",
12851285 .dependencies = featureSet(&[_]Feature{
12861286 .v1_3,
12871287 }),
12881288 };
1289 result[@enumToInt(Feature.StorageInputOutput16)] = .{
1289 result[@intFromEnum(Feature.StorageInputOutput16)] = .{
12901290 .llvm_name = null,
12911291 .description = "Enable SPIR-V capability StorageInputOutput16",
12921292 .dependencies = featureSet(&[_]Feature{
12931293 .v1_3,
12941294 }),
12951295 };
1296 result[@enumToInt(Feature.DeviceGroup)] = .{
1296 result[@intFromEnum(Feature.DeviceGroup)] = .{
12971297 .llvm_name = null,
12981298 .description = "Enable SPIR-V capability DeviceGroup",
12991299 .dependencies = featureSet(&[_]Feature{
13001300 .v1_3,
13011301 }),
13021302 };
1303 result[@enumToInt(Feature.MultiView)] = .{
1303 result[@intFromEnum(Feature.MultiView)] = .{
13041304 .llvm_name = null,
13051305 .description = "Enable SPIR-V capability MultiView",
13061306 .dependencies = featureSet(&[_]Feature{
......@@ -1308,7 +1308,7 @@ pub const all_features = blk: {
13081308 .Shader,
13091309 }),
13101310 };
1311 result[@enumToInt(Feature.VariablePointersStorageBuffer)] = .{
1311 result[@intFromEnum(Feature.VariablePointersStorageBuffer)] = .{
13121312 .llvm_name = null,
13131313 .description = "Enable SPIR-V capability VariablePointersStorageBuffer",
13141314 .dependencies = featureSet(&[_]Feature{
......@@ -1316,7 +1316,7 @@ pub const all_features = blk: {
13161316 .Shader,
13171317 }),
13181318 };
1319 result[@enumToInt(Feature.VariablePointers)] = .{
1319 result[@intFromEnum(Feature.VariablePointers)] = .{
13201320 .llvm_name = null,
13211321 .description = "Enable SPIR-V capability VariablePointers",
13221322 .dependencies = featureSet(&[_]Feature{
......@@ -1324,24 +1324,24 @@ pub const all_features = blk: {
13241324 .VariablePointersStorageBuffer,
13251325 }),
13261326 };
1327 result[@enumToInt(Feature.AtomicStorageOps)] = .{
1327 result[@intFromEnum(Feature.AtomicStorageOps)] = .{
13281328 .llvm_name = null,
13291329 .description = "Enable SPIR-V capability AtomicStorageOps",
13301330 .dependencies = featureSet(&[_]Feature{}),
13311331 };
1332 result[@enumToInt(Feature.SampleMaskPostDepthCoverage)] = .{
1332 result[@intFromEnum(Feature.SampleMaskPostDepthCoverage)] = .{
13331333 .llvm_name = null,
13341334 .description = "Enable SPIR-V capability SampleMaskPostDepthCoverage",
13351335 .dependencies = featureSet(&[_]Feature{}),
13361336 };
1337 result[@enumToInt(Feature.StorageBuffer8BitAccess)] = .{
1337 result[@intFromEnum(Feature.StorageBuffer8BitAccess)] = .{
13381338 .llvm_name = null,
13391339 .description = "Enable SPIR-V capability StorageBuffer8BitAccess",
13401340 .dependencies = featureSet(&[_]Feature{
13411341 .v1_5,
13421342 }),
13431343 };
1344 result[@enumToInt(Feature.UniformAndStorageBuffer8BitAccess)] = .{
1344 result[@intFromEnum(Feature.UniformAndStorageBuffer8BitAccess)] = .{
13451345 .llvm_name = null,
13461346 .description = "Enable SPIR-V capability UniformAndStorageBuffer8BitAccess",
13471347 .dependencies = featureSet(&[_]Feature{
......@@ -1349,63 +1349,63 @@ pub const all_features = blk: {
13491349 .StorageBuffer8BitAccess,
13501350 }),
13511351 };
1352 result[@enumToInt(Feature.StoragePushConstant8)] = .{
1352 result[@intFromEnum(Feature.StoragePushConstant8)] = .{
13531353 .llvm_name = null,
13541354 .description = "Enable SPIR-V capability StoragePushConstant8",
13551355 .dependencies = featureSet(&[_]Feature{
13561356 .v1_5,
13571357 }),
13581358 };
1359 result[@enumToInt(Feature.DenormPreserve)] = .{
1359 result[@intFromEnum(Feature.DenormPreserve)] = .{
13601360 .llvm_name = null,
13611361 .description = "Enable SPIR-V capability DenormPreserve",
13621362 .dependencies = featureSet(&[_]Feature{
13631363 .v1_4,
13641364 }),
13651365 };
1366 result[@enumToInt(Feature.DenormFlushToZero)] = .{
1366 result[@intFromEnum(Feature.DenormFlushToZero)] = .{
13671367 .llvm_name = null,
13681368 .description = "Enable SPIR-V capability DenormFlushToZero",
13691369 .dependencies = featureSet(&[_]Feature{
13701370 .v1_4,
13711371 }),
13721372 };
1373 result[@enumToInt(Feature.SignedZeroInfNanPreserve)] = .{
1373 result[@intFromEnum(Feature.SignedZeroInfNanPreserve)] = .{
13741374 .llvm_name = null,
13751375 .description = "Enable SPIR-V capability SignedZeroInfNanPreserve",
13761376 .dependencies = featureSet(&[_]Feature{
13771377 .v1_4,
13781378 }),
13791379 };
1380 result[@enumToInt(Feature.RoundingModeRTE)] = .{
1380 result[@intFromEnum(Feature.RoundingModeRTE)] = .{
13811381 .llvm_name = null,
13821382 .description = "Enable SPIR-V capability RoundingModeRTE",
13831383 .dependencies = featureSet(&[_]Feature{
13841384 .v1_4,
13851385 }),
13861386 };
1387 result[@enumToInt(Feature.RoundingModeRTZ)] = .{
1387 result[@intFromEnum(Feature.RoundingModeRTZ)] = .{
13881388 .llvm_name = null,
13891389 .description = "Enable SPIR-V capability RoundingModeRTZ",
13901390 .dependencies = featureSet(&[_]Feature{
13911391 .v1_4,
13921392 }),
13931393 };
1394 result[@enumToInt(Feature.RayQueryProvisionalKHR)] = .{
1394 result[@intFromEnum(Feature.RayQueryProvisionalKHR)] = .{
13951395 .llvm_name = null,
13961396 .description = "Enable SPIR-V capability RayQueryProvisionalKHR",
13971397 .dependencies = featureSet(&[_]Feature{
13981398 .Shader,
13991399 }),
14001400 };
1401 result[@enumToInt(Feature.RayQueryKHR)] = .{
1401 result[@intFromEnum(Feature.RayQueryKHR)] = .{
14021402 .llvm_name = null,
14031403 .description = "Enable SPIR-V capability RayQueryKHR",
14041404 .dependencies = featureSet(&[_]Feature{
14051405 .Shader,
14061406 }),
14071407 };
1408 result[@enumToInt(Feature.RayTraversalPrimitiveCullingKHR)] = .{
1408 result[@intFromEnum(Feature.RayTraversalPrimitiveCullingKHR)] = .{
14091409 .llvm_name = null,
14101410 .description = "Enable SPIR-V capability RayTraversalPrimitiveCullingKHR",
14111411 .dependencies = featureSet(&[_]Feature{
......@@ -1413,160 +1413,160 @@ pub const all_features = blk: {
14131413 .RayTracingKHR,
14141414 }),
14151415 };
1416 result[@enumToInt(Feature.RayTracingKHR)] = .{
1416 result[@intFromEnum(Feature.RayTracingKHR)] = .{
14171417 .llvm_name = null,
14181418 .description = "Enable SPIR-V capability RayTracingKHR",
14191419 .dependencies = featureSet(&[_]Feature{
14201420 .Shader,
14211421 }),
14221422 };
1423 result[@enumToInt(Feature.Float16ImageAMD)] = .{
1423 result[@intFromEnum(Feature.Float16ImageAMD)] = .{
14241424 .llvm_name = null,
14251425 .description = "Enable SPIR-V capability Float16ImageAMD",
14261426 .dependencies = featureSet(&[_]Feature{
14271427 .Shader,
14281428 }),
14291429 };
1430 result[@enumToInt(Feature.ImageGatherBiasLodAMD)] = .{
1430 result[@intFromEnum(Feature.ImageGatherBiasLodAMD)] = .{
14311431 .llvm_name = null,
14321432 .description = "Enable SPIR-V capability ImageGatherBiasLodAMD",
14331433 .dependencies = featureSet(&[_]Feature{
14341434 .Shader,
14351435 }),
14361436 };
1437 result[@enumToInt(Feature.FragmentMaskAMD)] = .{
1437 result[@intFromEnum(Feature.FragmentMaskAMD)] = .{
14381438 .llvm_name = null,
14391439 .description = "Enable SPIR-V capability FragmentMaskAMD",
14401440 .dependencies = featureSet(&[_]Feature{
14411441 .Shader,
14421442 }),
14431443 };
1444 result[@enumToInt(Feature.StencilExportEXT)] = .{
1444 result[@intFromEnum(Feature.StencilExportEXT)] = .{
14451445 .llvm_name = null,
14461446 .description = "Enable SPIR-V capability StencilExportEXT",
14471447 .dependencies = featureSet(&[_]Feature{
14481448 .Shader,
14491449 }),
14501450 };
1451 result[@enumToInt(Feature.ImageReadWriteLodAMD)] = .{
1451 result[@intFromEnum(Feature.ImageReadWriteLodAMD)] = .{
14521452 .llvm_name = null,
14531453 .description = "Enable SPIR-V capability ImageReadWriteLodAMD",
14541454 .dependencies = featureSet(&[_]Feature{
14551455 .Shader,
14561456 }),
14571457 };
1458 result[@enumToInt(Feature.Int64ImageEXT)] = .{
1458 result[@intFromEnum(Feature.Int64ImageEXT)] = .{
14591459 .llvm_name = null,
14601460 .description = "Enable SPIR-V capability Int64ImageEXT",
14611461 .dependencies = featureSet(&[_]Feature{
14621462 .Shader,
14631463 }),
14641464 };
1465 result[@enumToInt(Feature.ShaderClockKHR)] = .{
1465 result[@intFromEnum(Feature.ShaderClockKHR)] = .{
14661466 .llvm_name = null,
14671467 .description = "Enable SPIR-V capability ShaderClockKHR",
14681468 .dependencies = featureSet(&[_]Feature{
14691469 .Shader,
14701470 }),
14711471 };
1472 result[@enumToInt(Feature.SampleMaskOverrideCoverageNV)] = .{
1472 result[@intFromEnum(Feature.SampleMaskOverrideCoverageNV)] = .{
14731473 .llvm_name = null,
14741474 .description = "Enable SPIR-V capability SampleMaskOverrideCoverageNV",
14751475 .dependencies = featureSet(&[_]Feature{
14761476 .SampleRateShading,
14771477 }),
14781478 };
1479 result[@enumToInt(Feature.GeometryShaderPassthroughNV)] = .{
1479 result[@intFromEnum(Feature.GeometryShaderPassthroughNV)] = .{
14801480 .llvm_name = null,
14811481 .description = "Enable SPIR-V capability GeometryShaderPassthroughNV",
14821482 .dependencies = featureSet(&[_]Feature{
14831483 .Geometry,
14841484 }),
14851485 };
1486 result[@enumToInt(Feature.ShaderViewportIndexLayerEXT)] = .{
1486 result[@intFromEnum(Feature.ShaderViewportIndexLayerEXT)] = .{
14871487 .llvm_name = null,
14881488 .description = "Enable SPIR-V capability ShaderViewportIndexLayerEXT",
14891489 .dependencies = featureSet(&[_]Feature{
14901490 .MultiViewport,
14911491 }),
14921492 };
1493 result[@enumToInt(Feature.ShaderViewportIndexLayerNV)] = .{
1493 result[@intFromEnum(Feature.ShaderViewportIndexLayerNV)] = .{
14941494 .llvm_name = null,
14951495 .description = "Enable SPIR-V capability ShaderViewportIndexLayerNV",
14961496 .dependencies = featureSet(&[_]Feature{
14971497 .MultiViewport,
14981498 }),
14991499 };
1500 result[@enumToInt(Feature.ShaderViewportMaskNV)] = .{
1500 result[@intFromEnum(Feature.ShaderViewportMaskNV)] = .{
15011501 .llvm_name = null,
15021502 .description = "Enable SPIR-V capability ShaderViewportMaskNV",
15031503 .dependencies = featureSet(&[_]Feature{
15041504 .ShaderViewportIndexLayerNV,
15051505 }),
15061506 };
1507 result[@enumToInt(Feature.ShaderStereoViewNV)] = .{
1507 result[@intFromEnum(Feature.ShaderStereoViewNV)] = .{
15081508 .llvm_name = null,
15091509 .description = "Enable SPIR-V capability ShaderStereoViewNV",
15101510 .dependencies = featureSet(&[_]Feature{
15111511 .ShaderViewportMaskNV,
15121512 }),
15131513 };
1514 result[@enumToInt(Feature.PerViewAttributesNV)] = .{
1514 result[@intFromEnum(Feature.PerViewAttributesNV)] = .{
15151515 .llvm_name = null,
15161516 .description = "Enable SPIR-V capability PerViewAttributesNV",
15171517 .dependencies = featureSet(&[_]Feature{
15181518 .MultiView,
15191519 }),
15201520 };
1521 result[@enumToInt(Feature.FragmentFullyCoveredEXT)] = .{
1521 result[@intFromEnum(Feature.FragmentFullyCoveredEXT)] = .{
15221522 .llvm_name = null,
15231523 .description = "Enable SPIR-V capability FragmentFullyCoveredEXT",
15241524 .dependencies = featureSet(&[_]Feature{
15251525 .Shader,
15261526 }),
15271527 };
1528 result[@enumToInt(Feature.MeshShadingNV)] = .{
1528 result[@intFromEnum(Feature.MeshShadingNV)] = .{
15291529 .llvm_name = null,
15301530 .description = "Enable SPIR-V capability MeshShadingNV",
15311531 .dependencies = featureSet(&[_]Feature{
15321532 .Shader,
15331533 }),
15341534 };
1535 result[@enumToInt(Feature.ImageFootprintNV)] = .{
1535 result[@intFromEnum(Feature.ImageFootprintNV)] = .{
15361536 .llvm_name = null,
15371537 .description = "Enable SPIR-V capability ImageFootprintNV",
15381538 .dependencies = featureSet(&[_]Feature{}),
15391539 };
1540 result[@enumToInt(Feature.FragmentBarycentricNV)] = .{
1540 result[@intFromEnum(Feature.FragmentBarycentricNV)] = .{
15411541 .llvm_name = null,
15421542 .description = "Enable SPIR-V capability FragmentBarycentricNV",
15431543 .dependencies = featureSet(&[_]Feature{}),
15441544 };
1545 result[@enumToInt(Feature.ComputeDerivativeGroupQuadsNV)] = .{
1545 result[@intFromEnum(Feature.ComputeDerivativeGroupQuadsNV)] = .{
15461546 .llvm_name = null,
15471547 .description = "Enable SPIR-V capability ComputeDerivativeGroupQuadsNV",
15481548 .dependencies = featureSet(&[_]Feature{}),
15491549 };
1550 result[@enumToInt(Feature.FragmentDensityEXT)] = .{
1550 result[@intFromEnum(Feature.FragmentDensityEXT)] = .{
15511551 .llvm_name = null,
15521552 .description = "Enable SPIR-V capability FragmentDensityEXT",
15531553 .dependencies = featureSet(&[_]Feature{
15541554 .Shader,
15551555 }),
15561556 };
1557 result[@enumToInt(Feature.ShadingRateNV)] = .{
1557 result[@intFromEnum(Feature.ShadingRateNV)] = .{
15581558 .llvm_name = null,
15591559 .description = "Enable SPIR-V capability ShadingRateNV",
15601560 .dependencies = featureSet(&[_]Feature{
15611561 .Shader,
15621562 }),
15631563 };
1564 result[@enumToInt(Feature.GroupNonUniformPartitionedNV)] = .{
1564 result[@intFromEnum(Feature.GroupNonUniformPartitionedNV)] = .{
15651565 .llvm_name = null,
15661566 .description = "Enable SPIR-V capability GroupNonUniformPartitionedNV",
15671567 .dependencies = featureSet(&[_]Feature{}),
15681568 };
1569 result[@enumToInt(Feature.ShaderNonUniform)] = .{
1569 result[@intFromEnum(Feature.ShaderNonUniform)] = .{
15701570 .llvm_name = null,
15711571 .description = "Enable SPIR-V capability ShaderNonUniform",
15721572 .dependencies = featureSet(&[_]Feature{
......@@ -1574,7 +1574,7 @@ pub const all_features = blk: {
15741574 .Shader,
15751575 }),
15761576 };
1577 result[@enumToInt(Feature.ShaderNonUniformEXT)] = .{
1577 result[@intFromEnum(Feature.ShaderNonUniformEXT)] = .{
15781578 .llvm_name = null,
15791579 .description = "Enable SPIR-V capability ShaderNonUniformEXT",
15801580 .dependencies = featureSet(&[_]Feature{
......@@ -1582,7 +1582,7 @@ pub const all_features = blk: {
15821582 .Shader,
15831583 }),
15841584 };
1585 result[@enumToInt(Feature.RuntimeDescriptorArray)] = .{
1585 result[@intFromEnum(Feature.RuntimeDescriptorArray)] = .{
15861586 .llvm_name = null,
15871587 .description = "Enable SPIR-V capability RuntimeDescriptorArray",
15881588 .dependencies = featureSet(&[_]Feature{
......@@ -1590,7 +1590,7 @@ pub const all_features = blk: {
15901590 .Shader,
15911591 }),
15921592 };
1593 result[@enumToInt(Feature.RuntimeDescriptorArrayEXT)] = .{
1593 result[@intFromEnum(Feature.RuntimeDescriptorArrayEXT)] = .{
15941594 .llvm_name = null,
15951595 .description = "Enable SPIR-V capability RuntimeDescriptorArrayEXT",
15961596 .dependencies = featureSet(&[_]Feature{
......@@ -1598,7 +1598,7 @@ pub const all_features = blk: {
15981598 .Shader,
15991599 }),
16001600 };
1601 result[@enumToInt(Feature.InputAttachmentArrayDynamicIndexing)] = .{
1601 result[@intFromEnum(Feature.InputAttachmentArrayDynamicIndexing)] = .{
16021602 .llvm_name = null,
16031603 .description = "Enable SPIR-V capability InputAttachmentArrayDynamicIndexing",
16041604 .dependencies = featureSet(&[_]Feature{
......@@ -1606,7 +1606,7 @@ pub const all_features = blk: {
16061606 .InputAttachment,
16071607 }),
16081608 };
1609 result[@enumToInt(Feature.InputAttachmentArrayDynamicIndexingEXT)] = .{
1609 result[@intFromEnum(Feature.InputAttachmentArrayDynamicIndexingEXT)] = .{
16101610 .llvm_name = null,
16111611 .description = "Enable SPIR-V capability InputAttachmentArrayDynamicIndexingEXT",
16121612 .dependencies = featureSet(&[_]Feature{
......@@ -1614,7 +1614,7 @@ pub const all_features = blk: {
16141614 .InputAttachment,
16151615 }),
16161616 };
1617 result[@enumToInt(Feature.UniformTexelBufferArrayDynamicIndexing)] = .{
1617 result[@intFromEnum(Feature.UniformTexelBufferArrayDynamicIndexing)] = .{
16181618 .llvm_name = null,
16191619 .description = "Enable SPIR-V capability UniformTexelBufferArrayDynamicIndexing",
16201620 .dependencies = featureSet(&[_]Feature{
......@@ -1622,7 +1622,7 @@ pub const all_features = blk: {
16221622 .SampledBuffer,
16231623 }),
16241624 };
1625 result[@enumToInt(Feature.UniformTexelBufferArrayDynamicIndexingEXT)] = .{
1625 result[@intFromEnum(Feature.UniformTexelBufferArrayDynamicIndexingEXT)] = .{
16261626 .llvm_name = null,
16271627 .description = "Enable SPIR-V capability UniformTexelBufferArrayDynamicIndexingEXT",
16281628 .dependencies = featureSet(&[_]Feature{
......@@ -1630,7 +1630,7 @@ pub const all_features = blk: {
16301630 .SampledBuffer,
16311631 }),
16321632 };
1633 result[@enumToInt(Feature.StorageTexelBufferArrayDynamicIndexing)] = .{
1633 result[@intFromEnum(Feature.StorageTexelBufferArrayDynamicIndexing)] = .{
16341634 .llvm_name = null,
16351635 .description = "Enable SPIR-V capability StorageTexelBufferArrayDynamicIndexing",
16361636 .dependencies = featureSet(&[_]Feature{
......@@ -1638,7 +1638,7 @@ pub const all_features = blk: {
16381638 .ImageBuffer,
16391639 }),
16401640 };
1641 result[@enumToInt(Feature.StorageTexelBufferArrayDynamicIndexingEXT)] = .{
1641 result[@intFromEnum(Feature.StorageTexelBufferArrayDynamicIndexingEXT)] = .{
16421642 .llvm_name = null,
16431643 .description = "Enable SPIR-V capability StorageTexelBufferArrayDynamicIndexingEXT",
16441644 .dependencies = featureSet(&[_]Feature{
......@@ -1646,7 +1646,7 @@ pub const all_features = blk: {
16461646 .ImageBuffer,
16471647 }),
16481648 };
1649 result[@enumToInt(Feature.UniformBufferArrayNonUniformIndexing)] = .{
1649 result[@intFromEnum(Feature.UniformBufferArrayNonUniformIndexing)] = .{
16501650 .llvm_name = null,
16511651 .description = "Enable SPIR-V capability UniformBufferArrayNonUniformIndexing",
16521652 .dependencies = featureSet(&[_]Feature{
......@@ -1654,7 +1654,7 @@ pub const all_features = blk: {
16541654 .ShaderNonUniform,
16551655 }),
16561656 };
1657 result[@enumToInt(Feature.UniformBufferArrayNonUniformIndexingEXT)] = .{
1657 result[@intFromEnum(Feature.UniformBufferArrayNonUniformIndexingEXT)] = .{
16581658 .llvm_name = null,
16591659 .description = "Enable SPIR-V capability UniformBufferArrayNonUniformIndexingEXT",
16601660 .dependencies = featureSet(&[_]Feature{
......@@ -1662,7 +1662,7 @@ pub const all_features = blk: {
16621662 .ShaderNonUniform,
16631663 }),
16641664 };
1665 result[@enumToInt(Feature.SampledImageArrayNonUniformIndexing)] = .{
1665 result[@intFromEnum(Feature.SampledImageArrayNonUniformIndexing)] = .{
16661666 .llvm_name = null,
16671667 .description = "Enable SPIR-V capability SampledImageArrayNonUniformIndexing",
16681668 .dependencies = featureSet(&[_]Feature{
......@@ -1670,7 +1670,7 @@ pub const all_features = blk: {
16701670 .ShaderNonUniform,
16711671 }),
16721672 };
1673 result[@enumToInt(Feature.SampledImageArrayNonUniformIndexingEXT)] = .{
1673 result[@intFromEnum(Feature.SampledImageArrayNonUniformIndexingEXT)] = .{
16741674 .llvm_name = null,
16751675 .description = "Enable SPIR-V capability SampledImageArrayNonUniformIndexingEXT",
16761676 .dependencies = featureSet(&[_]Feature{
......@@ -1678,7 +1678,7 @@ pub const all_features = blk: {
16781678 .ShaderNonUniform,
16791679 }),
16801680 };
1681 result[@enumToInt(Feature.StorageBufferArrayNonUniformIndexing)] = .{
1681 result[@intFromEnum(Feature.StorageBufferArrayNonUniformIndexing)] = .{
16821682 .llvm_name = null,
16831683 .description = "Enable SPIR-V capability StorageBufferArrayNonUniformIndexing",
16841684 .dependencies = featureSet(&[_]Feature{
......@@ -1686,7 +1686,7 @@ pub const all_features = blk: {
16861686 .ShaderNonUniform,
16871687 }),
16881688 };
1689 result[@enumToInt(Feature.StorageBufferArrayNonUniformIndexingEXT)] = .{
1689 result[@intFromEnum(Feature.StorageBufferArrayNonUniformIndexingEXT)] = .{
16901690 .llvm_name = null,
16911691 .description = "Enable SPIR-V capability StorageBufferArrayNonUniformIndexingEXT",
16921692 .dependencies = featureSet(&[_]Feature{
......@@ -1694,7 +1694,7 @@ pub const all_features = blk: {
16941694 .ShaderNonUniform,
16951695 }),
16961696 };
1697 result[@enumToInt(Feature.StorageImageArrayNonUniformIndexing)] = .{
1697 result[@intFromEnum(Feature.StorageImageArrayNonUniformIndexing)] = .{
16981698 .llvm_name = null,
16991699 .description = "Enable SPIR-V capability StorageImageArrayNonUniformIndexing",
17001700 .dependencies = featureSet(&[_]Feature{
......@@ -1702,7 +1702,7 @@ pub const all_features = blk: {
17021702 .ShaderNonUniform,
17031703 }),
17041704 };
1705 result[@enumToInt(Feature.StorageImageArrayNonUniformIndexingEXT)] = .{
1705 result[@intFromEnum(Feature.StorageImageArrayNonUniformIndexingEXT)] = .{
17061706 .llvm_name = null,
17071707 .description = "Enable SPIR-V capability StorageImageArrayNonUniformIndexingEXT",
17081708 .dependencies = featureSet(&[_]Feature{
......@@ -1710,7 +1710,7 @@ pub const all_features = blk: {
17101710 .ShaderNonUniform,
17111711 }),
17121712 };
1713 result[@enumToInt(Feature.InputAttachmentArrayNonUniformIndexing)] = .{
1713 result[@intFromEnum(Feature.InputAttachmentArrayNonUniformIndexing)] = .{
17141714 .llvm_name = null,
17151715 .description = "Enable SPIR-V capability InputAttachmentArrayNonUniformIndexing",
17161716 .dependencies = featureSet(&[_]Feature{
......@@ -1719,7 +1719,7 @@ pub const all_features = blk: {
17191719 .ShaderNonUniform,
17201720 }),
17211721 };
1722 result[@enumToInt(Feature.InputAttachmentArrayNonUniformIndexingEXT)] = .{
1722 result[@intFromEnum(Feature.InputAttachmentArrayNonUniformIndexingEXT)] = .{
17231723 .llvm_name = null,
17241724 .description = "Enable SPIR-V capability InputAttachmentArrayNonUniformIndexingEXT",
17251725 .dependencies = featureSet(&[_]Feature{
......@@ -1728,7 +1728,7 @@ pub const all_features = blk: {
17281728 .ShaderNonUniform,
17291729 }),
17301730 };
1731 result[@enumToInt(Feature.UniformTexelBufferArrayNonUniformIndexing)] = .{
1731 result[@intFromEnum(Feature.UniformTexelBufferArrayNonUniformIndexing)] = .{
17321732 .llvm_name = null,
17331733 .description = "Enable SPIR-V capability UniformTexelBufferArrayNonUniformIndexing",
17341734 .dependencies = featureSet(&[_]Feature{
......@@ -1737,7 +1737,7 @@ pub const all_features = blk: {
17371737 .ShaderNonUniform,
17381738 }),
17391739 };
1740 result[@enumToInt(Feature.UniformTexelBufferArrayNonUniformIndexingEXT)] = .{
1740 result[@intFromEnum(Feature.UniformTexelBufferArrayNonUniformIndexingEXT)] = .{
17411741 .llvm_name = null,
17421742 .description = "Enable SPIR-V capability UniformTexelBufferArrayNonUniformIndexingEXT",
17431743 .dependencies = featureSet(&[_]Feature{
......@@ -1746,7 +1746,7 @@ pub const all_features = blk: {
17461746 .ShaderNonUniform,
17471747 }),
17481748 };
1749 result[@enumToInt(Feature.StorageTexelBufferArrayNonUniformIndexing)] = .{
1749 result[@intFromEnum(Feature.StorageTexelBufferArrayNonUniformIndexing)] = .{
17501750 .llvm_name = null,
17511751 .description = "Enable SPIR-V capability StorageTexelBufferArrayNonUniformIndexing",
17521752 .dependencies = featureSet(&[_]Feature{
......@@ -1755,7 +1755,7 @@ pub const all_features = blk: {
17551755 .ShaderNonUniform,
17561756 }),
17571757 };
1758 result[@enumToInt(Feature.StorageTexelBufferArrayNonUniformIndexingEXT)] = .{
1758 result[@intFromEnum(Feature.StorageTexelBufferArrayNonUniformIndexingEXT)] = .{
17591759 .llvm_name = null,
17601760 .description = "Enable SPIR-V capability StorageTexelBufferArrayNonUniformIndexingEXT",
17611761 .dependencies = featureSet(&[_]Feature{
......@@ -1764,42 +1764,42 @@ pub const all_features = blk: {
17641764 .ShaderNonUniform,
17651765 }),
17661766 };
1767 result[@enumToInt(Feature.RayTracingNV)] = .{
1767 result[@intFromEnum(Feature.RayTracingNV)] = .{
17681768 .llvm_name = null,
17691769 .description = "Enable SPIR-V capability RayTracingNV",
17701770 .dependencies = featureSet(&[_]Feature{
17711771 .Shader,
17721772 }),
17731773 };
1774 result[@enumToInt(Feature.VulkanMemoryModel)] = .{
1774 result[@intFromEnum(Feature.VulkanMemoryModel)] = .{
17751775 .llvm_name = null,
17761776 .description = "Enable SPIR-V capability VulkanMemoryModel",
17771777 .dependencies = featureSet(&[_]Feature{
17781778 .v1_5,
17791779 }),
17801780 };
1781 result[@enumToInt(Feature.VulkanMemoryModelKHR)] = .{
1781 result[@intFromEnum(Feature.VulkanMemoryModelKHR)] = .{
17821782 .llvm_name = null,
17831783 .description = "Enable SPIR-V capability VulkanMemoryModelKHR",
17841784 .dependencies = featureSet(&[_]Feature{
17851785 .v1_5,
17861786 }),
17871787 };
1788 result[@enumToInt(Feature.VulkanMemoryModelDeviceScope)] = .{
1788 result[@intFromEnum(Feature.VulkanMemoryModelDeviceScope)] = .{
17891789 .llvm_name = null,
17901790 .description = "Enable SPIR-V capability VulkanMemoryModelDeviceScope",
17911791 .dependencies = featureSet(&[_]Feature{
17921792 .v1_5,
17931793 }),
17941794 };
1795 result[@enumToInt(Feature.VulkanMemoryModelDeviceScopeKHR)] = .{
1795 result[@intFromEnum(Feature.VulkanMemoryModelDeviceScopeKHR)] = .{
17961796 .llvm_name = null,
17971797 .description = "Enable SPIR-V capability VulkanMemoryModelDeviceScopeKHR",
17981798 .dependencies = featureSet(&[_]Feature{
17991799 .v1_5,
18001800 }),
18011801 };
1802 result[@enumToInt(Feature.PhysicalStorageBufferAddresses)] = .{
1802 result[@intFromEnum(Feature.PhysicalStorageBufferAddresses)] = .{
18031803 .llvm_name = null,
18041804 .description = "Enable SPIR-V capability PhysicalStorageBufferAddresses",
18051805 .dependencies = featureSet(&[_]Feature{
......@@ -1807,7 +1807,7 @@ pub const all_features = blk: {
18071807 .Shader,
18081808 }),
18091809 };
1810 result[@enumToInt(Feature.PhysicalStorageBufferAddressesEXT)] = .{
1810 result[@intFromEnum(Feature.PhysicalStorageBufferAddressesEXT)] = .{
18111811 .llvm_name = null,
18121812 .description = "Enable SPIR-V capability PhysicalStorageBufferAddressesEXT",
18131813 .dependencies = featureSet(&[_]Feature{
......@@ -1815,261 +1815,261 @@ pub const all_features = blk: {
18151815 .Shader,
18161816 }),
18171817 };
1818 result[@enumToInt(Feature.ComputeDerivativeGroupLinearNV)] = .{
1818 result[@intFromEnum(Feature.ComputeDerivativeGroupLinearNV)] = .{
18191819 .llvm_name = null,
18201820 .description = "Enable SPIR-V capability ComputeDerivativeGroupLinearNV",
18211821 .dependencies = featureSet(&[_]Feature{}),
18221822 };
1823 result[@enumToInt(Feature.RayTracingProvisionalKHR)] = .{
1823 result[@intFromEnum(Feature.RayTracingProvisionalKHR)] = .{
18241824 .llvm_name = null,
18251825 .description = "Enable SPIR-V capability RayTracingProvisionalKHR",
18261826 .dependencies = featureSet(&[_]Feature{
18271827 .Shader,
18281828 }),
18291829 };
1830 result[@enumToInt(Feature.CooperativeMatrixNV)] = .{
1830 result[@intFromEnum(Feature.CooperativeMatrixNV)] = .{
18311831 .llvm_name = null,
18321832 .description = "Enable SPIR-V capability CooperativeMatrixNV",
18331833 .dependencies = featureSet(&[_]Feature{
18341834 .Shader,
18351835 }),
18361836 };
1837 result[@enumToInt(Feature.FragmentShaderSampleInterlockEXT)] = .{
1837 result[@intFromEnum(Feature.FragmentShaderSampleInterlockEXT)] = .{
18381838 .llvm_name = null,
18391839 .description = "Enable SPIR-V capability FragmentShaderSampleInterlockEXT",
18401840 .dependencies = featureSet(&[_]Feature{
18411841 .Shader,
18421842 }),
18431843 };
1844 result[@enumToInt(Feature.FragmentShaderShadingRateInterlockEXT)] = .{
1844 result[@intFromEnum(Feature.FragmentShaderShadingRateInterlockEXT)] = .{
18451845 .llvm_name = null,
18461846 .description = "Enable SPIR-V capability FragmentShaderShadingRateInterlockEXT",
18471847 .dependencies = featureSet(&[_]Feature{
18481848 .Shader,
18491849 }),
18501850 };
1851 result[@enumToInt(Feature.ShaderSMBuiltinsNV)] = .{
1851 result[@intFromEnum(Feature.ShaderSMBuiltinsNV)] = .{
18521852 .llvm_name = null,
18531853 .description = "Enable SPIR-V capability ShaderSMBuiltinsNV",
18541854 .dependencies = featureSet(&[_]Feature{
18551855 .Shader,
18561856 }),
18571857 };
1858 result[@enumToInt(Feature.FragmentShaderPixelInterlockEXT)] = .{
1858 result[@intFromEnum(Feature.FragmentShaderPixelInterlockEXT)] = .{
18591859 .llvm_name = null,
18601860 .description = "Enable SPIR-V capability FragmentShaderPixelInterlockEXT",
18611861 .dependencies = featureSet(&[_]Feature{
18621862 .Shader,
18631863 }),
18641864 };
1865 result[@enumToInt(Feature.DemoteToHelperInvocationEXT)] = .{
1865 result[@intFromEnum(Feature.DemoteToHelperInvocationEXT)] = .{
18661866 .llvm_name = null,
18671867 .description = "Enable SPIR-V capability DemoteToHelperInvocationEXT",
18681868 .dependencies = featureSet(&[_]Feature{
18691869 .Shader,
18701870 }),
18711871 };
1872 result[@enumToInt(Feature.SubgroupShuffleINTEL)] = .{
1872 result[@intFromEnum(Feature.SubgroupShuffleINTEL)] = .{
18731873 .llvm_name = null,
18741874 .description = "Enable SPIR-V capability SubgroupShuffleINTEL",
18751875 .dependencies = featureSet(&[_]Feature{}),
18761876 };
1877 result[@enumToInt(Feature.SubgroupBufferBlockIOINTEL)] = .{
1877 result[@intFromEnum(Feature.SubgroupBufferBlockIOINTEL)] = .{
18781878 .llvm_name = null,
18791879 .description = "Enable SPIR-V capability SubgroupBufferBlockIOINTEL",
18801880 .dependencies = featureSet(&[_]Feature{}),
18811881 };
1882 result[@enumToInt(Feature.SubgroupImageBlockIOINTEL)] = .{
1882 result[@intFromEnum(Feature.SubgroupImageBlockIOINTEL)] = .{
18831883 .llvm_name = null,
18841884 .description = "Enable SPIR-V capability SubgroupImageBlockIOINTEL",
18851885 .dependencies = featureSet(&[_]Feature{}),
18861886 };
1887 result[@enumToInt(Feature.SubgroupImageMediaBlockIOINTEL)] = .{
1887 result[@intFromEnum(Feature.SubgroupImageMediaBlockIOINTEL)] = .{
18881888 .llvm_name = null,
18891889 .description = "Enable SPIR-V capability SubgroupImageMediaBlockIOINTEL",
18901890 .dependencies = featureSet(&[_]Feature{}),
18911891 };
1892 result[@enumToInt(Feature.RoundToInfinityINTEL)] = .{
1892 result[@intFromEnum(Feature.RoundToInfinityINTEL)] = .{
18931893 .llvm_name = null,
18941894 .description = "Enable SPIR-V capability RoundToInfinityINTEL",
18951895 .dependencies = featureSet(&[_]Feature{}),
18961896 };
1897 result[@enumToInt(Feature.FloatingPointModeINTEL)] = .{
1897 result[@intFromEnum(Feature.FloatingPointModeINTEL)] = .{
18981898 .llvm_name = null,
18991899 .description = "Enable SPIR-V capability FloatingPointModeINTEL",
19001900 .dependencies = featureSet(&[_]Feature{}),
19011901 };
1902 result[@enumToInt(Feature.IntegerFunctions2INTEL)] = .{
1902 result[@intFromEnum(Feature.IntegerFunctions2INTEL)] = .{
19031903 .llvm_name = null,
19041904 .description = "Enable SPIR-V capability IntegerFunctions2INTEL",
19051905 .dependencies = featureSet(&[_]Feature{
19061906 .Shader,
19071907 }),
19081908 };
1909 result[@enumToInt(Feature.FunctionPointersINTEL)] = .{
1909 result[@intFromEnum(Feature.FunctionPointersINTEL)] = .{
19101910 .llvm_name = null,
19111911 .description = "Enable SPIR-V capability FunctionPointersINTEL",
19121912 .dependencies = featureSet(&[_]Feature{}),
19131913 };
1914 result[@enumToInt(Feature.IndirectReferencesINTEL)] = .{
1914 result[@intFromEnum(Feature.IndirectReferencesINTEL)] = .{
19151915 .llvm_name = null,
19161916 .description = "Enable SPIR-V capability IndirectReferencesINTEL",
19171917 .dependencies = featureSet(&[_]Feature{}),
19181918 };
1919 result[@enumToInt(Feature.AsmINTEL)] = .{
1919 result[@intFromEnum(Feature.AsmINTEL)] = .{
19201920 .llvm_name = null,
19211921 .description = "Enable SPIR-V capability AsmINTEL",
19221922 .dependencies = featureSet(&[_]Feature{}),
19231923 };
1924 result[@enumToInt(Feature.AtomicFloat32MinMaxEXT)] = .{
1924 result[@intFromEnum(Feature.AtomicFloat32MinMaxEXT)] = .{
19251925 .llvm_name = null,
19261926 .description = "Enable SPIR-V capability AtomicFloat32MinMaxEXT",
19271927 .dependencies = featureSet(&[_]Feature{}),
19281928 };
1929 result[@enumToInt(Feature.AtomicFloat64MinMaxEXT)] = .{
1929 result[@intFromEnum(Feature.AtomicFloat64MinMaxEXT)] = .{
19301930 .llvm_name = null,
19311931 .description = "Enable SPIR-V capability AtomicFloat64MinMaxEXT",
19321932 .dependencies = featureSet(&[_]Feature{}),
19331933 };
1934 result[@enumToInt(Feature.AtomicFloat16MinMaxEXT)] = .{
1934 result[@intFromEnum(Feature.AtomicFloat16MinMaxEXT)] = .{
19351935 .llvm_name = null,
19361936 .description = "Enable SPIR-V capability AtomicFloat16MinMaxEXT",
19371937 .dependencies = featureSet(&[_]Feature{}),
19381938 };
1939 result[@enumToInt(Feature.VectorComputeINTEL)] = .{
1939 result[@intFromEnum(Feature.VectorComputeINTEL)] = .{
19401940 .llvm_name = null,
19411941 .description = "Enable SPIR-V capability VectorComputeINTEL",
19421942 .dependencies = featureSet(&[_]Feature{
19431943 .VectorAnyINTEL,
19441944 }),
19451945 };
1946 result[@enumToInt(Feature.VectorAnyINTEL)] = .{
1946 result[@intFromEnum(Feature.VectorAnyINTEL)] = .{
19471947 .llvm_name = null,
19481948 .description = "Enable SPIR-V capability VectorAnyINTEL",
19491949 .dependencies = featureSet(&[_]Feature{}),
19501950 };
1951 result[@enumToInt(Feature.ExpectAssumeKHR)] = .{
1951 result[@intFromEnum(Feature.ExpectAssumeKHR)] = .{
19521952 .llvm_name = null,
19531953 .description = "Enable SPIR-V capability ExpectAssumeKHR",
19541954 .dependencies = featureSet(&[_]Feature{}),
19551955 };
1956 result[@enumToInt(Feature.SubgroupAvcMotionEstimationINTEL)] = .{
1956 result[@intFromEnum(Feature.SubgroupAvcMotionEstimationINTEL)] = .{
19571957 .llvm_name = null,
19581958 .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationINTEL",
19591959 .dependencies = featureSet(&[_]Feature{}),
19601960 };
1961 result[@enumToInt(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{
1961 result[@intFromEnum(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{
19621962 .llvm_name = null,
19631963 .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationIntraINTEL",
19641964 .dependencies = featureSet(&[_]Feature{}),
19651965 };
1966 result[@enumToInt(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{
1966 result[@intFromEnum(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{
19671967 .llvm_name = null,
19681968 .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationChromaINTEL",
19691969 .dependencies = featureSet(&[_]Feature{}),
19701970 };
1971 result[@enumToInt(Feature.VariableLengthArrayINTEL)] = .{
1971 result[@intFromEnum(Feature.VariableLengthArrayINTEL)] = .{
19721972 .llvm_name = null,
19731973 .description = "Enable SPIR-V capability VariableLengthArrayINTEL",
19741974 .dependencies = featureSet(&[_]Feature{}),
19751975 };
1976 result[@enumToInt(Feature.FunctionFloatControlINTEL)] = .{
1976 result[@intFromEnum(Feature.FunctionFloatControlINTEL)] = .{
19771977 .llvm_name = null,
19781978 .description = "Enable SPIR-V capability FunctionFloatControlINTEL",
19791979 .dependencies = featureSet(&[_]Feature{}),
19801980 };
1981 result[@enumToInt(Feature.FPGAMemoryAttributesINTEL)] = .{
1981 result[@intFromEnum(Feature.FPGAMemoryAttributesINTEL)] = .{
19821982 .llvm_name = null,
19831983 .description = "Enable SPIR-V capability FPGAMemoryAttributesINTEL",
19841984 .dependencies = featureSet(&[_]Feature{}),
19851985 };
1986 result[@enumToInt(Feature.FPFastMathModeINTEL)] = .{
1986 result[@intFromEnum(Feature.FPFastMathModeINTEL)] = .{
19871987 .llvm_name = null,
19881988 .description = "Enable SPIR-V capability FPFastMathModeINTEL",
19891989 .dependencies = featureSet(&[_]Feature{
19901990 .Kernel,
19911991 }),
19921992 };
1993 result[@enumToInt(Feature.ArbitraryPrecisionIntegersINTEL)] = .{
1993 result[@intFromEnum(Feature.ArbitraryPrecisionIntegersINTEL)] = .{
19941994 .llvm_name = null,
19951995 .description = "Enable SPIR-V capability ArbitraryPrecisionIntegersINTEL",
19961996 .dependencies = featureSet(&[_]Feature{}),
19971997 };
1998 result[@enumToInt(Feature.UnstructuredLoopControlsINTEL)] = .{
1998 result[@intFromEnum(Feature.UnstructuredLoopControlsINTEL)] = .{
19991999 .llvm_name = null,
20002000 .description = "Enable SPIR-V capability UnstructuredLoopControlsINTEL",
20012001 .dependencies = featureSet(&[_]Feature{}),
20022002 };
2003 result[@enumToInt(Feature.FPGALoopControlsINTEL)] = .{
2003 result[@intFromEnum(Feature.FPGALoopControlsINTEL)] = .{
20042004 .llvm_name = null,
20052005 .description = "Enable SPIR-V capability FPGALoopControlsINTEL",
20062006 .dependencies = featureSet(&[_]Feature{}),
20072007 };
2008 result[@enumToInt(Feature.KernelAttributesINTEL)] = .{
2008 result[@intFromEnum(Feature.KernelAttributesINTEL)] = .{
20092009 .llvm_name = null,
20102010 .description = "Enable SPIR-V capability KernelAttributesINTEL",
20112011 .dependencies = featureSet(&[_]Feature{}),
20122012 };
2013 result[@enumToInt(Feature.FPGAKernelAttributesINTEL)] = .{
2013 result[@intFromEnum(Feature.FPGAKernelAttributesINTEL)] = .{
20142014 .llvm_name = null,
20152015 .description = "Enable SPIR-V capability FPGAKernelAttributesINTEL",
20162016 .dependencies = featureSet(&[_]Feature{}),
20172017 };
2018 result[@enumToInt(Feature.FPGAMemoryAccessesINTEL)] = .{
2018 result[@intFromEnum(Feature.FPGAMemoryAccessesINTEL)] = .{
20192019 .llvm_name = null,
20202020 .description = "Enable SPIR-V capability FPGAMemoryAccessesINTEL",
20212021 .dependencies = featureSet(&[_]Feature{}),
20222022 };
2023 result[@enumToInt(Feature.FPGAClusterAttributesINTEL)] = .{
2023 result[@intFromEnum(Feature.FPGAClusterAttributesINTEL)] = .{
20242024 .llvm_name = null,
20252025 .description = "Enable SPIR-V capability FPGAClusterAttributesINTEL",
20262026 .dependencies = featureSet(&[_]Feature{}),
20272027 };
2028 result[@enumToInt(Feature.LoopFuseINTEL)] = .{
2028 result[@intFromEnum(Feature.LoopFuseINTEL)] = .{
20292029 .llvm_name = null,
20302030 .description = "Enable SPIR-V capability LoopFuseINTEL",
20312031 .dependencies = featureSet(&[_]Feature{}),
20322032 };
2033 result[@enumToInt(Feature.FPGABufferLocationINTEL)] = .{
2033 result[@intFromEnum(Feature.FPGABufferLocationINTEL)] = .{
20342034 .llvm_name = null,
20352035 .description = "Enable SPIR-V capability FPGABufferLocationINTEL",
20362036 .dependencies = featureSet(&[_]Feature{}),
20372037 };
2038 result[@enumToInt(Feature.USMStorageClassesINTEL)] = .{
2038 result[@intFromEnum(Feature.USMStorageClassesINTEL)] = .{
20392039 .llvm_name = null,
20402040 .description = "Enable SPIR-V capability USMStorageClassesINTEL",
20412041 .dependencies = featureSet(&[_]Feature{}),
20422042 };
2043 result[@enumToInt(Feature.IOPipesINTEL)] = .{
2043 result[@intFromEnum(Feature.IOPipesINTEL)] = .{
20442044 .llvm_name = null,
20452045 .description = "Enable SPIR-V capability IOPipesINTEL",
20462046 .dependencies = featureSet(&[_]Feature{}),
20472047 };
2048 result[@enumToInt(Feature.BlockingPipesINTEL)] = .{
2048 result[@intFromEnum(Feature.BlockingPipesINTEL)] = .{
20492049 .llvm_name = null,
20502050 .description = "Enable SPIR-V capability BlockingPipesINTEL",
20512051 .dependencies = featureSet(&[_]Feature{}),
20522052 };
2053 result[@enumToInt(Feature.FPGARegINTEL)] = .{
2053 result[@intFromEnum(Feature.FPGARegINTEL)] = .{
20542054 .llvm_name = null,
20552055 .description = "Enable SPIR-V capability FPGARegINTEL",
20562056 .dependencies = featureSet(&[_]Feature{}),
20572057 };
2058 result[@enumToInt(Feature.AtomicFloat32AddEXT)] = .{
2058 result[@intFromEnum(Feature.AtomicFloat32AddEXT)] = .{
20592059 .llvm_name = null,
20602060 .description = "Enable SPIR-V capability AtomicFloat32AddEXT",
20612061 .dependencies = featureSet(&[_]Feature{
20622062 .Shader,
20632063 }),
20642064 };
2065 result[@enumToInt(Feature.AtomicFloat64AddEXT)] = .{
2065 result[@intFromEnum(Feature.AtomicFloat64AddEXT)] = .{
20662066 .llvm_name = null,
20672067 .description = "Enable SPIR-V capability AtomicFloat64AddEXT",
20682068 .dependencies = featureSet(&[_]Feature{
20692069 .Shader,
20702070 }),
20712071 };
2072 result[@enumToInt(Feature.LongConstantCompositeINTEL)] = .{
2072 result[@intFromEnum(Feature.LongConstantCompositeINTEL)] = .{
20732073 .llvm_name = null,
20742074 .description = "Enable SPIR-V capability LongConstantCompositeINTEL",
20752075 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/ve.zig+1-1
......@@ -17,7 +17,7 @@ pub const all_features = blk: {
1717 const len = @typeInfo(Feature).Enum.fields.len;
1818 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
1919 var result: [len]CpuFeature = undefined;
20 result[@enumToInt(Feature.vpu)] = .{
20 result[@intFromEnum(Feature.vpu)] = .{
2121 .llvm_name = "vpu",
2222 .description = "Enable the VPU",
2323 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/wasm.zig+12-12
......@@ -28,62 +28,62 @@ pub const all_features = blk: {
2828 const len = @typeInfo(Feature).Enum.fields.len;
2929 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
3030 var result: [len]CpuFeature = undefined;
31 result[@enumToInt(Feature.atomics)] = .{
31 result[@intFromEnum(Feature.atomics)] = .{
3232 .llvm_name = "atomics",
3333 .description = "Enable Atomics",
3434 .dependencies = featureSet(&[_]Feature{}),
3535 };
36 result[@enumToInt(Feature.bulk_memory)] = .{
36 result[@intFromEnum(Feature.bulk_memory)] = .{
3737 .llvm_name = "bulk-memory",
3838 .description = "Enable bulk memory operations",
3939 .dependencies = featureSet(&[_]Feature{}),
4040 };
41 result[@enumToInt(Feature.exception_handling)] = .{
41 result[@intFromEnum(Feature.exception_handling)] = .{
4242 .llvm_name = "exception-handling",
4343 .description = "Enable Wasm exception handling",
4444 .dependencies = featureSet(&[_]Feature{}),
4545 };
46 result[@enumToInt(Feature.extended_const)] = .{
46 result[@intFromEnum(Feature.extended_const)] = .{
4747 .llvm_name = "extended-const",
4848 .description = "Enable extended const expressions",
4949 .dependencies = featureSet(&[_]Feature{}),
5050 };
51 result[@enumToInt(Feature.multivalue)] = .{
51 result[@intFromEnum(Feature.multivalue)] = .{
5252 .llvm_name = "multivalue",
5353 .description = "Enable multivalue blocks, instructions, and functions",
5454 .dependencies = featureSet(&[_]Feature{}),
5555 };
56 result[@enumToInt(Feature.mutable_globals)] = .{
56 result[@intFromEnum(Feature.mutable_globals)] = .{
5757 .llvm_name = "mutable-globals",
5858 .description = "Enable mutable globals",
5959 .dependencies = featureSet(&[_]Feature{}),
6060 };
61 result[@enumToInt(Feature.nontrapping_fptoint)] = .{
61 result[@intFromEnum(Feature.nontrapping_fptoint)] = .{
6262 .llvm_name = "nontrapping-fptoint",
6363 .description = "Enable non-trapping float-to-int conversion operators",
6464 .dependencies = featureSet(&[_]Feature{}),
6565 };
66 result[@enumToInt(Feature.reference_types)] = .{
66 result[@intFromEnum(Feature.reference_types)] = .{
6767 .llvm_name = "reference-types",
6868 .description = "Enable reference types",
6969 .dependencies = featureSet(&[_]Feature{}),
7070 };
71 result[@enumToInt(Feature.relaxed_simd)] = .{
71 result[@intFromEnum(Feature.relaxed_simd)] = .{
7272 .llvm_name = "relaxed-simd",
7373 .description = "Enable relaxed-simd instructions",
7474 .dependencies = featureSet(&[_]Feature{}),
7575 };
76 result[@enumToInt(Feature.sign_ext)] = .{
76 result[@intFromEnum(Feature.sign_ext)] = .{
7777 .llvm_name = "sign-ext",
7878 .description = "Enable sign extension operators",
7979 .dependencies = featureSet(&[_]Feature{}),
8080 };
81 result[@enumToInt(Feature.simd128)] = .{
81 result[@intFromEnum(Feature.simd128)] = .{
8282 .llvm_name = "simd128",
8383 .description = "Enable 128-bit SIMD",
8484 .dependencies = featureSet(&[_]Feature{}),
8585 };
86 result[@enumToInt(Feature.tail_call)] = .{
86 result[@intFromEnum(Feature.tail_call)] = .{
8787 .llvm_name = "tail-call",
8888 .description = "Enable tail call instructions",
8989 .dependencies = featureSet(&[_]Feature{}),
lib/std/target/x86.zig+162-162
......@@ -178,135 +178,135 @@ pub const all_features = blk: {
178178 const len = @typeInfo(Feature).Enum.fields.len;
179179 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
180180 var result: [len]CpuFeature = undefined;
181 result[@enumToInt(Feature.@"16bit_mode")] = .{
181 result[@intFromEnum(Feature.@"16bit_mode")] = .{
182182 .llvm_name = "16bit-mode",
183183 .description = "16-bit mode (i8086)",
184184 .dependencies = featureSet(&[_]Feature{}),
185185 };
186 result[@enumToInt(Feature.@"32bit_mode")] = .{
186 result[@intFromEnum(Feature.@"32bit_mode")] = .{
187187 .llvm_name = "32bit-mode",
188188 .description = "32-bit mode (80386)",
189189 .dependencies = featureSet(&[_]Feature{}),
190190 };
191 result[@enumToInt(Feature.@"3dnow")] = .{
191 result[@intFromEnum(Feature.@"3dnow")] = .{
192192 .llvm_name = "3dnow",
193193 .description = "Enable 3DNow! instructions",
194194 .dependencies = featureSet(&[_]Feature{
195195 .mmx,
196196 }),
197197 };
198 result[@enumToInt(Feature.@"3dnowa")] = .{
198 result[@intFromEnum(Feature.@"3dnowa")] = .{
199199 .llvm_name = "3dnowa",
200200 .description = "Enable 3DNow! Athlon instructions",
201201 .dependencies = featureSet(&[_]Feature{
202202 .@"3dnow",
203203 }),
204204 };
205 result[@enumToInt(Feature.@"64bit")] = .{
205 result[@intFromEnum(Feature.@"64bit")] = .{
206206 .llvm_name = "64bit",
207207 .description = "Support 64-bit instructions",
208208 .dependencies = featureSet(&[_]Feature{}),
209209 };
210 result[@enumToInt(Feature.adx)] = .{
210 result[@intFromEnum(Feature.adx)] = .{
211211 .llvm_name = "adx",
212212 .description = "Support ADX instructions",
213213 .dependencies = featureSet(&[_]Feature{}),
214214 };
215 result[@enumToInt(Feature.aes)] = .{
215 result[@intFromEnum(Feature.aes)] = .{
216216 .llvm_name = "aes",
217217 .description = "Enable AES instructions",
218218 .dependencies = featureSet(&[_]Feature{
219219 .sse2,
220220 }),
221221 };
222 result[@enumToInt(Feature.allow_light_256_bit)] = .{
222 result[@intFromEnum(Feature.allow_light_256_bit)] = .{
223223 .llvm_name = "allow-light-256-bit",
224224 .description = "Enable generation of 256-bit load/stores even if we prefer 128-bit",
225225 .dependencies = featureSet(&[_]Feature{}),
226226 };
227 result[@enumToInt(Feature.amx_bf16)] = .{
227 result[@intFromEnum(Feature.amx_bf16)] = .{
228228 .llvm_name = "amx-bf16",
229229 .description = "Support AMX-BF16 instructions",
230230 .dependencies = featureSet(&[_]Feature{
231231 .amx_tile,
232232 }),
233233 };
234 result[@enumToInt(Feature.amx_fp16)] = .{
234 result[@intFromEnum(Feature.amx_fp16)] = .{
235235 .llvm_name = "amx-fp16",
236236 .description = "Support AMX amx-fp16 instructions",
237237 .dependencies = featureSet(&[_]Feature{
238238 .amx_tile,
239239 }),
240240 };
241 result[@enumToInt(Feature.amx_int8)] = .{
241 result[@intFromEnum(Feature.amx_int8)] = .{
242242 .llvm_name = "amx-int8",
243243 .description = "Support AMX-INT8 instructions",
244244 .dependencies = featureSet(&[_]Feature{
245245 .amx_tile,
246246 }),
247247 };
248 result[@enumToInt(Feature.amx_tile)] = .{
248 result[@intFromEnum(Feature.amx_tile)] = .{
249249 .llvm_name = "amx-tile",
250250 .description = "Support AMX-TILE instructions",
251251 .dependencies = featureSet(&[_]Feature{}),
252252 };
253 result[@enumToInt(Feature.avx)] = .{
253 result[@intFromEnum(Feature.avx)] = .{
254254 .llvm_name = "avx",
255255 .description = "Enable AVX instructions",
256256 .dependencies = featureSet(&[_]Feature{
257257 .sse4_2,
258258 }),
259259 };
260 result[@enumToInt(Feature.avx2)] = .{
260 result[@intFromEnum(Feature.avx2)] = .{
261261 .llvm_name = "avx2",
262262 .description = "Enable AVX2 instructions",
263263 .dependencies = featureSet(&[_]Feature{
264264 .avx,
265265 }),
266266 };
267 result[@enumToInt(Feature.avx512bf16)] = .{
267 result[@intFromEnum(Feature.avx512bf16)] = .{
268268 .llvm_name = "avx512bf16",
269269 .description = "Support bfloat16 floating point",
270270 .dependencies = featureSet(&[_]Feature{
271271 .avx512bw,
272272 }),
273273 };
274 result[@enumToInt(Feature.avx512bitalg)] = .{
274 result[@intFromEnum(Feature.avx512bitalg)] = .{
275275 .llvm_name = "avx512bitalg",
276276 .description = "Enable AVX-512 Bit Algorithms",
277277 .dependencies = featureSet(&[_]Feature{
278278 .avx512bw,
279279 }),
280280 };
281 result[@enumToInt(Feature.avx512bw)] = .{
281 result[@intFromEnum(Feature.avx512bw)] = .{
282282 .llvm_name = "avx512bw",
283283 .description = "Enable AVX-512 Byte and Word Instructions",
284284 .dependencies = featureSet(&[_]Feature{
285285 .avx512f,
286286 }),
287287 };
288 result[@enumToInt(Feature.avx512cd)] = .{
288 result[@intFromEnum(Feature.avx512cd)] = .{
289289 .llvm_name = "avx512cd",
290290 .description = "Enable AVX-512 Conflict Detection Instructions",
291291 .dependencies = featureSet(&[_]Feature{
292292 .avx512f,
293293 }),
294294 };
295 result[@enumToInt(Feature.avx512dq)] = .{
295 result[@intFromEnum(Feature.avx512dq)] = .{
296296 .llvm_name = "avx512dq",
297297 .description = "Enable AVX-512 Doubleword and Quadword Instructions",
298298 .dependencies = featureSet(&[_]Feature{
299299 .avx512f,
300300 }),
301301 };
302 result[@enumToInt(Feature.avx512er)] = .{
302 result[@intFromEnum(Feature.avx512er)] = .{
303303 .llvm_name = "avx512er",
304304 .description = "Enable AVX-512 Exponential and Reciprocal Instructions",
305305 .dependencies = featureSet(&[_]Feature{
306306 .avx512f,
307307 }),
308308 };
309 result[@enumToInt(Feature.avx512f)] = .{
309 result[@intFromEnum(Feature.avx512f)] = .{
310310 .llvm_name = "avx512f",
311311 .description = "Enable AVX-512 instructions",
312312 .dependencies = featureSet(&[_]Feature{
......@@ -315,7 +315,7 @@ pub const all_features = blk: {
315315 .fma,
316316 }),
317317 };
318 result[@enumToInt(Feature.avx512fp16)] = .{
318 result[@intFromEnum(Feature.avx512fp16)] = .{
319319 .llvm_name = "avx512fp16",
320320 .description = "Support 16-bit floating point",
321321 .dependencies = featureSet(&[_]Feature{
......@@ -324,287 +324,287 @@ pub const all_features = blk: {
324324 .avx512vl,
325325 }),
326326 };
327 result[@enumToInt(Feature.avx512ifma)] = .{
327 result[@intFromEnum(Feature.avx512ifma)] = .{
328328 .llvm_name = "avx512ifma",
329329 .description = "Enable AVX-512 Integer Fused Multiply-Add",
330330 .dependencies = featureSet(&[_]Feature{
331331 .avx512f,
332332 }),
333333 };
334 result[@enumToInt(Feature.avx512pf)] = .{
334 result[@intFromEnum(Feature.avx512pf)] = .{
335335 .llvm_name = "avx512pf",
336336 .description = "Enable AVX-512 PreFetch Instructions",
337337 .dependencies = featureSet(&[_]Feature{
338338 .avx512f,
339339 }),
340340 };
341 result[@enumToInt(Feature.avx512vbmi)] = .{
341 result[@intFromEnum(Feature.avx512vbmi)] = .{
342342 .llvm_name = "avx512vbmi",
343343 .description = "Enable AVX-512 Vector Byte Manipulation Instructions",
344344 .dependencies = featureSet(&[_]Feature{
345345 .avx512bw,
346346 }),
347347 };
348 result[@enumToInt(Feature.avx512vbmi2)] = .{
348 result[@intFromEnum(Feature.avx512vbmi2)] = .{
349349 .llvm_name = "avx512vbmi2",
350350 .description = "Enable AVX-512 further Vector Byte Manipulation Instructions",
351351 .dependencies = featureSet(&[_]Feature{
352352 .avx512bw,
353353 }),
354354 };
355 result[@enumToInt(Feature.avx512vl)] = .{
355 result[@intFromEnum(Feature.avx512vl)] = .{
356356 .llvm_name = "avx512vl",
357357 .description = "Enable AVX-512 Vector Length eXtensions",
358358 .dependencies = featureSet(&[_]Feature{
359359 .avx512f,
360360 }),
361361 };
362 result[@enumToInt(Feature.avx512vnni)] = .{
362 result[@intFromEnum(Feature.avx512vnni)] = .{
363363 .llvm_name = "avx512vnni",
364364 .description = "Enable AVX-512 Vector Neural Network Instructions",
365365 .dependencies = featureSet(&[_]Feature{
366366 .avx512f,
367367 }),
368368 };
369 result[@enumToInt(Feature.avx512vp2intersect)] = .{
369 result[@intFromEnum(Feature.avx512vp2intersect)] = .{
370370 .llvm_name = "avx512vp2intersect",
371371 .description = "Enable AVX-512 vp2intersect",
372372 .dependencies = featureSet(&[_]Feature{
373373 .avx512f,
374374 }),
375375 };
376 result[@enumToInt(Feature.avx512vpopcntdq)] = .{
376 result[@intFromEnum(Feature.avx512vpopcntdq)] = .{
377377 .llvm_name = "avx512vpopcntdq",
378378 .description = "Enable AVX-512 Population Count Instructions",
379379 .dependencies = featureSet(&[_]Feature{
380380 .avx512f,
381381 }),
382382 };
383 result[@enumToInt(Feature.avxifma)] = .{
383 result[@intFromEnum(Feature.avxifma)] = .{
384384 .llvm_name = "avxifma",
385385 .description = "Enable AVX-IFMA",
386386 .dependencies = featureSet(&[_]Feature{
387387 .avx2,
388388 }),
389389 };
390 result[@enumToInt(Feature.avxneconvert)] = .{
390 result[@intFromEnum(Feature.avxneconvert)] = .{
391391 .llvm_name = "avxneconvert",
392392 .description = "Support AVX-NE-CONVERT instructions",
393393 .dependencies = featureSet(&[_]Feature{
394394 .avx2,
395395 }),
396396 };
397 result[@enumToInt(Feature.avxvnni)] = .{
397 result[@intFromEnum(Feature.avxvnni)] = .{
398398 .llvm_name = "avxvnni",
399399 .description = "Support AVX_VNNI encoding",
400400 .dependencies = featureSet(&[_]Feature{
401401 .avx2,
402402 }),
403403 };
404 result[@enumToInt(Feature.avxvnniint8)] = .{
404 result[@intFromEnum(Feature.avxvnniint8)] = .{
405405 .llvm_name = "avxvnniint8",
406406 .description = "Enable AVX-VNNI-INT8",
407407 .dependencies = featureSet(&[_]Feature{
408408 .avx2,
409409 }),
410410 };
411 result[@enumToInt(Feature.bmi)] = .{
411 result[@intFromEnum(Feature.bmi)] = .{
412412 .llvm_name = "bmi",
413413 .description = "Support BMI instructions",
414414 .dependencies = featureSet(&[_]Feature{}),
415415 };
416 result[@enumToInt(Feature.bmi2)] = .{
416 result[@intFromEnum(Feature.bmi2)] = .{
417417 .llvm_name = "bmi2",
418418 .description = "Support BMI2 instructions",
419419 .dependencies = featureSet(&[_]Feature{}),
420420 };
421 result[@enumToInt(Feature.branchfusion)] = .{
421 result[@intFromEnum(Feature.branchfusion)] = .{
422422 .llvm_name = "branchfusion",
423423 .description = "CMP/TEST can be fused with conditional branches",
424424 .dependencies = featureSet(&[_]Feature{}),
425425 };
426 result[@enumToInt(Feature.cldemote)] = .{
426 result[@intFromEnum(Feature.cldemote)] = .{
427427 .llvm_name = "cldemote",
428428 .description = "Enable Cache Line Demote",
429429 .dependencies = featureSet(&[_]Feature{}),
430430 };
431 result[@enumToInt(Feature.clflushopt)] = .{
431 result[@intFromEnum(Feature.clflushopt)] = .{
432432 .llvm_name = "clflushopt",
433433 .description = "Flush A Cache Line Optimized",
434434 .dependencies = featureSet(&[_]Feature{}),
435435 };
436 result[@enumToInt(Feature.clwb)] = .{
436 result[@intFromEnum(Feature.clwb)] = .{
437437 .llvm_name = "clwb",
438438 .description = "Cache Line Write Back",
439439 .dependencies = featureSet(&[_]Feature{}),
440440 };
441 result[@enumToInt(Feature.clzero)] = .{
441 result[@intFromEnum(Feature.clzero)] = .{
442442 .llvm_name = "clzero",
443443 .description = "Enable Cache Line Zero",
444444 .dependencies = featureSet(&[_]Feature{}),
445445 };
446 result[@enumToInt(Feature.cmov)] = .{
446 result[@intFromEnum(Feature.cmov)] = .{
447447 .llvm_name = "cmov",
448448 .description = "Enable conditional move instructions",
449449 .dependencies = featureSet(&[_]Feature{}),
450450 };
451 result[@enumToInt(Feature.cmpccxadd)] = .{
451 result[@intFromEnum(Feature.cmpccxadd)] = .{
452452 .llvm_name = "cmpccxadd",
453453 .description = "Support CMPCCXADD instructions",
454454 .dependencies = featureSet(&[_]Feature{}),
455455 };
456 result[@enumToInt(Feature.crc32)] = .{
456 result[@intFromEnum(Feature.crc32)] = .{
457457 .llvm_name = "crc32",
458458 .description = "Enable SSE 4.2 CRC32 instruction (used when SSE4.2 is supported but function is GPR only)",
459459 .dependencies = featureSet(&[_]Feature{}),
460460 };
461 result[@enumToInt(Feature.cx16)] = .{
461 result[@intFromEnum(Feature.cx16)] = .{
462462 .llvm_name = "cx16",
463463 .description = "64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips)",
464464 .dependencies = featureSet(&[_]Feature{
465465 .cx8,
466466 }),
467467 };
468 result[@enumToInt(Feature.cx8)] = .{
468 result[@intFromEnum(Feature.cx8)] = .{
469469 .llvm_name = "cx8",
470470 .description = "Support CMPXCHG8B instructions",
471471 .dependencies = featureSet(&[_]Feature{}),
472472 };
473 result[@enumToInt(Feature.enqcmd)] = .{
473 result[@intFromEnum(Feature.enqcmd)] = .{
474474 .llvm_name = "enqcmd",
475475 .description = "Has ENQCMD instructions",
476476 .dependencies = featureSet(&[_]Feature{}),
477477 };
478 result[@enumToInt(Feature.ermsb)] = .{
478 result[@intFromEnum(Feature.ermsb)] = .{
479479 .llvm_name = "ermsb",
480480 .description = "REP MOVS/STOS are fast",
481481 .dependencies = featureSet(&[_]Feature{}),
482482 };
483 result[@enumToInt(Feature.f16c)] = .{
483 result[@intFromEnum(Feature.f16c)] = .{
484484 .llvm_name = "f16c",
485485 .description = "Support 16-bit floating point conversion instructions",
486486 .dependencies = featureSet(&[_]Feature{
487487 .avx,
488488 }),
489489 };
490 result[@enumToInt(Feature.false_deps_getmant)] = .{
490 result[@intFromEnum(Feature.false_deps_getmant)] = .{
491491 .llvm_name = "false-deps-getmant",
492492 .description = "VGETMANTSS/SD/SH and VGETMANDPS/PD(memory version) has a false dependency on dest register",
493493 .dependencies = featureSet(&[_]Feature{}),
494494 };
495 result[@enumToInt(Feature.false_deps_lzcnt_tzcnt)] = .{
495 result[@intFromEnum(Feature.false_deps_lzcnt_tzcnt)] = .{
496496 .llvm_name = "false-deps-lzcnt-tzcnt",
497497 .description = "LZCNT/TZCNT have a false dependency on dest register",
498498 .dependencies = featureSet(&[_]Feature{}),
499499 };
500 result[@enumToInt(Feature.false_deps_mulc)] = .{
500 result[@intFromEnum(Feature.false_deps_mulc)] = .{
501501 .llvm_name = "false-deps-mulc",
502502 .description = "VF[C]MULCPH/SH has a false dependency on dest register",
503503 .dependencies = featureSet(&[_]Feature{}),
504504 };
505 result[@enumToInt(Feature.false_deps_mullq)] = .{
505 result[@intFromEnum(Feature.false_deps_mullq)] = .{
506506 .llvm_name = "false-deps-mullq",
507507 .description = "VPMULLQ has a false dependency on dest register",
508508 .dependencies = featureSet(&[_]Feature{}),
509509 };
510 result[@enumToInt(Feature.false_deps_perm)] = .{
510 result[@intFromEnum(Feature.false_deps_perm)] = .{
511511 .llvm_name = "false-deps-perm",
512512 .description = "VPERMD/Q/PS/PD has a false dependency on dest register",
513513 .dependencies = featureSet(&[_]Feature{}),
514514 };
515 result[@enumToInt(Feature.false_deps_popcnt)] = .{
515 result[@intFromEnum(Feature.false_deps_popcnt)] = .{
516516 .llvm_name = "false-deps-popcnt",
517517 .description = "POPCNT has a false dependency on dest register",
518518 .dependencies = featureSet(&[_]Feature{}),
519519 };
520 result[@enumToInt(Feature.false_deps_range)] = .{
520 result[@intFromEnum(Feature.false_deps_range)] = .{
521521 .llvm_name = "false-deps-range",
522522 .description = "VRANGEPD/PS/SD/SS has a false dependency on dest register",
523523 .dependencies = featureSet(&[_]Feature{}),
524524 };
525 result[@enumToInt(Feature.fast_11bytenop)] = .{
525 result[@intFromEnum(Feature.fast_11bytenop)] = .{
526526 .llvm_name = "fast-11bytenop",
527527 .description = "Target can quickly decode up to 11 byte NOPs",
528528 .dependencies = featureSet(&[_]Feature{}),
529529 };
530 result[@enumToInt(Feature.fast_15bytenop)] = .{
530 result[@intFromEnum(Feature.fast_15bytenop)] = .{
531531 .llvm_name = "fast-15bytenop",
532532 .description = "Target can quickly decode up to 15 byte NOPs",
533533 .dependencies = featureSet(&[_]Feature{}),
534534 };
535 result[@enumToInt(Feature.fast_7bytenop)] = .{
535 result[@intFromEnum(Feature.fast_7bytenop)] = .{
536536 .llvm_name = "fast-7bytenop",
537537 .description = "Target can quickly decode up to 7 byte NOPs",
538538 .dependencies = featureSet(&[_]Feature{}),
539539 };
540 result[@enumToInt(Feature.fast_bextr)] = .{
540 result[@intFromEnum(Feature.fast_bextr)] = .{
541541 .llvm_name = "fast-bextr",
542542 .description = "Indicates that the BEXTR instruction is implemented as a single uop with good throughput",
543543 .dependencies = featureSet(&[_]Feature{}),
544544 };
545 result[@enumToInt(Feature.fast_gather)] = .{
545 result[@intFromEnum(Feature.fast_gather)] = .{
546546 .llvm_name = "fast-gather",
547547 .description = "Indicates if gather is reasonably fast (this is true for Skylake client and all AVX-512 CPUs)",
548548 .dependencies = featureSet(&[_]Feature{}),
549549 };
550 result[@enumToInt(Feature.fast_hops)] = .{
550 result[@intFromEnum(Feature.fast_hops)] = .{
551551 .llvm_name = "fast-hops",
552552 .description = "Prefer horizontal vector math instructions (haddp, phsub, etc.) over normal vector instructions with shuffles",
553553 .dependencies = featureSet(&[_]Feature{}),
554554 };
555 result[@enumToInt(Feature.fast_lzcnt)] = .{
555 result[@intFromEnum(Feature.fast_lzcnt)] = .{
556556 .llvm_name = "fast-lzcnt",
557557 .description = "LZCNT instructions are as fast as most simple integer ops",
558558 .dependencies = featureSet(&[_]Feature{}),
559559 };
560 result[@enumToInt(Feature.fast_movbe)] = .{
560 result[@intFromEnum(Feature.fast_movbe)] = .{
561561 .llvm_name = "fast-movbe",
562562 .description = "Prefer a movbe over a single-use load + bswap / single-use bswap + store",
563563 .dependencies = featureSet(&[_]Feature{}),
564564 };
565 result[@enumToInt(Feature.fast_scalar_fsqrt)] = .{
565 result[@intFromEnum(Feature.fast_scalar_fsqrt)] = .{
566566 .llvm_name = "fast-scalar-fsqrt",
567567 .description = "Scalar SQRT is fast (disable Newton-Raphson)",
568568 .dependencies = featureSet(&[_]Feature{}),
569569 };
570 result[@enumToInt(Feature.fast_scalar_shift_masks)] = .{
570 result[@intFromEnum(Feature.fast_scalar_shift_masks)] = .{
571571 .llvm_name = "fast-scalar-shift-masks",
572572 .description = "Prefer a left/right scalar logical shift pair over a shift+and pair",
573573 .dependencies = featureSet(&[_]Feature{}),
574574 };
575 result[@enumToInt(Feature.fast_shld_rotate)] = .{
575 result[@intFromEnum(Feature.fast_shld_rotate)] = .{
576576 .llvm_name = "fast-shld-rotate",
577577 .description = "SHLD can be used as a faster rotate",
578578 .dependencies = featureSet(&[_]Feature{}),
579579 };
580 result[@enumToInt(Feature.fast_variable_crosslane_shuffle)] = .{
580 result[@intFromEnum(Feature.fast_variable_crosslane_shuffle)] = .{
581581 .llvm_name = "fast-variable-crosslane-shuffle",
582582 .description = "Cross-lane shuffles with variable masks are fast",
583583 .dependencies = featureSet(&[_]Feature{}),
584584 };
585 result[@enumToInt(Feature.fast_variable_perlane_shuffle)] = .{
585 result[@intFromEnum(Feature.fast_variable_perlane_shuffle)] = .{
586586 .llvm_name = "fast-variable-perlane-shuffle",
587587 .description = "Per-lane shuffles with variable masks are fast",
588588 .dependencies = featureSet(&[_]Feature{}),
589589 };
590 result[@enumToInt(Feature.fast_vector_fsqrt)] = .{
590 result[@intFromEnum(Feature.fast_vector_fsqrt)] = .{
591591 .llvm_name = "fast-vector-fsqrt",
592592 .description = "Vector SQRT is fast (disable Newton-Raphson)",
593593 .dependencies = featureSet(&[_]Feature{}),
594594 };
595 result[@enumToInt(Feature.fast_vector_shift_masks)] = .{
595 result[@intFromEnum(Feature.fast_vector_shift_masks)] = .{
596596 .llvm_name = "fast-vector-shift-masks",
597597 .description = "Prefer a left/right vector logical shift pair over a shift+and pair",
598598 .dependencies = featureSet(&[_]Feature{}),
599599 };
600 result[@enumToInt(Feature.fma)] = .{
600 result[@intFromEnum(Feature.fma)] = .{
601601 .llvm_name = "fma",
602602 .description = "Enable three-operand fused multiply-add",
603603 .dependencies = featureSet(&[_]Feature{
604604 .avx,
605605 }),
606606 };
607 result[@enumToInt(Feature.fma4)] = .{
607 result[@intFromEnum(Feature.fma4)] = .{
608608 .llvm_name = "fma4",
609609 .description = "Enable four-operand fused multiply-add",
610610 .dependencies = featureSet(&[_]Feature{
......@@ -612,218 +612,218 @@ pub const all_features = blk: {
612612 .sse4a,
613613 }),
614614 };
615 result[@enumToInt(Feature.fsgsbase)] = .{
615 result[@intFromEnum(Feature.fsgsbase)] = .{
616616 .llvm_name = "fsgsbase",
617617 .description = "Support FS/GS Base instructions",
618618 .dependencies = featureSet(&[_]Feature{}),
619619 };
620 result[@enumToInt(Feature.fsrm)] = .{
620 result[@intFromEnum(Feature.fsrm)] = .{
621621 .llvm_name = "fsrm",
622622 .description = "REP MOVSB of short lengths is faster",
623623 .dependencies = featureSet(&[_]Feature{}),
624624 };
625 result[@enumToInt(Feature.fxsr)] = .{
625 result[@intFromEnum(Feature.fxsr)] = .{
626626 .llvm_name = "fxsr",
627627 .description = "Support fxsave/fxrestore instructions",
628628 .dependencies = featureSet(&[_]Feature{}),
629629 };
630 result[@enumToInt(Feature.gfni)] = .{
630 result[@intFromEnum(Feature.gfni)] = .{
631631 .llvm_name = "gfni",
632632 .description = "Enable Galois Field Arithmetic Instructions",
633633 .dependencies = featureSet(&[_]Feature{
634634 .sse2,
635635 }),
636636 };
637 result[@enumToInt(Feature.harden_sls_ijmp)] = .{
637 result[@intFromEnum(Feature.harden_sls_ijmp)] = .{
638638 .llvm_name = "harden-sls-ijmp",
639639 .description = "Harden against straight line speculation across indirect JMP instructions.",
640640 .dependencies = featureSet(&[_]Feature{}),
641641 };
642 result[@enumToInt(Feature.harden_sls_ret)] = .{
642 result[@intFromEnum(Feature.harden_sls_ret)] = .{
643643 .llvm_name = "harden-sls-ret",
644644 .description = "Harden against straight line speculation across RET instructions.",
645645 .dependencies = featureSet(&[_]Feature{}),
646646 };
647 result[@enumToInt(Feature.hreset)] = .{
647 result[@intFromEnum(Feature.hreset)] = .{
648648 .llvm_name = "hreset",
649649 .description = "Has hreset instruction",
650650 .dependencies = featureSet(&[_]Feature{}),
651651 };
652 result[@enumToInt(Feature.idivl_to_divb)] = .{
652 result[@intFromEnum(Feature.idivl_to_divb)] = .{
653653 .llvm_name = "idivl-to-divb",
654654 .description = "Use 8-bit divide for positive values less than 256",
655655 .dependencies = featureSet(&[_]Feature{}),
656656 };
657 result[@enumToInt(Feature.idivq_to_divl)] = .{
657 result[@intFromEnum(Feature.idivq_to_divl)] = .{
658658 .llvm_name = "idivq-to-divl",
659659 .description = "Use 32-bit divide for positive values less than 2^32",
660660 .dependencies = featureSet(&[_]Feature{}),
661661 };
662 result[@enumToInt(Feature.invpcid)] = .{
662 result[@intFromEnum(Feature.invpcid)] = .{
663663 .llvm_name = "invpcid",
664664 .description = "Invalidate Process-Context Identifier",
665665 .dependencies = featureSet(&[_]Feature{}),
666666 };
667 result[@enumToInt(Feature.kl)] = .{
667 result[@intFromEnum(Feature.kl)] = .{
668668 .llvm_name = "kl",
669669 .description = "Support Key Locker kl Instructions",
670670 .dependencies = featureSet(&[_]Feature{
671671 .sse2,
672672 }),
673673 };
674 result[@enumToInt(Feature.lea_sp)] = .{
674 result[@intFromEnum(Feature.lea_sp)] = .{
675675 .llvm_name = "lea-sp",
676676 .description = "Use LEA for adjusting the stack pointer (this is an optimization for Intel Atom processors)",
677677 .dependencies = featureSet(&[_]Feature{}),
678678 };
679 result[@enumToInt(Feature.lea_uses_ag)] = .{
679 result[@intFromEnum(Feature.lea_uses_ag)] = .{
680680 .llvm_name = "lea-uses-ag",
681681 .description = "LEA instruction needs inputs at AG stage",
682682 .dependencies = featureSet(&[_]Feature{}),
683683 };
684 result[@enumToInt(Feature.lvi_cfi)] = .{
684 result[@intFromEnum(Feature.lvi_cfi)] = .{
685685 .llvm_name = "lvi-cfi",
686686 .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.",
687687 .dependencies = featureSet(&[_]Feature{}),
688688 };
689 result[@enumToInt(Feature.lvi_load_hardening)] = .{
689 result[@intFromEnum(Feature.lvi_load_hardening)] = .{
690690 .llvm_name = "lvi-load-hardening",
691691 .description = "Insert LFENCE instructions to prevent data speculatively injected into loads from being used maliciously.",
692692 .dependencies = featureSet(&[_]Feature{}),
693693 };
694 result[@enumToInt(Feature.lwp)] = .{
694 result[@intFromEnum(Feature.lwp)] = .{
695695 .llvm_name = "lwp",
696696 .description = "Enable LWP instructions",
697697 .dependencies = featureSet(&[_]Feature{}),
698698 };
699 result[@enumToInt(Feature.lzcnt)] = .{
699 result[@intFromEnum(Feature.lzcnt)] = .{
700700 .llvm_name = "lzcnt",
701701 .description = "Support LZCNT instruction",
702702 .dependencies = featureSet(&[_]Feature{}),
703703 };
704 result[@enumToInt(Feature.macrofusion)] = .{
704 result[@intFromEnum(Feature.macrofusion)] = .{
705705 .llvm_name = "macrofusion",
706706 .description = "Various instructions can be fused with conditional branches",
707707 .dependencies = featureSet(&[_]Feature{}),
708708 };
709 result[@enumToInt(Feature.mmx)] = .{
709 result[@intFromEnum(Feature.mmx)] = .{
710710 .llvm_name = "mmx",
711711 .description = "Enable MMX instructions",
712712 .dependencies = featureSet(&[_]Feature{}),
713713 };
714 result[@enumToInt(Feature.movbe)] = .{
714 result[@intFromEnum(Feature.movbe)] = .{
715715 .llvm_name = "movbe",
716716 .description = "Support MOVBE instruction",
717717 .dependencies = featureSet(&[_]Feature{}),
718718 };
719 result[@enumToInt(Feature.movdir64b)] = .{
719 result[@intFromEnum(Feature.movdir64b)] = .{
720720 .llvm_name = "movdir64b",
721721 .description = "Support movdir64b instruction (direct store 64 bytes)",
722722 .dependencies = featureSet(&[_]Feature{}),
723723 };
724 result[@enumToInt(Feature.movdiri)] = .{
724 result[@intFromEnum(Feature.movdiri)] = .{
725725 .llvm_name = "movdiri",
726726 .description = "Support movdiri instruction (direct store integer)",
727727 .dependencies = featureSet(&[_]Feature{}),
728728 };
729 result[@enumToInt(Feature.mwaitx)] = .{
729 result[@intFromEnum(Feature.mwaitx)] = .{
730730 .llvm_name = "mwaitx",
731731 .description = "Enable MONITORX/MWAITX timer functionality",
732732 .dependencies = featureSet(&[_]Feature{}),
733733 };
734 result[@enumToInt(Feature.nopl)] = .{
734 result[@intFromEnum(Feature.nopl)] = .{
735735 .llvm_name = "nopl",
736736 .description = "Enable NOPL instruction (generally pentium pro+)",
737737 .dependencies = featureSet(&[_]Feature{}),
738738 };
739 result[@enumToInt(Feature.pad_short_functions)] = .{
739 result[@intFromEnum(Feature.pad_short_functions)] = .{
740740 .llvm_name = "pad-short-functions",
741741 .description = "Pad short functions (to prevent a stall when returning too early)",
742742 .dependencies = featureSet(&[_]Feature{}),
743743 };
744 result[@enumToInt(Feature.pclmul)] = .{
744 result[@intFromEnum(Feature.pclmul)] = .{
745745 .llvm_name = "pclmul",
746746 .description = "Enable packed carry-less multiplication instructions",
747747 .dependencies = featureSet(&[_]Feature{
748748 .sse2,
749749 }),
750750 };
751 result[@enumToInt(Feature.pconfig)] = .{
751 result[@intFromEnum(Feature.pconfig)] = .{
752752 .llvm_name = "pconfig",
753753 .description = "platform configuration instruction",
754754 .dependencies = featureSet(&[_]Feature{}),
755755 };
756 result[@enumToInt(Feature.pku)] = .{
756 result[@intFromEnum(Feature.pku)] = .{
757757 .llvm_name = "pku",
758758 .description = "Enable protection keys",
759759 .dependencies = featureSet(&[_]Feature{}),
760760 };
761 result[@enumToInt(Feature.popcnt)] = .{
761 result[@intFromEnum(Feature.popcnt)] = .{
762762 .llvm_name = "popcnt",
763763 .description = "Support POPCNT instruction",
764764 .dependencies = featureSet(&[_]Feature{}),
765765 };
766 result[@enumToInt(Feature.prefer_128_bit)] = .{
766 result[@intFromEnum(Feature.prefer_128_bit)] = .{
767767 .llvm_name = "prefer-128-bit",
768768 .description = "Prefer 128-bit AVX instructions",
769769 .dependencies = featureSet(&[_]Feature{}),
770770 };
771 result[@enumToInt(Feature.prefer_256_bit)] = .{
771 result[@intFromEnum(Feature.prefer_256_bit)] = .{
772772 .llvm_name = "prefer-256-bit",
773773 .description = "Prefer 256-bit AVX instructions",
774774 .dependencies = featureSet(&[_]Feature{}),
775775 };
776 result[@enumToInt(Feature.prefer_mask_registers)] = .{
776 result[@intFromEnum(Feature.prefer_mask_registers)] = .{
777777 .llvm_name = "prefer-mask-registers",
778778 .description = "Prefer AVX512 mask registers over PTEST/MOVMSK",
779779 .dependencies = featureSet(&[_]Feature{}),
780780 };
781 result[@enumToInt(Feature.prefetchi)] = .{
781 result[@intFromEnum(Feature.prefetchi)] = .{
782782 .llvm_name = "prefetchi",
783783 .description = "Prefetch instruction with T0 or T1 Hint",
784784 .dependencies = featureSet(&[_]Feature{}),
785785 };
786 result[@enumToInt(Feature.prefetchwt1)] = .{
786 result[@intFromEnum(Feature.prefetchwt1)] = .{
787787 .llvm_name = "prefetchwt1",
788788 .description = "Prefetch with Intent to Write and T1 Hint",
789789 .dependencies = featureSet(&[_]Feature{}),
790790 };
791 result[@enumToInt(Feature.prfchw)] = .{
791 result[@intFromEnum(Feature.prfchw)] = .{
792792 .llvm_name = "prfchw",
793793 .description = "Support PRFCHW instructions",
794794 .dependencies = featureSet(&[_]Feature{}),
795795 };
796 result[@enumToInt(Feature.ptwrite)] = .{
796 result[@intFromEnum(Feature.ptwrite)] = .{
797797 .llvm_name = "ptwrite",
798798 .description = "Support ptwrite instruction",
799799 .dependencies = featureSet(&[_]Feature{}),
800800 };
801 result[@enumToInt(Feature.raoint)] = .{
801 result[@intFromEnum(Feature.raoint)] = .{
802802 .llvm_name = "raoint",
803803 .description = "Support RAO-INT instructions",
804804 .dependencies = featureSet(&[_]Feature{}),
805805 };
806 result[@enumToInt(Feature.rdpid)] = .{
806 result[@intFromEnum(Feature.rdpid)] = .{
807807 .llvm_name = "rdpid",
808808 .description = "Support RDPID instructions",
809809 .dependencies = featureSet(&[_]Feature{}),
810810 };
811 result[@enumToInt(Feature.rdpru)] = .{
811 result[@intFromEnum(Feature.rdpru)] = .{
812812 .llvm_name = "rdpru",
813813 .description = "Support RDPRU instructions",
814814 .dependencies = featureSet(&[_]Feature{}),
815815 };
816 result[@enumToInt(Feature.rdrnd)] = .{
816 result[@intFromEnum(Feature.rdrnd)] = .{
817817 .llvm_name = "rdrnd",
818818 .description = "Support RDRAND instruction",
819819 .dependencies = featureSet(&[_]Feature{}),
820820 };
821 result[@enumToInt(Feature.rdseed)] = .{
821 result[@intFromEnum(Feature.rdseed)] = .{
822822 .llvm_name = "rdseed",
823823 .description = "Support RDSEED instruction",
824824 .dependencies = featureSet(&[_]Feature{}),
825825 };
826 result[@enumToInt(Feature.retpoline)] = .{
826 result[@intFromEnum(Feature.retpoline)] = .{
827827 .llvm_name = "retpoline",
828828 .description = "Remove speculation of indirect branches from the generated code, either by avoiding them entirely or lowering them with a speculation blocking construct",
829829 .dependencies = featureSet(&[_]Feature{
......@@ -831,200 +831,200 @@ pub const all_features = blk: {
831831 .retpoline_indirect_calls,
832832 }),
833833 };
834 result[@enumToInt(Feature.retpoline_external_thunk)] = .{
834 result[@intFromEnum(Feature.retpoline_external_thunk)] = .{
835835 .llvm_name = "retpoline-external-thunk",
836836 .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",
837837 .dependencies = featureSet(&[_]Feature{
838838 .retpoline_indirect_calls,
839839 }),
840840 };
841 result[@enumToInt(Feature.retpoline_indirect_branches)] = .{
841 result[@intFromEnum(Feature.retpoline_indirect_branches)] = .{
842842 .llvm_name = "retpoline-indirect-branches",
843843 .description = "Remove speculation of indirect branches from the generated code",
844844 .dependencies = featureSet(&[_]Feature{}),
845845 };
846 result[@enumToInt(Feature.retpoline_indirect_calls)] = .{
846 result[@intFromEnum(Feature.retpoline_indirect_calls)] = .{
847847 .llvm_name = "retpoline-indirect-calls",
848848 .description = "Remove speculation of indirect calls from the generated code",
849849 .dependencies = featureSet(&[_]Feature{}),
850850 };
851 result[@enumToInt(Feature.rtm)] = .{
851 result[@intFromEnum(Feature.rtm)] = .{
852852 .llvm_name = "rtm",
853853 .description = "Support RTM instructions",
854854 .dependencies = featureSet(&[_]Feature{}),
855855 };
856 result[@enumToInt(Feature.sahf)] = .{
856 result[@intFromEnum(Feature.sahf)] = .{
857857 .llvm_name = "sahf",
858858 .description = "Support LAHF and SAHF instructions in 64-bit mode",
859859 .dependencies = featureSet(&[_]Feature{}),
860860 };
861 result[@enumToInt(Feature.sbb_dep_breaking)] = .{
861 result[@intFromEnum(Feature.sbb_dep_breaking)] = .{
862862 .llvm_name = "sbb-dep-breaking",
863863 .description = "SBB with same register has no source dependency",
864864 .dependencies = featureSet(&[_]Feature{}),
865865 };
866 result[@enumToInt(Feature.serialize)] = .{
866 result[@intFromEnum(Feature.serialize)] = .{
867867 .llvm_name = "serialize",
868868 .description = "Has serialize instruction",
869869 .dependencies = featureSet(&[_]Feature{}),
870870 };
871 result[@enumToInt(Feature.seses)] = .{
871 result[@intFromEnum(Feature.seses)] = .{
872872 .llvm_name = "seses",
873873 .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.",
874874 .dependencies = featureSet(&[_]Feature{
875875 .lvi_cfi,
876876 }),
877877 };
878 result[@enumToInt(Feature.sgx)] = .{
878 result[@intFromEnum(Feature.sgx)] = .{
879879 .llvm_name = "sgx",
880880 .description = "Enable Software Guard Extensions",
881881 .dependencies = featureSet(&[_]Feature{}),
882882 };
883 result[@enumToInt(Feature.sha)] = .{
883 result[@intFromEnum(Feature.sha)] = .{
884884 .llvm_name = "sha",
885885 .description = "Enable SHA instructions",
886886 .dependencies = featureSet(&[_]Feature{
887887 .sse2,
888888 }),
889889 };
890 result[@enumToInt(Feature.shstk)] = .{
890 result[@intFromEnum(Feature.shstk)] = .{
891891 .llvm_name = "shstk",
892892 .description = "Support CET Shadow-Stack instructions",
893893 .dependencies = featureSet(&[_]Feature{}),
894894 };
895 result[@enumToInt(Feature.slow_3ops_lea)] = .{
895 result[@intFromEnum(Feature.slow_3ops_lea)] = .{
896896 .llvm_name = "slow-3ops-lea",
897897 .description = "LEA instruction with 3 ops or certain registers is slow",
898898 .dependencies = featureSet(&[_]Feature{}),
899899 };
900 result[@enumToInt(Feature.slow_incdec)] = .{
900 result[@intFromEnum(Feature.slow_incdec)] = .{
901901 .llvm_name = "slow-incdec",
902902 .description = "INC and DEC instructions are slower than ADD and SUB",
903903 .dependencies = featureSet(&[_]Feature{}),
904904 };
905 result[@enumToInt(Feature.slow_lea)] = .{
905 result[@intFromEnum(Feature.slow_lea)] = .{
906906 .llvm_name = "slow-lea",
907907 .description = "LEA instruction with certain arguments is slow",
908908 .dependencies = featureSet(&[_]Feature{}),
909909 };
910 result[@enumToInt(Feature.slow_pmaddwd)] = .{
910 result[@intFromEnum(Feature.slow_pmaddwd)] = .{
911911 .llvm_name = "slow-pmaddwd",
912912 .description = "PMADDWD is slower than PMULLD",
913913 .dependencies = featureSet(&[_]Feature{}),
914914 };
915 result[@enumToInt(Feature.slow_pmulld)] = .{
915 result[@intFromEnum(Feature.slow_pmulld)] = .{
916916 .llvm_name = "slow-pmulld",
917917 .description = "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)",
918918 .dependencies = featureSet(&[_]Feature{}),
919919 };
920 result[@enumToInt(Feature.slow_shld)] = .{
920 result[@intFromEnum(Feature.slow_shld)] = .{
921921 .llvm_name = "slow-shld",
922922 .description = "SHLD instruction is slow",
923923 .dependencies = featureSet(&[_]Feature{}),
924924 };
925 result[@enumToInt(Feature.slow_two_mem_ops)] = .{
925 result[@intFromEnum(Feature.slow_two_mem_ops)] = .{
926926 .llvm_name = "slow-two-mem-ops",
927927 .description = "Two memory operand instructions are slow",
928928 .dependencies = featureSet(&[_]Feature{}),
929929 };
930 result[@enumToInt(Feature.slow_unaligned_mem_16)] = .{
930 result[@intFromEnum(Feature.slow_unaligned_mem_16)] = .{
931931 .llvm_name = "slow-unaligned-mem-16",
932932 .description = "Slow unaligned 16-byte memory access",
933933 .dependencies = featureSet(&[_]Feature{}),
934934 };
935 result[@enumToInt(Feature.slow_unaligned_mem_32)] = .{
935 result[@intFromEnum(Feature.slow_unaligned_mem_32)] = .{
936936 .llvm_name = "slow-unaligned-mem-32",
937937 .description = "Slow unaligned 32-byte memory access",
938938 .dependencies = featureSet(&[_]Feature{}),
939939 };
940 result[@enumToInt(Feature.soft_float)] = .{
940 result[@intFromEnum(Feature.soft_float)] = .{
941941 .llvm_name = "soft-float",
942942 .description = "Use software floating point features",
943943 .dependencies = featureSet(&[_]Feature{}),
944944 };
945 result[@enumToInt(Feature.sse)] = .{
945 result[@intFromEnum(Feature.sse)] = .{
946946 .llvm_name = "sse",
947947 .description = "Enable SSE instructions",
948948 .dependencies = featureSet(&[_]Feature{}),
949949 };
950 result[@enumToInt(Feature.sse2)] = .{
950 result[@intFromEnum(Feature.sse2)] = .{
951951 .llvm_name = "sse2",
952952 .description = "Enable SSE2 instructions",
953953 .dependencies = featureSet(&[_]Feature{
954954 .sse,
955955 }),
956956 };
957 result[@enumToInt(Feature.sse3)] = .{
957 result[@intFromEnum(Feature.sse3)] = .{
958958 .llvm_name = "sse3",
959959 .description = "Enable SSE3 instructions",
960960 .dependencies = featureSet(&[_]Feature{
961961 .sse2,
962962 }),
963963 };
964 result[@enumToInt(Feature.sse4_1)] = .{
964 result[@intFromEnum(Feature.sse4_1)] = .{
965965 .llvm_name = "sse4.1",
966966 .description = "Enable SSE 4.1 instructions",
967967 .dependencies = featureSet(&[_]Feature{
968968 .ssse3,
969969 }),
970970 };
971 result[@enumToInt(Feature.sse4_2)] = .{
971 result[@intFromEnum(Feature.sse4_2)] = .{
972972 .llvm_name = "sse4.2",
973973 .description = "Enable SSE 4.2 instructions",
974974 .dependencies = featureSet(&[_]Feature{
975975 .sse4_1,
976976 }),
977977 };
978 result[@enumToInt(Feature.sse4a)] = .{
978 result[@intFromEnum(Feature.sse4a)] = .{
979979 .llvm_name = "sse4a",
980980 .description = "Support SSE 4a instructions",
981981 .dependencies = featureSet(&[_]Feature{
982982 .sse3,
983983 }),
984984 };
985 result[@enumToInt(Feature.sse_unaligned_mem)] = .{
985 result[@intFromEnum(Feature.sse_unaligned_mem)] = .{
986986 .llvm_name = "sse-unaligned-mem",
987987 .description = "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)",
988988 .dependencies = featureSet(&[_]Feature{}),
989989 };
990 result[@enumToInt(Feature.ssse3)] = .{
990 result[@intFromEnum(Feature.ssse3)] = .{
991991 .llvm_name = "ssse3",
992992 .description = "Enable SSSE3 instructions",
993993 .dependencies = featureSet(&[_]Feature{
994994 .sse3,
995995 }),
996996 };
997 result[@enumToInt(Feature.tagged_globals)] = .{
997 result[@intFromEnum(Feature.tagged_globals)] = .{
998998 .llvm_name = "tagged-globals",
999999 .description = "Use an instruction sequence for taking the address of a global that allows a memory tag in the upper address bits.",
10001000 .dependencies = featureSet(&[_]Feature{}),
10011001 };
1002 result[@enumToInt(Feature.tbm)] = .{
1002 result[@intFromEnum(Feature.tbm)] = .{
10031003 .llvm_name = "tbm",
10041004 .description = "Enable TBM instructions",
10051005 .dependencies = featureSet(&[_]Feature{}),
10061006 };
1007 result[@enumToInt(Feature.tsxldtrk)] = .{
1007 result[@intFromEnum(Feature.tsxldtrk)] = .{
10081008 .llvm_name = "tsxldtrk",
10091009 .description = "Support TSXLDTRK instructions",
10101010 .dependencies = featureSet(&[_]Feature{}),
10111011 };
1012 result[@enumToInt(Feature.uintr)] = .{
1012 result[@intFromEnum(Feature.uintr)] = .{
10131013 .llvm_name = "uintr",
10141014 .description = "Has UINTR Instructions",
10151015 .dependencies = featureSet(&[_]Feature{}),
10161016 };
1017 result[@enumToInt(Feature.use_glm_div_sqrt_costs)] = .{
1017 result[@intFromEnum(Feature.use_glm_div_sqrt_costs)] = .{
10181018 .llvm_name = "use-glm-div-sqrt-costs",
10191019 .description = "Use Goldmont specific floating point div/sqrt costs",
10201020 .dependencies = featureSet(&[_]Feature{}),
10211021 };
1022 result[@enumToInt(Feature.use_slm_arith_costs)] = .{
1022 result[@intFromEnum(Feature.use_slm_arith_costs)] = .{
10231023 .llvm_name = "use-slm-arith-costs",
10241024 .description = "Use Silvermont specific arithmetic costs",
10251025 .dependencies = featureSet(&[_]Feature{}),
10261026 };
1027 result[@enumToInt(Feature.vaes)] = .{
1027 result[@intFromEnum(Feature.vaes)] = .{
10281028 .llvm_name = "vaes",
10291029 .description = "Promote selected AES instructions to AVX512/AVX registers",
10301030 .dependencies = featureSet(&[_]Feature{
......@@ -1032,7 +1032,7 @@ pub const all_features = blk: {
10321032 .avx,
10331033 }),
10341034 };
1035 result[@enumToInt(Feature.vpclmulqdq)] = .{
1035 result[@intFromEnum(Feature.vpclmulqdq)] = .{
10361036 .llvm_name = "vpclmulqdq",
10371037 .description = "Enable vpclmulqdq instructions",
10381038 .dependencies = featureSet(&[_]Feature{
......@@ -1040,60 +1040,60 @@ pub const all_features = blk: {
10401040 .pclmul,
10411041 }),
10421042 };
1043 result[@enumToInt(Feature.vzeroupper)] = .{
1043 result[@intFromEnum(Feature.vzeroupper)] = .{
10441044 .llvm_name = "vzeroupper",
10451045 .description = "Should insert vzeroupper instructions",
10461046 .dependencies = featureSet(&[_]Feature{}),
10471047 };
1048 result[@enumToInt(Feature.waitpkg)] = .{
1048 result[@intFromEnum(Feature.waitpkg)] = .{
10491049 .llvm_name = "waitpkg",
10501050 .description = "Wait and pause enhancements",
10511051 .dependencies = featureSet(&[_]Feature{}),
10521052 };
1053 result[@enumToInt(Feature.wbnoinvd)] = .{
1053 result[@intFromEnum(Feature.wbnoinvd)] = .{
10541054 .llvm_name = "wbnoinvd",
10551055 .description = "Write Back No Invalidate",
10561056 .dependencies = featureSet(&[_]Feature{}),
10571057 };
1058 result[@enumToInt(Feature.widekl)] = .{
1058 result[@intFromEnum(Feature.widekl)] = .{
10591059 .llvm_name = "widekl",
10601060 .description = "Support Key Locker wide Instructions",
10611061 .dependencies = featureSet(&[_]Feature{
10621062 .kl,
10631063 }),
10641064 };
1065 result[@enumToInt(Feature.x87)] = .{
1065 result[@intFromEnum(Feature.x87)] = .{
10661066 .llvm_name = "x87",
10671067 .description = "Enable X87 float instructions",
10681068 .dependencies = featureSet(&[_]Feature{}),
10691069 };
1070 result[@enumToInt(Feature.xop)] = .{
1070 result[@intFromEnum(Feature.xop)] = .{
10711071 .llvm_name = "xop",
10721072 .description = "Enable XOP instructions",
10731073 .dependencies = featureSet(&[_]Feature{
10741074 .fma4,
10751075 }),
10761076 };
1077 result[@enumToInt(Feature.xsave)] = .{
1077 result[@intFromEnum(Feature.xsave)] = .{
10781078 .llvm_name = "xsave",
10791079 .description = "Support xsave instructions",
10801080 .dependencies = featureSet(&[_]Feature{}),
10811081 };
1082 result[@enumToInt(Feature.xsavec)] = .{
1082 result[@intFromEnum(Feature.xsavec)] = .{
10831083 .llvm_name = "xsavec",
10841084 .description = "Support xsavec instructions",
10851085 .dependencies = featureSet(&[_]Feature{
10861086 .xsave,
10871087 }),
10881088 };
1089 result[@enumToInt(Feature.xsaveopt)] = .{
1089 result[@intFromEnum(Feature.xsaveopt)] = .{
10901090 .llvm_name = "xsaveopt",
10911091 .description = "Support xsaveopt instructions",
10921092 .dependencies = featureSet(&[_]Feature{
10931093 .xsave,
10941094 }),
10951095 };
1096 result[@enumToInt(Feature.xsaves)] = .{
1096 result[@intFromEnum(Feature.xsaves)] = .{
10971097 .llvm_name = "xsaves",
10981098 .description = "Support xsaves instructions",
10991099 .dependencies = featureSet(&[_]Feature{
lib/std/target/xtensa.zig+1-1
......@@ -17,7 +17,7 @@ pub const all_features = blk: {
1717 const len = @typeInfo(Feature).Enum.fields.len;
1818 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
1919 var result: [len]CpuFeature = undefined;
20 result[@enumToInt(Feature.density)] = .{
20 result[@intFromEnum(Feature.density)] = .{
2121 .llvm_name = "density",
2222 .description = "Enable Density instructions",
2323 .dependencies = featureSet(&[_]Feature{}),
lib/std/time/epoch.zig+2-2
......@@ -83,7 +83,7 @@ pub const Month = enum(u4) {
8383 /// return the numeric calendar value for the given month
8484 /// i.e. jan=1, feb=2, etc
8585 pub fn numeric(self: Month) u4 {
86 return @enumToInt(self);
86 return @intFromEnum(self);
8787 }
8888};
8989
......@@ -122,7 +122,7 @@ pub const YearAndDay = struct {
122122 if (days_left < days_in_month)
123123 break;
124124 days_left -= days_in_month;
125 month = @intToEnum(Month, @enumToInt(month) + 1);
125 month = @enumFromInt(Month, @intFromEnum(month) + 1);
126126 }
127127 return .{ .month = month, .day_index = @intCast(u5, days_left) };
128128 }
lib/std/treap.zig+11-11
......@@ -159,7 +159,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
159159 if (order == .eq) break;
160160
161161 parent_ref.* = current;
162 node = current.children[@boolToInt(order == .gt)];
162 node = current.children[@intFromBool(order == .gt)];
163163 }
164164
165165 return node;
......@@ -168,12 +168,12 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
168168 fn insert(self: *Self, key: Key, parent: ?*Node, node: *Node) void {
169169 // generate a random priority & prepare the node to be inserted into the tree
170170 node.key = key;
171 node.priority = self.prng.random(@ptrToInt(node));
171 node.priority = self.prng.random(@intFromPtr(node));
172172 node.parent = parent;
173173 node.children = [_]?*Node{ null, null };
174174
175175 // point the parent at the new node
176 const link = if (parent) |p| &p.children[@boolToInt(compare(key, p.key) == .gt)] else &self.root;
176 const link = if (parent) |p| &p.children[@intFromBool(compare(key, p.key) == .gt)] else &self.root;
177177 assert(link.* == null);
178178 link.* = node;
179179
......@@ -182,7 +182,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
182182 if (p.priority <= node.priority) break;
183183
184184 const is_right = p.children[1] == node;
185 assert(p.children[@boolToInt(is_right)] == node);
185 assert(p.children[@intFromBool(is_right)] == node);
186186
187187 const rotate_right = !is_right;
188188 self.rotate(p, rotate_right);
......@@ -197,7 +197,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
197197 new.children = old.children;
198198
199199 // point the parent at the new node
200 const link = if (old.parent) |p| &p.children[@boolToInt(p.children[1] == old)] else &self.root;
200 const link = if (old.parent) |p| &p.children[@intFromBool(p.children[1] == old)] else &self.root;
201201 assert(link.* == old);
202202 link.* = new;
203203
......@@ -220,7 +220,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
220220 }
221221
222222 // node is a now a leaf; remove by nulling out the parent's reference to it.
223 const link = if (node.parent) |p| &p.children[@boolToInt(p.children[1] == node)] else &self.root;
223 const link = if (node.parent) |p| &p.children[@intFromBool(p.children[1] == node)] else &self.root;
224224 assert(link.* == node);
225225 link.* = null;
226226
......@@ -240,12 +240,12 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
240240 // parent -> (node (target YY adjacent) XX)
241241 // parent -> (target YY (node adjacent XX))
242242 const parent = node.parent;
243 const target = node.children[@boolToInt(!right)] orelse unreachable;
244 const adjacent = target.children[@boolToInt(right)];
243 const target = node.children[@intFromBool(!right)] orelse unreachable;
244 const adjacent = target.children[@intFromBool(right)];
245245
246246 // rotate the children
247 target.children[@boolToInt(right)] = node;
248 node.children[@boolToInt(!right)] = adjacent;
247 target.children[@intFromBool(right)] = node;
248 node.children[@intFromBool(!right)] = adjacent;
249249
250250 // rotate the parents
251251 node.parent = target;
......@@ -253,7 +253,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
253253 if (adjacent) |adj| adj.parent = node;
254254
255255 // fix the parent link
256 const link = if (parent) |p| &p.children[@boolToInt(p.children[1] == node)] else &self.root;
256 const link = if (parent) |p| &p.children[@intFromBool(p.children[1] == node)] else &self.root;
257257 assert(link.* == node);
258258 link.* = target;
259259 }
lib/std/unicode/throughput_test.zig+2-2
......@@ -32,8 +32,8 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
3232 }
3333 const end = timer.read();
3434
35 const elapsed_s = @intToFloat(f64, end - start) / time.ns_per_s;
36 const throughput = @floatToInt(u64, @intToFloat(f64, bytes) / elapsed_s);
35 const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
36 const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s);
3737
3838 return ResultCount{ .count = r, .throughput = throughput };
3939}
lib/std/valgrind.zig+20-20
......@@ -94,7 +94,7 @@ pub fn IsTool(base: [2]u8, code: usize) bool {
9494}
9595
9696fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
97 return doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
97 return doClientRequest(default, @intCast(usize, @intFromEnum(request)), a1, a2, a3, a4, a5);
9898}
9999
100100fn 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" {
117117/// a JITter or some such, since it provides a way to make sure valgrind will
118118/// retranslate the invalidated area. Returns no value.
119119pub fn discardTranslations(qzz: []const u8) void {
120 doClientRequestStmt(.DiscardTranslations, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
120 doClientRequestStmt(.DiscardTranslations, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0);
121121}
122122
123123pub fn innerThreads(qzz: [*]u8) void {
......@@ -125,19 +125,19 @@ pub fn innerThreads(qzz: [*]u8) void {
125125}
126126
127127pub fn nonSIMDCall0(func: fn (usize) usize) usize {
128 return doClientRequestExpr(0, .ClientCall0, @ptrToInt(func), 0, 0, 0, 0);
128 return doClientRequestExpr(0, .ClientCall0, @intFromPtr(func), 0, 0, 0, 0);
129129}
130130
131131pub fn nonSIMDCall1(func: fn (usize, usize) usize, a1: usize) usize {
132 return doClientRequestExpr(0, .ClientCall1, @ptrToInt(func), a1, 0, 0, 0);
132 return doClientRequestExpr(0, .ClientCall1, @intFromPtr(func), a1, 0, 0, 0);
133133}
134134
135135pub fn nonSIMDCall2(func: fn (usize, usize, usize) usize, a1: usize, a2: usize) usize {
136 return doClientRequestExpr(0, .ClientCall2, @ptrToInt(func), a1, a2, 0, 0);
136 return doClientRequestExpr(0, .ClientCall2, @intFromPtr(func), a1, a2, 0, 0);
137137}
138138
139139pub fn nonSIMDCall3(func: fn (usize, usize, usize, usize) usize, a1: usize, a2: usize, a3: usize) usize {
140 return doClientRequestExpr(0, .ClientCall3, @ptrToInt(func), a1, a2, a3, 0);
140 return doClientRequestExpr(0, .ClientCall3, @intFromPtr(func), a1, a2, a3, 0);
141141}
142142
143143/// Counts the number of errors that have been recorded by a tool. Nb:
......@@ -149,15 +149,15 @@ pub fn countErrors() usize {
149149}
150150
151151pub fn mallocLikeBlock(mem: []u8, rzB: usize, is_zeroed: bool) void {
152 doClientRequestStmt(.MalloclikeBlock, @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed), 0);
152 doClientRequestStmt(.MalloclikeBlock, @intFromPtr(mem.ptr), mem.len, rzB, @intFromBool(is_zeroed), 0);
153153}
154154
155155pub fn resizeInPlaceBlock(oldmem: []u8, newsize: usize, rzB: usize) void {
156 doClientRequestStmt(.ResizeinplaceBlock, @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB, 0);
156 doClientRequestStmt(.ResizeinplaceBlock, @intFromPtr(oldmem.ptr), oldmem.len, newsize, rzB, 0);
157157}
158158
159159pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void {
160 doClientRequestStmt(.FreelikeBlock, @ptrToInt(addr), rzB, 0, 0, 0);
160 doClientRequestStmt(.FreelikeBlock, @intFromPtr(addr), rzB, 0, 0, 0);
161161}
162162
163163/// Create a memory pool.
......@@ -166,7 +166,7 @@ pub const MempoolFlags = struct {
166166 pub const MetaPool = 2;
167167};
168168pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void {
169 doClientRequestStmt(.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0);
169 doClientRequestStmt(.CreateMempool, @intFromPtr(pool), rzB, @intFromBool(is_zeroed), flags, 0);
170170}
171171
172172/// Destroy a memory pool.
......@@ -176,39 +176,39 @@ pub fn destroyMempool(pool: [*]u8) void {
176176
177177/// Associate a piece of memory with a memory pool.
178178pub fn mempoolAlloc(pool: [*]u8, mem: []u8) void {
179 doClientRequestStmt(.MempoolAlloc, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0);
179 doClientRequestStmt(.MempoolAlloc, @intFromPtr(pool), @intFromPtr(mem.ptr), mem.len, 0, 0);
180180}
181181
182182/// Disassociate a piece of memory from a memory pool.
183183pub fn mempoolFree(pool: [*]u8, addr: [*]u8) void {
184 doClientRequestStmt(.MempoolFree, @ptrToInt(pool), @ptrToInt(addr), 0, 0, 0);
184 doClientRequestStmt(.MempoolFree, @intFromPtr(pool), @intFromPtr(addr), 0, 0, 0);
185185}
186186
187187/// Disassociate any pieces outside a particular range.
188188pub fn mempoolTrim(pool: [*]u8, mem: []u8) void {
189 doClientRequestStmt(.MempoolTrim, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0);
189 doClientRequestStmt(.MempoolTrim, @intFromPtr(pool), @intFromPtr(mem.ptr), mem.len, 0, 0);
190190}
191191
192192/// Resize and/or move a piece associated with a memory pool.
193193pub fn moveMempool(poolA: [*]u8, poolB: [*]u8) void {
194 doClientRequestStmt(.MoveMempool, @ptrToInt(poolA), @ptrToInt(poolB), 0, 0, 0);
194 doClientRequestStmt(.MoveMempool, @intFromPtr(poolA), @intFromPtr(poolB), 0, 0, 0);
195195}
196196
197197/// Resize and/or move a piece associated with a memory pool.
198198pub fn mempoolChange(pool: [*]u8, addrA: [*]u8, mem: []u8) void {
199 doClientRequestStmt(.MempoolChange, @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len, 0);
199 doClientRequestStmt(.MempoolChange, @intFromPtr(pool), @intFromPtr(addrA), @intFromPtr(mem.ptr), mem.len, 0);
200200}
201201
202202/// Return if a mempool exists.
203203pub fn mempoolExists(pool: [*]u8) bool {
204 return doClientRequestExpr(0, .MempoolExists, @ptrToInt(pool), 0, 0, 0, 0) != 0;
204 return doClientRequestExpr(0, .MempoolExists, @intFromPtr(pool), 0, 0, 0, 0) != 0;
205205}
206206
207207/// Mark a piece of memory as being a stack. Returns a stack id.
208208/// start is the lowest addressable stack byte, end is the highest
209209/// addressable stack byte.
210210pub fn stackRegister(stack: []u8) usize {
211 return doClientRequestExpr(0, .StackRegister, @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len, 0, 0, 0);
211 return doClientRequestExpr(0, .StackRegister, @intFromPtr(stack.ptr), @intFromPtr(stack.ptr) + stack.len, 0, 0, 0);
212212}
213213
214214/// Unmark the piece of memory associated with a stack id as being a stack.
......@@ -220,7 +220,7 @@ pub fn stackDeregister(id: usize) void {
220220/// start is the new lowest addressable stack byte, end is the new highest
221221/// addressable stack byte.
222222pub fn stackChange(id: usize, newstack: []u8) void {
223 doClientRequestStmt(.StackChange, id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len, 0, 0);
223 doClientRequestStmt(.StackChange, id, @intFromPtr(newstack.ptr), @intFromPtr(newstack.ptr) + newstack.len, 0, 0);
224224}
225225
226226// Load PDB debug info for Wine PE image_map.
......@@ -235,7 +235,7 @@ pub fn stackChange(id: usize, newstack: []u8) void {
235235/// result will be dumped in there and is guaranteed to be zero
236236/// terminated. If no info is found, the first byte is set to zero.
237237pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {
238 return doClientRequestExpr(0, .MapIpToSrcloc, @ptrToInt(addr), @ptrToInt(&buf64[0]), 0, 0, 0);
238 return doClientRequestExpr(0, .MapIpToSrcloc, @intFromPtr(addr), @intFromPtr(&buf64[0]), 0, 0, 0);
239239}
240240
241241/// Disable error reporting for this thread. Behaves in a stack like
......@@ -261,7 +261,7 @@ pub fn enableErrorReporting() void {
261261/// If no connection is opened, output will go to the log output.
262262/// Returns 1 if command not recognised, 0 otherwise.
263263pub fn monitorCommand(command: [*]u8) bool {
264 return doClientRequestExpr(0, .GdbMonitorCommand, @ptrToInt(command.ptr), 0, 0, 0, 0) != 0;
264 return doClientRequestExpr(0, .GdbMonitorCommand, @intFromPtr(command.ptr), 0, 0, 0, 0) != 0;
265265}
266266
267267pub const memcheck = @import("valgrind/memcheck.zig");
lib/std/valgrind/callgrind.zig+2-2
......@@ -11,7 +11,7 @@ pub const CallgrindClientRequest = enum(usize) {
1111};
1212
1313fn doCallgrindClientRequestExpr(default: usize, request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
14 return valgrind.doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
14 return valgrind.doClientRequest(default, @intCast(usize, @intFromEnum(request)), a1, a2, a3, a4, a5);
1515}
1616
1717fn doCallgrindClientRequestStmt(request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void {
......@@ -28,7 +28,7 @@ pub fn dumpStats() void {
2828/// the dump. This string is written as a description field into the
2929/// profile data dump.
3030pub fn dumpStatsAt(pos_str: [*]u8) void {
31 doCallgrindClientRequestStmt(.DumpStatsAt, @ptrToInt(pos_str), 0, 0, 0, 0);
31 doCallgrindClientRequestStmt(.DumpStatsAt, @intFromPtr(pos_str), 0, 0, 0, 0);
3232}
3333
3434/// Zero cost centers
lib/std/valgrind/memcheck.zig+20-20
......@@ -21,7 +21,7 @@ pub const MemCheckClientRequest = enum(usize) {
2121};
2222
2323fn doMemCheckClientRequestExpr(default: usize, request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
24 return valgrind.doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
24 return valgrind.doClientRequest(default, @intCast(usize, @intFromEnum(request)), a1, a2, a3, a4, a5);
2525}
2626
2727fn 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
3232/// This returns -1 when run on Valgrind and 0 otherwise.
3333pub fn makeMemNoAccess(qzz: []u8) i1 {
3434 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
35 .MakeMemNoAccess, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
35 .MakeMemNoAccess, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0));
3636}
3737
3838/// Similarly, mark memory at qzz.ptr as addressable but undefined
......@@ -40,7 +40,7 @@ pub fn makeMemNoAccess(qzz: []u8) i1 {
4040/// This returns -1 when run on Valgrind and 0 otherwise.
4141pub fn makeMemUndefined(qzz: []u8) i1 {
4242 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
43 .MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
43 .MakeMemUndefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0));
4444}
4545
4646/// Similarly, mark memory at qzz.ptr as addressable and defined
......@@ -48,7 +48,7 @@ pub fn makeMemUndefined(qzz: []u8) i1 {
4848pub fn makeMemDefined(qzz: []u8) i1 {
4949 // This returns -1 when run on Valgrind and 0 otherwise.
5050 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
51 .MakeMemDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
51 .MakeMemDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0));
5252}
5353
5454/// Similar to makeMemDefined except that addressability is
......@@ -57,7 +57,7 @@ pub fn makeMemDefined(qzz: []u8) i1 {
5757/// This returns -1 when run on Valgrind and 0 otherwise.
5858pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 {
5959 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
60 .MakeMemDefinedIfAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
60 .MakeMemDefinedIfAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0));
6161}
6262
6363/// Create a block-description handle. The description is an ascii
......@@ -66,7 +66,7 @@ pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 {
6666/// properties of the memory range.
6767pub fn createBlock(qzz: []u8, desc: [*]u8) usize {
6868 return doMemCheckClientRequestExpr(0, // default return
69 .CreateBlock, @ptrToInt(qzz.ptr), qzz.len, @ptrToInt(desc), 0, 0);
69 .CreateBlock, @intFromPtr(qzz.ptr), qzz.len, @intFromPtr(desc), 0, 0);
7070}
7171
7272/// Discard a block-description-handle. Returns 1 for an
......@@ -81,7 +81,7 @@ pub fn discard(blkindex: usize) bool {
8181/// error message and returns the address of the first offending byte.
8282/// Otherwise it returns zero.
8383pub fn checkMemIsAddressable(qzz: []u8) usize {
84 return doMemCheckClientRequestExpr(0, .CheckMemIsAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
84 return doMemCheckClientRequestExpr(0, .CheckMemIsAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0);
8585}
8686
8787/// Check that memory at qzz.ptr is addressable and defined for
......@@ -89,7 +89,7 @@ pub fn checkMemIsAddressable(qzz: []u8) usize {
8989/// established, Valgrind prints an error message and returns the
9090/// address of the first offending byte. Otherwise it returns zero.
9191pub fn checkMemIsDefined(qzz: []u8) usize {
92 return doMemCheckClientRequestExpr(0, .CheckMemIsDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
92 return doMemCheckClientRequestExpr(0, .CheckMemIsDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0);
9393}
9494
9595/// Do a full memory leak check (like --leak-check=full) mid-execution.
......@@ -134,10 +134,10 @@ pub fn countLeaks() CountResult {
134134 };
135135 doMemCheckClientRequestStmt(
136136 .CountLeaks,
137 @ptrToInt(&res.leaked),
138 @ptrToInt(&res.dubious),
139 @ptrToInt(&res.reachable),
140 @ptrToInt(&res.suppressed),
137 @intFromPtr(&res.leaked),
138 @intFromPtr(&res.dubious),
139 @intFromPtr(&res.reachable),
140 @intFromPtr(&res.suppressed),
141141 0,
142142 );
143143 return res;
......@@ -164,10 +164,10 @@ pub fn countLeakBlocks() CountResult {
164164 };
165165 doMemCheckClientRequestStmt(
166166 .CountLeakBlocks,
167 @ptrToInt(&res.leaked),
168 @ptrToInt(&res.dubious),
169 @ptrToInt(&res.reachable),
170 @ptrToInt(&res.suppressed),
167 @intFromPtr(&res.leaked),
168 @intFromPtr(&res.dubious),
169 @intFromPtr(&res.reachable),
170 @intFromPtr(&res.suppressed),
171171 0,
172172 );
173173 return res;
......@@ -195,7 +195,7 @@ test "countLeakBlocks" {
195195/// impossible to segfault your system by using this call.
196196pub fn getVbits(zza: []u8, zzvbits: []u8) u2 {
197197 std.debug.assert(zzvbits.len >= zza.len / 8);
198 return @intCast(u2, doMemCheckClientRequestExpr(0, .GetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0));
198 return @intCast(u2, doMemCheckClientRequestExpr(0, .GetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0));
199199}
200200
201201/// Set the validity data for addresses zza, copying it
......@@ -208,17 +208,17 @@ pub fn getVbits(zza: []u8, zzvbits: []u8) u2 {
208208/// impossible to segfault your system by using this call.
209209pub fn setVbits(zzvbits: []u8, zza: []u8) u2 {
210210 std.debug.assert(zzvbits.len >= zza.len / 8);
211 return @intCast(u2, doMemCheckClientRequestExpr(0, .SetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0));
211 return @intCast(u2, doMemCheckClientRequestExpr(0, .SetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0));
212212}
213213
214214/// Disable and re-enable reporting of addressing errors in the
215215/// specified address range.
216216pub fn disableAddrErrorReportingInRange(qzz: []u8) usize {
217217 return doMemCheckClientRequestExpr(0, // default return
218 .DisableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
218 .DisableAddrErrorReportingInRange, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0);
219219}
220220
221221pub fn enableAddrErrorReportingInRange(qzz: []u8) usize {
222222 return doMemCheckClientRequestExpr(0, // default return
223 .EnableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
223 .EnableAddrErrorReportingInRange, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0);
224224}
lib/std/wasm.zig+10-10
......@@ -198,7 +198,7 @@ pub const Opcode = enum(u8) {
198198/// Returns the integer value of an `Opcode`. Used by the Zig compiler
199199/// to write instructions to the wasm binary file
200200pub fn opcode(op: Opcode) u8 {
201 return @enumToInt(op);
201 return @intFromEnum(op);
202202}
203203
204204test "Wasm - opcodes" {
......@@ -244,7 +244,7 @@ pub const MiscOpcode = enum(u32) {
244244/// Returns the integer value of an `MiscOpcode`. Used by the Zig compiler
245245/// to write instructions to the wasm binary file
246246pub fn miscOpcode(op: MiscOpcode) u32 {
247 return @enumToInt(op);
247 return @intFromEnum(op);
248248}
249249
250250/// Simd opcodes that require a prefix `0xFD`.
......@@ -515,7 +515,7 @@ pub const SimdOpcode = enum(u32) {
515515/// Returns the integer value of an `SimdOpcode`. Used by the Zig compiler
516516/// to write instructions to the wasm binary file
517517pub fn simdOpcode(op: SimdOpcode) u32 {
518 return @enumToInt(op);
518 return @intFromEnum(op);
519519}
520520
521521/// Simd opcodes that require a prefix `0xFE`.
......@@ -595,7 +595,7 @@ pub const AtomicsOpcode = enum(u32) {
595595/// Returns the integer value of an `AtomicsOpcode`. Used by the Zig compiler
596596/// to write instructions to the wasm binary file
597597pub fn atomicsOpcode(op: AtomicsOpcode) u32 {
598 return @enumToInt(op);
598 return @intFromEnum(op);
599599}
600600
601601/// Enum representing all Wasm value types as per spec:
......@@ -610,7 +610,7 @@ pub const Valtype = enum(u8) {
610610
611611/// Returns the integer value of a `Valtype`
612612pub fn valtype(value: Valtype) u8 {
613 return @enumToInt(value);
613 return @intFromEnum(value);
614614}
615615
616616/// Reference types, where the funcref references to a function regardless of its type
......@@ -622,7 +622,7 @@ pub const RefType = enum(u8) {
622622
623623/// Returns the integer value of a `Reftype`
624624pub fn reftype(value: RefType) u8 {
625 return @enumToInt(value);
625 return @intFromEnum(value);
626626}
627627
628628test "Wasm - valtypes" {
......@@ -649,11 +649,11 @@ pub const Limits = struct {
649649 };
650650
651651 pub fn hasFlag(limits: Limits, flag: Flags) bool {
652 return limits.flags & @enumToInt(flag) != 0;
652 return limits.flags & @intFromEnum(flag) != 0;
653653 }
654654
655655 pub fn setFlag(limits: *Limits, flag: Flags) void {
656 limits.flags |= @enumToInt(flag);
656 limits.flags |= @intFromEnum(flag);
657657 }
658658};
659659
......@@ -790,7 +790,7 @@ pub const Section = enum(u8) {
790790
791791/// Returns the integer value of a given `Section`
792792pub fn section(val: Section) u8 {
793 return @enumToInt(val);
793 return @intFromEnum(val);
794794}
795795
796796/// The kind of the type when importing or exporting to/from the host environment
......@@ -804,7 +804,7 @@ pub const ExternalKind = enum(u8) {
804804
805805/// Returns the integer value of a given `ExternalKind`
806806pub fn externalKind(val: ExternalKind) u8 {
807 return @enumToInt(val);
807 return @intFromEnum(val);
808808}
809809
810810/// Defines the enum values for each subsection id for the "Names" custom section
lib/std/zig/Ast.zig+22-22
......@@ -208,22 +208,22 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
208208 },
209209 .expected_block => {
210210 return stream.print("expected block, found '{s}'", .{
211 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
211 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
212212 });
213213 },
214214 .expected_block_or_assignment => {
215215 return stream.print("expected block or assignment, found '{s}'", .{
216 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
216 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
217217 });
218218 },
219219 .expected_block_or_expr => {
220220 return stream.print("expected block or expression, found '{s}'", .{
221 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
221 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
222222 });
223223 },
224224 .expected_block_or_field => {
225225 return stream.print("expected block or field, found '{s}'", .{
226 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
226 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
227227 });
228228 },
229229 .expected_container_members => {
......@@ -233,42 +233,42 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
233233 },
234234 .expected_expr => {
235235 return stream.print("expected expression, found '{s}'", .{
236 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
236 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
237237 });
238238 },
239239 .expected_expr_or_assignment => {
240240 return stream.print("expected expression or assignment, found '{s}'", .{
241 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
241 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
242242 });
243243 },
244244 .expected_fn => {
245245 return stream.print("expected function, found '{s}'", .{
246 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
246 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
247247 });
248248 },
249249 .expected_inlinable => {
250250 return stream.print("expected 'while' or 'for', found '{s}'", .{
251 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
251 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
252252 });
253253 },
254254 .expected_labelable => {
255255 return stream.print("expected 'while', 'for', 'inline', or '{{', found '{s}'", .{
256 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
256 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
257257 });
258258 },
259259 .expected_param_list => {
260260 return stream.print("expected parameter list, found '{s}'", .{
261 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
261 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
262262 });
263263 },
264264 .expected_prefix_expr => {
265265 return stream.print("expected prefix expression, found '{s}'", .{
266 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
266 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
267267 });
268268 },
269269 .expected_primary_type_expr => {
270270 return stream.print("expected primary type expression, found '{s}'", .{
271 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
271 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
272272 });
273273 },
274274 .expected_pub_item => {
......@@ -276,7 +276,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
276276 },
277277 .expected_return_type => {
278278 return stream.print("expected return type expression, found '{s}'", .{
279 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
279 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
280280 });
281281 },
282282 .expected_semi_or_else => {
......@@ -292,32 +292,32 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
292292 },
293293 .expected_suffix_op => {
294294 return stream.print("expected pointer dereference, optional unwrap, or field access, found '{s}'", .{
295 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
295 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
296296 });
297297 },
298298 .expected_type_expr => {
299299 return stream.print("expected type expression, found '{s}'", .{
300 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
300 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
301301 });
302302 },
303303 .expected_var_decl => {
304304 return stream.print("expected variable declaration, found '{s}'", .{
305 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
305 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
306306 });
307307 },
308308 .expected_var_decl_or_fn => {
309309 return stream.print("expected variable declaration or function, found '{s}'", .{
310 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
310 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
311311 });
312312 },
313313 .expected_loop_payload => {
314314 return stream.print("expected loop payload, found '{s}'", .{
315 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
315 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
316316 });
317317 },
318318 .expected_container => {
319319 return stream.print("expected a struct, enum or union, found '{s}'", .{
320 token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)].symbol(),
320 token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)].symbol(),
321321 });
322322 },
323323 .extern_fn_body => {
......@@ -434,7 +434,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
434434 },
435435
436436 .expected_token => {
437 const found_tag = token_tags[parse_error.token + @boolToInt(parse_error.token_is_prev)];
437 const found_tag = token_tags[parse_error.token + @intFromBool(parse_error.token_is_prev)];
438438 const expected_symbol = parse_error.extra.expected_tag.symbol();
439439 switch (found_tag) {
440440 .invalid => return stream.print("expected '{s}', found invalid bytes", .{
......@@ -1289,7 +1289,7 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
12891289 },
12901290 .@"for" => {
12911291 const extra = @bitCast(Node.For, datas[n].rhs);
1292 n = tree.extra_data[datas[n].lhs + extra.inputs + @boolToInt(extra.has_else)];
1292 n = tree.extra_data[datas[n].lhs + extra.inputs + @intFromBool(extra.has_else)];
12931293 },
12941294 .@"suspend" => {
12951295 if (datas[n].lhs != 0) {
......@@ -2291,7 +2291,7 @@ fn fullForComponents(tree: Ast, info: full.For.Components) full.For {
22912291 result.label_token = tok_i - 1;
22922292 }
22932293 const last_cond_token = tree.lastToken(info.inputs[info.inputs.len - 1]);
2294 result.payload_token = last_cond_token + 3 + @boolToInt(token_tags[last_cond_token + 1] == .comma);
2294 result.payload_token = last_cond_token + 3 + @intFromBool(token_tags[last_cond_token + 1] == .comma);
22952295 if (info.else_expr != 0) {
22962296 result.else_token = tree.lastToken(info.then_expr) + 1;
22972297 }
lib/std/zig/ErrorBundle.zig+13-13
......@@ -98,17 +98,17 @@ pub fn getMessages(eb: ErrorBundle) []const MessageIndex {
9898}
9999
100100pub fn getErrorMessage(eb: ErrorBundle, index: MessageIndex) ErrorMessage {
101 return eb.extraData(ErrorMessage, @enumToInt(index)).data;
101 return eb.extraData(ErrorMessage, @intFromEnum(index)).data;
102102}
103103
104104pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLocation {
105105 assert(index != .none);
106 return eb.extraData(SourceLocation, @enumToInt(index)).data;
106 return eb.extraData(SourceLocation, @intFromEnum(index)).data;
107107}
108108
109109pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex {
110110 const notes_len = eb.getErrorMessage(index).notes_len;
111 const start = @enumToInt(index) + @typeInfo(ErrorMessage).Struct.fields.len;
111 const start = @intFromEnum(index) + @typeInfo(ErrorMessage).Struct.fields.len;
112112 return @ptrCast([]const MessageIndex, eb.extra[start..][0..notes_len]);
113113}
114114
......@@ -125,8 +125,8 @@ fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T,
125125 inline for (fields) |field| {
126126 @field(result, field.name) = switch (field.type) {
127127 u32 => eb.extra[i],
128 MessageIndex => @intToEnum(MessageIndex, eb.extra[i]),
129 SourceLocationIndex => @intToEnum(SourceLocationIndex, eb.extra[i]),
128 MessageIndex => @enumFromInt(MessageIndex, eb.extra[i]),
129 SourceLocationIndex => @enumFromInt(SourceLocationIndex, eb.extra[i]),
130130 else => @compileError("bad field type"),
131131 };
132132 i += 1;
......@@ -189,7 +189,7 @@ fn renderErrorMessageToWriter(
189189 const counting_stderr = counting_writer.writer();
190190 const err_msg = eb.getErrorMessage(err_msg_index);
191191 if (err_msg.src_loc != .none) {
192 const src = eb.extraData(SourceLocation, @enumToInt(err_msg.src_loc));
192 const src = eb.extraData(SourceLocation, @intFromEnum(err_msg.src_loc));
193193 try counting_stderr.writeByteNTimes(' ', indent);
194194 try ttyconf.setColor(stderr, .bold);
195195 try counting_stderr.print("{s}:{d}:{d}: ", .{
......@@ -407,15 +407,15 @@ pub const Wip = struct {
407407 }
408408
409409 pub fn addErrorMessage(wip: *Wip, em: ErrorMessage) !MessageIndex {
410 return @intToEnum(MessageIndex, try addExtra(wip, em));
410 return @enumFromInt(MessageIndex, try addExtra(wip, em));
411411 }
412412
413413 pub fn addErrorMessageAssumeCapacity(wip: *Wip, em: ErrorMessage) MessageIndex {
414 return @intToEnum(MessageIndex, addExtraAssumeCapacity(wip, em));
414 return @enumFromInt(MessageIndex, addExtraAssumeCapacity(wip, em));
415415 }
416416
417417 pub fn addSourceLocation(wip: *Wip, sl: SourceLocation) !SourceLocationIndex {
418 return @intToEnum(SourceLocationIndex, try addExtra(wip, sl));
418 return @enumFromInt(SourceLocationIndex, try addExtra(wip, sl));
419419 }
420420
421421 pub fn addReferenceTrace(wip: *Wip, rt: ReferenceTrace) !void {
......@@ -433,7 +433,7 @@ pub const Wip = struct {
433433 // The ensureUnusedCapacity call above guarantees this.
434434 const notes_start = wip.reserveNotes(@intCast(u32, other_list.len)) catch unreachable;
435435 for (notes_start.., other_list) |note, message| {
436 wip.extra.items[note] = @enumToInt(wip.addOtherMessage(other, message) catch unreachable);
436 wip.extra.items[note] = @intFromEnum(wip.addOtherMessage(other, message) catch unreachable);
437437 }
438438 }
439439
......@@ -455,7 +455,7 @@ pub const Wip = struct {
455455 });
456456 const notes_start = try wip.reserveNotes(other_msg.notes_len);
457457 for (notes_start.., other.getNotes(msg_index)) |note, other_note| {
458 wip.extra.items[note] = @enumToInt(try wip.addOtherMessage(other, other_note));
458 wip.extra.items[note] = @intFromEnum(try wip.addOtherMessage(other, other_note));
459459 }
460460 return msg;
461461 }
......@@ -505,8 +505,8 @@ pub const Wip = struct {
505505 inline for (fields) |field| {
506506 wip.extra.items[i] = switch (field.type) {
507507 u32 => @field(extra, field.name),
508 MessageIndex => @enumToInt(@field(extra, field.name)),
509 SourceLocationIndex => @enumToInt(@field(extra, field.name)),
508 MessageIndex => @intFromEnum(@field(extra, field.name)),
509 SourceLocationIndex => @intFromEnum(@field(extra, field.name)),
510510 else => @compileError("bad field type"),
511511 };
512512 i += 1;
lib/std/zig/Parse.zig+1-1
......@@ -1486,7 +1486,7 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!Node.Index {
14861486
14871487 while (true) {
14881488 const tok_tag = p.token_tags[p.tok_i];
1489 const info = operTable[@intCast(usize, @enumToInt(tok_tag))];
1489 const info = operTable[@intCast(usize, @intFromEnum(tok_tag))];
14901490 if (info.prec < min_prec) {
14911491 break;
14921492 }
lib/std/zig/Server.zig+2-2
......@@ -253,7 +253,7 @@ fn bswap(x: anytype) @TypeOf(x) {
253253
254254 const T = @TypeOf(x);
255255 switch (@typeInfo(T)) {
256 .Enum => return @intToEnum(T, @byteSwap(@enumToInt(x))),
256 .Enum => return @enumFromInt(T, @byteSwap(@intFromEnum(x))),
257257 .Int => return @byteSwap(x),
258258 .Struct => |info| switch (info.layout) {
259259 .Extern => {
......@@ -286,7 +286,7 @@ fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 {
286286/// workaround for https://github.com/ziglang/zig/issues/14904
287287fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag {
288288 const int = std.mem.readIntLittle(u32, bytes_ptr);
289 return @intToEnum(InMessage.Tag, int);
289 return @enumFromInt(InMessage.Tag, int);
290290}
291291
292292const OutMessage = std.zig.Server.Message;
lib/std/zig/c_builtins.zig+6-6
......@@ -11,10 +11,10 @@ pub inline fn __builtin_bswap64(val: u64) u64 {
1111}
1212
1313pub inline fn __builtin_signbit(val: f64) c_int {
14 return @boolToInt(std.math.signbit(val));
14 return @intFromBool(std.math.signbit(val));
1515}
1616pub inline fn __builtin_signbitf(val: f32) c_int {
17 return @boolToInt(std.math.signbit(val));
17 return @intFromBool(std.math.signbit(val));
1818}
1919
2020pub inline fn __builtin_popcount(val: c_uint) c_int {
......@@ -215,11 +215,11 @@ pub inline fn __builtin_inff() f32 {
215215}
216216
217217pub inline fn __builtin_isnan(x: anytype) c_int {
218 return @boolToInt(std.math.isNan(x));
218 return @intFromBool(std.math.isNan(x));
219219}
220220
221221pub inline fn __builtin_isinf(x: anytype) c_int {
222 return @boolToInt(std.math.isInf(x));
222 return @intFromBool(std.math.isInf(x));
223223}
224224
225225/// 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 {
230230
231231pub inline fn __has_builtin(func: anytype) c_int {
232232 _ = func;
233 return @boolToInt(true);
233 return @intFromBool(true);
234234}
235235
236236pub inline fn __builtin_assume(cond: bool) void {
......@@ -243,7 +243,7 @@ pub inline fn __builtin_unreachable() noreturn {
243243
244244pub inline fn __builtin_constant_p(expr: anytype) c_int {
245245 _ = expr;
246 return @boolToInt(false);
246 return @intFromBool(false);
247247}
248248pub fn __builtin_mul_overflow(a: anytype, b: anytype, result: *@TypeOf(a, b)) c_int {
249249 const res = @mulWithOverflow(a, b);
lib/std/zig/c_translation.zig+22-22
......@@ -21,30 +21,30 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
2121 .Int => {
2222 switch (@typeInfo(SourceType)) {
2323 .Pointer => {
24 return castInt(DestType, @ptrToInt(target));
24 return castInt(DestType, @intFromPtr(target));
2525 },
2626 .Optional => |opt| {
2727 if (@typeInfo(opt.child) == .Pointer) {
28 return castInt(DestType, @ptrToInt(target));
28 return castInt(DestType, @intFromPtr(target));
2929 }
3030 },
3131 .Int => {
3232 return castInt(DestType, target);
3333 },
3434 .Fn => {
35 return castInt(DestType, @ptrToInt(&target));
35 return castInt(DestType, @intFromPtr(&target));
3636 },
3737 .Bool => {
38 return @boolToInt(target);
38 return @intFromBool(target);
3939 },
4040 else => {},
4141 }
4242 },
4343 .Float => {
4444 switch (@typeInfo(SourceType)) {
45 .Int => return @intToFloat(DestType, target),
45 .Int => return @floatFromInt(DestType, target),
4646 .Float => return @floatCast(DestType, target),
47 .Bool => return @intToFloat(DestType, @boolToInt(target)),
47 .Bool => return @floatFromInt(DestType, @intFromBool(target)),
4848 else => {},
4949 }
5050 },
......@@ -88,13 +88,13 @@ fn castPtr(comptime DestType: type, target: anytype) DestType {
8888fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {
8989 switch (@typeInfo(SourceType)) {
9090 .Int => {
91 return @intToPtr(DestType, castInt(usize, target));
91 return @ptrFromInt(DestType, castInt(usize, target));
9292 },
9393 .ComptimeInt => {
9494 if (target < 0)
95 return @intToPtr(DestType, @bitCast(usize, @intCast(isize, target)))
95 return @ptrFromInt(DestType, @bitCast(usize, @intCast(isize, target)))
9696 else
97 return @intToPtr(DestType, @intCast(usize, target));
97 return @ptrFromInt(DestType, @intCast(usize, target));
9898 },
9999 .Pointer => {
100100 return castPtr(DestType, target);
......@@ -120,34 +120,34 @@ fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer {
120120test "cast" {
121121 var i = @as(i64, 10);
122122
123 try testing.expect(cast(*u8, 16) == @intToPtr(*u8, 16));
123 try testing.expect(cast(*u8, 16) == @ptrFromInt(*u8, 16));
124124 try testing.expect(cast(*u64, &i).* == @as(u64, 10));
125125 try testing.expect(cast(*i64, @as(?*align(1) i64, &i)) == &i);
126126
127 try testing.expect(cast(?*u8, 2) == @intToPtr(*u8, 2));
127 try testing.expect(cast(?*u8, 2) == @ptrFromInt(*u8, 2));
128128 try testing.expect(cast(?*i64, @as(*align(1) i64, &i)) == &i);
129129 try testing.expect(cast(?*i64, @as(?*align(1) i64, &i)) == &i);
130130
131 try testing.expectEqual(@as(u32, 4), cast(u32, @intToPtr(*u32, 4)));
132 try testing.expectEqual(@as(u32, 4), cast(u32, @intToPtr(?*u32, 4)));
131 try testing.expectEqual(@as(u32, 4), cast(u32, @ptrFromInt(*u32, 4)));
132 try testing.expectEqual(@as(u32, 4), cast(u32, @ptrFromInt(?*u32, 4)));
133133 try testing.expectEqual(@as(u32, 10), cast(u32, @as(u64, 10)));
134134
135135 try testing.expectEqual(@bitCast(i32, @as(u32, 0x8000_0000)), cast(i32, @as(u32, 0x8000_0000)));
136136
137 try testing.expectEqual(@intToPtr(*u8, 2), cast(*u8, @intToPtr(*const u8, 2)));
138 try testing.expectEqual(@intToPtr(*u8, 2), cast(*u8, @intToPtr(*volatile u8, 2)));
137 try testing.expectEqual(@ptrFromInt(*u8, 2), cast(*u8, @ptrFromInt(*const u8, 2)));
138 try testing.expectEqual(@ptrFromInt(*u8, 2), cast(*u8, @ptrFromInt(*volatile u8, 2)));
139139
140 try testing.expectEqual(@intToPtr(?*anyopaque, 2), cast(?*anyopaque, @intToPtr(*u8, 2)));
140 try testing.expectEqual(@ptrFromInt(?*anyopaque, 2), cast(?*anyopaque, @ptrFromInt(*u8, 2)));
141141
142142 var foo: c_int = -1;
143 try testing.expect(cast(*anyopaque, -1) == @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1))));
144 try testing.expect(cast(*anyopaque, foo) == @intToPtr(*anyopaque, @bitCast(usize, @as(isize, -1))));
145 try testing.expect(cast(?*anyopaque, -1) == @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))));
146 try testing.expect(cast(?*anyopaque, foo) == @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))));
143 try testing.expect(cast(*anyopaque, -1) == @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))));
144 try testing.expect(cast(*anyopaque, foo) == @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))));
145 try testing.expect(cast(?*anyopaque, -1) == @ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1))));
146 try testing.expect(cast(?*anyopaque, foo) == @ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1))));
147147
148148 const FnPtr = ?*align(1) const fn (*anyopaque) void;
149 try testing.expect(cast(FnPtr, 0) == @intToPtr(FnPtr, @as(usize, 0)));
150 try testing.expect(cast(FnPtr, foo) == @intToPtr(FnPtr, @bitCast(usize, @as(isize, -1))));
149 try testing.expect(cast(FnPtr, 0) == @ptrFromInt(FnPtr, @as(usize, 0)));
150 try testing.expect(cast(FnPtr, foo) == @ptrFromInt(FnPtr, @bitCast(usize, @as(isize, -1))));
151151}
152152
153153/// Given a value returns its size as C's sizeof operator would.
lib/std/zig/number_literal.zig+3-3
......@@ -141,7 +141,7 @@ pub fn parseNumberLiteral(bytes: []const u8) Result {
141141 'a'...'z' => c - 'a' + 10,
142142 else => return .{ .failure = .{ .invalid_character = i } },
143143 };
144 if (digit >= base) return .{ .failure = .{ .invalid_digit = .{ .i = i, .base = @intToEnum(Base, base) } } };
144 if (digit >= base) return .{ .failure = .{ .invalid_digit = .{ .i = i, .base = @enumFromInt(Base, base) } } };
145145 if (exponent and digit >= 10) return .{ .failure = .{ .invalid_digit_exponent = i } };
146146 underscore = false;
147147 special = 0;
......@@ -159,7 +159,7 @@ pub fn parseNumberLiteral(bytes: []const u8) Result {
159159 if (underscore) return .{ .failure = .{ .trailing_underscore = bytes.len - 1 } };
160160 if (special != 0) return .{ .failure = .{ .trailing_special = bytes.len - 1 } };
161161
162 if (float) return .{ .float = @intToEnum(FloatBase, base) };
163 if (overflow) return .{ .big_int = @intToEnum(Base, base) };
162 if (float) return .{ .float = @enumFromInt(FloatBase, base) };
163 if (overflow) return .{ .big_int = @enumFromInt(Base, base) };
164164 return .{ .int = x };
165165}
lib/std/zig/parser_test.zig+2-2
......@@ -628,7 +628,7 @@ test "zig fmt: builtin call with trailing comma" {
628628 try testCanonical(
629629 \\pub fn main() void {
630630 \\ @breakpoint();
631 \\ _ = @boolToInt(a);
631 \\ _ = @intFromBool(a);
632632 \\ _ = @call(
633633 \\ a,
634634 \\ b,
......@@ -4815,7 +4815,7 @@ test "zig fmt: use of comments and multiline string literals may force the param
48154815 \\ \\ Consider providing your own hash function.
48164816 \\ );
48174817 \\ return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
4818 \\ .MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
4818 \\ .MakeMemUndefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0));
48194819 \\}
48204820 \\
48214821 \\// This looks like garbage don't do this
lib/std/zig/perf_test.zig+3-3
......@@ -18,9 +18,9 @@ pub fn main() !void {
1818 }
1919 const end = timer.read();
2020 memory_used /= iterations;
21 const elapsed_s = @intToFloat(f64, end - start) / std.time.ns_per_s;
22 const bytes_per_sec_float = @intToFloat(f64, source.len * iterations) / elapsed_s;
23 const bytes_per_sec = @floatToInt(u64, @floor(bytes_per_sec_float));
21 const elapsed_s = @floatFromInt(f64, end - start) / std.time.ns_per_s;
22 const bytes_per_sec_float = @floatFromInt(f64, source.len * iterations) / elapsed_s;
23 const bytes_per_sec = @intFromFloat(u64, @floor(bytes_per_sec_float));
2424
2525 var stdout_file = std.io.getStdOut();
2626 const stdout = stdout_file.writer();
lib/std/zig/render.zig+21-1
......@@ -1396,6 +1396,26 @@ fn renderBuiltinCall(
13961396 try ais.writer().writeAll("@max");
13971397 } else if (mem.eql(u8, slice, "@minimum")) {
13981398 try ais.writer().writeAll("@min");
1399 }
1400 //
1401 else if (mem.eql(u8, slice, "@boolToInt")) {
1402 try ais.writer().writeAll("@intFromBool");
1403 } else if (mem.eql(u8, slice, "@enumToInt")) {
1404 try ais.writer().writeAll("@intFromEnum");
1405 } else if (mem.eql(u8, slice, "@errorToInt")) {
1406 try ais.writer().writeAll("@intFromError");
1407 } else if (mem.eql(u8, slice, "@floatToInt")) {
1408 try ais.writer().writeAll("@intFromFloat");
1409 } else if (mem.eql(u8, slice, "@intToEnum")) {
1410 try ais.writer().writeAll("@enumFromInt");
1411 } else if (mem.eql(u8, slice, "@intToError")) {
1412 try ais.writer().writeAll("@errorFromInt");
1413 } else if (mem.eql(u8, slice, "@intToFloat")) {
1414 try ais.writer().writeAll("@floatFromInt");
1415 } else if (mem.eql(u8, slice, "@intToPtr")) {
1416 try ais.writer().writeAll("@ptrFromInt");
1417 } else if (mem.eql(u8, slice, "@ptrToInt")) {
1418 try ais.writer().writeAll("@intFromPtr");
13991419 } else {
14001420 try renderToken(ais, tree, builtin_token, .none); // @name
14011421 }
......@@ -1703,7 +1723,7 @@ fn renderSwitchCase(
17031723
17041724 if (switch_case.payload_token) |payload_token| {
17051725 try renderToken(ais, tree, payload_token - 1, .none); // pipe
1706 const ident = payload_token + @boolToInt(token_tags[payload_token] == .asterisk);
1726 const ident = payload_token + @intFromBool(token_tags[payload_token] == .asterisk);
17071727 if (token_tags[payload_token] == .asterisk) {
17081728 try renderToken(ais, tree, payload_token, .none); // asterisk
17091729 }
lib/std/zig/system/NativeTargetInfo.zig+4-4
......@@ -207,10 +207,10 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
207207 })) {
208208 switch (result.target.abi) {
209209 .code16 => result.target.cpu.features.addFeature(
210 @enumToInt(std.Target.x86.Feature.@"16bit_mode"),
210 @intFromEnum(std.Target.x86.Feature.@"16bit_mode"),
211211 ),
212212 else => result.target.cpu.features.addFeature(
213 @enumToInt(std.Target.x86.Feature.@"32bit_mode"),
213 @intFromEnum(std.Target.x86.Feature.@"32bit_mode"),
214214 ),
215215 }
216216 }
......@@ -221,7 +221,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
221221 },
222222 .thumb, .thumbeb => {
223223 result.target.cpu.features.addFeature(
224 @enumToInt(std.Target.arm.Feature.thumb_mode),
224 @intFromEnum(std.Target.arm.Feature.thumb_mode),
225225 );
226226 },
227227 else => {},
......@@ -268,7 +268,7 @@ fn detectAbiAndDynamicLinker(
268268 // and supported by Zig. But that means that we must detect the system ABI here rather than
269269 // relying on `builtin.target`.
270270 const all_abis = comptime blk: {
271 assert(@enumToInt(Target.Abi.none) == 0);
271 assert(@intFromEnum(Target.Abi.none) == 0);
272272 const fields = std.meta.fields(Target.Abi)[1..];
273273 var array: [fields.len]Target.Abi = undefined;
274274 inline for (fields, 0..) |field, i| {
lib/std/zig/system/arm.zig+1-1
......@@ -135,7 +135,7 @@ pub const cpu_models = struct {
135135
136136pub const aarch64 = struct {
137137 fn setFeature(cpu: *Target.Cpu, feature: Target.aarch64.Feature, enabled: bool) void {
138 const idx = @as(Target.Cpu.Feature.Set.Index, @enumToInt(feature));
138 const idx = @as(Target.Cpu.Feature.Set.Index, @intFromEnum(feature));
139139
140140 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);
141141 }
lib/std/zig/system/windows.zig+2-2
......@@ -43,7 +43,7 @@ pub fn detectRuntimeVersion() WindowsVersion {
4343
4444 const version: u32 = @as(u32, os_ver) << 16 | @as(u16, sp_ver) << 8 | sub_ver;
4545
46 return @intToEnum(WindowsVersion, version);
46 return @enumFromInt(WindowsVersion, version);
4747}
4848
4949// 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 {
188188}
189189
190190fn setFeature(comptime Feature: type, cpu: *Target.Cpu, feature: Feature, enabled: bool) void {
191 const idx = @as(Target.Cpu.Feature.Set.Index, @enumToInt(feature));
191 const idx = @as(Target.Cpu.Feature.Set.Index, @intFromEnum(feature));
192192
193193 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);
194194}
lib/std/zig/system/x86.zig+1-1
......@@ -10,7 +10,7 @@ const XCR0_ZMM0_15 = 0x40;
1010const XCR0_ZMM16_31 = 0x80;
1111
1212fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void {
13 const idx = @as(Target.Cpu.Feature.Set.Index, @enumToInt(feature));
13 const idx = @as(Target.Cpu.Feature.Set.Index, @intFromEnum(feature));
1414
1515 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);
1616}
lib/test_runner.zig+3-3
......@@ -117,7 +117,7 @@ fn mainServer() !void {
117117 },
118118
119119 else => {
120 std.debug.print("unsupported message: {x}", .{@enumToInt(hdr.tag)});
120 std.debug.print("unsupported message: {x}", .{@intFromEnum(hdr.tag)});
121121 std.process.exit(1);
122122 },
123123 }
......@@ -216,10 +216,10 @@ pub fn log(
216216 comptime format: []const u8,
217217 args: anytype,
218218) void {
219 if (@enumToInt(message_level) <= @enumToInt(std.log.Level.err)) {
219 if (@intFromEnum(message_level) <= @intFromEnum(std.log.Level.err)) {
220220 log_err_count += 1;
221221 }
222 if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) {
222 if (@intFromEnum(message_level) <= @intFromEnum(std.testing.log_level)) {
223223 std.debug.print(
224224 "[" ++ @tagName(scope) ++ "] (" ++ @tagName(message_level) ++ "): " ++ format ++ "\n",
225225 args,
src/Air.zig+114-114
......@@ -478,11 +478,11 @@ pub const Inst = struct {
478478 /// Converts a pointer to its address. Result type is always `usize`.
479479 /// Pointer type size may be any, including slice.
480480 /// Uses the `un_op` field.
481 ptrtoint,
481 int_from_ptr,
482482 /// Given a boolean, returns 0 or 1.
483483 /// Result type is always `u1`.
484484 /// Uses the `un_op` field.
485 bool_to_int,
485 int_from_bool,
486486 /// Return a value from a function.
487487 /// Result type is always noreturn; no instructions in a block follow this one.
488488 /// Uses the `un_op` field.
......@@ -629,12 +629,12 @@ pub const Inst = struct {
629629 array_to_slice,
630630 /// Given a float operand, return the integer with the closest mathematical meaning.
631631 /// Uses the `ty_op` field.
632 float_to_int,
633 /// Same as `float_to_int` with optimized float mode.
634 float_to_int_optimized,
632 int_from_float,
633 /// Same as `int_from_float` with optimized float mode.
634 int_from_float_optimized,
635635 /// Given an integer operand, return the float with the closest mathematical meaning.
636636 /// Uses the `ty_op` field.
637 int_to_float,
637 float_from_int,
638638
639639 /// Transforms a vector into a scalar value by performing a sequential
640640 /// horizontal reduction of its elements using the specified operator.
......@@ -850,93 +850,93 @@ pub const Inst = struct {
850850 pub const Index = u32;
851851
852852 pub const Ref = enum(u32) {
853 u1_type = @enumToInt(InternPool.Index.u1_type),
854 u8_type = @enumToInt(InternPool.Index.u8_type),
855 i8_type = @enumToInt(InternPool.Index.i8_type),
856 u16_type = @enumToInt(InternPool.Index.u16_type),
857 i16_type = @enumToInt(InternPool.Index.i16_type),
858 u29_type = @enumToInt(InternPool.Index.u29_type),
859 u32_type = @enumToInt(InternPool.Index.u32_type),
860 i32_type = @enumToInt(InternPool.Index.i32_type),
861 u64_type = @enumToInt(InternPool.Index.u64_type),
862 i64_type = @enumToInt(InternPool.Index.i64_type),
863 u80_type = @enumToInt(InternPool.Index.u80_type),
864 u128_type = @enumToInt(InternPool.Index.u128_type),
865 i128_type = @enumToInt(InternPool.Index.i128_type),
866 usize_type = @enumToInt(InternPool.Index.usize_type),
867 isize_type = @enumToInt(InternPool.Index.isize_type),
868 c_char_type = @enumToInt(InternPool.Index.c_char_type),
869 c_short_type = @enumToInt(InternPool.Index.c_short_type),
870 c_ushort_type = @enumToInt(InternPool.Index.c_ushort_type),
871 c_int_type = @enumToInt(InternPool.Index.c_int_type),
872 c_uint_type = @enumToInt(InternPool.Index.c_uint_type),
873 c_long_type = @enumToInt(InternPool.Index.c_long_type),
874 c_ulong_type = @enumToInt(InternPool.Index.c_ulong_type),
875 c_longlong_type = @enumToInt(InternPool.Index.c_longlong_type),
876 c_ulonglong_type = @enumToInt(InternPool.Index.c_ulonglong_type),
877 c_longdouble_type = @enumToInt(InternPool.Index.c_longdouble_type),
878 f16_type = @enumToInt(InternPool.Index.f16_type),
879 f32_type = @enumToInt(InternPool.Index.f32_type),
880 f64_type = @enumToInt(InternPool.Index.f64_type),
881 f80_type = @enumToInt(InternPool.Index.f80_type),
882 f128_type = @enumToInt(InternPool.Index.f128_type),
883 anyopaque_type = @enumToInt(InternPool.Index.anyopaque_type),
884 bool_type = @enumToInt(InternPool.Index.bool_type),
885 void_type = @enumToInt(InternPool.Index.void_type),
886 type_type = @enumToInt(InternPool.Index.type_type),
887 anyerror_type = @enumToInt(InternPool.Index.anyerror_type),
888 comptime_int_type = @enumToInt(InternPool.Index.comptime_int_type),
889 comptime_float_type = @enumToInt(InternPool.Index.comptime_float_type),
890 noreturn_type = @enumToInt(InternPool.Index.noreturn_type),
891 anyframe_type = @enumToInt(InternPool.Index.anyframe_type),
892 null_type = @enumToInt(InternPool.Index.null_type),
893 undefined_type = @enumToInt(InternPool.Index.undefined_type),
894 enum_literal_type = @enumToInt(InternPool.Index.enum_literal_type),
895 atomic_order_type = @enumToInt(InternPool.Index.atomic_order_type),
896 atomic_rmw_op_type = @enumToInt(InternPool.Index.atomic_rmw_op_type),
897 calling_convention_type = @enumToInt(InternPool.Index.calling_convention_type),
898 address_space_type = @enumToInt(InternPool.Index.address_space_type),
899 float_mode_type = @enumToInt(InternPool.Index.float_mode_type),
900 reduce_op_type = @enumToInt(InternPool.Index.reduce_op_type),
901 call_modifier_type = @enumToInt(InternPool.Index.call_modifier_type),
902 prefetch_options_type = @enumToInt(InternPool.Index.prefetch_options_type),
903 export_options_type = @enumToInt(InternPool.Index.export_options_type),
904 extern_options_type = @enumToInt(InternPool.Index.extern_options_type),
905 type_info_type = @enumToInt(InternPool.Index.type_info_type),
906 manyptr_u8_type = @enumToInt(InternPool.Index.manyptr_u8_type),
907 manyptr_const_u8_type = @enumToInt(InternPool.Index.manyptr_const_u8_type),
908 manyptr_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.manyptr_const_u8_sentinel_0_type),
909 single_const_pointer_to_comptime_int_type = @enumToInt(InternPool.Index.single_const_pointer_to_comptime_int_type),
910 slice_const_u8_type = @enumToInt(InternPool.Index.slice_const_u8_type),
911 slice_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.slice_const_u8_sentinel_0_type),
912 anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type),
913 generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type),
914 empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type),
915 undef = @enumToInt(InternPool.Index.undef),
916 zero = @enumToInt(InternPool.Index.zero),
917 zero_usize = @enumToInt(InternPool.Index.zero_usize),
918 zero_u8 = @enumToInt(InternPool.Index.zero_u8),
919 one = @enumToInt(InternPool.Index.one),
920 one_usize = @enumToInt(InternPool.Index.one_usize),
921 one_u8 = @enumToInt(InternPool.Index.one_u8),
922 four_u8 = @enumToInt(InternPool.Index.four_u8),
923 negative_one = @enumToInt(InternPool.Index.negative_one),
924 calling_convention_c = @enumToInt(InternPool.Index.calling_convention_c),
925 calling_convention_inline = @enumToInt(InternPool.Index.calling_convention_inline),
926 void_value = @enumToInt(InternPool.Index.void_value),
927 unreachable_value = @enumToInt(InternPool.Index.unreachable_value),
928 null_value = @enumToInt(InternPool.Index.null_value),
929 bool_true = @enumToInt(InternPool.Index.bool_true),
930 bool_false = @enumToInt(InternPool.Index.bool_false),
931 empty_struct = @enumToInt(InternPool.Index.empty_struct),
932 generic_poison = @enumToInt(InternPool.Index.generic_poison),
853 u1_type = @intFromEnum(InternPool.Index.u1_type),
854 u8_type = @intFromEnum(InternPool.Index.u8_type),
855 i8_type = @intFromEnum(InternPool.Index.i8_type),
856 u16_type = @intFromEnum(InternPool.Index.u16_type),
857 i16_type = @intFromEnum(InternPool.Index.i16_type),
858 u29_type = @intFromEnum(InternPool.Index.u29_type),
859 u32_type = @intFromEnum(InternPool.Index.u32_type),
860 i32_type = @intFromEnum(InternPool.Index.i32_type),
861 u64_type = @intFromEnum(InternPool.Index.u64_type),
862 i64_type = @intFromEnum(InternPool.Index.i64_type),
863 u80_type = @intFromEnum(InternPool.Index.u80_type),
864 u128_type = @intFromEnum(InternPool.Index.u128_type),
865 i128_type = @intFromEnum(InternPool.Index.i128_type),
866 usize_type = @intFromEnum(InternPool.Index.usize_type),
867 isize_type = @intFromEnum(InternPool.Index.isize_type),
868 c_char_type = @intFromEnum(InternPool.Index.c_char_type),
869 c_short_type = @intFromEnum(InternPool.Index.c_short_type),
870 c_ushort_type = @intFromEnum(InternPool.Index.c_ushort_type),
871 c_int_type = @intFromEnum(InternPool.Index.c_int_type),
872 c_uint_type = @intFromEnum(InternPool.Index.c_uint_type),
873 c_long_type = @intFromEnum(InternPool.Index.c_long_type),
874 c_ulong_type = @intFromEnum(InternPool.Index.c_ulong_type),
875 c_longlong_type = @intFromEnum(InternPool.Index.c_longlong_type),
876 c_ulonglong_type = @intFromEnum(InternPool.Index.c_ulonglong_type),
877 c_longdouble_type = @intFromEnum(InternPool.Index.c_longdouble_type),
878 f16_type = @intFromEnum(InternPool.Index.f16_type),
879 f32_type = @intFromEnum(InternPool.Index.f32_type),
880 f64_type = @intFromEnum(InternPool.Index.f64_type),
881 f80_type = @intFromEnum(InternPool.Index.f80_type),
882 f128_type = @intFromEnum(InternPool.Index.f128_type),
883 anyopaque_type = @intFromEnum(InternPool.Index.anyopaque_type),
884 bool_type = @intFromEnum(InternPool.Index.bool_type),
885 void_type = @intFromEnum(InternPool.Index.void_type),
886 type_type = @intFromEnum(InternPool.Index.type_type),
887 anyerror_type = @intFromEnum(InternPool.Index.anyerror_type),
888 comptime_int_type = @intFromEnum(InternPool.Index.comptime_int_type),
889 comptime_float_type = @intFromEnum(InternPool.Index.comptime_float_type),
890 noreturn_type = @intFromEnum(InternPool.Index.noreturn_type),
891 anyframe_type = @intFromEnum(InternPool.Index.anyframe_type),
892 null_type = @intFromEnum(InternPool.Index.null_type),
893 undefined_type = @intFromEnum(InternPool.Index.undefined_type),
894 enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type),
895 atomic_order_type = @intFromEnum(InternPool.Index.atomic_order_type),
896 atomic_rmw_op_type = @intFromEnum(InternPool.Index.atomic_rmw_op_type),
897 calling_convention_type = @intFromEnum(InternPool.Index.calling_convention_type),
898 address_space_type = @intFromEnum(InternPool.Index.address_space_type),
899 float_mode_type = @intFromEnum(InternPool.Index.float_mode_type),
900 reduce_op_type = @intFromEnum(InternPool.Index.reduce_op_type),
901 call_modifier_type = @intFromEnum(InternPool.Index.call_modifier_type),
902 prefetch_options_type = @intFromEnum(InternPool.Index.prefetch_options_type),
903 export_options_type = @intFromEnum(InternPool.Index.export_options_type),
904 extern_options_type = @intFromEnum(InternPool.Index.extern_options_type),
905 type_info_type = @intFromEnum(InternPool.Index.type_info_type),
906 manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type),
907 manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type),
908 manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type),
909 single_const_pointer_to_comptime_int_type = @intFromEnum(InternPool.Index.single_const_pointer_to_comptime_int_type),
910 slice_const_u8_type = @intFromEnum(InternPool.Index.slice_const_u8_type),
911 slice_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.slice_const_u8_sentinel_0_type),
912 anyerror_void_error_union_type = @intFromEnum(InternPool.Index.anyerror_void_error_union_type),
913 generic_poison_type = @intFromEnum(InternPool.Index.generic_poison_type),
914 empty_struct_type = @intFromEnum(InternPool.Index.empty_struct_type),
915 undef = @intFromEnum(InternPool.Index.undef),
916 zero = @intFromEnum(InternPool.Index.zero),
917 zero_usize = @intFromEnum(InternPool.Index.zero_usize),
918 zero_u8 = @intFromEnum(InternPool.Index.zero_u8),
919 one = @intFromEnum(InternPool.Index.one),
920 one_usize = @intFromEnum(InternPool.Index.one_usize),
921 one_u8 = @intFromEnum(InternPool.Index.one_u8),
922 four_u8 = @intFromEnum(InternPool.Index.four_u8),
923 negative_one = @intFromEnum(InternPool.Index.negative_one),
924 calling_convention_c = @intFromEnum(InternPool.Index.calling_convention_c),
925 calling_convention_inline = @intFromEnum(InternPool.Index.calling_convention_inline),
926 void_value = @intFromEnum(InternPool.Index.void_value),
927 unreachable_value = @intFromEnum(InternPool.Index.unreachable_value),
928 null_value = @intFromEnum(InternPool.Index.null_value),
929 bool_true = @intFromEnum(InternPool.Index.bool_true),
930 bool_false = @intFromEnum(InternPool.Index.bool_false),
931 empty_struct = @intFromEnum(InternPool.Index.empty_struct),
932 generic_poison = @intFromEnum(InternPool.Index.generic_poison),
933933
934934 /// This Ref does not correspond to any AIR instruction or constant
935935 /// value. It is used to handle argument types of var args functions.
936 var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
936 var_args_param_type = @intFromEnum(InternPool.Index.var_args_param_type),
937937 /// This Ref does not correspond to any AIR instruction or constant
938938 /// value and may instead be used as a sentinel to indicate null.
939 none = @enumToInt(InternPool.Index.none),
939 none = @intFromEnum(InternPool.Index.none),
940940 _,
941941 };
942942
......@@ -1103,11 +1103,11 @@ pub const VectorCmp = struct {
11031103 op: u32,
11041104
11051105 pub fn compareOperator(self: VectorCmp) std.math.CompareOperator {
1106 return @intToEnum(std.math.CompareOperator, @truncate(u3, self.op));
1106 return @enumFromInt(std.math.CompareOperator, @truncate(u3, self.op));
11071107 }
11081108
11091109 pub fn encodeOp(compare_operator: std.math.CompareOperator) u32 {
1110 return @enumToInt(compare_operator);
1110 return @intFromEnum(compare_operator);
11111111 }
11121112};
11131113
......@@ -1148,11 +1148,11 @@ pub const Cmpxchg = struct {
11481148 flags: u32,
11491149
11501150 pub fn successOrder(self: Cmpxchg) std.builtin.AtomicOrder {
1151 return @intToEnum(std.builtin.AtomicOrder, @truncate(u3, self.flags));
1151 return @enumFromInt(std.builtin.AtomicOrder, @truncate(u3, self.flags));
11521152 }
11531153
11541154 pub fn failureOrder(self: Cmpxchg) std.builtin.AtomicOrder {
1155 return @intToEnum(std.builtin.AtomicOrder, @truncate(u3, self.flags >> 3));
1155 return @enumFromInt(std.builtin.AtomicOrder, @truncate(u3, self.flags >> 3));
11561156 }
11571157};
11581158
......@@ -1163,11 +1163,11 @@ pub const AtomicRmw = struct {
11631163 flags: u32,
11641164
11651165 pub fn ordering(self: AtomicRmw) std.builtin.AtomicOrder {
1166 return @intToEnum(std.builtin.AtomicOrder, @truncate(u3, self.flags));
1166 return @enumFromInt(std.builtin.AtomicOrder, @truncate(u3, self.flags));
11671167 }
11681168
11691169 pub fn op(self: AtomicRmw) std.builtin.AtomicRmwOp {
1170 return @intToEnum(std.builtin.AtomicRmwOp, @truncate(u4, self.flags >> 3));
1170 return @enumFromInt(std.builtin.AtomicRmwOp, @truncate(u4, self.flags >> 3));
11711171 }
11721172};
11731173
......@@ -1177,13 +1177,13 @@ pub const UnionInit = struct {
11771177};
11781178
11791179pub fn getMainBody(air: Air) []const Air.Inst.Index {
1180 const body_index = air.extra[@enumToInt(ExtraIndex.main_block)];
1180 const body_index = air.extra[@intFromEnum(ExtraIndex.main_block)];
11811181 const extra = air.extraData(Block, body_index);
11821182 return air.extra[extra.end..][0..extra.data.body_len];
11831183}
11841184
11851185pub fn typeOf(air: Air, inst: Air.Inst.Ref, ip: *const InternPool) Type {
1186 const ref_int = @enumToInt(inst);
1186 const ref_int = @intFromEnum(inst);
11871187 if (ref_int < InternPool.static_keys.len) {
11881188 return InternPool.static_keys[ref_int].typeOf().toType();
11891189 }
......@@ -1337,9 +1337,9 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
13371337 .struct_field_ptr_index_2,
13381338 .struct_field_ptr_index_3,
13391339 .array_to_slice,
1340 .float_to_int,
1341 .float_to_int_optimized,
1342 .int_to_float,
1340 .int_from_float,
1341 .int_from_float_optimized,
1342 .float_from_int,
13431343 .splat,
13441344 .get_union_tag,
13451345 .clz,
......@@ -1387,7 +1387,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
13871387 .c_va_end,
13881388 => return Type.void,
13891389
1390 .ptrtoint,
1390 .int_from_ptr,
13911391 .slice_len,
13921392 .ret_addr,
13931393 .frame_addr,
......@@ -1397,7 +1397,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
13971397 .wasm_memory_grow => return Type.i32,
13981398 .wasm_memory_size => return Type.u32,
13991399
1400 .bool_to_int => return Type.u1,
1400 .int_from_bool => return Type.u1,
14011401
14021402 .tag_name, .error_name => return Type.slice_const_u8_sentinel_0,
14031403
......@@ -1446,9 +1446,9 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
14461446}
14471447
14481448pub fn getRefType(air: Air, ref: Air.Inst.Ref) Type {
1449 const ref_int = @enumToInt(ref);
1449 const ref_int = @intFromEnum(ref);
14501450 if (ref_int < ref_start_index) {
1451 const ip_index = @intToEnum(InternPool.Index, ref_int);
1451 const ip_index = @enumFromInt(InternPool.Index, ref_int);
14521452 return ip_index.toType();
14531453 }
14541454 const inst_index = ref_int - ref_start_index;
......@@ -1469,9 +1469,9 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end
14691469 inline for (fields) |field| {
14701470 @field(result, field.name) = switch (field.type) {
14711471 u32 => air.extra[i],
1472 Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]),
1472 Inst.Ref => @enumFromInt(Inst.Ref, air.extra[i]),
14731473 i32 => @bitCast(i32, air.extra[i]),
1474 InternPool.Index => @intToEnum(InternPool.Index, air.extra[i]),
1474 InternPool.Index => @enumFromInt(InternPool.Index, air.extra[i]),
14751475 else => @compileError("bad field type: " ++ @typeName(field.type)),
14761476 };
14771477 i += 1;
......@@ -1491,12 +1491,12 @@ pub fn deinit(air: *Air, gpa: std.mem.Allocator) void {
14911491pub const ref_start_index: u32 = InternPool.static_len;
14921492
14931493pub fn indexToRef(inst: Inst.Index) Inst.Ref {
1494 return @intToEnum(Inst.Ref, ref_start_index + inst);
1494 return @enumFromInt(Inst.Ref, ref_start_index + inst);
14951495}
14961496
14971497pub fn refToIndex(inst: Inst.Ref) ?Inst.Index {
14981498 assert(inst != .none);
1499 const ref_int = @enumToInt(inst);
1499 const ref_int = @intFromEnum(inst);
15001500 if (ref_int >= ref_start_index) {
15011501 return ref_int - ref_start_index;
15021502 } else {
......@@ -1511,9 +1511,9 @@ pub fn refToIndexAllowNone(inst: Inst.Ref) ?Inst.Index {
15111511
15121512/// Returns `null` if runtime-known.
15131513pub fn value(air: Air, inst: Inst.Ref, mod: *Module) !?Value {
1514 const ref_int = @enumToInt(inst);
1514 const ref_int = @intFromEnum(inst);
15151515 if (ref_int < ref_start_index) {
1516 const ip_index = @intToEnum(InternPool.Index, ref_int);
1516 const ip_index = @enumFromInt(InternPool.Index, ref_int);
15171517 return ip_index.toValue();
15181518 }
15191519 const inst_index = @intCast(Air.Inst.Index, ref_int - ref_start_index);
......@@ -1687,8 +1687,8 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
16871687 .is_non_err_ptr,
16881688 .bool_and,
16891689 .bool_or,
1690 .ptrtoint,
1691 .bool_to_int,
1690 .int_from_ptr,
1691 .int_from_bool,
16921692 .fptrunc,
16931693 .fpext,
16941694 .intcast,
......@@ -1718,9 +1718,9 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
17181718 .slice_elem_ptr,
17191719 .ptr_elem_ptr,
17201720 .array_to_slice,
1721 .float_to_int,
1722 .float_to_int_optimized,
1723 .int_to_float,
1721 .int_from_float,
1722 .int_from_float_optimized,
1723 .float_from_int,
17241724 .reduce,
17251725 .reduce_optimized,
17261726 .splat,
src/AstGen.zig+174-174
......@@ -82,7 +82,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
8282 inline for (fields) |field| {
8383 astgen.extra.items[i] = switch (field.type) {
8484 u32 => @field(extra, field.name),
85 Zir.Inst.Ref => @enumToInt(@field(extra, field.name)),
85 Zir.Inst.Ref => @intFromEnum(@field(extra, field.name)),
8686 i32 => @bitCast(u32, @field(extra, field.name)),
8787 Zir.Inst.Call.Flags => @bitCast(u32, @field(extra, field.name)),
8888 Zir.Inst.BuiltinCall.Flags => @bitCast(u32, @field(extra, field.name)),
......@@ -168,7 +168,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
168168 try lowerAstErrors(&astgen);
169169 }
170170
171 const err_index = @enumToInt(Zir.ExtraIndex.compile_errors);
171 const err_index = @intFromEnum(Zir.ExtraIndex.compile_errors);
172172 if (astgen.compile_errors.items.len == 0) {
173173 astgen.extra.items[err_index] = 0;
174174 } else {
......@@ -184,7 +184,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
184184 }
185185 }
186186
187 const imports_index = @enumToInt(Zir.ExtraIndex.imports);
187 const imports_index = @intFromEnum(Zir.ExtraIndex.imports);
188188 if (astgen.imports.count() == 0) {
189189 astgen.extra.items[imports_index] = 0;
190190 } else {
......@@ -1513,7 +1513,7 @@ fn arrayInitExprRlNone(
15131513
15141514 for (elements) |elem_init| {
15151515 const elem_ref = try expr(gz, scope, .{ .rl = .none }, elem_init);
1516 astgen.extra.items[extra_index] = @enumToInt(elem_ref);
1516 astgen.extra.items[extra_index] = @intFromEnum(elem_ref);
15171517 extra_index += 1;
15181518 }
15191519 return try gz.addPlNodePayloadIndex(tag, node, payload_index);
......@@ -1530,13 +1530,13 @@ fn arrayInitExprInner(
15301530) InnerError!Zir.Inst.Ref {
15311531 const astgen = gz.astgen;
15321532
1533 const len = elements.len + @boolToInt(array_ty_inst != .none);
1533 const len = elements.len + @intFromBool(array_ty_inst != .none);
15341534 const payload_index = try addExtra(astgen, Zir.Inst.MultiOp{
15351535 .operands_len = @intCast(u32, len),
15361536 });
15371537 var extra_index = try reserveExtra(astgen, len);
15381538 if (array_ty_inst != .none) {
1539 astgen.extra.items[extra_index] = @enumToInt(array_ty_inst);
1539 astgen.extra.items[extra_index] = @intFromEnum(array_ty_inst);
15401540 extra_index += 1;
15411541 }
15421542
......@@ -1548,14 +1548,14 @@ fn arrayInitExprInner(
15481548 .tag = .elem_type_index,
15491549 .data = .{ .bin = .{
15501550 .lhs = array_ty_inst,
1551 .rhs = @intToEnum(Zir.Inst.Ref, i),
1551 .rhs = @enumFromInt(Zir.Inst.Ref, i),
15521552 } },
15531553 });
15541554 break :ri ResultInfo{ .rl = .{ .coerced_ty = ty_expr } };
15551555 } else ResultInfo{ .rl = .{ .none = {} } };
15561556
15571557 const elem_ref = try expr(gz, scope, ri, elem_init);
1558 astgen.extra.items[extra_index] = @enumToInt(elem_ref);
1558 astgen.extra.items[extra_index] = @intFromEnum(elem_ref);
15591559 extra_index += 1;
15601560 }
15611561
......@@ -2626,15 +2626,15 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
26262626 .error_set_decl,
26272627 .error_set_decl_anon,
26282628 .error_set_decl_func,
2629 .int_to_enum,
2630 .enum_to_int,
2629 .enum_from_int,
2630 .int_from_enum,
26312631 .type_info,
26322632 .size_of,
26332633 .bit_size_of,
26342634 .typeof_log2_int_type,
2635 .ptr_to_int,
2635 .int_from_ptr,
26362636 .align_of,
2637 .bool_to_int,
2637 .int_from_bool,
26382638 .embed_file,
26392639 .error_name,
26402640 .sqrt,
......@@ -2655,9 +2655,9 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
26552655 .type_name,
26562656 .frame_type,
26572657 .frame_size,
2658 .float_to_int,
2659 .int_to_float,
2660 .int_to_ptr,
2658 .int_from_float,
2659 .float_from_int,
2660 .ptr_from_int,
26612661 .float_cast,
26622662 .int_cast,
26632663 .ptr_cast,
......@@ -3515,17 +3515,17 @@ fn ptrType(
35153515 .src_node = gz.nodeIndexToRelative(node),
35163516 });
35173517 if (sentinel_ref != .none) {
3518 gz.astgen.extra.appendAssumeCapacity(@enumToInt(sentinel_ref));
3518 gz.astgen.extra.appendAssumeCapacity(@intFromEnum(sentinel_ref));
35193519 }
35203520 if (align_ref != .none) {
3521 gz.astgen.extra.appendAssumeCapacity(@enumToInt(align_ref));
3521 gz.astgen.extra.appendAssumeCapacity(@intFromEnum(align_ref));
35223522 }
35233523 if (addrspace_ref != .none) {
3524 gz.astgen.extra.appendAssumeCapacity(@enumToInt(addrspace_ref));
3524 gz.astgen.extra.appendAssumeCapacity(@intFromEnum(addrspace_ref));
35253525 }
35263526 if (bit_start_ref != .none) {
3527 gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_start_ref));
3528 gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_end_ref));
3527 gz.astgen.extra.appendAssumeCapacity(@intFromEnum(bit_start_ref));
3528 gz.astgen.extra.appendAssumeCapacity(@intFromEnum(bit_end_ref));
35293529 }
35303530
35313531 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
......@@ -3644,10 +3644,10 @@ const WipMembers = struct {
36443644 assert(index < self.decls_start);
36453645 const bit_bag: u32 = if (self.decl_index % decls_per_u32 == 0) 0 else self.payload.items[index];
36463646 self.payload.items[index] = (bit_bag >> bits_per_decl) |
3647 (@as(u32, @boolToInt(is_pub)) << 28) |
3648 (@as(u32, @boolToInt(is_export)) << 29) |
3649 (@as(u32, @boolToInt(has_align)) << 30) |
3650 (@as(u32, @boolToInt(has_section_or_addrspace)) << 31);
3647 (@as(u32, @intFromBool(is_pub)) << 28) |
3648 (@as(u32, @intFromBool(is_export)) << 29) |
3649 (@as(u32, @intFromBool(has_align)) << 30) |
3650 (@as(u32, @intFromBool(has_section_or_addrspace)) << 31);
36513651 self.decl_index += 1;
36523652 }
36533653
......@@ -3659,7 +3659,7 @@ const WipMembers = struct {
36593659 bit_bag >>= bits_per_field;
36603660 comptime var i = 0;
36613661 inline while (i < bits_per_field) : (i += 1) {
3662 bit_bag |= @as(u32, @boolToInt(bits[i])) << (32 - bits_per_field + i);
3662 bit_bag |= @as(u32, @intFromBool(bits[i])) << (32 - bits_per_field + i);
36633663 }
36643664 self.payload.items[index] = bit_bag;
36653665 self.field_index += 1;
......@@ -4233,11 +4233,11 @@ fn globalVarDecl(
42334233 wip_members.appendToDecl(block_inst);
42344234 wip_members.appendToDecl(doc_comment_index); // doc_comment wip
42354235 if (align_inst != .none) {
4236 wip_members.appendToDecl(@enumToInt(align_inst));
4236 wip_members.appendToDecl(@intFromEnum(align_inst));
42374237 }
42384238 if (has_section_or_addrspace) {
4239 wip_members.appendToDecl(@enumToInt(section_inst));
4240 wip_members.appendToDecl(@enumToInt(addrspace_inst));
4239 wip_members.appendToDecl(@intFromEnum(section_inst));
4240 wip_members.appendToDecl(@intFromEnum(addrspace_inst));
42414241 }
42424242}
42434243
......@@ -4727,7 +4727,7 @@ fn structDeclInner(
47274727 wip_members.appendToField(@intCast(u32, astgen.scratch.items.len - old_scratch_len));
47284728 block_scope.instructions.items.len = block_scope.instructions_top;
47294729 } else {
4730 wip_members.appendToField(@enumToInt(field_type));
4730 wip_members.appendToField(@intFromEnum(field_type));
47314731 }
47324732
47334733 if (have_align) {
......@@ -4878,13 +4878,13 @@ fn unionDeclInner(
48784878
48794879 if (have_type) {
48804880 const field_type = try typeExpr(&block_scope, &namespace.base, member.ast.type_expr);
4881 wip_members.appendToField(@enumToInt(field_type));
4881 wip_members.appendToField(@intFromEnum(field_type));
48824882 } else if (arg_inst == .none and auto_enum_tok == null) {
48834883 return astgen.failNode(member_node, "union field missing type", .{});
48844884 }
48854885 if (have_align) {
48864886 const align_inst = try expr(&block_scope, &block_scope.base, .{ .rl = .{ .ty = .u32_type } }, member.ast.align_expr);
4887 wip_members.appendToField(@enumToInt(align_inst));
4887 wip_members.appendToField(@intFromEnum(align_inst));
48884888 }
48894889 if (have_value) {
48904890 if (arg_inst == .none) {
......@@ -4916,7 +4916,7 @@ fn unionDeclInner(
49164916 );
49174917 }
49184918 const tag_value = try expr(&block_scope, &block_scope.base, .{ .rl = .{ .ty = arg_inst } }, member.ast.value_expr);
4919 wip_members.appendToField(@enumToInt(tag_value));
4919 wip_members.appendToField(@intFromEnum(tag_value));
49204920 }
49214921 }
49224922
......@@ -5167,7 +5167,7 @@ fn containerDecl(
51675167 }
51685168 namespace.base.tag = .enum_namespace;
51695169 const tag_value_inst = try expr(&block_scope, &namespace.base, .{ .rl = .{ .ty = arg_inst } }, member.ast.value_expr);
5170 wip_members.appendToField(@enumToInt(tag_value_inst));
5170 wip_members.appendToField(@intFromEnum(tag_value_inst));
51715171 }
51725172 }
51735173
......@@ -5846,7 +5846,7 @@ fn ifExpr(
58465846 else
58475847 .err_union_payload_unsafe;
58485848 const payload_inst = try then_scope.addUnNode(tag, cond.inst, then_node);
5849 const token_name_index = payload_token + @boolToInt(payload_is_ref);
5849 const token_name_index = payload_token + @intFromBool(payload_is_ref);
58505850 const ident_name = try astgen.identAsString(token_name_index);
58515851 const token_name_str = tree.tokenSlice(token_name_index);
58525852 if (mem.eql(u8, "_", token_name_str))
......@@ -6000,8 +6000,8 @@ fn setCondBrPayload(
60006000 const astgen = then_scope.astgen;
60016001 const then_body = then_scope.instructionsSliceUpto(else_scope);
60026002 const else_body = else_scope.instructionsSlice();
6003 const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @boolToInt(then_break != 0);
6004 const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @boolToInt(else_break != 0);
6003 const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @intFromBool(then_break != 0);
6004 const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @intFromBool(else_break != 0);
60056005 try astgen.extra.ensureUnusedCapacity(
60066006 astgen.gpa,
60076007 @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len,
......@@ -6036,8 +6036,8 @@ fn setCondBrPayloadElideBlockStorePtr(
60366036 const else_body = else_scope.instructionsSlice();
60376037 const has_then_break = then_break != 0;
60386038 const has_else_break = else_break != 0;
6039 const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @boolToInt(has_then_break);
6040 const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @boolToInt(has_else_break);
6039 const then_body_len = astgen.countBodyLenAfterFixups(then_body) + @intFromBool(has_then_break);
6040 const else_body_len = astgen.countBodyLenAfterFixups(else_body) + @intFromBool(has_else_break);
60416041 try astgen.extra.ensureUnusedCapacity(
60426042 astgen.gpa,
60436043 @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len,
......@@ -6197,7 +6197,7 @@ fn whileExpr(
61976197 const ident_bytes = tree.tokenSlice(ident_token);
61986198 if (mem.eql(u8, "_", ident_bytes))
61996199 break :s &then_scope.base;
6200 const payload_name_loc = payload_token + @boolToInt(payload_is_ref);
6200 const payload_name_loc = payload_token + @intFromBool(payload_is_ref);
62016201 const ident_name = try astgen.identAsString(payload_name_loc);
62026202 try astgen.detectLocalShadowing(&then_scope.base, ident_name, payload_name_loc, ident_bytes, .capture);
62036203 payload_val_scope = .{
......@@ -6439,7 +6439,7 @@ fn forExpr(
64396439 for (for_full.ast.inputs, 0..) |input, i_usize| {
64406440 const i = @intCast(u32, i_usize);
64416441 const capture_is_ref = token_tags[capture_token] == .asterisk;
6442 const ident_tok = capture_token + @boolToInt(capture_is_ref);
6442 const ident_tok = capture_token + @intFromBool(capture_is_ref);
64436443 const is_discard = mem.eql(u8, tree.tokenSlice(ident_tok), "_");
64446444
64456445 if (is_discard and capture_is_ref) {
......@@ -6567,7 +6567,7 @@ fn forExpr(
65676567 for (for_full.ast.inputs, 0..) |input, i_usize| {
65686568 const i = @intCast(u32, i_usize);
65696569 const capture_is_ref = token_tags[capture_token] == .asterisk;
6570 const ident_tok = capture_token + @boolToInt(capture_is_ref);
6570 const ident_tok = capture_token + @intFromBool(capture_is_ref);
65716571 const capture_name = tree.tokenSlice(ident_tok);
65726572 // Skip over the comma, and on to the next capture (or the ending pipe character).
65736573 capture_token = ident_tok + 2;
......@@ -6591,7 +6591,7 @@ fn forExpr(
65916591 // indexables, we use it as an element index. This is so similar
65926592 // that they can share the same code paths, branching only on the
65936593 // ZIR tag.
6594 const switch_cond = (@as(u2, @boolToInt(capture_is_ref)) << 1) | @boolToInt(is_counter);
6594 const switch_cond = (@as(u2, @intFromBool(capture_is_ref)) << 1) | @intFromBool(is_counter);
65956595 const tag: Zir.Inst.Tag = switch (switch_cond) {
65966596 0b00 => .elem_val,
65976597 0b01 => .add,
......@@ -6842,7 +6842,7 @@ fn switchExpr(
68426842 const payloads = &astgen.scratch;
68436843 const scratch_top = astgen.scratch.items.len;
68446844 const case_table_start = scratch_top;
6845 const scalar_case_table = case_table_start + @boolToInt(special_prong != .none);
6845 const scalar_case_table = case_table_start + @intFromBool(special_prong != .none);
68466846 const multi_case_table = scalar_case_table + scalar_cases_len;
68476847 const case_table_end = multi_case_table + multi_cases_len;
68486848 try astgen.scratch.resize(gpa, case_table_end);
......@@ -6971,7 +6971,7 @@ fn switchExpr(
69716971 items_len += 1;
69726972
69736973 const item_inst = try comptimeExpr(parent_gz, scope, item_ri, item_node);
6974 try payloads.append(gpa, @enumToInt(item_inst));
6974 try payloads.append(gpa, @intFromEnum(item_inst));
69756975 }
69766976
69776977 // ranges
......@@ -6983,7 +6983,7 @@ fn switchExpr(
69836983 const first = try comptimeExpr(parent_gz, scope, item_ri, node_datas[range].lhs);
69846984 const last = try comptimeExpr(parent_gz, scope, item_ri, node_datas[range].rhs);
69856985 try payloads.appendSlice(gpa, &[_]u32{
6986 @enumToInt(first), @enumToInt(last),
6986 @intFromEnum(first), @intFromEnum(last),
69876987 });
69886988 }
69896989
......@@ -7000,7 +7000,7 @@ fn switchExpr(
70007000 try payloads.resize(gpa, header_index + 2); // item, body_len
70017001 const item_node = case.ast.values[0];
70027002 const item_inst = try comptimeExpr(parent_gz, scope, item_ri, item_node);
7003 payloads.items[header_index] = @enumToInt(item_inst);
7003 payloads.items[header_index] = @intFromEnum(item_inst);
70047004 break :blk header_index + 1;
70057005 };
70067006
......@@ -7069,8 +7069,8 @@ fn switchExpr(
70697069 try parent_gz.instructions.append(gpa, switch_block);
70707070
70717071 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).Struct.fields.len +
7072 @boolToInt(multi_cases_len != 0) +
7073 @boolToInt(any_has_tag_capture) +
7072 @intFromBool(multi_cases_len != 0) +
7073 @intFromBool(any_has_tag_capture) +
70747074 payloads.items.len - case_table_end);
70757075
70767076 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{
......@@ -7633,8 +7633,8 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node:
76337633 const gpa = astgen.gpa;
76347634 var big_int = try std.math.big.int.Managed.init(gpa);
76357635 defer big_int.deinit();
7636 const prefix_offset = @as(u8, 2) * @boolToInt(base != .decimal);
7637 big_int.setString(@enumToInt(base), bytes[prefix_offset..]) catch |err| switch (err) {
7636 const prefix_offset = @as(u8, 2) * @intFromBool(base != .decimal);
7637 big_int.setString(@intFromEnum(base), bytes[prefix_offset..]) catch |err| switch (err) {
76387638 error.InvalidCharacter => unreachable, // caught in `parseNumberLiteral`
76397639 error.InvalidBase => unreachable, // we only pass 16, 8, 2, see above
76407640 error.OutOfMemory => return error.OutOfMemory,
......@@ -7739,7 +7739,7 @@ fn asmExpr(
77397739 },
77407740 else => .{
77417741 .tag = .asm_expr,
7742 .tmpl = @enumToInt(try comptimeExpr(gz, scope, .{ .rl = .none }, full.ast.template)),
7742 .tmpl = @intFromEnum(try comptimeExpr(gz, scope, .{ .rl = .none }, full.ast.template)),
77437743 },
77447744 };
77457745
......@@ -7977,7 +7977,7 @@ fn typeOf(
79777977
79787978 for (args, 0..) |arg, i| {
79797979 const param_ref = try reachableExpr(&typeof_scope, &typeof_scope.base, .{ .rl = .none }, arg, node);
7980 astgen.extra.items[args_index + i] = @enumToInt(param_ref);
7980 astgen.extra.items[args_index + i] = @intFromEnum(param_ref);
79817981 }
79827982 _ = try typeof_scope.addBreak(.break_inline, refToIndex(typeof_inst).?, .void_value);
79837983
......@@ -8026,7 +8026,7 @@ fn minMax(
80268026 var extra_index = try reserveExtra(gz.astgen, args.len);
80278027 for (args) |arg| {
80288028 const arg_ref = try expr(gz, scope, .{ .rl = .none }, arg);
8029 astgen.extra.items[extra_index] = @enumToInt(arg_ref);
8029 astgen.extra.items[extra_index] = @intFromEnum(arg_ref);
80308030 extra_index += 1;
80318031 }
80328032 const tag: Zir.Inst.Extended = switch (op) {
......@@ -8101,7 +8101,7 @@ fn builtinCall(
81018101 var extra_index = try reserveExtra(gz.astgen, params.len);
81028102 for (params) |param| {
81038103 const param_ref = try expr(gz, scope, .{ .rl = .none }, param);
8104 astgen.extra.items[extra_index] = @enumToInt(param_ref);
8104 astgen.extra.items[extra_index] = @intFromEnum(param_ref);
81058105 extra_index += 1;
81068106 }
81078107 const result = try gz.addExtendedMultiOpPayloadIndex(.compile_log, payload_index, params.len);
......@@ -8281,11 +8281,11 @@ fn builtinCall(
82818281 .bit_size_of => return simpleUnOpType(gz, scope, ri, node, params[0], .bit_size_of),
82828282 .align_of => return simpleUnOpType(gz, scope, ri, node, params[0], .align_of),
82838283
8284 .ptr_to_int => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .ptr_to_int),
8284 .int_from_ptr => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .int_from_ptr),
82858285 .compile_error => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .slice_const_u8_type } }, params[0], .compile_error),
82868286 .set_eval_branch_quota => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0], .set_eval_branch_quota),
8287 .enum_to_int => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .enum_to_int),
8288 .bool_to_int => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .bool_to_int),
8287 .int_from_enum => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .int_from_enum),
8288 .int_from_bool => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .int_from_bool),
82898289 .embed_file => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .slice_const_u8_type } }, params[0], .embed_file),
82908290 .error_name => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .anyerror_type } }, params[0], .error_name),
82918291 .set_runtime_safety => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .set_runtime_safety),
......@@ -8308,10 +8308,10 @@ fn builtinCall(
83088308 .Frame => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .frame_type),
83098309 .frame_size => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .frame_size),
83108310
8311 .float_to_int => return typeCast(gz, scope, ri, node, params[0], params[1], .float_to_int),
8312 .int_to_float => return typeCast(gz, scope, ri, node, params[0], params[1], .int_to_float),
8313 .int_to_ptr => return typeCast(gz, scope, ri, node, params[0], params[1], .int_to_ptr),
8314 .int_to_enum => return typeCast(gz, scope, ri, node, params[0], params[1], .int_to_enum),
8311 .int_from_float => return typeCast(gz, scope, ri, node, params[0], params[1], .int_from_float),
8312 .float_from_int => return typeCast(gz, scope, ri, node, params[0], params[1], .float_from_int),
8313 .ptr_from_int => return typeCast(gz, scope, ri, node, params[0], params[1], .ptr_from_int),
8314 .enum_from_int => return typeCast(gz, scope, ri, node, params[0], params[1], .enum_from_int),
83158315 .float_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .float_cast),
83168316 .int_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .int_cast),
83178317 .ptr_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .ptr_cast),
......@@ -8335,7 +8335,7 @@ fn builtinCall(
83358335 .tag = .extended,
83368336 .data = .{ .extended = .{
83378337 .opcode = .reify,
8338 .small = @enumToInt(gz.anon_name_strategy),
8338 .small = @intFromEnum(gz.anon_name_strategy),
83398339 .operand = payload_index,
83408340 } },
83418341 });
......@@ -8352,17 +8352,17 @@ fn builtinCall(
83528352 _ = try gz.addNode(.trap, node);
83538353 return rvalue(gz, ri, .unreachable_value, node);
83548354 },
8355 .error_to_int => {
8355 .int_from_error => {
83568356 const operand = try expr(gz, scope, .{ .rl = .none }, params[0]);
8357 const result = try gz.addExtendedPayload(.error_to_int, Zir.Inst.UnNode{
8357 const result = try gz.addExtendedPayload(.int_from_error, Zir.Inst.UnNode{
83588358 .node = gz.nodeIndexToRelative(node),
83598359 .operand = operand,
83608360 });
83618361 return rvalue(gz, ri, result, node);
83628362 },
8363 .int_to_error => {
8363 .error_from_int => {
83648364 const operand = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, params[0]);
8365 const result = try gz.addExtendedPayload(.int_to_error, Zir.Inst.UnNode{
8365 const result = try gz.addExtendedPayload(.error_from_int, Zir.Inst.UnNode{
83668366 .node = gz.nodeIndexToRelative(node),
83678367 .operand = operand,
83688368 });
......@@ -8769,7 +8769,7 @@ fn simpleUnOp(
87698769 else
87708770 try expr(gz, scope, operand_ri, operand_node);
87718771 switch (tag) {
8772 .tag_name, .error_name, .ptr_to_int => try emitDbgStmt(gz, cursor),
8772 .tag_name, .error_name, .int_from_ptr => try emitDbgStmt(gz, cursor),
87738773 else => {},
87748774 }
87758775 const result = try gz.addUnNode(tag, operand, node);
......@@ -9050,7 +9050,7 @@ fn callExpr(
90509050 .callee = callee_obj,
90519051 .flags = .{
90529052 .pop_error_return_trace = !propagate_error_trace,
9053 .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @enumToInt(modifier)),
9053 .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @intFromEnum(modifier)),
90549054 .args_len = @intCast(Zir.Inst.Call.Flags.PackedArgsLen, call.ast.params.len),
90559055 },
90569056 });
......@@ -9071,7 +9071,7 @@ fn callExpr(
90719071 .field_name_start = callee_field.field_name_start,
90729072 .flags = .{
90739073 .pop_error_return_trace = !propagate_error_trace,
9074 .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @enumToInt(modifier)),
9074 .packed_modifier = @intCast(Zir.Inst.Call.Flags.PackedModifier, @intFromEnum(modifier)),
90759075 .args_len = @intCast(Zir.Inst.Call.Flags.PackedArgsLen, call.ast.params.len),
90769076 },
90779077 });
......@@ -10266,80 +10266,80 @@ fn rvalue(
1026610266 },
1026710267 .ty => |ty_inst| {
1026810268 // Quickly eliminate some common, unnecessary type coercion.
10269 const as_ty = @as(u64, @enumToInt(Zir.Inst.Ref.type_type)) << 32;
10270 const as_comptime_int = @as(u64, @enumToInt(Zir.Inst.Ref.comptime_int_type)) << 32;
10271 const as_bool = @as(u64, @enumToInt(Zir.Inst.Ref.bool_type)) << 32;
10272 const as_usize = @as(u64, @enumToInt(Zir.Inst.Ref.usize_type)) << 32;
10273 const as_void = @as(u64, @enumToInt(Zir.Inst.Ref.void_type)) << 32;
10274 switch ((@as(u64, @enumToInt(ty_inst)) << 32) | @as(u64, @enumToInt(result))) {
10275 as_ty | @enumToInt(Zir.Inst.Ref.u1_type),
10276 as_ty | @enumToInt(Zir.Inst.Ref.u8_type),
10277 as_ty | @enumToInt(Zir.Inst.Ref.i8_type),
10278 as_ty | @enumToInt(Zir.Inst.Ref.u16_type),
10279 as_ty | @enumToInt(Zir.Inst.Ref.u29_type),
10280 as_ty | @enumToInt(Zir.Inst.Ref.i16_type),
10281 as_ty | @enumToInt(Zir.Inst.Ref.u32_type),
10282 as_ty | @enumToInt(Zir.Inst.Ref.i32_type),
10283 as_ty | @enumToInt(Zir.Inst.Ref.u64_type),
10284 as_ty | @enumToInt(Zir.Inst.Ref.i64_type),
10285 as_ty | @enumToInt(Zir.Inst.Ref.u128_type),
10286 as_ty | @enumToInt(Zir.Inst.Ref.i128_type),
10287 as_ty | @enumToInt(Zir.Inst.Ref.usize_type),
10288 as_ty | @enumToInt(Zir.Inst.Ref.isize_type),
10289 as_ty | @enumToInt(Zir.Inst.Ref.c_char_type),
10290 as_ty | @enumToInt(Zir.Inst.Ref.c_short_type),
10291 as_ty | @enumToInt(Zir.Inst.Ref.c_ushort_type),
10292 as_ty | @enumToInt(Zir.Inst.Ref.c_int_type),
10293 as_ty | @enumToInt(Zir.Inst.Ref.c_uint_type),
10294 as_ty | @enumToInt(Zir.Inst.Ref.c_long_type),
10295 as_ty | @enumToInt(Zir.Inst.Ref.c_ulong_type),
10296 as_ty | @enumToInt(Zir.Inst.Ref.c_longlong_type),
10297 as_ty | @enumToInt(Zir.Inst.Ref.c_ulonglong_type),
10298 as_ty | @enumToInt(Zir.Inst.Ref.c_longdouble_type),
10299 as_ty | @enumToInt(Zir.Inst.Ref.f16_type),
10300 as_ty | @enumToInt(Zir.Inst.Ref.f32_type),
10301 as_ty | @enumToInt(Zir.Inst.Ref.f64_type),
10302 as_ty | @enumToInt(Zir.Inst.Ref.f80_type),
10303 as_ty | @enumToInt(Zir.Inst.Ref.f128_type),
10304 as_ty | @enumToInt(Zir.Inst.Ref.anyopaque_type),
10305 as_ty | @enumToInt(Zir.Inst.Ref.bool_type),
10306 as_ty | @enumToInt(Zir.Inst.Ref.void_type),
10307 as_ty | @enumToInt(Zir.Inst.Ref.type_type),
10308 as_ty | @enumToInt(Zir.Inst.Ref.anyerror_type),
10309 as_ty | @enumToInt(Zir.Inst.Ref.comptime_int_type),
10310 as_ty | @enumToInt(Zir.Inst.Ref.comptime_float_type),
10311 as_ty | @enumToInt(Zir.Inst.Ref.noreturn_type),
10312 as_ty | @enumToInt(Zir.Inst.Ref.anyframe_type),
10313 as_ty | @enumToInt(Zir.Inst.Ref.null_type),
10314 as_ty | @enumToInt(Zir.Inst.Ref.undefined_type),
10315 as_ty | @enumToInt(Zir.Inst.Ref.enum_literal_type),
10316 as_ty | @enumToInt(Zir.Inst.Ref.atomic_order_type),
10317 as_ty | @enumToInt(Zir.Inst.Ref.atomic_rmw_op_type),
10318 as_ty | @enumToInt(Zir.Inst.Ref.calling_convention_type),
10319 as_ty | @enumToInt(Zir.Inst.Ref.address_space_type),
10320 as_ty | @enumToInt(Zir.Inst.Ref.float_mode_type),
10321 as_ty | @enumToInt(Zir.Inst.Ref.reduce_op_type),
10322 as_ty | @enumToInt(Zir.Inst.Ref.call_modifier_type),
10323 as_ty | @enumToInt(Zir.Inst.Ref.prefetch_options_type),
10324 as_ty | @enumToInt(Zir.Inst.Ref.export_options_type),
10325 as_ty | @enumToInt(Zir.Inst.Ref.extern_options_type),
10326 as_ty | @enumToInt(Zir.Inst.Ref.type_info_type),
10327 as_ty | @enumToInt(Zir.Inst.Ref.manyptr_u8_type),
10328 as_ty | @enumToInt(Zir.Inst.Ref.manyptr_const_u8_type),
10329 as_ty | @enumToInt(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type),
10330 as_ty | @enumToInt(Zir.Inst.Ref.single_const_pointer_to_comptime_int_type),
10331 as_ty | @enumToInt(Zir.Inst.Ref.slice_const_u8_type),
10332 as_ty | @enumToInt(Zir.Inst.Ref.slice_const_u8_sentinel_0_type),
10333 as_ty | @enumToInt(Zir.Inst.Ref.anyerror_void_error_union_type),
10334 as_ty | @enumToInt(Zir.Inst.Ref.generic_poison_type),
10335 as_ty | @enumToInt(Zir.Inst.Ref.empty_struct_type),
10336 as_comptime_int | @enumToInt(Zir.Inst.Ref.zero),
10337 as_comptime_int | @enumToInt(Zir.Inst.Ref.one),
10338 as_bool | @enumToInt(Zir.Inst.Ref.bool_true),
10339 as_bool | @enumToInt(Zir.Inst.Ref.bool_false),
10340 as_usize | @enumToInt(Zir.Inst.Ref.zero_usize),
10341 as_usize | @enumToInt(Zir.Inst.Ref.one_usize),
10342 as_void | @enumToInt(Zir.Inst.Ref.void_value),
10269 const as_ty = @as(u64, @intFromEnum(Zir.Inst.Ref.type_type)) << 32;
10270 const as_comptime_int = @as(u64, @intFromEnum(Zir.Inst.Ref.comptime_int_type)) << 32;
10271 const as_bool = @as(u64, @intFromEnum(Zir.Inst.Ref.bool_type)) << 32;
10272 const as_usize = @as(u64, @intFromEnum(Zir.Inst.Ref.usize_type)) << 32;
10273 const as_void = @as(u64, @intFromEnum(Zir.Inst.Ref.void_type)) << 32;
10274 switch ((@as(u64, @intFromEnum(ty_inst)) << 32) | @as(u64, @intFromEnum(result))) {
10275 as_ty | @intFromEnum(Zir.Inst.Ref.u1_type),
10276 as_ty | @intFromEnum(Zir.Inst.Ref.u8_type),
10277 as_ty | @intFromEnum(Zir.Inst.Ref.i8_type),
10278 as_ty | @intFromEnum(Zir.Inst.Ref.u16_type),
10279 as_ty | @intFromEnum(Zir.Inst.Ref.u29_type),
10280 as_ty | @intFromEnum(Zir.Inst.Ref.i16_type),
10281 as_ty | @intFromEnum(Zir.Inst.Ref.u32_type),
10282 as_ty | @intFromEnum(Zir.Inst.Ref.i32_type),
10283 as_ty | @intFromEnum(Zir.Inst.Ref.u64_type),
10284 as_ty | @intFromEnum(Zir.Inst.Ref.i64_type),
10285 as_ty | @intFromEnum(Zir.Inst.Ref.u128_type),
10286 as_ty | @intFromEnum(Zir.Inst.Ref.i128_type),
10287 as_ty | @intFromEnum(Zir.Inst.Ref.usize_type),
10288 as_ty | @intFromEnum(Zir.Inst.Ref.isize_type),
10289 as_ty | @intFromEnum(Zir.Inst.Ref.c_char_type),
10290 as_ty | @intFromEnum(Zir.Inst.Ref.c_short_type),
10291 as_ty | @intFromEnum(Zir.Inst.Ref.c_ushort_type),
10292 as_ty | @intFromEnum(Zir.Inst.Ref.c_int_type),
10293 as_ty | @intFromEnum(Zir.Inst.Ref.c_uint_type),
10294 as_ty | @intFromEnum(Zir.Inst.Ref.c_long_type),
10295 as_ty | @intFromEnum(Zir.Inst.Ref.c_ulong_type),
10296 as_ty | @intFromEnum(Zir.Inst.Ref.c_longlong_type),
10297 as_ty | @intFromEnum(Zir.Inst.Ref.c_ulonglong_type),
10298 as_ty | @intFromEnum(Zir.Inst.Ref.c_longdouble_type),
10299 as_ty | @intFromEnum(Zir.Inst.Ref.f16_type),
10300 as_ty | @intFromEnum(Zir.Inst.Ref.f32_type),
10301 as_ty | @intFromEnum(Zir.Inst.Ref.f64_type),
10302 as_ty | @intFromEnum(Zir.Inst.Ref.f80_type),
10303 as_ty | @intFromEnum(Zir.Inst.Ref.f128_type),
10304 as_ty | @intFromEnum(Zir.Inst.Ref.anyopaque_type),
10305 as_ty | @intFromEnum(Zir.Inst.Ref.bool_type),
10306 as_ty | @intFromEnum(Zir.Inst.Ref.void_type),
10307 as_ty | @intFromEnum(Zir.Inst.Ref.type_type),
10308 as_ty | @intFromEnum(Zir.Inst.Ref.anyerror_type),
10309 as_ty | @intFromEnum(Zir.Inst.Ref.comptime_int_type),
10310 as_ty | @intFromEnum(Zir.Inst.Ref.comptime_float_type),
10311 as_ty | @intFromEnum(Zir.Inst.Ref.noreturn_type),
10312 as_ty | @intFromEnum(Zir.Inst.Ref.anyframe_type),
10313 as_ty | @intFromEnum(Zir.Inst.Ref.null_type),
10314 as_ty | @intFromEnum(Zir.Inst.Ref.undefined_type),
10315 as_ty | @intFromEnum(Zir.Inst.Ref.enum_literal_type),
10316 as_ty | @intFromEnum(Zir.Inst.Ref.atomic_order_type),
10317 as_ty | @intFromEnum(Zir.Inst.Ref.atomic_rmw_op_type),
10318 as_ty | @intFromEnum(Zir.Inst.Ref.calling_convention_type),
10319 as_ty | @intFromEnum(Zir.Inst.Ref.address_space_type),
10320 as_ty | @intFromEnum(Zir.Inst.Ref.float_mode_type),
10321 as_ty | @intFromEnum(Zir.Inst.Ref.reduce_op_type),
10322 as_ty | @intFromEnum(Zir.Inst.Ref.call_modifier_type),
10323 as_ty | @intFromEnum(Zir.Inst.Ref.prefetch_options_type),
10324 as_ty | @intFromEnum(Zir.Inst.Ref.export_options_type),
10325 as_ty | @intFromEnum(Zir.Inst.Ref.extern_options_type),
10326 as_ty | @intFromEnum(Zir.Inst.Ref.type_info_type),
10327 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_u8_type),
10328 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_type),
10329 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type),
10330 as_ty | @intFromEnum(Zir.Inst.Ref.single_const_pointer_to_comptime_int_type),
10331 as_ty | @intFromEnum(Zir.Inst.Ref.slice_const_u8_type),
10332 as_ty | @intFromEnum(Zir.Inst.Ref.slice_const_u8_sentinel_0_type),
10333 as_ty | @intFromEnum(Zir.Inst.Ref.anyerror_void_error_union_type),
10334 as_ty | @intFromEnum(Zir.Inst.Ref.generic_poison_type),
10335 as_ty | @intFromEnum(Zir.Inst.Ref.empty_struct_type),
10336 as_comptime_int | @intFromEnum(Zir.Inst.Ref.zero),
10337 as_comptime_int | @intFromEnum(Zir.Inst.Ref.one),
10338 as_bool | @intFromEnum(Zir.Inst.Ref.bool_true),
10339 as_bool | @intFromEnum(Zir.Inst.Ref.bool_false),
10340 as_usize | @intFromEnum(Zir.Inst.Ref.zero_usize),
10341 as_usize | @intFromEnum(Zir.Inst.Ref.one_usize),
10342 as_void | @intFromEnum(Zir.Inst.Ref.void_value),
1034310343 => return result, // type of result is already correct
1034410344
1034510345 // Need an explicit type coercion instruction.
......@@ -11429,8 +11429,8 @@ const GenZir = struct {
1142911429 fancyFnExprExtraLen(astgen, cc_body, args.cc_ref) +
1143011430 fancyFnExprExtraLen(astgen, ret_body, ret_ref) +
1143111431 body_len + src_locs.len +
11432 @boolToInt(args.lib_name != 0) +
11433 @boolToInt(args.noalias_bits != 0),
11432 @intFromBool(args.lib_name != 0) +
11433 @intFromBool(args.noalias_bits != 0),
1143411434 );
1143511435 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.FuncFancy{
1143611436 .param_block = args.param_block,
......@@ -11468,7 +11468,7 @@ const GenZir = struct {
1146811468 const inst_data = zir_datas[align_body[align_body.len - 1]].@"break";
1146911469 astgen.extra.items[inst_data.payload_index] = new_index;
1147011470 } else if (args.align_ref != .none) {
11471 astgen.extra.appendAssumeCapacity(@enumToInt(args.align_ref));
11471 astgen.extra.appendAssumeCapacity(@intFromEnum(args.align_ref));
1147211472 }
1147311473 if (addrspace_body.len != 0) {
1147411474 astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, addrspace_body));
......@@ -11476,7 +11476,7 @@ const GenZir = struct {
1147611476 const inst_data = zir_datas[addrspace_body[addrspace_body.len - 1]].@"break";
1147711477 astgen.extra.items[inst_data.payload_index] = new_index;
1147811478 } else if (args.addrspace_ref != .none) {
11479 astgen.extra.appendAssumeCapacity(@enumToInt(args.addrspace_ref));
11479 astgen.extra.appendAssumeCapacity(@intFromEnum(args.addrspace_ref));
1148011480 }
1148111481 if (section_body.len != 0) {
1148211482 astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, section_body));
......@@ -11484,7 +11484,7 @@ const GenZir = struct {
1148411484 const inst_data = zir_datas[section_body[section_body.len - 1]].@"break";
1148511485 astgen.extra.items[inst_data.payload_index] = new_index;
1148611486 } else if (args.section_ref != .none) {
11487 astgen.extra.appendAssumeCapacity(@enumToInt(args.section_ref));
11487 astgen.extra.appendAssumeCapacity(@intFromEnum(args.section_ref));
1148811488 }
1148911489 if (cc_body.len != 0) {
1149011490 astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, cc_body));
......@@ -11492,7 +11492,7 @@ const GenZir = struct {
1149211492 const inst_data = zir_datas[cc_body[cc_body.len - 1]].@"break";
1149311493 astgen.extra.items[inst_data.payload_index] = new_index;
1149411494 } else if (args.cc_ref != .none) {
11495 astgen.extra.appendAssumeCapacity(@enumToInt(args.cc_ref));
11495 astgen.extra.appendAssumeCapacity(@intFromEnum(args.cc_ref));
1149611496 }
1149711497 if (ret_body.len != 0) {
1149811498 astgen.extra.appendAssumeCapacity(countBodyLenAfterFixups(astgen, ret_body));
......@@ -11500,7 +11500,7 @@ const GenZir = struct {
1150011500 const inst_data = zir_datas[ret_body[ret_body.len - 1]].@"break";
1150111501 astgen.extra.items[inst_data.payload_index] = new_index;
1150211502 } else if (ret_ref != .none) {
11503 astgen.extra.appendAssumeCapacity(@enumToInt(ret_ref));
11503 astgen.extra.appendAssumeCapacity(@intFromEnum(ret_ref));
1150411504 }
1150511505
1150611506 if (args.noalias_bits != 0) {
......@@ -11542,7 +11542,7 @@ const GenZir = struct {
1154211542 const ret_body_len = if (ret_body.len != 0)
1154311543 countBodyLenAfterFixups(astgen, ret_body)
1154411544 else
11545 @boolToInt(ret_ref != .none);
11545 @intFromBool(ret_ref != .none);
1154611546
1154711547 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.Func{
1154811548 .param_block = args.param_block,
......@@ -11556,7 +11556,7 @@ const GenZir = struct {
1155611556 const inst_data = zir_datas[ret_body[ret_body.len - 1]].@"break";
1155711557 astgen.extra.items[inst_data.payload_index] = new_index;
1155811558 } else if (ret_ref != .none) {
11559 astgen.extra.appendAssumeCapacity(@enumToInt(ret_ref));
11559 astgen.extra.appendAssumeCapacity(@intFromEnum(ret_ref));
1156011560 }
1156111561 astgen.appendBodyWithFixups(body);
1156211562 astgen.extra.appendSliceAssumeCapacity(src_locs);
......@@ -11587,7 +11587,7 @@ const GenZir = struct {
1158711587 fn fancyFnExprExtraLen(astgen: *AstGen, body: []Zir.Inst.Index, ref: Zir.Inst.Ref) u32 {
1158811588 // In the case of non-empty body, there is one for the body length,
1158911589 // and then one for each instruction.
11590 return countBodyLenAfterFixups(astgen, body) + @boolToInt(ref != .none);
11590 return countBodyLenAfterFixups(astgen, body) + @intFromBool(ref != .none);
1159111591 }
1159211592
1159311593 fn addVar(gz: *GenZir, args: struct {
......@@ -11607,9 +11607,9 @@ const GenZir = struct {
1160711607 try astgen.extra.ensureUnusedCapacity(
1160811608 gpa,
1160911609 @typeInfo(Zir.Inst.ExtendedVar).Struct.fields.len +
11610 @boolToInt(args.lib_name != 0) +
11611 @boolToInt(args.align_inst != .none) +
11612 @boolToInt(args.init != .none),
11610 @intFromBool(args.lib_name != 0) +
11611 @intFromBool(args.align_inst != .none) +
11612 @intFromBool(args.init != .none),
1161311613 );
1161411614 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedVar{
1161511615 .var_type = args.var_type,
......@@ -11618,10 +11618,10 @@ const GenZir = struct {
1161811618 astgen.extra.appendAssumeCapacity(args.lib_name);
1161911619 }
1162011620 if (args.align_inst != .none) {
11621 astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst));
11621 astgen.extra.appendAssumeCapacity(@intFromEnum(args.align_inst));
1162211622 }
1162311623 if (args.init != .none) {
11624 astgen.extra.appendAssumeCapacity(@enumToInt(args.init));
11624 astgen.extra.appendAssumeCapacity(@intFromEnum(args.init));
1162511625 }
1162611626
1162711627 const new_index = @intCast(Zir.Inst.Index, astgen.instructions.len);
......@@ -12208,23 +12208,23 @@ const GenZir = struct {
1220812208 try astgen.extra.ensureUnusedCapacity(
1220912209 gpa,
1221012210 @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len +
12211 @as(usize, @boolToInt(args.type_inst != .none)) +
12212 @as(usize, @boolToInt(args.align_inst != .none)),
12211 @as(usize, @intFromBool(args.type_inst != .none)) +
12212 @as(usize, @intFromBool(args.align_inst != .none)),
1221312213 );
1221412214 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.AllocExtended{
1221512215 .src_node = gz.nodeIndexToRelative(args.node),
1221612216 });
1221712217 if (args.type_inst != .none) {
12218 astgen.extra.appendAssumeCapacity(@enumToInt(args.type_inst));
12218 astgen.extra.appendAssumeCapacity(@intFromEnum(args.type_inst));
1221912219 }
1222012220 if (args.align_inst != .none) {
12221 astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst));
12221 astgen.extra.appendAssumeCapacity(@intFromEnum(args.align_inst));
1222212222 }
1222312223
12224 const has_type: u4 = @boolToInt(args.type_inst != .none);
12225 const has_align: u4 = @boolToInt(args.align_inst != .none);
12226 const is_const: u4 = @boolToInt(args.is_const);
12227 const is_comptime: u4 = @boolToInt(args.is_comptime);
12224 const has_type: u4 = @intFromBool(args.type_inst != .none);
12225 const has_align: u4 = @intFromBool(args.align_inst != .none);
12226 const is_const: u4 = @intFromBool(args.is_const);
12227 const is_comptime: u4 = @intFromBool(args.is_comptime);
1222812228 const small: u16 = has_type | (has_align << 1) | (is_const << 2) | (is_comptime << 3);
1222912229
1223012230 const new_index = @intCast(Zir.Inst.Index, astgen.instructions.len);
......@@ -12284,7 +12284,7 @@ const GenZir = struct {
1228412284 const small: u16 = @intCast(u16, args.outputs.len) |
1228512285 @intCast(u16, args.inputs.len << 5) |
1228612286 @intCast(u16, args.clobbers.len << 10) |
12287 (@as(u16, @boolToInt(args.is_volatile)) << 15);
12287 (@as(u16, @intFromBool(args.is_volatile)) << 15);
1228812288
1228912289 const new_index = @intCast(Zir.Inst.Index, astgen.instructions.len);
1229012290 astgen.instructions.appendAssumeCapacity(.{
......@@ -12362,7 +12362,7 @@ const GenZir = struct {
1236212362 if (args.backing_int_ref != .none) {
1236312363 astgen.extra.appendAssumeCapacity(args.backing_int_body_len);
1236412364 if (args.backing_int_body_len == 0) {
12365 astgen.extra.appendAssumeCapacity(@enumToInt(args.backing_int_ref));
12365 astgen.extra.appendAssumeCapacity(@intFromEnum(args.backing_int_ref));
1236612366 }
1236712367 }
1236812368 astgen.instructions.set(inst, .{
......@@ -12405,7 +12405,7 @@ const GenZir = struct {
1240512405 astgen.extra.appendAssumeCapacity(@bitCast(u32, node_offset));
1240612406 }
1240712407 if (args.tag_type != .none) {
12408 astgen.extra.appendAssumeCapacity(@enumToInt(args.tag_type));
12408 astgen.extra.appendAssumeCapacity(@intFromEnum(args.tag_type));
1240912409 }
1241012410 if (args.body_len != 0) {
1241112411 astgen.extra.appendAssumeCapacity(args.body_len);
......@@ -12454,7 +12454,7 @@ const GenZir = struct {
1245412454 astgen.extra.appendAssumeCapacity(@bitCast(u32, node_offset));
1245512455 }
1245612456 if (args.tag_type != .none) {
12457 astgen.extra.appendAssumeCapacity(@enumToInt(args.tag_type));
12457 astgen.extra.appendAssumeCapacity(@intFromEnum(args.tag_type));
1245812458 }
1245912459 if (args.body_len != 0) {
1246012460 astgen.extra.appendAssumeCapacity(args.body_len);
......@@ -12948,10 +12948,10 @@ fn lowerAstErrors(astgen: *AstGen) !void {
1294812948 var notes: std.ArrayListUnmanaged(u32) = .{};
1294912949 defer notes.deinit(gpa);
1295012950
12951 if (token_tags[parse_err.token + @boolToInt(parse_err.token_is_prev)] == .invalid) {
12952 const tok = parse_err.token + @boolToInt(parse_err.token_is_prev);
12953 const bad_off = @intCast(u32, tree.tokenSlice(parse_err.token + @boolToInt(parse_err.token_is_prev)).len);
12954 const byte_abs = token_starts[parse_err.token + @boolToInt(parse_err.token_is_prev)] + bad_off;
12951 if (token_tags[parse_err.token + @intFromBool(parse_err.token_is_prev)] == .invalid) {
12952 const tok = parse_err.token + @intFromBool(parse_err.token_is_prev);
12953 const bad_off = @intCast(u32, tree.tokenSlice(parse_err.token + @intFromBool(parse_err.token_is_prev)).len);
12954 const byte_abs = token_starts[parse_err.token + @intFromBool(parse_err.token_is_prev)] + bad_off;
1295512955 try notes.append(gpa, try astgen.errNoteTokOff(tok, bad_off, "invalid byte: '{'}'", .{
1295612956 std.zig.fmtEscapes(tree.source[byte_abs..][0..1]),
1295712957 }));
src/Autodoc.zig+89-89
......@@ -107,10 +107,10 @@ pub fn generateZirData(self: *Autodoc) !void {
107107 const file = self.comp_module.import_table.get(abs_root_src_path).?; // file is expected to be present in the import table
108108 // Append all the types in Zir.Inst.Ref.
109109 {
110 comptime std.debug.assert(@enumToInt(InternPool.Index.first_type) == 0);
110 comptime std.debug.assert(@intFromEnum(InternPool.Index.first_type) == 0);
111111 var i: u32 = 0;
112 while (i <= @enumToInt(InternPool.Index.last_type)) : (i += 1) {
113 const ip_index = @intToEnum(InternPool.Index, i);
112 while (i <= @intFromEnum(InternPool.Index.last_type)) : (i += 1) {
113 const ip_index = @enumFromInt(InternPool.Index, i);
114114 var tmpbuf = std.ArrayList(u8).init(self.arena);
115115 if (ip_index == .generic_poison_type) {
116116 // Not a real type, doesn't have a normal name
......@@ -696,14 +696,14 @@ const DocData = struct {
696696 jsw.whitespace = opts.whitespace;
697697 try jsw.beginArray();
698698 try jsw.arrayElem();
699 try jsw.emitNumber(@enumToInt(active_tag));
699 try jsw.emitNumber(@intFromEnum(active_tag));
700700 inline for (comptime std.meta.fields(Type)) |case| {
701701 if (@field(Type, case.name) == active_tag) {
702702 const current_value = @field(self, case.name);
703703 inline for (comptime std.meta.fields(case.type)) |f| {
704704 try jsw.arrayElem();
705705 if (f.type == std.builtin.Type.Pointer.Size) {
706 try jsw.emitNumber(@enumToInt(@field(current_value, f.name)));
706 try jsw.emitNumber(@intFromEnum(@field(current_value, f.name)));
707707 } else {
708708 try std.json.stringify(@field(current_value, f.name), opts, w);
709709 jsw.state_index -= 1;
......@@ -756,7 +756,7 @@ const DocData = struct {
756756 as: As,
757757 sizeOf: usize, // index in `exprs`
758758 bitSizeOf: usize, // index in `exprs`
759 enumToInt: usize, // index in `exprs`
759 intFromEnum: usize, // index in `exprs`
760760 compileError: usize, //index in `exprs`
761761 errorSets: usize,
762762 string: []const u8, // direct value
......@@ -956,7 +956,7 @@ fn walkInstruction(
956956
957957 if (result.found_existing) {
958958 return DocData.WalkResult{
959 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
959 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
960960 .expr = .{ .type = result.value_ptr.main },
961961 };
962962 }
......@@ -1005,7 +1005,7 @@ fn walkInstruction(
10051005 const result = try self.files.getOrPut(self.arena, new_file.file);
10061006 if (result.found_existing) {
10071007 return DocData.WalkResult{
1008 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1008 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
10091009 .expr = .{ .type = result.value_ptr.* },
10101010 };
10111011 }
......@@ -1033,8 +1033,8 @@ fn walkInstruction(
10331033 },
10341034 .ret_type => {
10351035 return DocData.WalkResult{
1036 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1037 .expr = .{ .type = @enumToInt(Ref.type_type) },
1036 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
1037 .expr = .{ .type = @intFromEnum(Ref.type_type) },
10381038 };
10391039 },
10401040 .ret_node => {
......@@ -1093,7 +1093,7 @@ fn walkInstruction(
10931093 try self.types.append(self.arena, .{
10941094 .Array = .{
10951095 .len = .{ .int = .{ .value = str.len } },
1096 .child = .{ .type = @enumToInt(Ref.u8_type) },
1096 .child = .{ .type = @intFromEnum(Ref.u8_type) },
10971097 .sentinel = .{ .int = .{
10981098 .value = 0,
10991099 .negated = false,
......@@ -1155,7 +1155,7 @@ fn walkInstruction(
11551155 .int => {
11561156 const int = data[inst_index].int;
11571157 return DocData.WalkResult{
1158 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
1158 .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) },
11591159 .expr = .{ .int = .{ .value = int } },
11601160 };
11611161 },
......@@ -1176,7 +1176,7 @@ fn walkInstruction(
11761176 const as_string = try big_int.toStringAlloc(self.arena, 10, .lower);
11771177
11781178 return DocData.WalkResult{
1179 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
1179 .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) },
11801180 .expr = .{ .int_big = .{ .value = as_string } },
11811181 };
11821182 },
......@@ -1422,7 +1422,7 @@ fn walkInstruction(
14221422 } };
14231423
14241424 return DocData.WalkResult{
1425 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1425 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
14261426 .expr = .{ .binOpIndex = binop_index },
14271427 };
14281428 },
......@@ -1466,14 +1466,14 @@ fn walkInstruction(
14661466 } };
14671467
14681468 return DocData.WalkResult{
1469 .typeRef = .{ .type = @enumToInt(Ref.bool_type) },
1469 .typeRef = .{ .type = @intFromEnum(Ref.bool_type) },
14701470 .expr = .{ .binOpIndex = binop_index },
14711471 };
14721472 },
14731473
14741474 // builtin functions
14751475 .align_of,
1476 .bool_to_int,
1476 .int_from_bool,
14771477 .embed_file,
14781478 .error_name,
14791479 .panic,
......@@ -1496,7 +1496,7 @@ fn walkInstruction(
14961496 .type_name,
14971497 .frame_type,
14981498 .frame_size,
1499 .ptr_to_int,
1499 .int_from_ptr,
15001500 .bit_not,
15011501 // @check
15021502 .clz,
......@@ -1516,15 +1516,15 @@ fn walkInstruction(
15161516 self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(tags[inst_index]), .param = param_index } };
15171517
15181518 return DocData.WalkResult{
1519 .typeRef = param.typeRef orelse .{ .type = @enumToInt(Ref.type_type) },
1519 .typeRef = param.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) },
15201520 .expr = .{ .builtinIndex = bin_index },
15211521 };
15221522 },
15231523
1524 .float_to_int,
1525 .int_to_float,
1526 .int_to_ptr,
1527 .int_to_enum,
1524 .int_from_float,
1525 .float_from_int,
1526 .ptr_from_int,
1527 .enum_from_int,
15281528 .float_cast,
15291529 .int_cast,
15301530 .ptr_cast,
......@@ -1578,7 +1578,7 @@ fn walkInstruction(
15781578 self.exprs.items[binop_index] = .{ .builtinBin = .{ .name = @tagName(tags[inst_index]), .lhs = lhs_index, .rhs = rhs_index } };
15791579
15801580 return DocData.WalkResult{
1581 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1581 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
15821582 .expr = .{ .builtinBinIndex = binop_index },
15831583 };
15841584 },
......@@ -1608,7 +1608,7 @@ fn walkInstruction(
16081608 } });
16091609
16101610 return DocData.WalkResult{
1611 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1611 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
16121612 .expr = .{ .errorUnion = type_slot_index },
16131613 };
16141614 },
......@@ -1637,7 +1637,7 @@ fn walkInstruction(
16371637 } });
16381638
16391639 return DocData.WalkResult{
1640 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1640 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
16411641 .expr = .{ .errorSets = type_slot_index },
16421642 };
16431643 },
......@@ -1670,7 +1670,7 @@ fn walkInstruction(
16701670 // present in json
16711671 var sentinel: ?DocData.Expr = null;
16721672 if (ptr.flags.has_sentinel) {
1673 const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
1673 const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
16741674 const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false);
16751675 sentinel = ref_result.expr;
16761676 extra_index += 1;
......@@ -1678,21 +1678,21 @@ fn walkInstruction(
16781678
16791679 var @"align": ?DocData.Expr = null;
16801680 if (ptr.flags.has_align) {
1681 const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
1681 const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
16821682 const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false);
16831683 @"align" = ref_result.expr;
16841684 extra_index += 1;
16851685 }
16861686 var address_space: ?DocData.Expr = null;
16871687 if (ptr.flags.has_addrspace) {
1688 const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
1688 const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
16891689 const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false);
16901690 address_space = ref_result.expr;
16911691 extra_index += 1;
16921692 }
16931693 var bit_start: ?DocData.Expr = null;
16941694 if (ptr.flags.has_bit_range) {
1695 const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
1695 const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
16961696 const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false);
16971697 address_space = ref_result.expr;
16981698 extra_index += 1;
......@@ -1700,7 +1700,7 @@ fn walkInstruction(
17001700
17011701 var host_size: ?DocData.Expr = null;
17021702 if (ptr.flags.has_bit_range) {
1703 const ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
1703 const ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
17041704 const ref_result = try self.walkRef(file, parent_scope, parent_src, ref, false);
17051705 host_size = ref_result.expr;
17061706 }
......@@ -1724,7 +1724,7 @@ fn walkInstruction(
17241724 },
17251725 });
17261726 return DocData.WalkResult{
1727 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1727 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
17281728 .expr = .{ .type = type_slot_index },
17291729 };
17301730 },
......@@ -1744,7 +1744,7 @@ fn walkInstruction(
17441744 });
17451745
17461746 return DocData.WalkResult{
1747 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1747 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
17481748 .expr = .{ .type = type_slot_index },
17491749 };
17501750 },
......@@ -1764,7 +1764,7 @@ fn walkInstruction(
17641764 },
17651765 });
17661766 return DocData.WalkResult{
1767 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1767 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
17681768 .expr = .{ .type = type_slot_index },
17691769 };
17701770 },
......@@ -1863,7 +1863,7 @@ fn walkInstruction(
18631863 .float => {
18641864 const float = data[inst_index].float;
18651865 return DocData.WalkResult{
1866 .typeRef = .{ .type = @enumToInt(Ref.comptime_float_type) },
1866 .typeRef = .{ .type = @intFromEnum(Ref.comptime_float_type) },
18671867 .expr = .{ .float = float },
18681868 };
18691869 },
......@@ -1872,7 +1872,7 @@ fn walkInstruction(
18721872 const pl_node = data[inst_index].pl_node;
18731873 const extra = file.zir.extraData(Zir.Inst.Float128, pl_node.payload_index);
18741874 return DocData.WalkResult{
1875 .typeRef = .{ .type = @enumToInt(Ref.comptime_float_type) },
1875 .typeRef = .{ .type = @intFromEnum(Ref.comptime_float_type) },
18761876 .expr = .{ .float128 = extra.data.get() },
18771877 };
18781878 },
......@@ -1913,7 +1913,7 @@ fn walkInstruction(
19131913 const operand_index = self.exprs.items.len;
19141914 try self.exprs.append(self.arena, operand.expr);
19151915 return DocData.WalkResult{
1916 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
1916 .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) },
19171917 .expr = .{ .sizeOf = operand_index },
19181918 };
19191919 },
......@@ -1936,7 +1936,7 @@ fn walkInstruction(
19361936 .expr = .{ .bitSizeOf = operand_index },
19371937 };
19381938 },
1939 .enum_to_int => {
1939 .int_from_enum => {
19401940 // not working correctly with `align()`
19411941 const un_node = data[inst_index].un_node;
19421942 const operand = try self.walkRef(
......@@ -1950,8 +1950,8 @@ fn walkInstruction(
19501950 try self.exprs.append(self.arena, operand.expr);
19511951
19521952 return DocData.WalkResult{
1953 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
1954 .expr = .{ .enumToInt = operand_index },
1953 .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) },
1954 .expr = .{ .intFromEnum = operand_index },
19551955 };
19561956 },
19571957 .switch_block => {
......@@ -1992,7 +1992,7 @@ fn walkInstruction(
19921992 // } });
19931993
19941994 return DocData.WalkResult{
1995 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
1995 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
19961996 .expr = .{ .switchIndex = switch_index },
19971997 };
19981998 },
......@@ -2109,7 +2109,7 @@ fn walkInstruction(
21092109 });
21102110
21112111 return DocData.WalkResult{
2112 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2112 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
21132113 .expr = .{ .type = operand_idx },
21142114 };
21152115 },
......@@ -2210,13 +2210,13 @@ fn walkInstruction(
22102210 });
22112211
22122212 return DocData.WalkResult{
2213 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2213 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
22142214 .expr = .{ .type = self.types.items.len - 1 },
22152215 };
22162216 },
22172217 .block => {
22182218 const res = DocData.WalkResult{
2219 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2219 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
22202220 .expr = .{ .comptimeExpr = self.comptime_exprs.items.len },
22212221 };
22222222 const pl_node = data[inst_index].pl_node;
......@@ -2233,7 +2233,7 @@ fn walkInstruction(
22332233 parent_src,
22342234 getBlockInlineBreak(file.zir, inst_index) orelse {
22352235 const res = DocData.WalkResult{
2236 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2236 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
22372237 .expr = .{ .comptimeExpr = self.comptime_exprs.items.len },
22382238 };
22392239 const pl_node = data[inst_index].pl_node;
......@@ -2376,7 +2376,7 @@ fn walkInstruction(
23762376 });
23772377
23782378 return DocData.WalkResult{
2379 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2379 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
23802380 .expr = .{ .type = type_slot_index },
23812381 };
23822382 },
......@@ -2600,7 +2600,7 @@ fn walkInstruction(
26002600 // anyway, but maybe we should put it elsewhere.
26012601 }
26022602 return DocData.WalkResult{
2603 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2603 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
26042604 .expr = .{ .type = type_slot_index },
26052605 };
26062606 },
......@@ -2620,7 +2620,7 @@ fn walkInstruction(
26202620 };
26212621
26222622 if (small.has_init) {
2623 const var_init_ref = @intToEnum(Ref, file.zir.extra[extra_index]);
2623 const var_init_ref = @enumFromInt(Ref, file.zir.extra[extra_index]);
26242624 const var_init = try self.walkRef(file, parent_scope, parent_src, var_init_ref, need_type);
26252625 value.expr = var_init.expr;
26262626 value.typeRef = var_init.typeRef;
......@@ -2656,7 +2656,7 @@ fn walkInstruction(
26562656 const tag_type_ref: ?Ref = if (small.has_tag_type) blk: {
26572657 const tag_type = file.zir.extra[extra_index];
26582658 extra_index += 1;
2659 const tag_ref = @intToEnum(Ref, tag_type);
2659 const tag_ref = @enumFromInt(Ref, tag_type);
26602660 break :blk tag_ref;
26612661 } else null;
26622662
......@@ -2751,7 +2751,7 @@ fn walkInstruction(
27512751 }
27522752
27532753 return DocData.WalkResult{
2754 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2754 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
27552755 .expr = .{ .type = type_slot_index },
27562756 };
27572757 },
......@@ -2781,7 +2781,7 @@ fn walkInstruction(
27812781 const tag_type: ?DocData.Expr = if (small.has_tag_type) blk: {
27822782 const tag_type = file.zir.extra[extra_index];
27832783 extra_index += 1;
2784 const tag_ref = @intToEnum(Ref, tag_type);
2784 const tag_ref = @enumFromInt(Ref, tag_type);
27852785 const wr = try self.walkRef(file, parent_scope, parent_src, tag_ref, false);
27862786 break :blk wr.expr;
27872787 } else null;
......@@ -2839,7 +2839,7 @@ fn walkInstruction(
28392839 const value_expr: ?DocData.Expr = if (has_value) blk: {
28402840 const value_ref = file.zir.extra[extra_index];
28412841 extra_index += 1;
2842 const value = try self.walkRef(file, &scope, src_info, @intToEnum(Ref, value_ref), false);
2842 const value = try self.walkRef(file, &scope, src_info, @enumFromInt(Ref, value_ref), false);
28432843 break :blk value.expr;
28442844 } else null;
28452845 try field_values.append(self.arena, value_expr);
......@@ -2887,7 +2887,7 @@ fn walkInstruction(
28872887 // anyway, but maybe we should put it elsewhere.
28882888 }
28892889 return DocData.WalkResult{
2890 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
2890 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
28912891 .expr = .{ .type = type_slot_index },
28922892 };
28932893 },
......@@ -2928,7 +2928,7 @@ fn walkInstruction(
29282928 const backing_int_body_len = file.zir.extra[extra_index];
29292929 extra_index += 1; // backing_int_body_len
29302930 if (backing_int_body_len == 0) {
2931 const backing_int_ref = @intToEnum(Ref, file.zir.extra[extra_index]);
2931 const backing_int_ref = @enumFromInt(Ref, file.zir.extra[extra_index]);
29322932 const backing_int_res = try self.walkRef(file, &scope, src_info, backing_int_ref, true);
29332933 backing_int = backing_int_res.expr;
29342934 extra_index += 1; // backing_int_ref
......@@ -3006,13 +3006,13 @@ fn walkInstruction(
30063006 // anyway, but maybe we should put it elsewhere.
30073007 }
30083008 return DocData.WalkResult{
3009 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
3009 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
30103010 .expr = .{ .type = type_slot_index },
30113011 };
30123012 },
30133013 .this => {
30143014 return DocData.WalkResult{
3015 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
3015 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
30163016 .expr = .{
30173017 .this = parent_scope.enclosing_type.?,
30183018 // We know enclosing_type is always present
......@@ -3021,8 +3021,8 @@ fn walkInstruction(
30213021 },
30223022 };
30233023 },
3024 .error_to_int,
3025 .int_to_error,
3024 .int_from_error,
3025 .error_from_int,
30263026 .reify,
30273027 .const_cast,
30283028 .volatile_cast,
......@@ -3038,7 +3038,7 @@ fn walkInstruction(
30383038 self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(extended.opcode), .param = param_index } };
30393039
30403040 return DocData.WalkResult{
3041 .typeRef = param.typeRef orelse .{ .type = @enumToInt(Ref.type_type) },
3041 .typeRef = param.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) },
30423042 .expr = .{ .builtinIndex = bin_index },
30433043 };
30443044 },
......@@ -3058,7 +3058,7 @@ fn walkInstruction(
30583058
30593059 return DocData.WalkResult{
30603060 // from docs we know they return u32
3061 .typeRef = .{ .type = @enumToInt(Ref.u32_type) },
3061 .typeRef = .{ .type = @intFromEnum(Ref.u32_type) },
30623062 .expr = .{ .builtinIndex = bin_index },
30633063 };
30643064 },
......@@ -3131,7 +3131,7 @@ fn walkInstruction(
31313131 .failure_order = failure_order_index,
31323132 } });
31333133 return DocData.WalkResult{
3134 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
3134 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
31353135 .expr = .{ .cmpxchgIndex = cmpxchg_index },
31363136 };
31373137 },
......@@ -3280,21 +3280,21 @@ fn analyzeDecl(
32803280
32813281 extra_index += 1;
32823282 const align_inst: Zir.Inst.Ref = if (!has_align) .none else inst: {
3283 const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
3283 const inst = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
32843284 extra_index += 1;
32853285 break :inst inst;
32863286 };
32873287 _ = align_inst;
32883288
32893289 const section_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: {
3290 const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
3290 const inst = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
32913291 extra_index += 1;
32923292 break :inst inst;
32933293 };
32943294 _ = section_inst;
32953295
32963296 const addrspace_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: {
3297 const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
3297 const inst = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
32983298 extra_index += 1;
32993299 break :inst inst;
33003300 };
......@@ -4111,7 +4111,7 @@ fn analyzeFancyFunction(
41114111
41124112 var align_index: ?usize = null;
41134113 if (extra.data.bits.has_align_ref) {
4114 const align_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
4114 const align_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
41154115 align_index = self.exprs.items.len;
41164116 _ = try self.walkRef(file, scope, parent_src, align_ref, false);
41174117 extra_index += 1;
......@@ -4128,7 +4128,7 @@ fn analyzeFancyFunction(
41284128
41294129 var addrspace_index: ?usize = null;
41304130 if (extra.data.bits.has_addrspace_ref) {
4131 const addrspace_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
4131 const addrspace_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
41324132 addrspace_index = self.exprs.items.len;
41334133 _ = try self.walkRef(file, scope, parent_src, addrspace_ref, false);
41344134 extra_index += 1;
......@@ -4145,7 +4145,7 @@ fn analyzeFancyFunction(
41454145
41464146 var section_index: ?usize = null;
41474147 if (extra.data.bits.has_section_ref) {
4148 const section_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
4148 const section_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
41494149 section_index = self.exprs.items.len;
41504150 _ = try self.walkRef(file, scope, parent_src, section_ref, false);
41514151 extra_index += 1;
......@@ -4162,7 +4162,7 @@ fn analyzeFancyFunction(
41624162
41634163 var cc_index: ?usize = null;
41644164 if (extra.data.bits.has_cc_ref and !extra.data.bits.has_cc_body) {
4165 const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
4165 const cc_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
41664166 const cc_expr = try self.walkRef(file, scope, parent_src, cc_ref, false);
41674167
41684168 cc_index = self.exprs.items.len;
......@@ -4211,7 +4211,7 @@ fn analyzeFancyFunction(
42114211 const generic_ret: ?DocData.Expr = switch (ret_type_ref) {
42124212 .type => |t| blk: {
42134213 if (fn_info.body.len == 0) break :blk null;
4214 if (t == @enumToInt(Ref.type_type)) {
4214 if (t == @intFromEnum(Ref.type_type)) {
42154215 break :blk try self.getGenericReturnType(
42164216 file,
42174217 scope,
......@@ -4249,7 +4249,7 @@ fn analyzeFancyFunction(
42494249 };
42504250
42514251 return DocData.WalkResult{
4252 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
4252 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
42534253 .expr = .{ .type = type_slot_index },
42544254 };
42554255}
......@@ -4354,7 +4354,7 @@ fn analyzeFunction(
43544354 const generic_ret: ?DocData.Expr = switch (ret_type_ref) {
43554355 .type => |t| blk: {
43564356 if (fn_info.body.len == 0) break :blk null;
4357 if (t == @enumToInt(Ref.type_type)) {
4357 if (t == @intFromEnum(Ref.type_type)) {
43584358 break :blk try self.getGenericReturnType(
43594359 file,
43604360 scope,
......@@ -4395,7 +4395,7 @@ fn analyzeFunction(
43954395 };
43964396
43974397 return DocData.WalkResult{
4398 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
4398 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
43994399 .expr = .{ .type = type_slot_index },
44004400 };
44014401}
......@@ -4467,7 +4467,7 @@ fn collectUnionFieldInfo(
44674467 const doc_comment_index = file.zir.extra[extra_index];
44684468 extra_index += 1;
44694469 const field_type = if (has_type)
4470 @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index])
4470 @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index])
44714471 else
44724472 .void_type;
44734473 if (has_type) extra_index += 1;
......@@ -4561,7 +4561,7 @@ fn collectStructFieldInfo(
45614561 if (has_type_body) {
45624562 fields[field_i].type_body_len = file.zir.extra[extra_index];
45634563 } else {
4564 fields[field_i].type_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
4564 fields[field_i].type_ref = @enumFromInt(Zir.Inst.Ref, file.zir.extra[extra_index]);
45654565 }
45664566 extra_index += 1;
45674567
......@@ -4651,13 +4651,13 @@ fn walkRef(
46514651) AutodocErrors!DocData.WalkResult {
46524652 if (ref == .none) {
46534653 return .{ .expr = .{ .comptimeExpr = 0 } };
4654 } else if (@enumToInt(ref) <= @enumToInt(InternPool.Index.last_type)) {
4654 } else if (@intFromEnum(ref) <= @intFromEnum(InternPool.Index.last_type)) {
46554655 // We can just return a type that indexes into `types` with the
46564656 // enum value because in the beginning we pre-filled `types` with
46574657 // the types that are listed in `Ref`.
46584658 return DocData.WalkResult{
4659 .typeRef = .{ .type = @enumToInt(std.builtin.TypeId.Type) },
4660 .expr = .{ .type = @enumToInt(ref) },
4659 .typeRef = .{ .type = @intFromEnum(std.builtin.TypeId.Type) },
4660 .expr = .{ .type = @intFromEnum(ref) },
46614661 };
46624662 } else if (Zir.refToIndex(ref)) |zir_index| {
46634663 return self.walkInstruction(file, parent_scope, parent_src, zir_index, need_type);
......@@ -4676,26 +4676,26 @@ fn walkRef(
46764676 },
46774677 .zero => {
46784678 return DocData.WalkResult{
4679 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
4679 .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) },
46804680 .expr = .{ .int = .{ .value = 0 } },
46814681 };
46824682 },
46834683 .one => {
46844684 return DocData.WalkResult{
4685 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
4685 .typeRef = .{ .type = @intFromEnum(Ref.comptime_int_type) },
46864686 .expr = .{ .int = .{ .value = 1 } },
46874687 };
46884688 },
46894689
46904690 .void_value => {
46914691 return DocData.WalkResult{
4692 .typeRef = .{ .type = @enumToInt(Ref.void_type) },
4692 .typeRef = .{ .type = @intFromEnum(Ref.void_type) },
46934693 .expr = .{ .void = .{} },
46944694 };
46954695 },
46964696 .unreachable_value => {
46974697 return DocData.WalkResult{
4698 .typeRef = .{ .type = @enumToInt(Ref.noreturn_type) },
4698 .typeRef = .{ .type = @intFromEnum(Ref.noreturn_type) },
46994699 .expr = .{ .@"unreachable" = .{} },
47004700 };
47014701 },
......@@ -4704,13 +4704,13 @@ fn walkRef(
47044704 },
47054705 .bool_true => {
47064706 return DocData.WalkResult{
4707 .typeRef = .{ .type = @enumToInt(Ref.bool_type) },
4707 .typeRef = .{ .type = @intFromEnum(Ref.bool_type) },
47084708 .expr = .{ .bool = true },
47094709 };
47104710 },
47114711 .bool_false => {
47124712 return DocData.WalkResult{
4713 .typeRef = .{ .type = @enumToInt(Ref.bool_type) },
4713 .typeRef = .{ .type = @intFromEnum(Ref.bool_type) },
47144714 .expr = .{ .bool = false },
47154715 };
47164716 },
......@@ -4719,37 +4719,37 @@ fn walkRef(
47194719 },
47204720 .zero_usize => {
47214721 return DocData.WalkResult{
4722 .typeRef = .{ .type = @enumToInt(Ref.usize_type) },
4722 .typeRef = .{ .type = @intFromEnum(Ref.usize_type) },
47234723 .expr = .{ .int = .{ .value = 0 } },
47244724 };
47254725 },
47264726 .one_usize => {
47274727 return DocData.WalkResult{
4728 .typeRef = .{ .type = @enumToInt(Ref.usize_type) },
4728 .typeRef = .{ .type = @intFromEnum(Ref.usize_type) },
47294729 .expr = .{ .int = .{ .value = 1 } },
47304730 };
47314731 },
47324732 .calling_convention_type => {
47334733 return DocData.WalkResult{
4734 .typeRef = .{ .type = @enumToInt(Ref.type_type) },
4735 .expr = .{ .type = @enumToInt(Ref.calling_convention_type) },
4734 .typeRef = .{ .type = @intFromEnum(Ref.type_type) },
4735 .expr = .{ .type = @intFromEnum(Ref.calling_convention_type) },
47364736 };
47374737 },
47384738 .calling_convention_c => {
47394739 return DocData.WalkResult{
4740 .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) },
4740 .typeRef = .{ .type = @intFromEnum(Ref.calling_convention_type) },
47414741 .expr = .{ .enumLiteral = "C" },
47424742 };
47434743 },
47444744 .calling_convention_inline => {
47454745 return DocData.WalkResult{
4746 .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) },
4746 .typeRef = .{ .type = @intFromEnum(Ref.calling_convention_type) },
47474747 .expr = .{ .enumLiteral = "Inline" },
47484748 };
47494749 },
47504750 // .generic_poison => {
47514751 // return DocData.WalkResult{ .int = .{
4752 // .type = @enumToInt(Ref.comptime_int_type),
4752 // .type = @intFromEnum(Ref.comptime_int_type),
47534753 // .value = 1,
47544754 // } };
47554755 // },
src/BuiltinFn.zig+27-27
......@@ -12,7 +12,7 @@ pub const Tag = enum {
1212 atomic_store,
1313 bit_cast,
1414 bit_offset_of,
15 bool_to_int,
15 int_from_bool,
1616 bit_size_of,
1717 breakpoint,
1818 mul_add,
......@@ -39,10 +39,10 @@ pub const Tag = enum {
3939 div_floor,
4040 div_trunc,
4141 embed_file,
42 enum_to_int,
42 int_from_enum,
4343 error_name,
4444 error_return_trace,
45 error_to_int,
45 int_from_error,
4646 err_set_cast,
4747 @"export",
4848 @"extern",
......@@ -50,7 +50,7 @@ pub const Tag = enum {
5050 field,
5151 field_parent_ptr,
5252 float_cast,
53 float_to_int,
53 int_from_float,
5454 frame,
5555 Frame,
5656 frame_address,
......@@ -60,10 +60,10 @@ pub const Tag = enum {
6060 import,
6161 in_comptime,
6262 int_cast,
63 int_to_enum,
64 int_to_error,
65 int_to_float,
66 int_to_ptr,
63 enum_from_int,
64 error_from_int,
65 float_from_int,
66 ptr_from_int,
6767 max,
6868 memcpy,
6969 memset,
......@@ -76,7 +76,7 @@ pub const Tag = enum {
7676 pop_count,
7777 prefetch,
7878 ptr_cast,
79 ptr_to_int,
79 int_from_ptr,
8080 rem,
8181 return_address,
8282 select,
......@@ -238,9 +238,9 @@ pub const list = list: {
238238 },
239239 },
240240 .{
241 "@boolToInt",
241 "@intFromBool",
242242 .{
243 .tag = .bool_to_int,
243 .tag = .int_from_bool,
244244 .param_count = 1,
245245 },
246246 },
......@@ -425,9 +425,9 @@ pub const list = list: {
425425 },
426426 },
427427 .{
428 "@enumToInt",
428 "@intFromEnum",
429429 .{
430 .tag = .enum_to_int,
430 .tag = .int_from_enum,
431431 .param_count = 1,
432432 },
433433 },
......@@ -446,9 +446,9 @@ pub const list = list: {
446446 },
447447 },
448448 .{
449 "@errorToInt",
449 "@intFromError",
450450 .{
451 .tag = .error_to_int,
451 .tag = .int_from_error,
452452 .param_count = 1,
453453 },
454454 },
......@@ -506,9 +506,9 @@ pub const list = list: {
506506 },
507507 },
508508 .{
509 "@floatToInt",
509 "@intFromFloat",
510510 .{
511 .tag = .float_to_int,
511 .tag = .int_from_float,
512512 .param_count = 2,
513513 },
514514 },
......@@ -576,31 +576,31 @@ pub const list = list: {
576576 },
577577 },
578578 .{
579 "@intToEnum",
579 "@enumFromInt",
580580 .{
581 .tag = .int_to_enum,
581 .tag = .enum_from_int,
582582 .param_count = 2,
583583 },
584584 },
585585 .{
586 "@intToError",
586 "@errorFromInt",
587587 .{
588 .tag = .int_to_error,
588 .tag = .error_from_int,
589589 .eval_to_error = .always,
590590 .param_count = 1,
591591 },
592592 },
593593 .{
594 "@intToFloat",
594 "@floatFromInt",
595595 .{
596 .tag = .int_to_float,
596 .tag = .float_from_int,
597597 .param_count = 2,
598598 },
599599 },
600600 .{
601 "@intToPtr",
601 "@ptrFromInt",
602602 .{
603 .tag = .int_to_ptr,
603 .tag = .ptr_from_int,
604604 .param_count = 2,
605605 },
606606 },
......@@ -689,9 +689,9 @@ pub const list = list: {
689689 },
690690 },
691691 .{
692 "@ptrToInt",
692 "@intFromPtr",
693693 .{
694 .tag = .ptr_to_int,
694 .tag = .int_from_ptr,
695695 .param_count = 1,
696696 },
697697 },
src/Compilation.zig+16-16
......@@ -1050,7 +1050,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
10501050 const is_enabled = options.target.cpu.features.isEnabled(index);
10511051
10521052 if (feature.llvm_name) |llvm_name| {
1053 const plus_or_minus = "-+"[@boolToInt(is_enabled)];
1053 const plus_or_minus = "-+"[@intFromBool(is_enabled)];
10541054 try buf.ensureUnusedCapacity(2 + llvm_name.len);
10551055 buf.appendAssumeCapacity(plus_or_minus);
10561056 buf.appendSliceAssumeCapacity(llvm_name);
......@@ -2506,7 +2506,7 @@ pub fn makeBinFileWritable(self: *Compilation) !void {
25062506/// This function is temporally single-threaded.
25072507pub fn totalErrorCount(self: *Compilation) u32 {
25082508 var total: usize = self.failed_c_objects.count() + self.misc_failures.count() +
2509 @boolToInt(self.alloc_failure_occurred) + self.lld_errors.items.len;
2509 @intFromBool(self.alloc_failure_occurred) + self.lld_errors.items.len;
25102510
25112511 if (self.bin_file.options.module) |module| {
25122512 total += module.failed_exports.count();
......@@ -2520,7 +2520,7 @@ pub fn totalErrorCount(self: *Compilation) u32 {
25202520 } else {
25212521 const file = entry.key_ptr.*;
25222522 assert(file.zir_loaded);
2523 const payload_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.compile_errors)];
2523 const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)];
25242524 assert(payload_index != 0);
25252525 const header = file.zir.extraData(Zir.Inst.CompileErrors, payload_index);
25262526 total += header.data.items_len;
......@@ -2551,14 +2551,14 @@ pub fn totalErrorCount(self: *Compilation) u32 {
25512551
25522552 // The "no entry point found" error only counts if there are no semantic analysis errors.
25532553 if (total == 0) {
2554 total += @boolToInt(self.link_error_flags.no_entry_point_found);
2554 total += @intFromBool(self.link_error_flags.no_entry_point_found);
25552555 }
2556 total += @boolToInt(self.link_error_flags.missing_libc);
2556 total += @intFromBool(self.link_error_flags.missing_libc);
25572557
25582558 // Compile log errors only count if there are no other errors.
25592559 if (total == 0) {
25602560 if (self.bin_file.options.module) |module| {
2561 total += @boolToInt(module.compile_log_decls.count() != 0);
2561 total += @intFromBool(module.compile_log_decls.count() != 0);
25622562 }
25632563 }
25642564
......@@ -2604,7 +2604,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
26042604 });
26052605 const notes_start = try bundle.reserveNotes(notes_len);
26062606 for (notes_start.., lld_error.context_lines) |note, context_line| {
2607 bundle.extra.items[note] = @enumToInt(bundle.addErrorMessageAssumeCapacity(.{
2607 bundle.extra.items[note] = @intFromEnum(bundle.addErrorMessageAssumeCapacity(.{
26082608 .msg = try bundle.addString(context_line),
26092609 }));
26102610 }
......@@ -2697,10 +2697,10 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
26972697 .notes_len = 2,
26982698 });
26992699 const notes_start = try bundle.reserveNotes(2);
2700 bundle.extra.items[notes_start + 0] = @enumToInt(try bundle.addErrorMessage(.{
2700 bundle.extra.items[notes_start + 0] = @intFromEnum(try bundle.addErrorMessage(.{
27012701 .msg = try bundle.addString("run 'zig libc -h' to learn about libc installations"),
27022702 }));
2703 bundle.extra.items[notes_start + 1] = @enumToInt(try bundle.addErrorMessage(.{
2703 bundle.extra.items[notes_start + 1] = @intFromEnum(try bundle.addErrorMessage(.{
27042704 .msg = try bundle.addString("run 'zig targets' to see the targets for which zig can always provide libc"),
27052705 }));
27062706 }
......@@ -2895,7 +2895,7 @@ pub fn addModuleErrorMsg(mod: *Module, eb: *ErrorBundle.Wip, module_err_msg: Mod
28952895 const notes_start = try eb.reserveNotes(notes_len);
28962896
28972897 for (notes_start.., notes.keys()) |i, note| {
2898 eb.extra.items[i] = @enumToInt(try eb.addErrorMessage(note));
2898 eb.extra.items[i] = @intFromEnum(try eb.addErrorMessage(note));
28992899 }
29002900}
29012901
......@@ -2903,7 +2903,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void {
29032903 assert(file.zir_loaded);
29042904 assert(file.tree_loaded);
29052905 assert(file.source_loaded);
2906 const payload_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.compile_errors)];
2906 const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)];
29072907 assert(payload_index != 0);
29082908 const gpa = eb.gpa;
29092909
......@@ -2963,7 +2963,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void {
29632963 const src_path = try file.fullPath(gpa);
29642964 defer gpa.free(src_path);
29652965
2966 eb.extra.items[note_i] = @enumToInt(try eb.addErrorMessage(.{
2966 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
29672967 .msg = try eb.addString(msg),
29682968 .src_loc = try eb.addSourceLocation(.{
29692969 .src_path = try eb.addString(src_path),
......@@ -3466,7 +3466,7 @@ fn workerAstGenFile(
34663466 // If we experience an error preemptively fetching the
34673467 // file, just ignore it and let it happen again later during Sema.
34683468 assert(file.zir_loaded);
3469 const imports_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)];
3469 const imports_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.imports)];
34703470 if (imports_index != 0) {
34713471 const extra = file.zir.extraData(Zir.Inst.Imports, imports_index);
34723472 var import_i: u32 = 0;
......@@ -4239,10 +4239,10 @@ pub fn addCCArgs(
42394239 }
42404240
42414241 try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
4242 @enumToInt(comp.libcxx_abi_version),
4242 @intFromEnum(comp.libcxx_abi_version),
42434243 }));
42444244 try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
4245 @enumToInt(comp.libcxx_abi_version),
4245 @intFromEnum(comp.libcxx_abi_version),
42464246 }));
42474247 }
42484248
......@@ -4307,7 +4307,7 @@ pub fn addCCArgs(
43074307
43084308 if (feature.llvm_name) |llvm_name| {
43094309 argv.appendSliceAssumeCapacity(&[_][]const u8{ "-Xclang", "-target-feature", "-Xclang" });
4310 const plus_or_minus = "-+"[@boolToInt(is_enabled)];
4310 const plus_or_minus = "-+"[@intFromBool(is_enabled)];
43114311 const arg = try std.fmt.allocPrint(arena, "{c}{s}", .{ plus_or_minus, llvm_name });
43124312 argv.appendAssumeCapacity(arg);
43134313 }
src/InternPool.zig+170-170
......@@ -80,7 +80,7 @@ const KeyAdapter = struct {
8080
8181 pub fn eql(ctx: @This(), a: Key, b_void: void, b_map_index: usize) bool {
8282 _ = b_void;
83 return ctx.intern_pool.indexToKey(@intToEnum(Index, b_map_index)).eql(a, ctx.intern_pool);
83 return ctx.intern_pool.indexToKey(@enumFromInt(Index, b_map_index)).eql(a, ctx.intern_pool);
8484 }
8585
8686 pub fn hash(ctx: @This(), a: Key) u32 {
......@@ -95,7 +95,7 @@ pub const OptionalMapIndex = enum(u32) {
9595
9696 pub fn unwrap(oi: OptionalMapIndex) ?MapIndex {
9797 if (oi == .none) return null;
98 return @intToEnum(MapIndex, @enumToInt(oi));
98 return @enumFromInt(MapIndex, @intFromEnum(oi));
9999 }
100100};
101101
......@@ -104,7 +104,7 @@ pub const MapIndex = enum(u32) {
104104 _,
105105
106106 pub fn toOptional(i: MapIndex) OptionalMapIndex {
107 return @intToEnum(OptionalMapIndex, @enumToInt(i));
107 return @enumFromInt(OptionalMapIndex, @intFromEnum(i));
108108 }
109109};
110110
......@@ -114,7 +114,7 @@ pub const RuntimeIndex = enum(u32) {
114114 _,
115115
116116 pub fn increment(ri: *RuntimeIndex) void {
117 ri.* = @intToEnum(RuntimeIndex, @enumToInt(ri.*) + 1);
117 ri.* = @enumFromInt(RuntimeIndex, @intFromEnum(ri.*) + 1);
118118 }
119119};
120120
......@@ -130,11 +130,11 @@ pub const NullTerminatedString = enum(u32) {
130130 _,
131131
132132 pub fn toString(self: NullTerminatedString) String {
133 return @intToEnum(String, @enumToInt(self));
133 return @enumFromInt(String, @intFromEnum(self));
134134 }
135135
136136 pub fn toOptional(self: NullTerminatedString) OptionalNullTerminatedString {
137 return @intToEnum(OptionalNullTerminatedString, @enumToInt(self));
137 return @enumFromInt(OptionalNullTerminatedString, @intFromEnum(self));
138138 }
139139
140140 const Adapter = struct {
......@@ -147,14 +147,14 @@ pub const NullTerminatedString = enum(u32) {
147147
148148 pub fn hash(ctx: @This(), a: NullTerminatedString) u32 {
149149 _ = ctx;
150 return std.hash.uint32(@enumToInt(a));
150 return std.hash.uint32(@intFromEnum(a));
151151 }
152152 };
153153
154154 /// Compare based on integer value alone, ignoring the string contents.
155155 pub fn indexLessThan(ctx: void, a: NullTerminatedString, b: NullTerminatedString) bool {
156156 _ = ctx;
157 return @enumToInt(a) < @enumToInt(b);
157 return @intFromEnum(a) < @intFromEnum(b);
158158 }
159159
160160 pub fn toUnsigned(self: NullTerminatedString, ip: *const InternPool) ?u32 {
......@@ -196,7 +196,7 @@ pub const OptionalNullTerminatedString = enum(u32) {
196196
197197 pub fn unwrap(oi: OptionalNullTerminatedString) ?NullTerminatedString {
198198 if (oi == .none) return null;
199 return @intToEnum(NullTerminatedString, @enumToInt(oi));
199 return @enumFromInt(NullTerminatedString, @intFromEnum(oi));
200200 }
201201};
202202
......@@ -279,7 +279,7 @@ pub const Key = union(enum) {
279279
280280 /// Look up field index based on field name.
281281 pub fn nameIndex(self: ErrorSetType, ip: *const InternPool, name: NullTerminatedString) ?u32 {
282 const map = &ip.maps.items[@enumToInt(self.names_map.unwrap().?)];
282 const map = &ip.maps.items[@intFromEnum(self.names_map.unwrap().?)];
283283 const adapter: NullTerminatedString.Adapter = .{ .strings = self.names };
284284 const field_index = map.getIndexAdapted(name, adapter) orelse return null;
285285 return @intCast(u32, field_index);
......@@ -417,7 +417,7 @@ pub const Key = union(enum) {
417417
418418 /// Look up field index based on field name.
419419 pub fn nameIndex(self: EnumType, ip: *const InternPool, name: NullTerminatedString) ?u32 {
420 const map = &ip.maps.items[@enumToInt(self.names_map.unwrap().?)];
420 const map = &ip.maps.items[@intFromEnum(self.names_map.unwrap().?)];
421421 const adapter: NullTerminatedString.Adapter = .{ .strings = self.names };
422422 const field_index = map.getIndexAdapted(name, adapter) orelse return null;
423423 return @intCast(u32, field_index);
......@@ -437,7 +437,7 @@ pub const Key = union(enum) {
437437 else => unreachable,
438438 };
439439 if (self.values_map.unwrap()) |values_map| {
440 const map = &ip.maps.items[@enumToInt(values_map)];
440 const map = &ip.maps.items[@intFromEnum(values_map)];
441441 const adapter: Index.Adapter = .{ .indexes = self.values };
442442 const field_index = map.getIndexAdapted(int_tag_val, adapter) orelse return null;
443443 return @intCast(u32, field_index);
......@@ -691,7 +691,7 @@ pub const Key = union(enum) {
691691 pub fn hash64(key: Key, ip: *const InternPool) u64 {
692692 const asBytes = std.mem.asBytes;
693693 const KeyTag = @typeInfo(Key).Union.tag_type.?;
694 const seed = @enumToInt(@as(KeyTag, key));
694 const seed = @intFromEnum(@as(KeyTag, key));
695695 return switch (key) {
696696 // TODO: assert no padding in these types
697697 inline .ptr_type,
......@@ -714,8 +714,8 @@ pub const Key = union(enum) {
714714 .un,
715715 => |x| Hash.hash(seed, asBytes(&x)),
716716
717 .int_type => |x| Hash.hash(seed + @enumToInt(x.signedness), asBytes(&x.bits)),
718 .union_type => |x| Hash.hash(seed + @enumToInt(x.runtime_tag), asBytes(&x.index)),
717 .int_type => |x| Hash.hash(seed + @intFromEnum(x.signedness), asBytes(&x.bits)),
718 .union_type => |x| Hash.hash(seed + @intFromEnum(x.runtime_tag), asBytes(&x.index)),
719719
720720 .error_union => |x| switch (x.val) {
721721 .err_name => |y| Hash.hash(seed + 0, asBytes(&x.ty) ++ asBytes(&y)),
......@@ -777,7 +777,7 @@ pub const Key = union(enum) {
777777 // Int-to-ptr pointers are hashed separately than decl-referencing pointers.
778778 // This is sound due to pointer provenance rules.
779779 const addr: @typeInfo(Key.Ptr.Addr).Union.tag_type.? = ptr.addr;
780 const seed2 = seed + @enumToInt(addr);
780 const seed2 = seed + @intFromEnum(addr);
781781 const common = asBytes(&ptr.ty) ++ asBytes(&ptr.len);
782782 return switch (ptr.addr) {
783783 .decl => |x| Hash.hash(seed2, common ++ asBytes(&x)),
......@@ -1381,7 +1381,7 @@ pub const Index = enum(u32) {
13811381
13821382 pub fn hash(ctx: @This(), a: Index) u32 {
13831383 _ = ctx;
1384 return std.hash.uint32(@enumToInt(a));
1384 return std.hash.uint32(@intFromEnum(a));
13851385 }
13861386 };
13871387
......@@ -2259,21 +2259,21 @@ pub const Alignment = enum(u6) {
22592259 pub fn toByteUnitsOptional(a: Alignment) ?u64 {
22602260 return switch (a) {
22612261 .none => null,
2262 _ => @as(u64, 1) << @enumToInt(a),
2262 _ => @as(u64, 1) << @intFromEnum(a),
22632263 };
22642264 }
22652265
22662266 pub fn toByteUnits(a: Alignment, default: u64) u64 {
22672267 return switch (a) {
22682268 .none => default,
2269 _ => @as(u64, 1) << @enumToInt(a),
2269 _ => @as(u64, 1) << @intFromEnum(a),
22702270 };
22712271 }
22722272
22732273 pub fn fromByteUnits(n: u64) Alignment {
22742274 if (n == 0) return .none;
22752275 assert(std.math.isPowerOfTwo(n));
2276 return @intToEnum(Alignment, @ctz(n));
2276 return @enumFromInt(Alignment, @ctz(n));
22772277 }
22782278
22792279 pub fn fromNonzeroByteUnits(n: u64) Alignment {
......@@ -2282,7 +2282,7 @@ pub const Alignment = enum(u6) {
22822282 }
22832283
22842284 pub fn min(a: Alignment, b: Alignment) Alignment {
2285 return @intToEnum(Alignment, @min(@enumToInt(a), @enumToInt(b)));
2285 return @enumFromInt(Alignment, @min(@intFromEnum(a), @intFromEnum(b)));
22862286 }
22872287};
22882288
......@@ -2509,10 +2509,10 @@ pub fn init(ip: *InternPool, gpa: Allocator) !void {
25092509 const cc_c = ip.indexToKey(.calling_convention_c).enum_tag.int;
25102510
25112511 assert(ip.indexToKey(cc_inline).int.storage.u64 ==
2512 @enumToInt(std.builtin.CallingConvention.Inline));
2512 @intFromEnum(std.builtin.CallingConvention.Inline));
25132513
25142514 assert(ip.indexToKey(cc_c).int.storage.u64 ==
2515 @enumToInt(std.builtin.CallingConvention.C));
2515 @intFromEnum(std.builtin.CallingConvention.C));
25162516
25172517 assert(ip.indexToKey(ip.typeOf(cc_inline)).int_type.bits ==
25182518 @typeInfo(@typeInfo(std.builtin.CallingConvention).Enum.tag_type).Int.bits);
......@@ -2550,7 +2550,7 @@ pub fn deinit(ip: *InternPool, gpa: Allocator) void {
25502550
25512551pub fn indexToKey(ip: *const InternPool, index: Index) Key {
25522552 assert(index != .none);
2553 const item = ip.items.get(@enumToInt(index));
2553 const item = ip.items.get(@intFromEnum(index));
25542554 const data = item.data;
25552555 return switch (item.tag) {
25562556 .type_int_signed => .{
......@@ -2581,8 +2581,8 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
25812581 .sentinel = .none,
25822582 } };
25832583 },
2584 .simple_type => .{ .simple_type = @intToEnum(SimpleType, data) },
2585 .simple_value => .{ .simple_value = @intToEnum(SimpleValue, data) },
2584 .simple_type => .{ .simple_type = @enumFromInt(SimpleType, data) },
2585 .simple_value => .{ .simple_value = @enumFromInt(SimpleValue, data) },
25862586
25872587 .type_vector => {
25882588 const vector_info = ip.extraData(Vector, data);
......@@ -2601,8 +2601,8 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
26012601 return .{ .ptr_type = ptr_info };
26022602 },
26032603
2604 .type_optional => .{ .opt_type = @intToEnum(Index, data) },
2605 .type_anyframe => .{ .anyframe_type = @intToEnum(Index, data) },
2604 .type_optional => .{ .opt_type = @enumFromInt(Index, data) },
2605 .type_anyframe => .{ .anyframe_type = @enumFromInt(Index, data) },
26062606
26072607 .type_error_union => .{ .error_union_type = ip.extraData(Key.ErrorUnionType, data) },
26082608 .type_error_set => {
......@@ -2615,12 +2615,12 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
26152615 } };
26162616 },
26172617 .type_inferred_error_set => .{
2618 .inferred_error_set_type = @intToEnum(Module.Fn.InferredErrorSet.Index, data),
2618 .inferred_error_set_type = @enumFromInt(Module.Fn.InferredErrorSet.Index, data),
26192619 },
26202620
26212621 .type_opaque => .{ .opaque_type = ip.extraData(Key.OpaqueType, data) },
26222622 .type_struct => {
2623 const struct_index = @intToEnum(Module.Struct.OptionalIndex, data);
2623 const struct_index = @enumFromInt(Module.Struct.OptionalIndex, data);
26242624 const namespace = if (struct_index.unwrap()) |i|
26252625 ip.structPtrConst(i).namespace.toOptional()
26262626 else
......@@ -2632,7 +2632,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
26322632 },
26332633 .type_struct_ns => .{ .struct_type = .{
26342634 .index = .none,
2635 .namespace = @intToEnum(Module.Namespace.Index, data).toOptional(),
2635 .namespace = @enumFromInt(Module.Namespace.Index, data).toOptional(),
26362636 } },
26372637
26382638 .type_struct_anon => {
......@@ -2660,15 +2660,15 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
26602660 },
26612661
26622662 .type_union_untagged => .{ .union_type = .{
2663 .index = @intToEnum(Module.Union.Index, data),
2663 .index = @enumFromInt(Module.Union.Index, data),
26642664 .runtime_tag = .none,
26652665 } },
26662666 .type_union_tagged => .{ .union_type = .{
2667 .index = @intToEnum(Module.Union.Index, data),
2667 .index = @enumFromInt(Module.Union.Index, data),
26682668 .runtime_tag = .tagged,
26692669 } },
26702670 .type_union_safety => .{ .union_type = .{
2671 .index = @intToEnum(Module.Union.Index, data),
2671 .index = @enumFromInt(Module.Union.Index, data),
26722672 .runtime_tag = .safety,
26732673 } },
26742674
......@@ -2693,10 +2693,10 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
26932693 .type_enum_nonexhaustive => ip.indexToKeyEnum(data, .nonexhaustive),
26942694 .type_function => .{ .func_type = ip.indexToKeyFuncType(data) },
26952695
2696 .undef => .{ .undef = @intToEnum(Index, data) },
2696 .undef => .{ .undef = @enumFromInt(Index, data) },
26972697 .runtime_value => .{ .runtime_value = ip.extraData(Tag.TypeValue, data) },
26982698 .opt_null => .{ .opt = .{
2699 .ty = @intToEnum(Index, data),
2699 .ty = @enumFromInt(Index, data),
27002700 .val = .none,
27012701 } },
27022702 .opt_payload => {
......@@ -2754,7 +2754,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
27542754 .ptr_elem => {
27552755 // Avoid `indexToKey` recursion by asserting the tag encoding.
27562756 const info = ip.extraData(PtrBaseIndex, data);
2757 const index_item = ip.items.get(@enumToInt(info.index));
2757 const index_item = ip.items.get(@intFromEnum(info.index));
27582758 return switch (index_item.tag) {
27592759 .int_usize => .{ .ptr = .{
27602760 .ty = info.ty,
......@@ -2770,7 +2770,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
27702770 .ptr_field => {
27712771 // Avoid `indexToKey` recursion by asserting the tag encoding.
27722772 const info = ip.extraData(PtrBaseIndex, data);
2773 const index_item = ip.items.get(@enumToInt(info.index));
2773 const index_item = ip.items.get(@intFromEnum(info.index));
27742774 return switch (index_item.tag) {
27752775 .int_usize => .{ .ptr = .{
27762776 .ty = info.ty,
......@@ -2785,7 +2785,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
27852785 },
27862786 .ptr_slice => {
27872787 const info = ip.extraData(PtrSlice, data);
2788 const ptr_item = ip.items.get(@enumToInt(info.ptr));
2788 const ptr_item = ip.items.get(@intFromEnum(info.ptr));
27892789 return .{
27902790 .ptr = .{
27912791 .ty = info.ty,
......@@ -2815,7 +2815,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
28152815 .ptr_elem => b: {
28162816 // Avoid `indexToKey` recursion by asserting the tag encoding.
28172817 const sub_info = ip.extraData(PtrBaseIndex, ptr_item.data);
2818 const index_item = ip.items.get(@enumToInt(sub_info.index));
2818 const index_item = ip.items.get(@intFromEnum(sub_info.index));
28192819 break :b switch (index_item.tag) {
28202820 .int_usize => .{ .elem = .{
28212821 .base = sub_info.base,
......@@ -2828,7 +2828,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
28282828 .ptr_field => b: {
28292829 // Avoid `indexToKey` recursion by asserting the tag encoding.
28302830 const sub_info = ip.extraData(PtrBaseIndex, ptr_item.data);
2831 const index_item = ip.items.get(@enumToInt(sub_info.index));
2831 const index_item = ip.items.get(@intFromEnum(sub_info.index));
28322832 break :b switch (index_item.tag) {
28332833 .int_usize => .{ .field = .{
28342834 .base = sub_info.base,
......@@ -2940,8 +2940,8 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
29402940 .extern_func => .{ .extern_func = ip.extraData(Tag.ExternFunc, data) },
29412941 .func => .{ .func = ip.extraData(Tag.Func, data) },
29422942 .only_possible_value => {
2943 const ty = @intToEnum(Index, data);
2944 const ty_item = ip.items.get(@enumToInt(ty));
2943 const ty = @enumFromInt(Index, data);
2944 const ty_item = ip.items.get(@intFromEnum(ty));
29452945 return switch (ty_item.tag) {
29462946 .type_array_big => {
29472947 const sentinel = @ptrCast(
......@@ -2950,7 +2950,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
29502950 );
29512951 return .{ .aggregate = .{
29522952 .ty = ty,
2953 .storage = .{ .elems = sentinel[0..@boolToInt(sentinel[0] != .none)] },
2953 .storage = .{ .elems = sentinel[0..@intFromBool(sentinel[0] != .none)] },
29542954 } };
29552955 },
29562956 .type_array_small, .type_vector => .{ .aggregate = .{
......@@ -2994,7 +2994,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
29942994 const len = @intCast(u32, ip.aggregateTypeLenIncludingSentinel(extra.ty));
29952995 return .{ .aggregate = .{
29962996 .ty = extra.ty,
2997 .storage = .{ .bytes = ip.string_bytes.items[@enumToInt(extra.bytes)..][0..len] },
2997 .storage = .{ .bytes = ip.string_bytes.items[@intFromEnum(extra.bytes)..][0..len] },
29982998 } };
29992999 },
30003000 .aggregate => {
......@@ -3029,7 +3029,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
30293029 .val = .{ .payload = extra.val },
30303030 } };
30313031 },
3032 .enum_literal => .{ .enum_literal = @intToEnum(NullTerminatedString, data) },
3032 .enum_literal => .{ .enum_literal = @enumFromInt(NullTerminatedString, data) },
30333033 .enum_tag => .{ .enum_tag = ip.extraData(Tag.EnumTag, data) },
30343034
30353035 .memoized_call => {
......@@ -3103,7 +3103,7 @@ fn indexToKeyBigInt(ip: *const InternPool, limb_index: u32, positive: bool) Key
31033103pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
31043104 const adapter: KeyAdapter = .{ .intern_pool = ip };
31053105 const gop = try ip.map.getOrPutAdapted(gpa, key, adapter);
3106 if (gop.found_existing) return @intToEnum(Index, gop.index);
3106 if (gop.found_existing) return @enumFromInt(Index, gop.index);
31073107 try ip.items.ensureUnusedCapacity(gpa, 1);
31083108 switch (key) {
31093109 .int_type => |int_type| {
......@@ -3129,9 +3129,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
31293129 try ip.items.ensureUnusedCapacity(gpa, 1);
31303130 ip.items.appendAssumeCapacity(.{
31313131 .tag = .type_slice,
3132 .data = @enumToInt(ptr_type_index),
3132 .data = @intFromEnum(ptr_type_index),
31333133 });
3134 return @intToEnum(Index, ip.items.len - 1);
3134 return @enumFromInt(Index, ip.items.len - 1);
31353135 }
31363136
31373137 var ptr_type_adjusted = ptr_type;
......@@ -3155,7 +3155,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
31553155 .child = array_type.child,
31563156 }),
31573157 });
3158 return @intToEnum(Index, ip.items.len - 1);
3158 return @enumFromInt(Index, ip.items.len - 1);
31593159 }
31603160 }
31613161
......@@ -3183,14 +3183,14 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
31833183 assert(payload_type != .none);
31843184 ip.items.appendAssumeCapacity(.{
31853185 .tag = .type_optional,
3186 .data = @enumToInt(payload_type),
3186 .data = @intFromEnum(payload_type),
31873187 });
31883188 },
31893189 .anyframe_type => |payload_type| {
31903190 // payload_type might be none, indicating the type is `anyframe`.
31913191 ip.items.appendAssumeCapacity(.{
31923192 .tag = .type_anyframe,
3193 .data = @enumToInt(payload_type),
3193 .data = @intFromEnum(payload_type),
31943194 });
31953195 },
31963196 .error_union_type => |error_union_type| {
......@@ -3218,26 +3218,26 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
32183218 .inferred_error_set_type => |ies_index| {
32193219 ip.items.appendAssumeCapacity(.{
32203220 .tag = .type_inferred_error_set,
3221 .data = @enumToInt(ies_index),
3221 .data = @intFromEnum(ies_index),
32223222 });
32233223 },
32243224 .simple_type => |simple_type| {
32253225 ip.items.appendAssumeCapacity(.{
32263226 .tag = .simple_type,
3227 .data = @enumToInt(simple_type),
3227 .data = @intFromEnum(simple_type),
32283228 });
32293229 },
32303230 .simple_value => |simple_value| {
32313231 ip.items.appendAssumeCapacity(.{
32323232 .tag = .simple_value,
3233 .data = @enumToInt(simple_value),
3233 .data = @intFromEnum(simple_value),
32343234 });
32353235 },
32363236 .undef => |ty| {
32373237 assert(ty != .none);
32383238 ip.items.appendAssumeCapacity(.{
32393239 .tag = .undef,
3240 .data = @enumToInt(ty),
3240 .data = @intFromEnum(ty),
32413241 });
32423242 },
32433243 .runtime_value => |runtime_value| {
......@@ -3251,13 +3251,13 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
32513251 .struct_type => |struct_type| {
32523252 ip.items.appendAssumeCapacity(if (struct_type.index.unwrap()) |i| .{
32533253 .tag = .type_struct,
3254 .data = @enumToInt(i),
3254 .data = @intFromEnum(i),
32553255 } else if (struct_type.namespace.unwrap()) |i| .{
32563256 .tag = .type_struct_ns,
3257 .data = @enumToInt(i),
3257 .data = @intFromEnum(i),
32583258 } else .{
32593259 .tag = .type_struct,
3260 .data = @enumToInt(Module.Struct.OptionalIndex.none),
3260 .data = @intFromEnum(Module.Struct.OptionalIndex.none),
32613261 });
32623262 },
32633263
......@@ -3279,7 +3279,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
32793279 });
32803280 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.types));
32813281 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.values));
3282 return @intToEnum(Index, ip.items.len - 1);
3282 return @enumFromInt(Index, ip.items.len - 1);
32833283 }
32843284
32853285 assert(anon_struct_type.names.len == anon_struct_type.types.len);
......@@ -3297,7 +3297,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
32973297 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.types));
32983298 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.values));
32993299 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, anon_struct_type.names));
3300 return @intToEnum(Index, ip.items.len - 1);
3300 return @enumFromInt(Index, ip.items.len - 1);
33013301 },
33023302
33033303 .union_type => |union_type| {
......@@ -3307,7 +3307,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
33073307 .safety => .type_union_safety,
33083308 .tagged => .type_union_tagged,
33093309 },
3310 .data = @enumToInt(union_type.index),
3310 .data = @intFromEnum(union_type.index),
33113311 });
33123312 },
33133313
......@@ -3343,7 +3343,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
33433343 }),
33443344 });
33453345 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, enum_type.names));
3346 return @intToEnum(Index, ip.items.len - 1);
3346 return @enumFromInt(Index, ip.items.len - 1);
33473347 },
33483348 .explicit => return finishGetEnum(ip, gpa, enum_type, .type_enum_explicit),
33493349 .nonexhaustive => return finishGetEnum(ip, gpa, enum_type, .type_enum_nonexhaustive),
......@@ -3540,7 +3540,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
35403540 });
35413541 },
35423542 }
3543 assert(ptr.ty == ip.indexToKey(@intToEnum(Index, ip.items.len - 1)).ptr.ty);
3543 assert(ptr.ty == ip.indexToKey(@enumFromInt(Index, ip.items.len - 1)).ptr.ty);
35443544 },
35453545
35463546 .opt => |opt| {
......@@ -3548,7 +3548,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
35483548 assert(opt.val == .none or ip.indexToKey(opt.ty).opt_type == ip.typeOf(opt.val));
35493549 ip.items.appendAssumeCapacity(if (opt.val == .none) .{
35503550 .tag = .opt_null,
3551 .data = @enumToInt(opt.ty),
3551 .data = @intFromEnum(opt.ty),
35523552 } else .{
35533553 .tag = .opt_payload,
35543554 .data = try ip.addExtra(gpa, Tag.TypeValue{
......@@ -3574,7 +3574,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
35743574 .lazy_ty = lazy_ty,
35753575 }),
35763576 });
3577 return @intToEnum(Index, ip.items.len - 1);
3577 return @enumFromInt(Index, ip.items.len - 1);
35783578 },
35793579 }
35803580 switch (int.ty) {
......@@ -3715,7 +3715,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
37153715 .value = casted,
37163716 }),
37173717 });
3718 return @intToEnum(Index, ip.items.len - 1);
3718 return @enumFromInt(Index, ip.items.len - 1);
37193719 } else |_| {}
37203720
37213721 const tag: Tag = if (big_int.positive) .int_positive else .int_negative;
......@@ -3730,7 +3730,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
37303730 .value = casted,
37313731 }),
37323732 });
3733 return @intToEnum(Index, ip.items.len - 1);
3733 return @enumFromInt(Index, ip.items.len - 1);
37343734 }
37353735
37363736 var buf: [2]Limb = undefined;
......@@ -3772,7 +3772,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
37723772
37733773 .enum_literal => |enum_literal| ip.items.appendAssumeCapacity(.{
37743774 .tag = .enum_literal,
3775 .data = @enumToInt(enum_literal),
3775 .data = @intFromEnum(enum_literal),
37763776 }),
37773777
37783778 .enum_tag => |enum_tag| {
......@@ -3790,7 +3790,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
37903790
37913791 .empty_enum_value => |enum_or_union_ty| ip.items.appendAssumeCapacity(.{
37923792 .tag = .only_possible_value,
3793 .data = @enumToInt(enum_or_union_ty),
3793 .data = @intFromEnum(enum_or_union_ty),
37943794 }),
37953795
37963796 .float => |float| {
......@@ -3847,7 +3847,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
38473847 .vector_type, .anon_struct_type, .struct_type => .none,
38483848 else => unreachable,
38493849 };
3850 const len_including_sentinel = len + @boolToInt(sentinel != .none);
3850 const len_including_sentinel = len + @intFromBool(sentinel != .none);
38513851 switch (aggregate.storage) {
38523852 .bytes => |bytes| {
38533853 assert(child == .u8_type);
......@@ -3891,9 +3891,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
38913891 if (len == 0) {
38923892 ip.items.appendAssumeCapacity(.{
38933893 .tag = .only_possible_value,
3894 .data = @enumToInt(aggregate.ty),
3894 .data = @intFromEnum(aggregate.ty),
38953895 });
3896 return @intToEnum(Index, ip.items.len - 1);
3896 return @enumFromInt(Index, ip.items.len - 1);
38973897 }
38983898
38993899 switch (ty_key) {
......@@ -3919,9 +3919,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
39193919 // in the aggregate fields.
39203920 ip.items.appendAssumeCapacity(.{
39213921 .tag = .only_possible_value,
3922 .data = @enumToInt(aggregate.ty),
3922 .data = @intFromEnum(aggregate.ty),
39233923 });
3924 return @intToEnum(Index, ip.items.len - 1);
3924 return @enumFromInt(Index, ip.items.len - 1);
39253925 },
39263926 else => {},
39273927 }
......@@ -3960,7 +3960,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
39603960 .elem_val = elem,
39613961 }),
39623962 });
3963 return @intToEnum(Index, ip.items.len - 1);
3963 return @enumFromInt(Index, ip.items.len - 1);
39643964 }
39653965
39663966 if (child == .u8_type) bytes: {
......@@ -3994,7 +3994,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
39943994 @intCast(u8, ip.indexToKey(sentinel).int.storage.u64),
39953995 );
39963996 const string = if (has_internal_null)
3997 @intToEnum(String, string_bytes_index)
3997 @enumFromInt(String, string_bytes_index)
39983998 else
39993999 (try ip.getOrPutTrailingString(gpa, @intCast(usize, len_including_sentinel))).toString();
40004000 ip.items.appendAssumeCapacity(.{
......@@ -4004,7 +4004,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
40044004 .bytes = string,
40054005 }),
40064006 });
4007 return @intToEnum(Index, ip.items.len - 1);
4007 return @enumFromInt(Index, ip.items.len - 1);
40084008 }
40094009
40104010 try ip.extra.ensureUnusedCapacity(
......@@ -4018,7 +4018,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
40184018 }),
40194019 });
40204020 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, aggregate.storage.elems));
4021 if (sentinel != .none) ip.extra.appendAssumeCapacity(@enumToInt(sentinel));
4021 if (sentinel != .none) ip.extra.appendAssumeCapacity(@intFromEnum(sentinel));
40224022 },
40234023
40244024 .un => |un| {
......@@ -4046,7 +4046,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
40464046 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, memoized_call.arg_values));
40474047 },
40484048 }
4049 return @intToEnum(Index, ip.items.len - 1);
4049 return @enumFromInt(Index, ip.items.len - 1);
40504050}
40514051
40524052/// Provides API for completing an enum type after calling `getIncompleteEnum`.
......@@ -4060,7 +4060,7 @@ pub const IncompleteEnumType = struct {
40604060
40614061 pub fn setTagType(self: @This(), ip: *InternPool, tag_ty: Index) void {
40624062 assert(tag_ty == .noreturn_type or ip.isIntegerType(tag_ty));
4063 ip.extra.items[self.tag_ty_index] = @enumToInt(tag_ty);
4063 ip.extra.items[self.tag_ty_index] = @intFromEnum(tag_ty);
40644064 }
40654065
40664066 /// Returns the already-existing field with the same name, if any.
......@@ -4070,7 +4070,7 @@ pub const IncompleteEnumType = struct {
40704070 gpa: Allocator,
40714071 name: NullTerminatedString,
40724072 ) Allocator.Error!?u32 {
4073 const map = &ip.maps.items[@enumToInt(self.names_map)];
4073 const map = &ip.maps.items[@intFromEnum(self.names_map)];
40744074 const field_index = map.count();
40754075 const strings = ip.extra.items[self.names_start..][0..field_index];
40764076 const adapter: NullTerminatedString.Adapter = .{
......@@ -4078,7 +4078,7 @@ pub const IncompleteEnumType = struct {
40784078 };
40794079 const gop = try map.getOrPutAdapted(gpa, name, adapter);
40804080 if (gop.found_existing) return @intCast(u32, gop.index);
4081 ip.extra.items[self.names_start + field_index] = @enumToInt(name);
4081 ip.extra.items[self.names_start + field_index] = @intFromEnum(name);
40824082 return null;
40834083 }
40844084
......@@ -4090,8 +4090,8 @@ pub const IncompleteEnumType = struct {
40904090 gpa: Allocator,
40914091 value: Index,
40924092 ) Allocator.Error!?u32 {
4093 assert(ip.typeOf(value) == @intToEnum(Index, ip.extra.items[self.tag_ty_index]));
4094 const map = &ip.maps.items[@enumToInt(self.values_map.unwrap().?)];
4093 assert(ip.typeOf(value) == @enumFromInt(Index, ip.extra.items[self.tag_ty_index]));
4094 const map = &ip.maps.items[@intFromEnum(self.values_map.unwrap().?)];
40954095 const field_index = map.count();
40964096 const indexes = ip.extra.items[self.values_start..][0..field_index];
40974097 const adapter: Index.Adapter = .{
......@@ -4099,7 +4099,7 @@ pub const IncompleteEnumType = struct {
40994099 };
41004100 const gop = try map.getOrPutAdapted(gpa, value, adapter);
41014101 if (gop.found_existing) return @intCast(u32, gop.index);
4102 ip.extra.items[self.values_start + field_index] = @enumToInt(value);
4102 ip.extra.items[self.values_start + field_index] = @intFromEnum(value);
41034103 return null;
41044104 }
41054105};
......@@ -4156,9 +4156,9 @@ fn getIncompleteEnumAuto(
41564156 .tag = .type_enum_auto,
41574157 .data = extra_index,
41584158 });
4159 ip.extra.appendNTimesAssumeCapacity(@enumToInt(Index.none), enum_type.fields_len);
4159 ip.extra.appendNTimesAssumeCapacity(@intFromEnum(Index.none), enum_type.fields_len);
41604160 return .{
4161 .index = @intToEnum(Index, ip.items.len - 1),
4161 .index = @enumFromInt(Index, ip.items.len - 1),
41624162 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumAuto, "int_tag_type").?,
41634163 .names_map = names_map,
41644164 .names_start = extra_index + extra_fields_len,
......@@ -4207,9 +4207,9 @@ fn getIncompleteEnumExplicit(
42074207 .data = extra_index,
42084208 });
42094209 // This is both fields and values (if present).
4210 ip.extra.appendNTimesAssumeCapacity(@enumToInt(Index.none), reserved_len);
4210 ip.extra.appendNTimesAssumeCapacity(@intFromEnum(Index.none), reserved_len);
42114211 return .{
4212 .index = @intToEnum(Index, ip.items.len - 1),
4212 .index = @enumFromInt(Index, ip.items.len - 1),
42134213 .tag_ty_index = extra_index + std.meta.fieldIndex(EnumExplicit, "int_tag_type").?,
42144214 .names_map = names_map,
42154215 .names_start = extra_index + extra_fields_len,
......@@ -4248,13 +4248,13 @@ pub fn finishGetEnum(
42484248 });
42494249 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, enum_type.names));
42504250 ip.extra.appendSliceAssumeCapacity(@ptrCast([]const u32, enum_type.values));
4251 return @intToEnum(Index, ip.items.len - 1);
4251 return @enumFromInt(Index, ip.items.len - 1);
42524252}
42534253
42544254pub fn getIfExists(ip: *const InternPool, key: Key) ?Index {
42554255 const adapter: KeyAdapter = .{ .intern_pool = ip };
42564256 const index = ip.map.getIndexAdapted(key, adapter) orelse return null;
4257 return @intToEnum(Index, index);
4257 return @enumFromInt(Index, index);
42584258}
42594259
42604260pub fn getAssumeExists(ip: *const InternPool, key: Key) Index {
......@@ -4267,7 +4267,7 @@ fn addStringsToMap(
42674267 map_index: MapIndex,
42684268 strings: []const NullTerminatedString,
42694269) Allocator.Error!void {
4270 const map = &ip.maps.items[@enumToInt(map_index)];
4270 const map = &ip.maps.items[@intFromEnum(map_index)];
42714271 const adapter: NullTerminatedString.Adapter = .{ .strings = strings };
42724272 for (strings) |string| {
42734273 const gop = try map.getOrPutAdapted(gpa, string, adapter);
......@@ -4281,7 +4281,7 @@ fn addIndexesToMap(
42814281 map_index: MapIndex,
42824282 indexes: []const Index,
42834283) Allocator.Error!void {
4284 const map = &ip.maps.items[@enumToInt(map_index)];
4284 const map = &ip.maps.items[@intFromEnum(map_index)];
42854285 const adapter: Index.Adapter = .{ .indexes = indexes };
42864286 for (indexes) |index| {
42874287 const gop = try map.getOrPutAdapted(gpa, index, adapter);
......@@ -4292,7 +4292,7 @@ fn addIndexesToMap(
42924292fn addMap(ip: *InternPool, gpa: Allocator) Allocator.Error!MapIndex {
42934293 const ptr = try ip.maps.addOne(gpa);
42944294 ptr.* = .{};
4295 return @intToEnum(MapIndex, ip.maps.items.len - 1);
4295 return @enumFromInt(MapIndex, ip.maps.items.len - 1);
42964296}
42974297
42984298/// This operation only happens under compile error conditions.
......@@ -4324,22 +4324,22 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
43244324 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {
43254325 ip.extra.appendAssumeCapacity(switch (field.type) {
43264326 u32 => @field(extra, field.name),
4327 Index => @enumToInt(@field(extra, field.name)),
4328 Module.Decl.Index => @enumToInt(@field(extra, field.name)),
4329 Module.Namespace.Index => @enumToInt(@field(extra, field.name)),
4330 Module.Namespace.OptionalIndex => @enumToInt(@field(extra, field.name)),
4331 Module.Fn.Index => @enumToInt(@field(extra, field.name)),
4332 MapIndex => @enumToInt(@field(extra, field.name)),
4333 OptionalMapIndex => @enumToInt(@field(extra, field.name)),
4334 RuntimeIndex => @enumToInt(@field(extra, field.name)),
4335 String => @enumToInt(@field(extra, field.name)),
4336 NullTerminatedString => @enumToInt(@field(extra, field.name)),
4337 OptionalNullTerminatedString => @enumToInt(@field(extra, field.name)),
4327 Index => @intFromEnum(@field(extra, field.name)),
4328 Module.Decl.Index => @intFromEnum(@field(extra, field.name)),
4329 Module.Namespace.Index => @intFromEnum(@field(extra, field.name)),
4330 Module.Namespace.OptionalIndex => @intFromEnum(@field(extra, field.name)),
4331 Module.Fn.Index => @intFromEnum(@field(extra, field.name)),
4332 MapIndex => @intFromEnum(@field(extra, field.name)),
4333 OptionalMapIndex => @intFromEnum(@field(extra, field.name)),
4334 RuntimeIndex => @intFromEnum(@field(extra, field.name)),
4335 String => @intFromEnum(@field(extra, field.name)),
4336 NullTerminatedString => @intFromEnum(@field(extra, field.name)),
4337 OptionalNullTerminatedString => @intFromEnum(@field(extra, field.name)),
43384338 i32 => @bitCast(u32, @field(extra, field.name)),
43394339 Tag.TypePointer.Flags => @bitCast(u32, @field(extra, field.name)),
43404340 TypeFunction.Flags => @bitCast(u32, @field(extra, field.name)),
43414341 Tag.TypePointer.PackedOffset => @bitCast(u32, @field(extra, field.name)),
4342 Tag.TypePointer.VectorIndex => @enumToInt(@field(extra, field.name)),
4342 Tag.TypePointer.VectorIndex => @intFromEnum(@field(extra, field.name)),
43434343 Tag.Variable.Flags => @bitCast(u32, @field(extra, field.name)),
43444344 else => @compileError("bad field type: " ++ @typeName(field.type)),
43454345 });
......@@ -4365,7 +4365,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
43654365 inline for (@typeInfo(@TypeOf(extra)).Struct.fields, 0..) |field, i| {
43664366 const new: u32 = switch (field.type) {
43674367 u32 => @field(extra, field.name),
4368 Index => @enumToInt(@field(extra, field.name)),
4368 Index => @intFromEnum(@field(extra, field.name)),
43694369 else => @compileError("bad field type: " ++ @typeName(field.type)),
43704370 };
43714371 if (i % 2 == 0) {
......@@ -4392,22 +4392,22 @@ fn extraDataTrail(ip: *const InternPool, comptime T: type, index: usize) struct
43924392 const int32 = ip.extra.items[i + index];
43934393 @field(result, field.name) = switch (field.type) {
43944394 u32 => int32,
4395 Index => @intToEnum(Index, int32),
4396 Module.Decl.Index => @intToEnum(Module.Decl.Index, int32),
4397 Module.Namespace.Index => @intToEnum(Module.Namespace.Index, int32),
4398 Module.Namespace.OptionalIndex => @intToEnum(Module.Namespace.OptionalIndex, int32),
4399 Module.Fn.Index => @intToEnum(Module.Fn.Index, int32),
4400 MapIndex => @intToEnum(MapIndex, int32),
4401 OptionalMapIndex => @intToEnum(OptionalMapIndex, int32),
4402 RuntimeIndex => @intToEnum(RuntimeIndex, int32),
4403 String => @intToEnum(String, int32),
4404 NullTerminatedString => @intToEnum(NullTerminatedString, int32),
4405 OptionalNullTerminatedString => @intToEnum(OptionalNullTerminatedString, int32),
4395 Index => @enumFromInt(Index, int32),
4396 Module.Decl.Index => @enumFromInt(Module.Decl.Index, int32),
4397 Module.Namespace.Index => @enumFromInt(Module.Namespace.Index, int32),
4398 Module.Namespace.OptionalIndex => @enumFromInt(Module.Namespace.OptionalIndex, int32),
4399 Module.Fn.Index => @enumFromInt(Module.Fn.Index, int32),
4400 MapIndex => @enumFromInt(MapIndex, int32),
4401 OptionalMapIndex => @enumFromInt(OptionalMapIndex, int32),
4402 RuntimeIndex => @enumFromInt(RuntimeIndex, int32),
4403 String => @enumFromInt(String, int32),
4404 NullTerminatedString => @enumFromInt(NullTerminatedString, int32),
4405 OptionalNullTerminatedString => @enumFromInt(OptionalNullTerminatedString, int32),
44064406 i32 => @bitCast(i32, int32),
44074407 Tag.TypePointer.Flags => @bitCast(Tag.TypePointer.Flags, int32),
44084408 TypeFunction.Flags => @bitCast(TypeFunction.Flags, int32),
44094409 Tag.TypePointer.PackedOffset => @bitCast(Tag.TypePointer.PackedOffset, int32),
4410 Tag.TypePointer.VectorIndex => @intToEnum(Tag.TypePointer.VectorIndex, int32),
4410 Tag.TypePointer.VectorIndex => @enumFromInt(Tag.TypePointer.VectorIndex, int32),
44114411 Tag.Variable.Flags => @bitCast(Tag.Variable.Flags, int32),
44124412 else => @compileError("bad field type: " ++ @typeName(field.type)),
44134413 };
......@@ -4439,7 +4439,7 @@ fn limbData(ip: *const InternPool, comptime T: type, index: usize) T {
44394439
44404440 @field(result, field.name) = switch (field.type) {
44414441 u32 => int32,
4442 Index => @intToEnum(Index, int32),
4442 Index => @enumFromInt(Index, int32),
44434443 else => @compileError("bad field type: " ++ @typeName(field.type)),
44444444 };
44454445 }
......@@ -4475,7 +4475,7 @@ fn limbsSliceToIndex(ip: *const InternPool, limbs: []const Limb) LimbsAsIndexes
44754475 };
44764476 // TODO: https://github.com/ziglang/zig/issues/1738
44774477 return .{
4478 .start = @intCast(u32, @divExact(@ptrToInt(limbs.ptr) - @ptrToInt(host_slice.ptr), @sizeOf(Limb))),
4478 .start = @intCast(u32, @divExact(@intFromPtr(limbs.ptr) - @intFromPtr(host_slice.ptr), @sizeOf(Limb))),
44794479 .len = @intCast(u32, limbs.len),
44804480 };
44814481}
......@@ -4536,16 +4536,16 @@ pub fn slicePtrType(ip: *const InternPool, i: Index) Index {
45364536 .slice_const_u8_sentinel_0_type => return .manyptr_const_u8_sentinel_0_type,
45374537 else => {},
45384538 }
4539 const item = ip.items.get(@enumToInt(i));
4539 const item = ip.items.get(@intFromEnum(i));
45404540 switch (item.tag) {
4541 .type_slice => return @intToEnum(Index, item.data),
4541 .type_slice => return @enumFromInt(Index, item.data),
45424542 else => unreachable, // not a slice type
45434543 }
45444544}
45454545
45464546/// Given a slice value, returns the value of the ptr field.
45474547pub fn slicePtr(ip: *const InternPool, i: Index) Index {
4548 const item = ip.items.get(@enumToInt(i));
4548 const item = ip.items.get(@intFromEnum(i));
45494549 switch (item.tag) {
45504550 .ptr_slice => return ip.extraData(PtrSlice, item.data).ptr,
45514551 else => unreachable, // not a slice value
......@@ -4554,7 +4554,7 @@ pub fn slicePtr(ip: *const InternPool, i: Index) Index {
45544554
45554555/// Given a slice value, returns the value of the len field.
45564556pub fn sliceLen(ip: *const InternPool, i: Index) Index {
4557 const item = ip.items.get(@enumToInt(i));
4557 const item = ip.items.get(@intFromEnum(i));
45584558 switch (item.tag) {
45594559 .ptr_slice => return ip.extraData(PtrSlice, item.data).len,
45604560 else => unreachable, // not a slice value
......@@ -4841,28 +4841,28 @@ pub fn getCoercedInts(ip: *InternPool, gpa: Allocator, int: Key.Int, new_ty: Ind
48414841pub fn indexToStructType(ip: *const InternPool, val: Index) Module.Struct.OptionalIndex {
48424842 assert(val != .none);
48434843 const tags = ip.items.items(.tag);
4844 if (tags[@enumToInt(val)] != .type_struct) return .none;
4844 if (tags[@intFromEnum(val)] != .type_struct) return .none;
48454845 const datas = ip.items.items(.data);
4846 return @intToEnum(Module.Struct.Index, datas[@enumToInt(val)]).toOptional();
4846 return @enumFromInt(Module.Struct.Index, datas[@intFromEnum(val)]).toOptional();
48474847}
48484848
48494849pub fn indexToUnionType(ip: *const InternPool, val: Index) Module.Union.OptionalIndex {
48504850 assert(val != .none);
48514851 const tags = ip.items.items(.tag);
4852 switch (tags[@enumToInt(val)]) {
4852 switch (tags[@intFromEnum(val)]) {
48534853 .type_union_tagged, .type_union_untagged, .type_union_safety => {},
48544854 else => return .none,
48554855 }
48564856 const datas = ip.items.items(.data);
4857 return @intToEnum(Module.Union.Index, datas[@enumToInt(val)]).toOptional();
4857 return @enumFromInt(Module.Union.Index, datas[@intFromEnum(val)]).toOptional();
48584858}
48594859
48604860pub fn indexToFuncType(ip: *const InternPool, val: Index) ?Key.FuncType {
48614861 assert(val != .none);
48624862 const tags = ip.items.items(.tag);
48634863 const datas = ip.items.items(.data);
4864 switch (tags[@enumToInt(val)]) {
4865 .type_function => return indexToKeyFuncType(ip, datas[@enumToInt(val)]),
4864 switch (tags[@intFromEnum(val)]) {
4865 .type_function => return indexToKeyFuncType(ip, datas[@intFromEnum(val)]),
48664866 else => return null,
48674867 }
48684868}
......@@ -4870,17 +4870,17 @@ pub fn indexToFuncType(ip: *const InternPool, val: Index) ?Key.FuncType {
48704870pub fn indexToFunc(ip: *const InternPool, val: Index) Module.Fn.OptionalIndex {
48714871 assert(val != .none);
48724872 const tags = ip.items.items(.tag);
4873 if (tags[@enumToInt(val)] != .func) return .none;
4873 if (tags[@intFromEnum(val)] != .func) return .none;
48744874 const datas = ip.items.items(.data);
4875 return ip.extraData(Tag.Func, datas[@enumToInt(val)]).index.toOptional();
4875 return ip.extraData(Tag.Func, datas[@intFromEnum(val)]).index.toOptional();
48764876}
48774877
48784878pub fn indexToInferredErrorSetType(ip: *const InternPool, val: Index) Module.Fn.InferredErrorSet.OptionalIndex {
48794879 assert(val != .none);
48804880 const tags = ip.items.items(.tag);
4881 if (tags[@enumToInt(val)] != .type_inferred_error_set) return .none;
4881 if (tags[@intFromEnum(val)] != .type_inferred_error_set) return .none;
48824882 const datas = ip.items.items(.data);
4883 return @intToEnum(Module.Fn.InferredErrorSet.Index, datas[@enumToInt(val)]).toOptional();
4883 return @enumFromInt(Module.Fn.InferredErrorSet.Index, datas[@intFromEnum(val)]).toOptional();
48844884}
48854885
48864886/// includes .comptime_int_type
......@@ -4956,9 +4956,9 @@ pub fn isAggregateType(ip: *const InternPool, ty: Index) bool {
49564956
49574957/// The is only legal because the initializer is not part of the hash.
49584958pub fn mutateVarInit(ip: *InternPool, index: Index, init_index: Index) void {
4959 const item = ip.items.get(@enumToInt(index));
4959 const item = ip.items.get(@intFromEnum(index));
49604960 assert(item.tag == .variable);
4961 ip.extra.items[item.data + std.meta.fieldIndex(Tag.Variable, "init").?] = @enumToInt(init_index);
4961 ip.extra.items[item.data + std.meta.fieldIndex(Tag.Variable, "init").?] = @intFromEnum(init_index);
49624962}
49634963
49644964pub fn dump(ip: *const InternPool) void {
......@@ -5038,7 +5038,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {
50385038 .type_enum_auto => @sizeOf(EnumAuto),
50395039 .type_opaque => @sizeOf(Key.OpaqueType),
50405040 .type_struct => b: {
5041 const struct_index = @intToEnum(Module.Struct.Index, data);
5041 const struct_index = @enumFromInt(Module.Struct.Index, data);
50425042 const struct_obj = ip.structPtrConst(struct_index);
50435043 break :b @sizeOf(Module.Struct) +
50445044 @sizeOf(Module.Namespace) +
......@@ -5107,7 +5107,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {
51075107 const info = ip.extraData(Bytes, data);
51085108 const len = @intCast(u32, ip.aggregateTypeLenIncludingSentinel(info.ty));
51095109 break :b @sizeOf(Bytes) + len +
5110 @boolToInt(ip.string_bytes.items[@enumToInt(info.bytes) + len - 1] != 0);
5110 @intFromBool(ip.string_bytes.items[@intFromEnum(info.bytes) + len - 1] != 0);
51115111 },
51125112 .aggregate => b: {
51135113 const info = ip.extraData(Tag.Aggregate, data);
......@@ -5162,8 +5162,8 @@ fn dumpAllFallible(ip: *const InternPool) anyerror!void {
51625162 for (tags, datas, 0..) |tag, data, i| {
51635163 try w.print("${d} = {s}(", .{ i, @tagName(tag) });
51645164 switch (tag) {
5165 .simple_type => try w.print("{s}", .{@tagName(@intToEnum(SimpleType, data))}),
5166 .simple_value => try w.print("{s}", .{@tagName(@intToEnum(SimpleValue, data))}),
5165 .simple_type => try w.print("{s}", .{@tagName(@enumFromInt(SimpleType, data))}),
5166 .simple_value => try w.print("{s}", .{@tagName(@enumFromInt(SimpleValue, data))}),
51675167
51685168 .type_int_signed,
51695169 .type_int_unsigned,
......@@ -5246,11 +5246,11 @@ fn dumpAllFallible(ip: *const InternPool) anyerror!void {
52465246}
52475247
52485248pub fn structPtr(ip: *InternPool, index: Module.Struct.Index) *Module.Struct {
5249 return ip.allocated_structs.at(@enumToInt(index));
5249 return ip.allocated_structs.at(@intFromEnum(index));
52505250}
52515251
52525252pub fn structPtrConst(ip: *const InternPool, index: Module.Struct.Index) *const Module.Struct {
5253 return ip.allocated_structs.at(@enumToInt(index));
5253 return ip.allocated_structs.at(@intFromEnum(index));
52545254}
52555255
52565256pub fn structPtrUnwrapConst(ip: *const InternPool, index: Module.Struct.OptionalIndex) ?*const Module.Struct {
......@@ -5258,27 +5258,27 @@ pub fn structPtrUnwrapConst(ip: *const InternPool, index: Module.Struct.Optional
52585258}
52595259
52605260pub fn unionPtr(ip: *InternPool, index: Module.Union.Index) *Module.Union {
5261 return ip.allocated_unions.at(@enumToInt(index));
5261 return ip.allocated_unions.at(@intFromEnum(index));
52625262}
52635263
52645264pub fn unionPtrConst(ip: *const InternPool, index: Module.Union.Index) *const Module.Union {
5265 return ip.allocated_unions.at(@enumToInt(index));
5265 return ip.allocated_unions.at(@intFromEnum(index));
52665266}
52675267
52685268pub fn funcPtr(ip: *InternPool, index: Module.Fn.Index) *Module.Fn {
5269 return ip.allocated_funcs.at(@enumToInt(index));
5269 return ip.allocated_funcs.at(@intFromEnum(index));
52705270}
52715271
52725272pub fn funcPtrConst(ip: *const InternPool, index: Module.Fn.Index) *const Module.Fn {
5273 return ip.allocated_funcs.at(@enumToInt(index));
5273 return ip.allocated_funcs.at(@intFromEnum(index));
52745274}
52755275
52765276pub fn inferredErrorSetPtr(ip: *InternPool, index: Module.Fn.InferredErrorSet.Index) *Module.Fn.InferredErrorSet {
5277 return ip.allocated_inferred_error_sets.at(@enumToInt(index));
5277 return ip.allocated_inferred_error_sets.at(@intFromEnum(index));
52785278}
52795279
52805280pub fn inferredErrorSetPtrConst(ip: *const InternPool, index: Module.Fn.InferredErrorSet.Index) *const Module.Fn.InferredErrorSet {
5281 return ip.allocated_inferred_error_sets.at(@enumToInt(index));
5281 return ip.allocated_inferred_error_sets.at(@intFromEnum(index));
52825282}
52835283
52845284pub fn createStruct(
......@@ -5287,12 +5287,12 @@ pub fn createStruct(
52875287 initialization: Module.Struct,
52885288) Allocator.Error!Module.Struct.Index {
52895289 if (ip.structs_free_list.popOrNull()) |index| {
5290 ip.allocated_structs.at(@enumToInt(index)).* = initialization;
5290 ip.allocated_structs.at(@intFromEnum(index)).* = initialization;
52915291 return index;
52925292 }
52935293 const ptr = try ip.allocated_structs.addOne(gpa);
52945294 ptr.* = initialization;
5295 return @intToEnum(Module.Struct.Index, ip.allocated_structs.len - 1);
5295 return @enumFromInt(Module.Struct.Index, ip.allocated_structs.len - 1);
52965296}
52975297
52985298pub fn destroyStruct(ip: *InternPool, gpa: Allocator, index: Module.Struct.Index) void {
......@@ -5309,12 +5309,12 @@ pub fn createUnion(
53095309 initialization: Module.Union,
53105310) Allocator.Error!Module.Union.Index {
53115311 if (ip.unions_free_list.popOrNull()) |index| {
5312 ip.allocated_unions.at(@enumToInt(index)).* = initialization;
5312 ip.allocated_unions.at(@intFromEnum(index)).* = initialization;
53135313 return index;
53145314 }
53155315 const ptr = try ip.allocated_unions.addOne(gpa);
53165316 ptr.* = initialization;
5317 return @intToEnum(Module.Union.Index, ip.allocated_unions.len - 1);
5317 return @enumFromInt(Module.Union.Index, ip.allocated_unions.len - 1);
53185318}
53195319
53205320pub fn destroyUnion(ip: *InternPool, gpa: Allocator, index: Module.Union.Index) void {
......@@ -5331,12 +5331,12 @@ pub fn createFunc(
53315331 initialization: Module.Fn,
53325332) Allocator.Error!Module.Fn.Index {
53335333 if (ip.funcs_free_list.popOrNull()) |index| {
5334 ip.allocated_funcs.at(@enumToInt(index)).* = initialization;
5334 ip.allocated_funcs.at(@intFromEnum(index)).* = initialization;
53355335 return index;
53365336 }
53375337 const ptr = try ip.allocated_funcs.addOne(gpa);
53385338 ptr.* = initialization;
5339 return @intToEnum(Module.Fn.Index, ip.allocated_funcs.len - 1);
5339 return @enumFromInt(Module.Fn.Index, ip.allocated_funcs.len - 1);
53405340}
53415341
53425342pub fn destroyFunc(ip: *InternPool, gpa: Allocator, index: Module.Fn.Index) void {
......@@ -5353,12 +5353,12 @@ pub fn createInferredErrorSet(
53535353 initialization: Module.Fn.InferredErrorSet,
53545354) Allocator.Error!Module.Fn.InferredErrorSet.Index {
53555355 if (ip.inferred_error_sets_free_list.popOrNull()) |index| {
5356 ip.allocated_inferred_error_sets.at(@enumToInt(index)).* = initialization;
5356 ip.allocated_inferred_error_sets.at(@intFromEnum(index)).* = initialization;
53575357 return index;
53585358 }
53595359 const ptr = try ip.allocated_inferred_error_sets.addOne(gpa);
53605360 ptr.* = initialization;
5361 return @intToEnum(Module.Fn.InferredErrorSet.Index, ip.allocated_inferred_error_sets.len - 1);
5361 return @enumFromInt(Module.Fn.InferredErrorSet.Index, ip.allocated_inferred_error_sets.len - 1);
53625362}
53635363
53645364pub fn destroyInferredErrorSet(ip: *InternPool, gpa: Allocator, index: Module.Fn.InferredErrorSet.Index) void {
......@@ -5425,11 +5425,11 @@ pub fn getOrPutTrailingString(
54255425 });
54265426 if (gop.found_existing) {
54275427 string_bytes.shrinkRetainingCapacity(str_index);
5428 return @intToEnum(NullTerminatedString, gop.key_ptr.*);
5428 return @enumFromInt(NullTerminatedString, gop.key_ptr.*);
54295429 } else {
54305430 gop.key_ptr.* = str_index;
54315431 string_bytes.appendAssumeCapacity(0);
5432 return @intToEnum(NullTerminatedString, str_index);
5432 return @enumFromInt(NullTerminatedString, str_index);
54335433 }
54345434}
54355435
......@@ -5437,7 +5437,7 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString {
54375437 if (ip.string_table.getKeyAdapted(s, std.hash_map.StringIndexAdapter{
54385438 .bytes = &ip.string_bytes,
54395439 })) |index| {
5440 return @intToEnum(NullTerminatedString, index).toOptional();
5440 return @enumFromInt(NullTerminatedString, index).toOptional();
54415441 } else {
54425442 return .none;
54435443 }
......@@ -5445,7 +5445,7 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString {
54455445
54465446pub fn stringToSlice(ip: *const InternPool, s: NullTerminatedString) [:0]const u8 {
54475447 const string_bytes = ip.string_bytes.items;
5448 const start = @enumToInt(s);
5448 const start = @intFromEnum(s);
54495449 var end: usize = start;
54505450 while (string_bytes[end] != 0) end += 1;
54515451 return string_bytes[start..end :0];
......@@ -5543,7 +5543,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
55435543
55445544 // This optimization on tags is needed so that indexToKey can call
55455545 // typeOf without being recursive.
5546 _ => switch (ip.items.items(.tag)[@enumToInt(index)]) {
5546 _ => switch (ip.items.items(.tag)[@intFromEnum(index)]) {
55475547 .type_int_signed,
55485548 .type_int_unsigned,
55495549 .type_array_big,
......@@ -5574,7 +5574,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
55745574 .undef,
55755575 .opt_null,
55765576 .only_possible_value,
5577 => @intToEnum(Index, ip.items.items(.data)[@enumToInt(index)]),
5577 => @enumFromInt(Index, ip.items.items(.data)[@intFromEnum(index)]),
55785578
55795579 .simple_value => unreachable, // handled via Index above
55805580
......@@ -5604,9 +5604,9 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
56045604 .aggregate,
56055605 .repeated,
56065606 => |t| {
5607 const extra_index = ip.items.items(.data)[@enumToInt(index)];
5607 const extra_index = ip.items.items(.data)[@intFromEnum(index)];
56085608 const field_index = std.meta.fieldIndex(t.Payload(), "ty").?;
5609 return @intToEnum(Index, ip.extra.items[extra_index + field_index]);
5609 return @enumFromInt(Index, ip.extra.items[extra_index + field_index]);
56105610 },
56115611
56125612 .int_u8 => .u8_type,
......@@ -5622,7 +5622,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
56225622 // Note these are stored in limbs data, not extra data.
56235623 .int_positive,
56245624 .int_negative,
5625 => ip.limbData(Int, ip.items.items(.data)[@enumToInt(index)]).ty,
5625 => ip.limbData(Int, ip.items.items(.data)[@intFromEnum(index)]).ty,
56265626
56275627 .enum_literal => .enum_literal_type,
56285628 .float_f16 => .f16_type,
......@@ -5648,7 +5648,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
56485648/// Assumes that the enum's field indexes equal its value tags.
56495649pub fn toEnum(ip: *const InternPool, comptime E: type, i: Index) E {
56505650 const int = ip.indexToKey(i).enum_tag.int;
5651 return @intToEnum(E, ip.indexToKey(int).int.storage.u64);
5651 return @enumFromInt(E, ip.indexToKey(int).int.storage.u64);
56525652}
56535653
56545654pub fn aggregateTypeLen(ip: *const InternPool, ty: Index) u64 {
......@@ -5665,7 +5665,7 @@ pub fn aggregateTypeLenIncludingSentinel(ip: *const InternPool, ty: Index) u64 {
56655665 return switch (ip.indexToKey(ty)) {
56665666 .struct_type => |struct_type| ip.structPtrConst(struct_type.index.unwrap() orelse return 0).fields.count(),
56675667 .anon_struct_type => |anon_struct_type| anon_struct_type.types.len,
5668 .array_type => |array_type| array_type.len + @boolToInt(array_type.sentinel != .none),
5668 .array_type => |array_type| array_type.len + @intFromBool(array_type.sentinel != .none),
56695669 .vector_type => |vector_type| vector_type.len,
56705670 else => unreachable,
56715671 };
......@@ -5783,7 +5783,7 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
57835783
57845784 .var_args_param_type => unreachable, // special tag
57855785
5786 _ => switch (ip.items.items(.tag)[@enumToInt(index)]) {
5786 _ => switch (ip.items.items(.tag)[@intFromEnum(index)]) {
57875787 .type_int_signed,
57885788 .type_int_unsigned,
57895789 => .Int,
src/Liveness.zig+11-11
......@@ -371,9 +371,9 @@ pub fn categorizeOperand(
371371 .struct_field_ptr_index_2,
372372 .struct_field_ptr_index_3,
373373 .array_to_slice,
374 .float_to_int,
375 .float_to_int_optimized,
376 .int_to_float,
374 .int_from_float,
375 .int_from_float_optimized,
376 .float_from_int,
377377 .get_union_tag,
378378 .clz,
379379 .ctz,
......@@ -407,8 +407,8 @@ pub fn categorizeOperand(
407407 .is_non_err,
408408 .is_err_ptr,
409409 .is_non_err_ptr,
410 .ptrtoint,
411 .bool_to_int,
410 .int_from_ptr,
411 .int_from_bool,
412412 .is_named_enum_value,
413413 .tag_name,
414414 .error_name,
......@@ -1007,9 +1007,9 @@ fn analyzeInst(
10071007 .struct_field_ptr_index_2,
10081008 .struct_field_ptr_index_3,
10091009 .array_to_slice,
1010 .float_to_int,
1011 .float_to_int_optimized,
1012 .int_to_float,
1010 .int_from_float,
1011 .int_from_float_optimized,
1012 .float_from_int,
10131013 .get_union_tag,
10141014 .clz,
10151015 .ctz,
......@@ -1034,8 +1034,8 @@ fn analyzeInst(
10341034 .is_non_err,
10351035 .is_err_ptr,
10361036 .is_non_err_ptr,
1037 .ptrtoint,
1038 .bool_to_int,
1037 .int_from_ptr,
1038 .int_from_bool,
10391039 .is_named_enum_value,
10401040 .tag_name,
10411041 .error_name,
......@@ -1286,7 +1286,7 @@ fn analyzeOperands(
12861286 break :blk true;
12871287 };
12881288
1289 var tomb_bits: Bpi = @as(Bpi, @boolToInt(immediate_death)) << (bpi - 1);
1289 var tomb_bits: Bpi = @as(Bpi, @intFromBool(immediate_death)) << (bpi - 1);
12901290
12911291 // If our result is unused and the instruction doesn't need to be lowered, backends will
12921292 // skip the lowering of this instruction, so we don't want to record uses of operands.
src/Liveness/Verify.zig+5-5
......@@ -97,9 +97,9 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
9797 .struct_field_ptr_index_2,
9898 .struct_field_ptr_index_3,
9999 .array_to_slice,
100 .float_to_int,
101 .float_to_int_optimized,
102 .int_to_float,
100 .int_from_float,
101 .int_from_float_optimized,
102 .float_from_int,
103103 .get_union_tag,
104104 .clz,
105105 .ctz,
......@@ -123,8 +123,8 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
123123 .is_non_err,
124124 .is_err_ptr,
125125 .is_non_err_ptr,
126 .ptrtoint,
127 .bool_to_int,
126 .int_from_ptr,
127 .int_from_bool,
128128 .is_named_enum_value,
129129 .tag_name,
130130 .error_name,
src/Manifest.zig+4-4
......@@ -39,7 +39,7 @@ pub const multihash_function: MultihashFunction = switch (Hash) {
3939comptime {
4040 // We avoid unnecessary uleb128 code in hexDigest by asserting here the
4141 // values are small enough to be contained in the one-byte encoding.
42 assert(@enumToInt(multihash_function) < 127);
42 assert(@intFromEnum(multihash_function) < 127);
4343 assert(Hash.digest_length < 127);
4444}
4545pub const multihash_len = 1 + 1 + Hash.digest_length;
......@@ -117,8 +117,8 @@ test hex64 {
117117pub fn hexDigest(digest: [Hash.digest_length]u8) [multihash_len * 2]u8 {
118118 var result: [multihash_len * 2]u8 = undefined;
119119
120 result[0] = hex_charset[@enumToInt(multihash_function) >> 4];
121 result[1] = hex_charset[@enumToInt(multihash_function) & 15];
120 result[0] = hex_charset[@intFromEnum(multihash_function) >> 4];
121 result[1] = hex_charset[@intFromEnum(multihash_function) & 15];
122122
123123 result[2] = hex_charset[Hash.digest_length >> 4];
124124 result[3] = hex_charset[Hash.digest_length & 15];
......@@ -284,7 +284,7 @@ const Parse = struct {
284284 @errorName(err),
285285 });
286286 };
287 if (@intToEnum(MultihashFunction, their_multihash_func) != multihash_function) {
287 if (@enumFromInt(MultihashFunction, their_multihash_func) != multihash_function) {
288288 return fail(p, tok, "unsupported hash function: only sha2-256 is supported", .{});
289289 }
290290 }
src/Module.zig+50-50
......@@ -223,7 +223,7 @@ pub const MonomorphedFuncsContext = struct {
223223
224224 pub fn hash(ctx: @This(), key: MonomorphedFuncKey) u64 {
225225 const key_args = ctx.mod.monomorphed_func_keys.items[key.args_index..][0..key.args_len];
226 return std.hash.Wyhash.hash(@enumToInt(key.func), std.mem.sliceAsBytes(key_args));
226 return std.hash.Wyhash.hash(@intFromEnum(key.func), std.mem.sliceAsBytes(key_args));
227227 }
228228};
229229
......@@ -236,7 +236,7 @@ pub const MonomorphedFuncsAdaptedContext = struct {
236236 }
237237
238238 pub fn hash(_: @This(), adapted_key: MonomorphedFuncAdaptedKey) u64 {
239 return std.hash.Wyhash.hash(@enumToInt(adapted_key.func), std.mem.sliceAsBytes(adapted_key.args));
239 return std.hash.Wyhash.hash(@intFromEnum(adapted_key.func), std.mem.sliceAsBytes(adapted_key.args));
240240 }
241241};
242242
......@@ -263,7 +263,7 @@ pub const GlobalEmitH = struct {
263263 allocated_emit_h: std.SegmentedList(EmitH, 0) = .{},
264264
265265 pub fn declPtr(global_emit_h: *GlobalEmitH, decl_index: Decl.Index) *EmitH {
266 return global_emit_h.allocated_emit_h.at(@enumToInt(decl_index));
266 return global_emit_h.allocated_emit_h.at(@intFromEnum(decl_index));
267267 }
268268};
269269
......@@ -553,7 +553,7 @@ pub const Decl = struct {
553553 _,
554554
555555 pub fn toOptional(i: Index) OptionalIndex {
556 return @intToEnum(OptionalIndex, @enumToInt(i));
556 return @enumFromInt(OptionalIndex, @intFromEnum(i));
557557 }
558558 };
559559
......@@ -562,12 +562,12 @@ pub const Decl = struct {
562562 _,
563563
564564 pub fn init(oi: ?Index) OptionalIndex {
565 return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none));
565 return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none));
566566 }
567567
568568 pub fn unwrap(oi: OptionalIndex) ?Index {
569569 if (oi == .none) return null;
570 return @intToEnum(Index, @enumToInt(oi));
570 return @enumFromInt(Index, @intFromEnum(oi));
571571 }
572572 };
573573
......@@ -632,23 +632,23 @@ pub const Decl = struct {
632632 if (!decl.has_align) return .none;
633633 assert(decl.zir_decl_index != 0);
634634 const zir = decl.getFileScope(mod).zir;
635 return @intToEnum(Zir.Inst.Ref, zir.extra[decl.zir_decl_index + 8]);
635 return @enumFromInt(Zir.Inst.Ref, zir.extra[decl.zir_decl_index + 8]);
636636 }
637637
638638 pub fn zirLinksectionRef(decl: Decl, mod: *Module) Zir.Inst.Ref {
639639 if (!decl.has_linksection_or_addrspace) return .none;
640640 assert(decl.zir_decl_index != 0);
641641 const zir = decl.getFileScope(mod).zir;
642 const extra_index = decl.zir_decl_index + 8 + @boolToInt(decl.has_align);
643 return @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
642 const extra_index = decl.zir_decl_index + 8 + @intFromBool(decl.has_align);
643 return @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
644644 }
645645
646646 pub fn zirAddrspaceRef(decl: Decl, mod: *Module) Zir.Inst.Ref {
647647 if (!decl.has_linksection_or_addrspace) return .none;
648648 assert(decl.zir_decl_index != 0);
649649 const zir = decl.getFileScope(mod).zir;
650 const extra_index = decl.zir_decl_index + 8 + @boolToInt(decl.has_align) + 1;
651 return @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
650 const extra_index = decl.zir_decl_index + 8 + @intFromBool(decl.has_align) + 1;
651 return @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
652652 }
653653
654654 pub fn relativeToLine(decl: Decl, offset: u32) u32 {
......@@ -831,7 +831,7 @@ pub const Decl = struct {
831831 decl.scope.sub_file_path,
832832 loc.line + 1,
833833 loc.column + 1,
834 @enumToInt(decl.name),
834 @intFromEnum(decl.name),
835835 @tagName(decl.analysis),
836836 });
837837 if (decl.has_tv) {
......@@ -927,7 +927,7 @@ pub const Struct = struct {
927927 _,
928928
929929 pub fn toOptional(i: Index) OptionalIndex {
930 return @intToEnum(OptionalIndex, @enumToInt(i));
930 return @enumFromInt(OptionalIndex, @intFromEnum(i));
931931 }
932932 };
933933
......@@ -936,12 +936,12 @@ pub const Struct = struct {
936936 _,
937937
938938 pub fn init(oi: ?Index) OptionalIndex {
939 return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none));
939 return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none));
940940 }
941941
942942 pub fn unwrap(oi: OptionalIndex) ?Index {
943943 if (oi == .none) return null;
944 return @intToEnum(Index, @enumToInt(oi));
944 return @enumFromInt(Index, @intFromEnum(oi));
945945 }
946946 };
947947
......@@ -1128,7 +1128,7 @@ pub const Union = struct {
11281128 _,
11291129
11301130 pub fn toOptional(i: Index) OptionalIndex {
1131 return @intToEnum(OptionalIndex, @enumToInt(i));
1131 return @enumFromInt(OptionalIndex, @intFromEnum(i));
11321132 }
11331133 };
11341134
......@@ -1137,12 +1137,12 @@ pub const Union = struct {
11371137 _,
11381138
11391139 pub fn init(oi: ?Index) OptionalIndex {
1140 return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none));
1140 return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none));
11411141 }
11421142
11431143 pub fn unwrap(oi: OptionalIndex) ?Index {
11441144 if (oi == .none) return null;
1145 return @intToEnum(Index, @enumToInt(oi));
1145 return @enumFromInt(Index, @intFromEnum(oi));
11461146 }
11471147 };
11481148
......@@ -1424,7 +1424,7 @@ pub const Fn = struct {
14241424 _,
14251425
14261426 pub fn toOptional(i: Index) OptionalIndex {
1427 return @intToEnum(OptionalIndex, @enumToInt(i));
1427 return @enumFromInt(OptionalIndex, @intFromEnum(i));
14281428 }
14291429 };
14301430
......@@ -1433,12 +1433,12 @@ pub const Fn = struct {
14331433 _,
14341434
14351435 pub fn init(oi: ?Index) OptionalIndex {
1436 return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none));
1436 return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none));
14371437 }
14381438
14391439 pub fn unwrap(oi: OptionalIndex) ?Index {
14401440 if (oi == .none) return null;
1441 return @intToEnum(Index, @enumToInt(oi));
1441 return @enumFromInt(Index, @intFromEnum(oi));
14421442 }
14431443 };
14441444
......@@ -1492,7 +1492,7 @@ pub const Fn = struct {
14921492 _,
14931493
14941494 pub fn toOptional(i: InferredErrorSet.Index) InferredErrorSet.OptionalIndex {
1495 return @intToEnum(InferredErrorSet.OptionalIndex, @enumToInt(i));
1495 return @enumFromInt(InferredErrorSet.OptionalIndex, @intFromEnum(i));
14961496 }
14971497 };
14981498
......@@ -1501,12 +1501,12 @@ pub const Fn = struct {
15011501 _,
15021502
15031503 pub fn init(oi: ?InferredErrorSet.Index) InferredErrorSet.OptionalIndex {
1504 return @intToEnum(InferredErrorSet.OptionalIndex, @enumToInt(oi orelse return .none));
1504 return @enumFromInt(InferredErrorSet.OptionalIndex, @intFromEnum(oi orelse return .none));
15051505 }
15061506
15071507 pub fn unwrap(oi: InferredErrorSet.OptionalIndex) ?InferredErrorSet.Index {
15081508 if (oi == .none) return null;
1509 return @intToEnum(InferredErrorSet.Index, @enumToInt(oi));
1509 return @enumFromInt(InferredErrorSet.Index, @intFromEnum(oi));
15101510 }
15111511 };
15121512
......@@ -1594,7 +1594,7 @@ pub const DeclAdapter = struct {
15941594
15951595 pub fn hash(self: @This(), s: InternPool.NullTerminatedString) u32 {
15961596 _ = self;
1597 return std.hash.uint32(@enumToInt(s));
1597 return std.hash.uint32(@intFromEnum(s));
15981598 }
15991599
16001600 pub fn eql(self: @This(), a: InternPool.NullTerminatedString, b_decl_index: Decl.Index, b_index: usize) bool {
......@@ -1628,7 +1628,7 @@ pub const Namespace = struct {
16281628 _,
16291629
16301630 pub fn toOptional(i: Index) OptionalIndex {
1631 return @intToEnum(OptionalIndex, @enumToInt(i));
1631 return @enumFromInt(OptionalIndex, @intFromEnum(i));
16321632 }
16331633 };
16341634
......@@ -1637,12 +1637,12 @@ pub const Namespace = struct {
16371637 _,
16381638
16391639 pub fn init(oi: ?Index) OptionalIndex {
1640 return @intToEnum(OptionalIndex, @enumToInt(oi orelse return .none));
1640 return @enumFromInt(OptionalIndex, @intFromEnum(oi orelse return .none));
16411641 }
16421642
16431643 pub fn unwrap(oi: OptionalIndex) ?Index {
16441644 if (oi == .none) return null;
1645 return @intToEnum(Index, @enumToInt(oi));
1645 return @enumFromInt(Index, @intFromEnum(oi));
16461646 }
16471647 };
16481648
......@@ -1651,7 +1651,7 @@ pub const Namespace = struct {
16511651
16521652 pub fn hash(ctx: @This(), decl_index: Decl.Index) u32 {
16531653 const decl = ctx.module.declPtr(decl_index);
1654 return std.hash.uint32(@enumToInt(decl.name));
1654 return std.hash.uint32(@intFromEnum(decl.name));
16551655 }
16561656
16571657 pub fn eql(ctx: @This(), a_decl_index: Decl.Index, b_decl_index: Decl.Index, b_index: usize) bool {
......@@ -2006,7 +2006,7 @@ pub const File = struct {
20062006 // be the case if there were other astgen failures in this file
20072007 if (!file.zir_loaded) return;
20082008
2009 const imports_index = file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)];
2009 const imports_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.imports)];
20102010 if (imports_index == 0) return;
20112011 const extra = file.zir.extraData(Zir.Inst.Imports, imports_index);
20122012
......@@ -3360,11 +3360,11 @@ pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void {
33603360}
33613361
33623362pub fn declPtr(mod: *Module, index: Decl.Index) *Decl {
3363 return mod.allocated_decls.at(@enumToInt(index));
3363 return mod.allocated_decls.at(@intFromEnum(index));
33643364}
33653365
33663366pub fn namespacePtr(mod: *Module, index: Namespace.Index) *Namespace {
3367 return mod.allocated_namespaces.at(@enumToInt(index));
3367 return mod.allocated_namespaces.at(@intFromEnum(index));
33683368}
33693369
33703370pub fn unionPtr(mod: *Module, index: Union.Index) *Union {
......@@ -3767,10 +3767,10 @@ fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_file: std.fs.File)
37673767 if (data_has_safety_tag) {
37683768 const tags = zir.instructions.items(.tag);
37693769 for (zir.instructions.items(.data), 0..) |*data, i| {
3770 const union_tag = Zir.Inst.Tag.data_tags[@enumToInt(tags[i])];
3770 const union_tag = Zir.Inst.Tag.data_tags[@intFromEnum(tags[i])];
37713771 const as_struct = @ptrCast(*HackDataLayout, data);
37723772 as_struct.* = .{
3773 .safety_tag = @enumToInt(union_tag),
3773 .safety_tag = @intFromEnum(union_tag),
37743774 .data = safety_buffer[i],
37753775 };
37763776 }
......@@ -4101,7 +4101,7 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
41014101 const update_level: Decl.DepType = if (!type_changed and decl.ty.zigTypeTag(mod) == .Fn) .function_body else .normal;
41024102
41034103 for (decl.dependants.keys(), decl.dependants.values()) |dep_index, dep_type| {
4104 if (@enumToInt(dep_type) < @enumToInt(update_level)) continue;
4104 if (@intFromEnum(dep_type) < @intFromEnum(update_level)) continue;
41054105
41064106 const dep = mod.declPtr(dep_index);
41074107 switch (dep.analysis) {
......@@ -4621,7 +4621,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
46214621
46224622 const is_inline = decl.ty.fnCallingConvention(mod) == .Inline;
46234623 if (decl.is_exported) {
4624 const export_src: LazySrcLoc = .{ .token_offset = @boolToInt(decl.is_pub) };
4624 const export_src: LazySrcLoc = .{ .token_offset = @intFromBool(decl.is_pub) };
46254625 if (is_inline) {
46264626 return sema.fail(&block_scope, export_src, "export of inline function", .{});
46274627 }
......@@ -4721,7 +4721,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
47214721 }
47224722
47234723 if (decl.is_exported) {
4724 const export_src: LazySrcLoc = .{ .token_offset = @boolToInt(decl.is_pub) };
4724 const export_src: LazySrcLoc = .{ .token_offset = @intFromBool(decl.is_pub) };
47254725 // The scope needs to have the decl in it.
47264726 try sema.analyzeExport(&block_scope, export_src, .{ .name = decl.name }, decl_index);
47274727 }
......@@ -4742,7 +4742,7 @@ pub fn declareDeclDependencyType(mod: *Module, depender_index: Decl.Index, depen
47424742 const dependee = mod.declPtr(dependee_index);
47434743
47444744 if (depender.dependencies.get(dependee_index)) |cur_type| {
4745 if (@enumToInt(cur_type) >= @enumToInt(dep_type)) {
4745 if (@intFromEnum(cur_type) >= @intFromEnum(dep_type)) {
47464746 // We already have this dependency (or stricter) marked
47474747 return;
47484748 }
......@@ -5611,7 +5611,7 @@ pub fn analyzeFnBody(mod: *Module, func_index: Fn.Index, arena: Allocator) SemaE
56115611 .body_len = @intCast(u32, inner_block.instructions.items.len),
56125612 });
56135613 sema.air_extra.appendSliceAssumeCapacity(inner_block.instructions.items);
5614 sema.air_extra.items[@enumToInt(Air.ExtraIndex.main_block)] = main_block_index;
5614 sema.air_extra.items[@intFromEnum(Air.ExtraIndex.main_block)] = main_block_index;
56155615
56165616 func.state = .success;
56175617
......@@ -5681,12 +5681,12 @@ fn markOutdatedDecl(mod: *Module, decl_index: Decl.Index) !void {
56815681
56825682pub fn createNamespace(mod: *Module, initialization: Namespace) !Namespace.Index {
56835683 if (mod.namespaces_free_list.popOrNull()) |index| {
5684 mod.allocated_namespaces.at(@enumToInt(index)).* = initialization;
5684 mod.allocated_namespaces.at(@intFromEnum(index)).* = initialization;
56855685 return index;
56865686 }
56875687 const ptr = try mod.allocated_namespaces.addOne(mod.gpa);
56885688 ptr.* = initialization;
5689 return @intToEnum(Namespace.Index, mod.allocated_namespaces.len - 1);
5689 return @enumFromInt(Namespace.Index, mod.allocated_namespaces.len - 1);
56905690}
56915691
56925692pub fn destroyNamespace(mod: *Module, index: Namespace.Index) void {
......@@ -5744,7 +5744,7 @@ pub fn allocateNewDecl(
57445744 }
57455745 break :d .{
57465746 .new_decl = decl,
5747 .decl_index = @intToEnum(Decl.Index, mod.allocated_decls.len - 1),
5747 .decl_index = @enumFromInt(Decl.Index, mod.allocated_decls.len - 1),
57485748 };
57495749 };
57505750
......@@ -5808,7 +5808,7 @@ pub fn createAnonymousDeclFromDecl(
58085808 const new_decl_index = try mod.allocateNewDecl(namespace, src_decl.src_node, src_scope);
58095809 errdefer mod.destroyDecl(new_decl_index);
58105810 const name = try mod.intern_pool.getOrPutStringFmt(mod.gpa, "{}__anon_{d}", .{
5811 src_decl.name.fmt(&mod.intern_pool), @enumToInt(new_decl_index),
5811 src_decl.name.fmt(&mod.intern_pool), @intFromEnum(new_decl_index),
58125812 });
58135813 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, tv, name);
58145814 return new_decl_index;
......@@ -6172,7 +6172,7 @@ pub fn argSrc(
61726172 @setCold(true);
61736173 const gpa = mod.gpa;
61746174 if (start_arg_i == 0 and bound_arg_src != null) return bound_arg_src.?;
6175 const arg_i = start_arg_i - @boolToInt(bound_arg_src != null);
6175 const arg_i = start_arg_i - @intFromBool(bound_arg_src != null);
61766176 const tree = decl.getFileScope(mod).getTree(gpa) catch |err| {
61776177 // In this case we emit a warning + a less precise source location.
61786178 log.warn("unable to load {s}: {s}", .{
......@@ -6743,7 +6743,7 @@ pub fn ptrType(mod: *Module, info: InternPool.Key.PtrType) Allocator.Error!Type
67436743 }
67446744 },
67456745 .runtime => {},
6746 _ => assert(@enumToInt(info.flags.vector_index) < info.packed_offset.host_size),
6746 _ => assert(@intFromEnum(info.flags.vector_index) < info.packed_offset.host_size),
67476747 }
67486748
67496749 return (try intern(mod, .{ .ptr_type = canon_info })).toType();
......@@ -6971,17 +6971,17 @@ pub fn intBitsForValue(mod: *Module, val: Value, sign: bool) u16 {
69716971 const key = mod.intern_pool.indexToKey(val.toIntern());
69726972 switch (key.int.storage) {
69736973 .i64 => |x| {
6974 if (std.math.cast(u64, x)) |casted| return Type.smallestUnsignedBits(casted) + @boolToInt(sign);
6974 if (std.math.cast(u64, x)) |casted| return Type.smallestUnsignedBits(casted) + @intFromBool(sign);
69756975 assert(sign);
69766976 // Protect against overflow in the following negation.
69776977 if (x == std.math.minInt(i64)) return 64;
69786978 return Type.smallestUnsignedBits(@intCast(u64, -(x + 1))) + 1;
69796979 },
69806980 .u64 => |x| {
6981 return Type.smallestUnsignedBits(x) + @boolToInt(sign);
6981 return Type.smallestUnsignedBits(x) + @intFromBool(sign);
69826982 },
69836983 .big_int => |big| {
6984 if (big.positive) return @intCast(u16, big.bitCountAbs() + @boolToInt(sign));
6984 if (big.positive) return @intCast(u16, big.bitCountAbs() + @intFromBool(sign));
69856985
69866986 // Zero is still a possibility, in which case unsigned is fine
69876987 if (big.eqZero()) return 0;
......@@ -6989,10 +6989,10 @@ pub fn intBitsForValue(mod: *Module, val: Value, sign: bool) u16 {
69896989 return @intCast(u16, big.bitCountTwosComp());
69906990 },
69916991 .lazy_align => |lazy_ty| {
6992 return Type.smallestUnsignedBits(lazy_ty.toType().abiAlignment(mod)) + @boolToInt(sign);
6992 return Type.smallestUnsignedBits(lazy_ty.toType().abiAlignment(mod)) + @intFromBool(sign);
69936993 },
69946994 .lazy_size => |lazy_ty| {
6995 return Type.smallestUnsignedBits(lazy_ty.toType().abiSize(mod)) + @boolToInt(sign);
6995 return Type.smallestUnsignedBits(lazy_ty.toType().abiSize(mod)) + @intFromBool(sign);
69966996 },
69976997 }
69986998}
src/Package.zig+3-3
......@@ -502,7 +502,7 @@ fn fetchAndUnpack(
502502
503503 if (req.response.status != .ok) {
504504 return report.fail(dep.url_tok, "Expected response status '200 OK' got '{} {s}'", .{
505 @enumToInt(req.response.status),
505 @intFromEnum(req.response.status),
506506 req.response.status.phrase() orelse "",
507507 });
508508 }
......@@ -568,7 +568,7 @@ fn fetchAndUnpack(
568568 .msg = "url field is missing corresponding hash field",
569569 });
570570 const notes_start = try eb.reserveNotes(notes_len);
571 eb.extra.items[notes_start] = @enumToInt(try eb.addErrorMessage(.{
571 eb.extra.items[notes_start] = @intFromEnum(try eb.addErrorMessage(.{
572572 .msg = try eb.printString("expected .hash = \"{s}\",", .{&actual_hex}),
573573 }));
574574 return error.PackageFetchFailed;
......@@ -715,7 +715,7 @@ fn hashFileFallible(dir: fs.Dir, hashed_file: *HashedFile) HashedFile.Error!void
715715 defer file.close();
716716 var hasher = Manifest.Hash.init(.{});
717717 hasher.update(hashed_file.normalized_path);
718 hasher.update(&.{ 0, @boolToInt(try isExecutable(file)) });
718 hasher.update(&.{ 0, @intFromBool(try isExecutable(file)) });
719719 while (true) {
720720 const bytes_read = try file.read(&buf);
721721 if (bytes_read == 0) break;
src/Sema.zig+162-162
......@@ -961,8 +961,8 @@ fn analyzeBodyInner(
961961 .elem_val_node => try sema.zirElemValNode(block, inst),
962962 .elem_type_index => try sema.zirElemTypeIndex(block, inst),
963963 .enum_literal => try sema.zirEnumLiteral(block, inst),
964 .enum_to_int => try sema.zirEnumToInt(block, inst),
965 .int_to_enum => try sema.zirIntToEnum(block, inst),
964 .int_from_enum => try sema.zirIntFromEnum(block, inst),
965 .enum_from_int => try sema.zirEnumFromInt(block, inst),
966966 .err_union_code => try sema.zirErrUnionCode(block, inst),
967967 .err_union_code_ptr => try sema.zirErrUnionCodePtr(block, inst),
968968 .err_union_payload_unsafe => try sema.zirErrUnionPayload(block, inst),
......@@ -1028,18 +1028,18 @@ fn analyzeBodyInner(
10281028 .union_init => try sema.zirUnionInit(block, inst),
10291029 .field_type => try sema.zirFieldType(block, inst),
10301030 .field_type_ref => try sema.zirFieldTypeRef(block, inst),
1031 .ptr_to_int => try sema.zirPtrToInt(block, inst),
1031 .int_from_ptr => try sema.zirIntFromPtr(block, inst),
10321032 .align_of => try sema.zirAlignOf(block, inst),
1033 .bool_to_int => try sema.zirBoolToInt(block, inst),
1033 .int_from_bool => try sema.zirIntFromBool(block, inst),
10341034 .embed_file => try sema.zirEmbedFile(block, inst),
10351035 .error_name => try sema.zirErrorName(block, inst),
10361036 .tag_name => try sema.zirTagName(block, inst),
10371037 .type_name => try sema.zirTypeName(block, inst),
10381038 .frame_type => try sema.zirFrameType(block, inst),
10391039 .frame_size => try sema.zirFrameSize(block, inst),
1040 .float_to_int => try sema.zirFloatToInt(block, inst),
1041 .int_to_float => try sema.zirIntToFloat(block, inst),
1042 .int_to_ptr => try sema.zirIntToPtr(block, inst),
1040 .int_from_float => try sema.zirIntFromFloat(block, inst),
1041 .float_from_int => try sema.zirFloatFromInt(block, inst),
1042 .ptr_from_int => try sema.zirPtrFromInt(block, inst),
10431043 .float_cast => try sema.zirFloatCast(block, inst),
10441044 .int_cast => try sema.zirIntCast(block, inst),
10451045 .ptr_cast => try sema.zirPtrCast(block, inst),
......@@ -1167,8 +1167,8 @@ fn analyzeBodyInner(
11671167 .err_set_cast => try sema.zirErrSetCast( block, extended),
11681168 .await_nosuspend => try sema.zirAwaitNosuspend( block, extended),
11691169 .select => try sema.zirSelect( block, extended),
1170 .error_to_int => try sema.zirErrorToInt( block, extended),
1171 .int_to_error => try sema.zirIntToError( block, extended),
1170 .int_from_error => try sema.zirIntFromError( block, extended),
1171 .error_from_int => try sema.zirErrorFromInt( block, extended),
11721172 .reify => try sema.zirReify( block, extended, inst),
11731173 .builtin_async_call => try sema.zirBuiltinAsyncCall( block, extended),
11741174 .cmpxchg => try sema.zirCmpxchg( block, extended),
......@@ -1387,7 +1387,7 @@ fn analyzeBodyInner(
13871387 check_block = check_block.parent.?;
13881388 };
13891389
1390 if (@enumToInt(target_runtime_index) < @enumToInt(block.runtime_index)) {
1390 if (@intFromEnum(target_runtime_index) < @intFromEnum(block.runtime_index)) {
13911391 const runtime_src = block.runtime_cond orelse block.runtime_loop.?;
13921392 const msg = msg: {
13931393 const msg = try sema.errMsg(block, src, "comptime control flow inside runtime block", .{});
......@@ -1761,10 +1761,10 @@ pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
17611761
17621762pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
17631763 assert(zir_ref != .none);
1764 const i = @enumToInt(zir_ref);
1764 const i = @intFromEnum(zir_ref);
17651765 // First section of indexes correspond to a set number of constant values.
17661766 // We intentionally map the same indexes to the same values between ZIR and AIR.
1767 if (i < InternPool.static_len) return @intToEnum(Air.Inst.Ref, i);
1767 if (i < InternPool.static_len) return @enumFromInt(Air.Inst.Ref, i);
17681768 // The last section of indexes refers to the map of ZIR => AIR.
17691769 const inst = sema.inst_map.get(i - InternPool.static_len).?;
17701770 if (inst == .generic_poison) return error.GenericPoison;
......@@ -2038,9 +2038,9 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime(
20382038) CompileError!?Value {
20392039 assert(inst != .none);
20402040 // First section of indexes correspond to a set number of constant values.
2041 const int = @enumToInt(inst);
2041 const int = @intFromEnum(inst);
20422042 if (int < InternPool.static_len) {
2043 return @intToEnum(InternPool.Index, int).toValue();
2043 return @enumFromInt(InternPool.Index, int).toValue();
20442044 }
20452045
20462046 const i = int - InternPool.static_len;
......@@ -2745,8 +2745,8 @@ pub fn analyzeStructDecl(
27452745 }
27462746
27472747 var extra_index: usize = extended.operand;
2748 extra_index += @boolToInt(small.has_src_node);
2749 extra_index += @boolToInt(small.has_fields_len);
2748 extra_index += @intFromBool(small.has_src_node);
2749 extra_index += @intFromBool(small.has_fields_len);
27502750 const decls_len = if (small.has_decls_len) blk: {
27512751 const decls_len = sema.code.extra[extra_index];
27522752 extra_index += 1;
......@@ -2857,7 +2857,7 @@ fn createAnonymousDeclTypeNamed(
28572857 // renamed.
28582858
28592859 const name = mod.intern_pool.getOrPutStringFmt(gpa, "{}__{s}_{d}", .{
2860 src_decl.name.fmt(&mod.intern_pool), anon_prefix, @enumToInt(new_decl_index),
2860 src_decl.name.fmt(&mod.intern_pool), anon_prefix, @intFromEnum(new_decl_index),
28612861 }) catch unreachable;
28622862 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, namespace, typed_value, name);
28632863 return new_decl_index;
......@@ -2948,7 +2948,7 @@ fn zirEnumDecl(
29482948 const tag_ty_src: LazySrcLoc = .{ .node_offset_container_tag = src.node_offset.x };
29492949
29502950 const tag_type_ref = if (small.has_tag_type) blk: {
2951 const tag_type_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
2951 const tag_type_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
29522952 extra_index += 1;
29532953 break :blk tag_type_ref;
29542954 } else .none;
......@@ -3131,7 +3131,7 @@ fn zirEnumDecl(
31313131 }
31323132
31333133 const tag_overflow = if (has_tag_value) overflow: {
3134 const tag_val_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
3134 const tag_val_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
31353135 extra_index += 1;
31363136 const tag_inst = try sema.resolveInst(tag_val_ref);
31373137 last_tag_val = sema.resolveConstValue(block, .unneeded, tag_inst, "") catch |err| switch (err) {
......@@ -3222,9 +3222,9 @@ fn zirUnionDecl(
32223222 break :blk LazySrcLoc.nodeOffset(node_offset);
32233223 } else sema.src;
32243224
3225 extra_index += @boolToInt(small.has_tag_type);
3226 extra_index += @boolToInt(small.has_body_len);
3227 extra_index += @boolToInt(small.has_fields_len);
3225 extra_index += @intFromBool(small.has_tag_type);
3226 extra_index += @intFromBool(small.has_body_len);
3227 extra_index += @intFromBool(small.has_fields_len);
32283228
32293229 const decls_len = if (small.has_decls_len) blk: {
32303230 const decls_len = sema.code.extra[extra_index];
......@@ -3574,13 +3574,13 @@ fn zirAllocExtended(
35743574 var extra_index: usize = extra.end;
35753575
35763576 const var_ty: Type = if (small.has_type) blk: {
3577 const type_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
3577 const type_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
35783578 extra_index += 1;
35793579 break :blk try sema.resolveType(block, ty_src, type_ref);
35803580 } else undefined;
35813581
35823582 const alignment: u32 = if (small.has_align) blk: {
3583 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
3583 const align_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
35843584 extra_index += 1;
35853585 const alignment = try sema.resolveAlign(block, align_src, align_ref);
35863586 break :blk alignment;
......@@ -6006,7 +6006,7 @@ fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) Co
60066006 const order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
60076007 const order = try sema.resolveAtomicOrder(block, order_src, extra.operand, "atomic order of @fence must be comptime-known");
60086008
6009 if (@enumToInt(order) < @enumToInt(std.builtin.AtomicOrder.Acquire)) {
6009 if (@intFromEnum(order) < @intFromEnum(std.builtin.AtomicOrder.Acquire)) {
60106010 return sema.fail(block, order_src, "atomic ordering must be Acquire or stricter", .{});
60116011 }
60126012
......@@ -6441,7 +6441,7 @@ fn zirCall(
64416441 const extra = sema.code.extraData(ExtraType, inst_data.payload_index);
64426442 const args_len = extra.data.flags.args_len;
64436443
6444 const modifier = @intToEnum(std.builtin.CallModifier, extra.data.flags.packed_modifier);
6444 const modifier = @enumFromInt(std.builtin.CallModifier, extra.data.flags.packed_modifier);
64456445 const ensure_result_used = extra.data.flags.ensure_result_used;
64466446 const pop_error_return_trace = extra.data.flags.pop_error_return_trace;
64476447
......@@ -6473,7 +6473,7 @@ fn zirCall(
64736473 }
64746474
64756475 const callee_ty = sema.typeOf(func);
6476 const total_args = args_len + @boolToInt(bound_arg_src != null);
6476 const total_args = args_len + @intFromBool(bound_arg_src != null);
64776477 const func_ty = try sema.checkCallArgumentCount(block, func, callee_src, callee_ty, total_args, bound_arg_src != null);
64786478
64796479 const args_body = sema.code.extra[extra.end..];
......@@ -6612,7 +6612,7 @@ fn checkCallArgumentCount(
66126612
66136613 const func_ty_info = mod.typeToFunc(func_ty).?;
66146614 const fn_params_len = func_ty_info.param_types.len;
6615 const args_len = total_args - @boolToInt(member_fn);
6615 const args_len = total_args - @intFromBool(member_fn);
66166616 if (func_ty_info.is_var_args) {
66176617 assert(func_ty_info.cc == .C);
66186618 if (total_args >= fn_params_len) return func_ty;
......@@ -6631,7 +6631,7 @@ fn checkCallArgumentCount(
66316631 .{
66326632 member_str,
66336633 variadic_str,
6634 fn_params_len - @boolToInt(member_fn),
6634 fn_params_len - @intFromBool(member_fn),
66356635 args_len,
66366636 },
66376637 );
......@@ -7538,7 +7538,7 @@ fn instantiateGenericCall(
75387538 const new_decl = mod.declPtr(new_decl_index);
75397539 // TODO better names for generic function instantiations
75407540 const decl_name = try mod.intern_pool.getOrPutStringFmt(gpa, "{}__anon_{d}", .{
7541 fn_owner_decl.name.fmt(&mod.intern_pool), @enumToInt(new_decl_index),
7541 fn_owner_decl.name.fmt(&mod.intern_pool), @intFromEnum(new_decl_index),
75427542 });
75437543 new_decl.name = decl_name;
75447544 new_decl.src_line = fn_owner_decl.src_line;
......@@ -7982,7 +7982,7 @@ fn zirElemTypeIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
79827982 const indexable_ty = try sema.resolveType(block, .unneeded, bin.lhs);
79837983 assert(indexable_ty.isIndexable(mod)); // validated by a previous instruction
79847984 if (indexable_ty.zigTypeTag(mod) == .Struct) {
7985 const elem_type = indexable_ty.structFieldType(@enumToInt(bin.rhs), mod);
7985 const elem_type = indexable_ty.structFieldType(@intFromEnum(bin.rhs), mod);
79867986 return sema.addType(elem_type);
79877987 } else {
79887988 const elem_type = indexable_ty.elemType2(mod);
......@@ -8116,7 +8116,7 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
81168116 } })).toValue());
81178117}
81188118
8119fn zirErrorToInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
8119fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
81208120 const tracy = trace(@src());
81218121 defer tracy.end();
81228122
......@@ -8156,7 +8156,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
81568156 return block.addBitCast(Type.err_int, operand);
81578157}
81588158
8159fn zirIntToError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
8159fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
81608160 const tracy = trace(@src());
81618161 defer tracy.end();
81628162
......@@ -8258,7 +8258,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
82588258 })).toValue());
82598259}
82608260
8261fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8261fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
82628262 const mod = sema.mod;
82638263 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
82648264 const src = inst_data.src();
......@@ -8295,7 +8295,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
82958295 }
82968296
82978297 if (try sema.resolveMaybeUndefVal(enum_tag)) |enum_tag_val| {
8298 const val = try enum_tag_val.enumToInt(enum_tag_ty, mod);
8298 const val = try enum_tag_val.intFromEnum(enum_tag_ty, mod);
82998299 return sema.addConstant(int_tag_ty, try val.copy(sema.arena));
83008300 }
83018301
......@@ -8303,7 +8303,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
83038303 return block.addBitCast(int_tag_ty, enum_tag);
83048304}
83058305
8306fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8306fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
83078307 const mod = sema.mod;
83088308 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
83098309 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
......@@ -8729,7 +8729,7 @@ fn zirFunc(
87298729 const ret_ty: Type = switch (extra.data.ret_body_len) {
87308730 0 => Type.void,
87318731 1 => blk: {
8732 const ret_ty_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
8732 const ret_ty_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
87338733 extra_index += 1;
87348734 if (sema.resolveType(block, ret_ty_src, ret_ty_ref)) |ret_ty| {
87358735 break :blk ret_ty;
......@@ -9518,7 +9518,7 @@ fn analyzeAs(
95189518 };
95199519}
95209520
9521fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
9521fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
95229522 const tracy = trace(@src());
95239523 defer tracy.end();
95249524
......@@ -9537,7 +9537,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
95379537 );
95389538 }
95399539 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);
9540 return block.addUnOp(.ptrtoint, ptr);
9540 return block.addUnOp(.int_from_ptr, ptr);
95419541}
95429542
95439543fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
......@@ -9668,8 +9668,8 @@ fn intCast(
96689668 const wanted_info = dest_scalar_ty.intInfo(mod);
96699669 const actual_bits = actual_info.bits;
96709670 const wanted_bits = wanted_info.bits;
9671 const actual_value_bits = actual_bits - @boolToInt(actual_info.signedness == .signed);
9672 const wanted_value_bits = wanted_bits - @boolToInt(wanted_info.signedness == .signed);
9671 const actual_value_bits = actual_bits - @intFromBool(actual_info.signedness == .signed);
9672 const wanted_value_bits = wanted_bits - @intFromBool(wanted_info.signedness == .signed);
96739673
96749674 // range shrinkage
96759675 // requirement: int value fits into target type
......@@ -9790,7 +9790,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
97909790 const msg = try sema.errMsg(block, dest_ty_src, "cannot @bitCast to '{}'", .{dest_ty.fmt(mod)});
97919791 errdefer msg.destroy(sema.gpa);
97929792 switch (operand_ty.zigTypeTag(mod)) {
9793 .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @intToEnum to cast from '{}'", .{operand_ty.fmt(mod)}),
9793 .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @enumFromInt to cast from '{}'", .{operand_ty.fmt(mod)}),
97949794 else => {},
97959795 }
97969796
......@@ -9804,7 +9804,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
98049804 const msg = try sema.errMsg(block, dest_ty_src, "cannot @bitCast to '{}'", .{dest_ty.fmt(mod)});
98059805 errdefer msg.destroy(sema.gpa);
98069806 switch (operand_ty.zigTypeTag(mod)) {
9807 .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @intToPtr to cast from '{}'", .{operand_ty.fmt(mod)}),
9807 .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @ptrFromInt to cast from '{}'", .{operand_ty.fmt(mod)}),
98089808 .Pointer => try sema.errNote(block, dest_ty_src, msg, "use @ptrCast to cast from '{}'", .{operand_ty.fmt(mod)}),
98099809 else => {},
98109810 }
......@@ -9854,7 +9854,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
98549854 const msg = try sema.errMsg(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(mod)});
98559855 errdefer msg.destroy(sema.gpa);
98569856 switch (dest_ty.zigTypeTag(mod)) {
9857 .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @enumToInt to cast to '{}'", .{dest_ty.fmt(mod)}),
9857 .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @intFromEnum to cast to '{}'", .{dest_ty.fmt(mod)}),
98589858 else => {},
98599859 }
98609860
......@@ -9867,7 +9867,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
98679867 const msg = try sema.errMsg(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(mod)});
98689868 errdefer msg.destroy(sema.gpa);
98699869 switch (dest_ty.zigTypeTag(mod)) {
9870 .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @ptrToInt to cast to '{}'", .{dest_ty.fmt(mod)}),
9870 .Int, .ComptimeInt => try sema.errNote(block, operand_src, msg, "use @intFromPtr to cast to '{}'", .{dest_ty.fmt(mod)}),
98719871 .Pointer => try sema.errNote(block, operand_src, msg, "use @ptrCast to cast to '{}'", .{dest_ty.fmt(mod)}),
98729872 else => {},
98739873 }
......@@ -10547,7 +10547,7 @@ const SwitchProngAnalysis = struct {
1054710547 try cases_extra.ensureUnusedCapacity(3 + coerce_block.instructions.items.len);
1054810548 cases_extra.appendAssumeCapacity(1); // items_len
1054910549 cases_extra.appendAssumeCapacity(@intCast(u32, coerce_block.instructions.items.len)); // body_len
10550 cases_extra.appendAssumeCapacity(@enumToInt(case_vals[idx])); // item
10550 cases_extra.appendAssumeCapacity(@intFromEnum(case_vals[idx])); // item
1055110551 cases_extra.appendSliceAssumeCapacity(coerce_block.instructions.items); // body
1055210552 }
1055310553 }
......@@ -10834,7 +10834,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1083410834 {
1083510835 var scalar_i: u32 = 0;
1083610836 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
10837 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
10837 const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1083810838 extra_index += 1;
1083910839 const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]);
1084010840 extra_index += 1 + info.body_len;
......@@ -10933,7 +10933,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1093310933 {
1093410934 var scalar_i: u32 = 0;
1093510935 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
10936 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
10936 const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1093710937 extra_index += 1;
1093810938 const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]);
1093910939 extra_index += 1 + info.body_len;
......@@ -11074,7 +11074,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1107411074 {
1107511075 var scalar_i: u32 = 0;
1107611076 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11077 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
11077 const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1107811078 extra_index += 1;
1107911079 const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]);
1108011080 extra_index += 1 + info.body_len;
......@@ -11116,9 +11116,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1111611116 try case_vals.ensureUnusedCapacity(gpa, 2 * ranges_len);
1111711117 var range_i: u32 = 0;
1111811118 while (range_i < ranges_len) : (range_i += 1) {
11119 const item_first = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
11119 const item_first = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1112011120 extra_index += 1;
11121 const item_last = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
11121 const item_last = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1112211122 extra_index += 1;
1112311123
1112411124 const vals = try sema.validateSwitchRange(
......@@ -11169,7 +11169,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1116911169 {
1117011170 var scalar_i: u32 = 0;
1117111171 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11172 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
11172 const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1117311173 extra_index += 1;
1117411174 const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]);
1117511175 extra_index += 1 + info.body_len;
......@@ -11251,7 +11251,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1125111251 {
1125211252 var scalar_i: u32 = 0;
1125311253 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
11254 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
11254 const item_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
1125511255 extra_index += 1;
1125611256 const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, sema.code.extra[extra_index]);
1125711257 extra_index += 1;
......@@ -11571,7 +11571,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1157111571 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1157211572 cases_extra.appendAssumeCapacity(1); // items_len
1157311573 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
11574 cases_extra.appendAssumeCapacity(@enumToInt(item));
11574 cases_extra.appendAssumeCapacity(@intFromEnum(item));
1157511575 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1157611576 }
1157711577
......@@ -11656,7 +11656,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1165611656 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1165711657 cases_extra.appendAssumeCapacity(1); // items_len
1165811658 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
11659 cases_extra.appendAssumeCapacity(@enumToInt(item_ref));
11659 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1166011660 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1166111661 }
1166211662 }
......@@ -11702,7 +11702,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1170211702 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1170311703 cases_extra.appendAssumeCapacity(1); // items_len
1170411704 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
11705 cases_extra.appendAssumeCapacity(@enumToInt(item));
11705 cases_extra.appendAssumeCapacity(@intFromEnum(item));
1170611706 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1170711707 }
1170811708
......@@ -11753,7 +11753,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1175311753 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
1175411754
1175511755 for (items) |item| {
11756 cases_extra.appendAssumeCapacity(@enumToInt(item));
11756 cases_extra.appendAssumeCapacity(@intFromEnum(item));
1175711757 }
1175811758
1175911759 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
......@@ -11903,7 +11903,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1190311903 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1190411904 cases_extra.appendAssumeCapacity(1); // items_len
1190511905 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
11906 cases_extra.appendAssumeCapacity(@enumToInt(item_ref));
11906 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1190711907 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1190811908 }
1190911909 },
......@@ -11944,7 +11944,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1194411944 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1194511945 cases_extra.appendAssumeCapacity(1); // items_len
1194611946 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
11947 cases_extra.appendAssumeCapacity(@enumToInt(item_ref));
11947 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1194811948 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1194911949 }
1195011950 },
......@@ -11975,7 +11975,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1197511975 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1197611976 cases_extra.appendAssumeCapacity(1); // items_len
1197711977 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
11978 cases_extra.appendAssumeCapacity(@enumToInt(item_ref));
11978 cases_extra.appendAssumeCapacity(@intFromEnum(item_ref));
1197911979 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1198011980 }
1198111981 },
......@@ -12003,7 +12003,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1200312003 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1200412004 cases_extra.appendAssumeCapacity(1); // items_len
1200512005 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
12006 cases_extra.appendAssumeCapacity(@enumToInt(Air.Inst.Ref.bool_true));
12006 cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_true));
1200712007 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1200812008 }
1200912009 if (false_count == 0) {
......@@ -12029,7 +12029,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1202912029 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
1203012030 cases_extra.appendAssumeCapacity(1); // items_len
1203112031 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
12032 cases_extra.appendAssumeCapacity(@enumToInt(Air.Inst.Ref.bool_false));
12032 cases_extra.appendAssumeCapacity(@intFromEnum(Air.Inst.Ref.bool_false));
1203312033 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
1203412034 }
1203512035 },
......@@ -15685,7 +15685,7 @@ fn zirAsm(
1568515685 const is_global_assembly = sema.func_index == .none;
1568615686
1568715687 const asm_source: []const u8 = if (tmpl_is_expr) blk: {
15688 const tmpl = @intToEnum(Zir.Inst.Ref, extra.data.asm_source);
15688 const tmpl = @enumFromInt(Zir.Inst.Ref, extra.data.asm_source);
1568915689 const s: []const u8 = try sema.resolveConstString(block, src, tmpl, "assembly code must be comptime-known");
1569015690 break :blk s;
1569115691 } else sema.code.nullTerminatedString(extra.data.asm_source);
......@@ -15789,7 +15789,7 @@ fn zirAsm(
1578915789 .source_len = @intCast(u32, asm_source.len),
1579015790 .outputs_len = outputs_len,
1579115791 .inputs_len = @intCast(u32, args.len),
15792 .flags = (@as(u32, @boolToInt(is_volatile)) << 31) | @intCast(u32, clobbers.len),
15792 .flags = (@as(u32, @intFromBool(is_volatile)) << 31) | @intCast(u32, clobbers.len),
1579315793 }),
1579415794 } },
1579515795 });
......@@ -16448,7 +16448,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1644816448 .EnumLiteral,
1644916449 => |type_info_tag| return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1645016450 .ty = type_info_ty.toIntern(),
16451 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(type_info_tag))).toIntern(),
16451 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(type_info_tag))).toIntern(),
1645216452 .val = .void_value,
1645316453 } })).toValue()),
1645416454 .Fn => {
......@@ -16543,7 +16543,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1654316543
1654416544 const field_values = .{
1654516545 // calling_convention: CallingConvention,
16546 (try mod.enumValueFieldIndex(callconv_ty, @enumToInt(info.cc))).toIntern(),
16546 (try mod.enumValueFieldIndex(callconv_ty, @intFromEnum(info.cc))).toIntern(),
1654716547 // alignment: comptime_int,
1654816548 (try mod.intValue(Type.comptime_int, ty.abiAlignment(mod))).toIntern(),
1654916549 // is_generic: bool,
......@@ -16557,7 +16557,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1655716557 };
1655816558 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1655916559 .ty = type_info_ty.toIntern(),
16560 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Fn))).toIntern(),
16560 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Fn))).toIntern(),
1656116561 .val = try mod.intern(.{ .aggregate = .{
1656216562 .ty = fn_info_ty.toIntern(),
1656316563 .storage = .{ .elems = &field_values },
......@@ -16580,13 +16580,13 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1658016580 const info = ty.intInfo(mod);
1658116581 const field_values = .{
1658216582 // signedness: Signedness,
16583 try (try mod.enumValueFieldIndex(signedness_ty, @enumToInt(info.signedness))).intern(signedness_ty, mod),
16583 try (try mod.enumValueFieldIndex(signedness_ty, @intFromEnum(info.signedness))).intern(signedness_ty, mod),
1658416584 // bits: u16,
1658516585 (try mod.intValue(Type.u16, info.bits)).toIntern(),
1658616586 };
1658716587 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1658816588 .ty = type_info_ty.toIntern(),
16589 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Int))).toIntern(),
16589 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Int))).toIntern(),
1659016590 .val = try mod.intern(.{ .aggregate = .{
1659116591 .ty = int_info_ty.toIntern(),
1659216592 .storage = .{ .elems = &field_values },
......@@ -16611,7 +16611,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1661116611 };
1661216612 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1661316613 .ty = type_info_ty.toIntern(),
16614 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Float))).toIntern(),
16614 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Float))).toIntern(),
1661516615 .val = try mod.intern(.{ .aggregate = .{
1661616616 .ty = float_info_ty.toIntern(),
1661716617 .storage = .{ .elems = &field_vals },
......@@ -16653,7 +16653,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1665316653
1665416654 const field_values = .{
1665516655 // size: Size,
16656 try (try mod.enumValueFieldIndex(ptr_size_ty, @enumToInt(info.size))).intern(ptr_size_ty, mod),
16656 try (try mod.enumValueFieldIndex(ptr_size_ty, @intFromEnum(info.size))).intern(ptr_size_ty, mod),
1665716657 // is_const: bool,
1665816658 Value.makeBool(!info.mutable).toIntern(),
1665916659 // is_volatile: bool,
......@@ -16661,7 +16661,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1666116661 // alignment: comptime_int,
1666216662 alignment.toIntern(),
1666316663 // address_space: AddressSpace
16664 try (try mod.enumValueFieldIndex(addrspace_ty, @enumToInt(info.@"addrspace"))).intern(addrspace_ty, mod),
16664 try (try mod.enumValueFieldIndex(addrspace_ty, @intFromEnum(info.@"addrspace"))).intern(addrspace_ty, mod),
1666516665 // child: type,
1666616666 info.pointee_type.toIntern(),
1666716667 // is_allowzero: bool,
......@@ -16671,7 +16671,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1667116671 };
1667216672 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1667316673 .ty = type_info_ty.toIntern(),
16674 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Pointer))).toIntern(),
16674 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Pointer))).toIntern(),
1667516675 .val = try mod.intern(.{ .aggregate = .{
1667616676 .ty = pointer_ty.toIntern(),
1667716677 .storage = .{ .elems = &field_values },
......@@ -16703,7 +16703,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1670316703 };
1670416704 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1670516705 .ty = type_info_ty.toIntern(),
16706 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Array))).toIntern(),
16706 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Array))).toIntern(),
1670716707 .val = try mod.intern(.{ .aggregate = .{
1670816708 .ty = array_field_ty.toIntern(),
1670916709 .storage = .{ .elems = &field_values },
......@@ -16733,7 +16733,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1673316733 };
1673416734 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1673516735 .ty = type_info_ty.toIntern(),
16736 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Vector))).toIntern(),
16736 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Vector))).toIntern(),
1673716737 .val = try mod.intern(.{ .aggregate = .{
1673816738 .ty = vector_field_ty.toIntern(),
1673916739 .storage = .{ .elems = &field_values },
......@@ -16760,7 +16760,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1676016760 };
1676116761 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1676216762 .ty = type_info_ty.toIntern(),
16763 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Optional))).toIntern(),
16763 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Optional))).toIntern(),
1676416764 .val = try mod.intern(.{ .aggregate = .{
1676516765 .ty = optional_field_ty.toIntern(),
1676616766 .storage = .{ .elems = &field_values },
......@@ -16870,7 +16870,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1687016870 // Construct Type{ .ErrorSet = errors_val }
1687116871 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1687216872 .ty = type_info_ty.toIntern(),
16873 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.ErrorSet))).toIntern(),
16873 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorSet))).toIntern(),
1687416874 .val = errors_val,
1687516875 } })).toValue());
1687616876 },
......@@ -16896,7 +16896,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1689616896 };
1689716897 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1689816898 .ty = type_info_ty.toIntern(),
16899 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.ErrorUnion))).toIntern(),
16899 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorUnion))).toIntern(),
1690016900 .val = try mod.intern(.{ .aggregate = .{
1690116901 .ty = error_union_field_ty.toIntern(),
1690216902 .storage = .{ .elems = &field_values },
......@@ -17023,7 +17023,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1702317023 };
1702417024 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1702517025 .ty = type_info_ty.toIntern(),
17026 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Enum))).toIntern(),
17026 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Enum))).toIntern(),
1702717027 .val = try mod.intern(.{ .aggregate = .{
1702817028 .ty = type_enum_ty.toIntern(),
1702917029 .storage = .{ .elems = &field_values },
......@@ -17164,7 +17164,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1716417164
1716517165 const field_values = .{
1716617166 // layout: ContainerLayout,
17167 (try mod.enumValueFieldIndex(container_layout_ty, @enumToInt(layout))).toIntern(),
17167 (try mod.enumValueFieldIndex(container_layout_ty, @intFromEnum(layout))).toIntern(),
1716817168
1716917169 // tag_type: ?type,
1717017170 enum_tag_ty_val,
......@@ -17175,7 +17175,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1717517175 };
1717617176 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1717717177 .ty = type_info_ty.toIntern(),
17178 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Union))).toIntern(),
17178 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Union))).toIntern(),
1717917179 .val = try mod.intern(.{ .aggregate = .{
1718017180 .ty = type_union_ty.toIntern(),
1718117181 .storage = .{ .elems = &field_values },
......@@ -17393,7 +17393,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1739317393
1739417394 const field_values = [_]InternPool.Index{
1739517395 // layout: ContainerLayout,
17396 (try mod.enumValueFieldIndex(container_layout_ty, @enumToInt(layout))).toIntern(),
17396 (try mod.enumValueFieldIndex(container_layout_ty, @intFromEnum(layout))).toIntern(),
1739717397 // backing_integer: ?type,
1739817398 backing_integer_val,
1739917399 // fields: []const StructField,
......@@ -17405,7 +17405,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1740517405 };
1740617406 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1740717407 .ty = type_info_ty.toIntern(),
17408 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Struct))).toIntern(),
17408 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Struct))).toIntern(),
1740917409 .val = try mod.intern(.{ .aggregate = .{
1741017410 .ty = type_struct_ty.toIntern(),
1741117411 .storage = .{ .elems = &field_values },
......@@ -17437,7 +17437,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1743717437 };
1743817438 return sema.addConstant(type_info_ty, (try mod.intern(.{ .un = .{
1743917439 .ty = type_info_ty.toIntern(),
17440 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @enumToInt(std.builtin.TypeId.Opaque))).toIntern(),
17440 .tag = (try mod.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Opaque))).toIntern(),
1744117441 .val = try mod.intern(.{ .aggregate = .{
1744217442 .ty = type_opaque_ty.toIntern(),
1744317443 .storage = .{ .elems = &field_values },
......@@ -18494,7 +18494,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1849418494 var extra_i = extra.end;
1849518495
1849618496 const sentinel = if (inst_data.flags.has_sentinel) blk: {
18497 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
18497 const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]);
1849818498 extra_i += 1;
1849918499 const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src);
1850018500 const val = try sema.resolveConstValue(block, sentinel_src, coerced, "pointer sentinel value must be comptime-known");
......@@ -18502,7 +18502,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1850218502 } else .none;
1850318503
1850418504 const abi_align: InternPool.Alignment = if (inst_data.flags.has_align) blk: {
18505 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
18505 const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]);
1850618506 extra_i += 1;
1850718507 const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src);
1850818508 const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime-known");
......@@ -18521,20 +18521,20 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1852118521 } else .none;
1852218522
1852318523 const address_space: std.builtin.AddressSpace = if (inst_data.flags.has_addrspace) blk: {
18524 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
18524 const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]);
1852518525 extra_i += 1;
1852618526 break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer);
1852718527 } else if (elem_ty.zigTypeTag(mod) == .Fn and target.cpu.arch == .avr) .flash else .generic;
1852818528
1852918529 const bit_offset = if (inst_data.flags.has_bit_range) blk: {
18530 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
18530 const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]);
1853118531 extra_i += 1;
1853218532 const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime-known");
1853318533 break :blk @intCast(u16, bit_offset);
1853418534 } else 0;
1853518535
1853618536 const host_size: u16 = if (inst_data.flags.has_bit_range) blk: {
18537 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
18537 const ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_i]);
1853818538 extra_i += 1;
1853918539 const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime-known");
1854018540 break :blk @intCast(u16, host_size);
......@@ -19093,7 +19093,7 @@ fn zirArrayInit(
1909319093 const array_ty = try sema.resolveType(block, src, args[0]);
1909419094 const sentinel_val = array_ty.sentinel(mod);
1909519095
19096 const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len - 1 + @boolToInt(sentinel_val != null));
19096 const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len - 1 + @intFromBool(sentinel_val != null));
1909719097 defer gpa.free(resolved_args);
1909819098 for (args[1..], 0..) |arg, i| {
1909919099 const resolved_arg = try sema.resolveInst(arg);
......@@ -19426,7 +19426,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1942619426 return sema.addConstant(Type.comptime_int, val);
1942719427}
1942819428
19429fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
19429fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1943019430 const mod = sema.mod;
1943119431 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1943219432 const operand = try sema.resolveInst(inst_data.operand);
......@@ -19435,7 +19435,7 @@ fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1943519435 if (val.toBool()) return sema.addConstant(Type.u1, try mod.intValue(Type.u1, 1));
1943619436 return sema.addConstant(Type.u1, try mod.intValue(Type.u1, 0));
1943719437 }
19438 return block.addUnOp(.bool_to_int, operand);
19438 return block.addUnOp(.int_from_bool, operand);
1943919439}
1944019440
1944119441fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
......@@ -19600,7 +19600,7 @@ fn zirReify(
1960019600 const mod = sema.mod;
1960119601 const gpa = sema.gpa;
1960219602 const ip = &mod.intern_pool;
19603 const name_strategy = @intToEnum(Zir.Inst.NameStrategy, extended.small);
19603 const name_strategy = @enumFromInt(Zir.Inst.NameStrategy, extended.small);
1960419604 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
1960519605 const src = LazySrcLoc.nodeOffset(extra.node);
1960619606 const type_info_ty = try sema.getBuiltinType("Type");
......@@ -19612,7 +19612,7 @@ fn zirReify(
1961219612 const target = mod.getTarget();
1961319613 if (try union_val.val.toValue().anyUndef(mod)) return sema.failWithUseOfUndef(block, src);
1961419614 const tag_index = type_info_ty.unionTagFieldIndex(union_val.tag.toValue(), mod).?;
19615 switch (@intToEnum(std.builtin.TypeId, tag_index)) {
19615 switch (@enumFromInt(std.builtin.TypeId, tag_index)) {
1961619616 .Type => return Air.Inst.Ref.type_type,
1961719617 .Void => return Air.Inst.Ref.void_type,
1961819618 .Bool => return Air.Inst.Ref.bool_type,
......@@ -20748,7 +20748,7 @@ fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2074820748 return sema.failWithUseOfAsync(block, src);
2074920749}
2075020750
20751fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
20751fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2075220752 const mod = sema.mod;
2075320753 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
2075420754 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
......@@ -20762,7 +20762,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2076220762 try sema.checkFloatType(block, operand_src, operand_ty);
2076320763
2076420764 if (try sema.resolveMaybeUndefVal(operand)) |val| {
20765 const result_val = try sema.floatToInt(block, operand_src, val, operand_ty, dest_ty);
20765 const result_val = try sema.intFromFloat(block, operand_src, val, operand_ty, dest_ty);
2076620766 return sema.addConstant(dest_ty, result_val);
2076720767 } else if (dest_ty.zigTypeTag(mod) == .ComptimeInt) {
2076820768 return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_int' must be comptime-known");
......@@ -20776,9 +20776,9 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2077620776 }
2077720777 return sema.addConstant(dest_ty, try mod.intValue(dest_ty, 0));
2077820778 }
20779 const result = try block.addTyOp(if (block.float_mode == .Optimized) .float_to_int_optimized else .float_to_int, dest_ty, operand);
20779 const result = try block.addTyOp(if (block.float_mode == .Optimized) .int_from_float_optimized else .int_from_float, dest_ty, operand);
2078020780 if (block.wantSafety()) {
20781 const back = try block.addTyOp(.int_to_float, operand_ty, result);
20781 const back = try block.addTyOp(.float_from_int, operand_ty, result);
2078220782 const diff = try block.addBinOp(.sub, operand, back);
2078320783 const ok_pos = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_lt_optimized else .cmp_lt, diff, try sema.addConstant(operand_ty, try mod.floatValue(operand_ty, 1.0)));
2078420784 const ok_neg = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_gt_optimized else .cmp_gt, diff, try sema.addConstant(operand_ty, try mod.floatValue(operand_ty, -1.0)));
......@@ -20788,7 +20788,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2078820788 return result;
2078920789}
2079020790
20791fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
20791fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2079220792 const mod = sema.mod;
2079320793 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
2079420794 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
......@@ -20802,17 +20802,17 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2080220802 _ = try sema.checkIntType(block, operand_src, operand_ty);
2080320803
2080420804 if (try sema.resolveMaybeUndefVal(operand)) |val| {
20805 const result_val = try val.intToFloatAdvanced(sema.arena, operand_ty, dest_ty, sema.mod, sema);
20805 const result_val = try val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, sema.mod, sema);
2080620806 return sema.addConstant(dest_ty, result_val);
2080720807 } else if (dest_ty.zigTypeTag(mod) == .ComptimeFloat) {
2080820808 return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_float' must be comptime-known");
2080920809 }
2081020810
2081120811 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
20812 return block.addTyOp(.int_to_float, dest_ty, operand);
20812 return block.addTyOp(.float_from_int, dest_ty, operand);
2081320813}
2081420814
20815fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
20815fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2081620816 const mod = sema.mod;
2081720817 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
2081820818 const src = inst_data.src();
......@@ -21084,7 +21084,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2108421084 if (block.wantSafety() and operand_ty.ptrAllowsZero(mod) and !dest_ty.ptrAllowsZero(mod) and
2108521085 (try sema.typeHasRuntimeBits(dest_ty.elemType2(mod)) or dest_ty.elemType2(mod).zigTypeTag(mod) == .Fn))
2108621086 {
21087 const ptr_int = try block.addUnOp(.ptrtoint, ptr);
21087 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
2108821088 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
2108921089 const ok = if (operand_is_slice) ok: {
2109021090 const len = try sema.analyzeSliceLen(block, operand_src, operand);
......@@ -21265,7 +21265,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2126521265 try sema.analyzeSlicePtr(block, ptr_src, ptr, ptr_ty)
2126621266 else
2126721267 ptr;
21268 const ptr_int = try block.addUnOp(.ptrtoint, actual_ptr);
21268 const ptr_int = try block.addUnOp(.int_from_ptr, actual_ptr);
2126921269 const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);
2127021270 const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize);
2127121271 const ok = if (ptr_ty.isSlice(mod)) ok: {
......@@ -21750,7 +21750,7 @@ fn checkComptimeVarStore(
2175021750 src: LazySrcLoc,
2175121751 decl_ref_mut: InternPool.Key.Ptr.Addr.MutDecl,
2175221752) CompileError!void {
21753 if (@enumToInt(decl_ref_mut.runtime_index) < @enumToInt(block.runtime_index)) {
21753 if (@intFromEnum(decl_ref_mut.runtime_index) < @intFromEnum(block.runtime_index)) {
2175421754 if (block.runtime_cond) |cond_src| {
2175521755 const msg = msg: {
2175621756 const msg = try sema.errMsg(block, src, "store to comptime variable depends on runtime condition", .{});
......@@ -22065,13 +22065,13 @@ fn zirCmpxchg(
2206522065 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, "atomic order of cmpxchg success must be comptime-known");
2206622066 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, "atomic order of cmpxchg failure must be comptime-known");
2206722067
22068 if (@enumToInt(success_order) < @enumToInt(std.builtin.AtomicOrder.Monotonic)) {
22068 if (@intFromEnum(success_order) < @intFromEnum(std.builtin.AtomicOrder.Monotonic)) {
2206922069 return sema.fail(block, success_order_src, "success atomic ordering must be Monotonic or stricter", .{});
2207022070 }
22071 if (@enumToInt(failure_order) < @enumToInt(std.builtin.AtomicOrder.Monotonic)) {
22071 if (@intFromEnum(failure_order) < @intFromEnum(std.builtin.AtomicOrder.Monotonic)) {
2207222072 return sema.fail(block, failure_order_src, "failure atomic ordering must be Monotonic or stricter", .{});
2207322073 }
22074 if (@enumToInt(failure_order) > @enumToInt(success_order)) {
22074 if (@intFromEnum(failure_order) > @intFromEnum(success_order)) {
2207522075 return sema.fail(block, failure_order_src, "failure atomic ordering must be no stricter than success", .{});
2207622076 }
2207722077 if (failure_order == .Release or failure_order == .AcqRel) {
......@@ -22110,8 +22110,8 @@ fn zirCmpxchg(
2211022110 } else break :rs expected_src;
2211122111 } else ptr_src;
2211222112
22113 const flags: u32 = @as(u32, @enumToInt(success_order)) |
22114 (@as(u32, @enumToInt(failure_order)) << 3);
22113 const flags: u32 = @as(u32, @intFromEnum(success_order)) |
22114 (@as(u32, @intFromEnum(failure_order)) << 3);
2211522115
2211622116 try sema.requireRuntimeBlock(block, src, runtime_src);
2211722117 return block.addInst(.{
......@@ -22610,7 +22610,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2261022610 } else break :rs ptr_src;
2261122611 } else ptr_src;
2261222612
22613 const flags: u32 = @as(u32, @enumToInt(order)) | (@as(u32, @enumToInt(op)) << 3);
22613 const flags: u32 = @as(u32, @intFromEnum(order)) | (@as(u32, @intFromEnum(op)) << 3);
2261422614
2261522615 try sema.requireRuntimeBlock(block, src, runtime_src);
2261622616 return block.addInst(.{
......@@ -23556,7 +23556,7 @@ fn zirVarExtended(
2355623556 assert(!small.has_align);
2355723557
2355823558 const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: {
23559 const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
23559 const init_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
2356023560 extra_index += 1;
2356123561 break :blk try sema.resolveInst(init_ref);
2356223562 } else .none;
......@@ -23641,7 +23641,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2364123641 break :blk alignment;
2364223642 }
2364323643 } else if (extra.data.bits.has_align_ref) blk: {
23644 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
23644 const align_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
2364523645 extra_index += 1;
2364623646 const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime-known") catch |err| switch (err) {
2364723647 error.GenericPoison => {
......@@ -23671,7 +23671,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2367123671 }
2367223672 break :blk mod.toEnum(std.builtin.AddressSpace, val);
2367323673 } else if (extra.data.bits.has_addrspace_ref) blk: {
23674 const addrspace_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
23674 const addrspace_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
2367523675 extra_index += 1;
2367623676 const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime-known") catch |err| switch (err) {
2367723677 error.GenericPoison => {
......@@ -23695,7 +23695,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2369523695 }
2369623696 break :blk FuncLinkSection{ .explicit = try val.toIpString(ty, mod) };
2369723697 } else if (extra.data.bits.has_section_ref) blk: {
23698 const section_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
23698 const section_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
2369923699 extra_index += 1;
2370023700 const section_name = sema.resolveConstStringIntern(block, section_src, section_ref, "linksection must be comptime-known") catch |err| switch (err) {
2370123701 error.GenericPoison => {
......@@ -23719,7 +23719,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2371923719 }
2372023720 break :blk mod.toEnum(std.builtin.CallingConvention, val);
2372123721 } else if (extra.data.bits.has_cc_ref) blk: {
23722 const cc_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
23722 const cc_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
2372323723 extra_index += 1;
2372423724 const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime-known") catch |err| switch (err) {
2372523725 error.GenericPoison => {
......@@ -23743,7 +23743,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2374323743 const ty = val.toType();
2374423744 break :blk ty;
2374523745 } else if (extra.data.bits.has_ret_ty_ref) blk: {
23746 const ret_ty_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
23746 const ret_ty_ref = @enumFromInt(Zir.Inst.Ref, sema.code.extra[extra_index]);
2374723747 extra_index += 1;
2374823748 const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) {
2374923749 error.GenericPoison => {
......@@ -26354,7 +26354,7 @@ fn elemValArray(
2635426354 const array_ty = sema.typeOf(array);
2635526355 const array_sent = array_ty.sentinel(mod);
2635626356 const array_len = array_ty.arrayLen(mod);
26357 const array_len_s = array_len + @boolToInt(array_sent != null);
26357 const array_len_s = array_len + @intFromBool(array_sent != null);
2635826358 const elem_ty = array_ty.childType(mod);
2635926359
2636026360 if (array_len_s == 0) {
......@@ -26419,7 +26419,7 @@ fn elemPtrArray(
2641926419 const array_ty = array_ptr_ty.childType(mod);
2642026420 const array_sent = array_ty.sentinel(mod) != null;
2642126421 const array_len = array_ty.arrayLen(mod);
26422 const array_len_s = array_len + @boolToInt(array_sent);
26422 const array_len_s = array_len + @intFromBool(array_sent);
2642326423
2642426424 if (array_len_s == 0) {
2642526425 return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{});
......@@ -26489,7 +26489,7 @@ fn elemValSlice(
2648926489 if (maybe_slice_val) |slice_val| {
2649026490 runtime_src = elem_index_src;
2649126491 const slice_len = slice_val.sliceLen(mod);
26492 const slice_len_s = slice_len + @boolToInt(slice_sent);
26492 const slice_len_s = slice_len + @intFromBool(slice_sent);
2649326493 if (slice_len_s == 0) {
2649426494 return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{});
2649526495 }
......@@ -26551,7 +26551,7 @@ fn elemPtrSlice(
2655126551 return sema.addConstUndef(elem_ptr_ty);
2655226552 }
2655326553 const slice_len = slice_val.sliceLen(mod);
26554 const slice_len_s = slice_len + @boolToInt(slice_sent);
26554 const slice_len_s = slice_len + @intFromBool(slice_sent);
2655526555 if (slice_len_s == 0) {
2655626556 return sema.fail(block, slice_src, "indexing into empty slice is not allowed", .{});
2655726557 }
......@@ -27020,7 +27020,7 @@ fn coerceExtra(
2702027020 .{ val.fmtValue(inst_ty, mod), dest_ty.fmt(mod) },
2702127021 );
2702227022 }
27023 const result_val = try sema.floatToInt(block, inst_src, val, inst_ty, dest_ty);
27023 const result_val = try sema.intFromFloat(block, inst_src, val, inst_ty, dest_ty);
2702427024 return try sema.addConstant(dest_ty, result_val);
2702527025 },
2702627026 .Int, .ComptimeInt => {
......@@ -27102,9 +27102,9 @@ fn coerceExtra(
2710227102 }
2710327103 break :int;
2710427104 };
27105 const result_val = try val.intToFloatAdvanced(sema.arena, inst_ty, dest_ty, mod, sema);
27105 const result_val = try val.floatFromIntAdvanced(sema.arena, inst_ty, dest_ty, mod, sema);
2710627106 // TODO implement this compile error
27107 //const int_again_val = try result_val.floatToInt(sema.arena, inst_ty);
27107 //const int_again_val = try result_val.intFromFloat(sema.arena, inst_ty);
2710827108 //if (!int_again_val.eql(val, inst_ty, mod)) {
2710927109 // return sema.fail(
2711027110 // block,
......@@ -29504,7 +29504,7 @@ fn coerceCompatiblePtrs(
2950429504 try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty)
2950529505 else
2950629506 inst;
29507 const ptr_int = try block.addUnOp(.ptrtoint, actual_ptr);
29507 const ptr_int = try block.addUnOp(.int_from_ptr, actual_ptr);
2950829508 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
2950929509 const ok = if (inst_ty.isSlice(mod)) ok: {
2951029510 const len = try sema.analyzeSliceLen(block, inst_src, inst);
......@@ -30773,7 +30773,7 @@ fn analyzeSlice(
3077330773 }
3077430774 const has_sentinel = slice_ty.sentinel(mod) != null;
3077530775 const slice_len = slice_val.sliceLen(mod);
30776 const len_plus_sent = slice_len + @boolToInt(has_sentinel);
30776 const len_plus_sent = slice_len + @intFromBool(has_sentinel);
3077730777 const slice_len_val_with_sentinel = try mod.intValue(Type.usize, len_plus_sent);
3077830778 if (!(try sema.compareAll(end_val, .lte, slice_len_val_with_sentinel, Type.usize))) {
3077930779 const sentinel_label: []const u8 = if (has_sentinel)
......@@ -31234,12 +31234,12 @@ fn cmpNumeric(
3123431234 } else {
3123531235 lhs_bits = lhs_val.intBitCountTwosComp(mod);
3123631236 }
31237 lhs_bits += @boolToInt(!lhs_is_signed and dest_int_is_signed);
31237 lhs_bits += @intFromBool(!lhs_is_signed and dest_int_is_signed);
3123831238 } else if (lhs_is_float) {
3123931239 dest_float_type = lhs_ty;
3124031240 } else {
3124131241 const int_info = lhs_ty.intInfo(mod);
31242 lhs_bits = int_info.bits + @boolToInt(int_info.signedness == .unsigned and dest_int_is_signed);
31242 lhs_bits = int_info.bits + @intFromBool(int_info.signedness == .unsigned and dest_int_is_signed);
3124331243 }
3124431244
3124531245 var rhs_bits: usize = undefined;
......@@ -31292,12 +31292,12 @@ fn cmpNumeric(
3129231292 } else {
3129331293 rhs_bits = rhs_val.intBitCountTwosComp(mod);
3129431294 }
31295 rhs_bits += @boolToInt(!rhs_is_signed and dest_int_is_signed);
31295 rhs_bits += @intFromBool(!rhs_is_signed and dest_int_is_signed);
3129631296 } else if (rhs_is_float) {
3129731297 dest_float_type = rhs_ty;
3129831298 } else {
3129931299 const int_info = rhs_ty.intInfo(mod);
31300 rhs_bits = int_info.bits + @boolToInt(int_info.signedness == .unsigned and dest_int_is_signed);
31300 rhs_bits = int_info.bits + @intFromBool(int_info.signedness == .unsigned and dest_int_is_signed);
3130131301 }
3130231302
3130331303 const dest_ty = if (dest_float_type) |ft| ft else blk: {
......@@ -31356,7 +31356,7 @@ fn compareIntsOnlyPossibleResult(
3135631356 .neq, .lt, .lte => true,
3135731357 };
3135831358
31359 const sign_adj = @boolToInt(!is_negative and rhs_info.signedness == .signed);
31359 const sign_adj = @intFromBool(!is_negative and rhs_info.signedness == .signed);
3136031360 const req_bits = lhs_val.intBitCountTwosComp(mod) + sign_adj;
3136131361
3136231362 // No sized type can have more than 65535 bits.
......@@ -31628,7 +31628,7 @@ const PeerResolveStrategy = enum {
3162831628 // Our merging should be order-independent. Thus, even though the union order is arbitrary,
3162931629 // by sorting the tags and switching first on the smaller, we have half as many cases to
3163031630 // worry about (since we avoid the duplicates).
31631 const s0_is_a = @enumToInt(a) <= @enumToInt(b);
31631 const s0_is_a = @intFromEnum(a) <= @intFromEnum(b);
3163231632 const s0 = if (s0_is_a) a else b;
3163331633 const s1 = if (s0_is_a) b else a;
3163431634
......@@ -33288,9 +33288,9 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi
3328833288
3328933289 if (small.has_backing_int) {
3329033290 var extra_index: usize = extended.operand;
33291 extra_index += @boolToInt(small.has_src_node);
33292 extra_index += @boolToInt(small.has_fields_len);
33293 extra_index += @boolToInt(small.has_decls_len);
33291 extra_index += @intFromBool(small.has_src_node);
33292 extra_index += @intFromBool(small.has_fields_len);
33293 extra_index += @intFromBool(small.has_decls_len);
3329433294
3329533295 const backing_int_body_len = zir.extra[extra_index];
3329633296 extra_index += 1;
......@@ -33338,7 +33338,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi
3333833338 const backing_int_src: LazySrcLoc = .{ .node_offset_container_tag = 0 };
3333933339 const backing_int_ty = blk: {
3334033340 if (backing_int_body_len == 0) {
33341 const backing_int_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
33341 const backing_int_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
3334233342 break :blk try sema.resolveType(&block, backing_int_src, backing_int_ref);
3334333343 } else {
3334433344 const body = zir.extra[extra_index..][0..backing_int_body_len];
......@@ -34013,7 +34013,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3401334013 var extra_index: usize = extended.operand;
3401434014
3401534015 const src = LazySrcLoc.nodeOffset(0);
34016 extra_index += @boolToInt(small.has_src_node);
34016 extra_index += @intFromBool(small.has_src_node);
3401734017
3401834018 const fields_len = if (small.has_fields_len) blk: {
3401934019 const fields_len = zir.extra[extra_index];
......@@ -34140,7 +34140,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3414034140 if (has_type_body) {
3414134141 fields[field_i].type_body_len = zir.extra[extra_index];
3414234142 } else {
34143 fields[field_i].type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
34143 fields[field_i].type_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
3414434144 }
3414534145 extra_index += 1;
3414634146
......@@ -34364,10 +34364,10 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3436434364 var extra_index: usize = extended.operand;
3436534365
3436634366 const src = LazySrcLoc.nodeOffset(0);
34367 extra_index += @boolToInt(small.has_src_node);
34367 extra_index += @intFromBool(small.has_src_node);
3436834368
3436934369 const tag_type_ref: Zir.Inst.Ref = if (small.has_tag_type) blk: {
34370 const ty_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
34370 const ty_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
3437134371 extra_index += 1;
3437234372 break :blk ty_ref;
3437334373 } else .none;
......@@ -34532,19 +34532,19 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3453234532 extra_index += 1;
3453334533
3453434534 const field_type_ref: Zir.Inst.Ref = if (has_type) blk: {
34535 const field_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
34535 const field_type_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
3453634536 extra_index += 1;
3453734537 break :blk field_type_ref;
3453834538 } else .none;
3453934539
3454034540 const align_ref: Zir.Inst.Ref = if (has_align) blk: {
34541 const align_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
34541 const align_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
3454234542 extra_index += 1;
3454334543 break :blk align_ref;
3454434544 } else .none;
3454534545
3454634546 const tag_ref: Air.Inst.Ref = if (has_tag) blk: {
34547 const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
34547 const tag_ref = @enumFromInt(Zir.Inst.Ref, zir.extra[extra_index]);
3454834548 extra_index += 1;
3454934549 break :blk try sema.resolveInst(tag_ref);
3455034550 } else .none;
......@@ -34955,7 +34955,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3495534955
3495634956 inline .array_type, .vector_type => |seq_type, seq_tag| {
3495734957 const has_sentinel = seq_tag == .array_type and seq_type.sentinel != .none;
34958 if (seq_type.len + @boolToInt(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
34958 if (seq_type.len + @intFromBool(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
3495934959 .ty = ty.toIntern(),
3496034960 .storage = .{ .elems = &.{} },
3496134961 } })).toValue();
......@@ -35177,8 +35177,8 @@ pub fn getTmpAir(sema: Sema) Air {
3517735177}
3517835178
3517935179pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
35180 if (@enumToInt(ty.toIntern()) < Air.ref_start_index)
35181 return @intToEnum(Air.Inst.Ref, @enumToInt(ty.toIntern()));
35180 if (@intFromEnum(ty.toIntern()) < Air.ref_start_index)
35181 return @enumFromInt(Air.Inst.Ref, @intFromEnum(ty.toIntern()));
3518235182 try sema.air_instructions.append(sema.gpa, .{
3518335183 .tag = .interned,
3518435184 .data = .{ .interned = ty.toIntern() },
......@@ -35209,8 +35209,8 @@ pub fn addConstant(sema: *Sema, ty: Type, val: Value) SemaError!Air.Inst.Ref {
3520935209 });
3521035210 }
3521135211 }
35212 if (@enumToInt(val.toIntern()) < Air.ref_start_index)
35213 return @intToEnum(Air.Inst.Ref, @enumToInt(val.toIntern()));
35212 if (@intFromEnum(val.toIntern()) < Air.ref_start_index)
35213 return @enumFromInt(Air.Inst.Ref, @intFromEnum(val.toIntern()));
3521435214 try sema.air_instructions.append(gpa, .{
3521535215 .tag = .interned,
3521635216 .data = .{ .interned = val.toIntern() },
......@@ -35230,9 +35230,9 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {
3523035230 inline for (fields) |field| {
3523135231 sema.air_extra.appendAssumeCapacity(switch (field.type) {
3523235232 u32 => @field(extra, field.name),
35233 Air.Inst.Ref => @enumToInt(@field(extra, field.name)),
35233 Air.Inst.Ref => @intFromEnum(@field(extra, field.name)),
3523435234 i32 => @bitCast(u32, @field(extra, field.name)),
35235 InternPool.Index => @enumToInt(@field(extra, field.name)),
35235 InternPool.Index => @intFromEnum(@field(extra, field.name)),
3523635236 else => @compileError("bad field type: " ++ @typeName(field.type)),
3523735237 });
3523835238 }
......@@ -36001,12 +36001,12 @@ fn intSubWithOverflowScalar(
3600136001 const overflowed = result_bigint.subWrap(lhs_bigint, rhs_bigint, info.signedness, info.bits);
3600236002 const wrapped_result = try mod.intValue_big(ty, result_bigint.toConst());
3600336003 return Value.OverflowArithmeticResult{
36004 .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)),
36004 .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)),
3600536005 .wrapped_result = wrapped_result,
3600636006 };
3600736007}
3600836008
36009fn floatToInt(
36009fn intFromFloat(
3601036010 sema: *Sema,
3601136011 block: *Block,
3601236012 src: LazySrcLoc,
......@@ -36021,14 +36021,14 @@ fn floatToInt(
3602136021 const scalar_ty = int_ty.scalarType(mod);
3602236022 for (result_data, 0..) |*scalar, i| {
3602336023 const elem_val = try val.elemValue(sema.mod, i);
36024 scalar.* = try (try sema.floatToIntScalar(block, src, elem_val, elem_ty, int_ty.scalarType(mod))).intern(scalar_ty, mod);
36024 scalar.* = try (try sema.intFromFloatScalar(block, src, elem_val, elem_ty, int_ty.scalarType(mod))).intern(scalar_ty, mod);
3602536025 }
3602636026 return (try mod.intern(.{ .aggregate = .{
3602736027 .ty = int_ty.toIntern(),
3602836028 .storage = .{ .elems = result_data },
3602936029 } })).toValue();
3603036030 }
36031 return sema.floatToIntScalar(block, src, val, float_ty, int_ty);
36031 return sema.intFromFloatScalar(block, src, val, float_ty, int_ty);
3603236032}
3603336033
3603436034// float is expected to be finite and non-NaN
......@@ -36056,7 +36056,7 @@ fn float128IntPartToBigInt(
3605636056 return rational.p;
3605736057}
3605836058
36059fn floatToIntScalar(
36059fn intFromFloatScalar(
3606036060 sema: *Sema,
3606136061 block: *Block,
3606236062 src: LazySrcLoc,
......@@ -36123,21 +36123,21 @@ fn intFitsInType(
3612336123 return big_int.fitsInTwosComp(info.signedness, info.bits);
3612436124 },
3612536125 .lazy_align => |lazy_ty| {
36126 const max_needed_bits = @as(u16, 16) + @boolToInt(info.signedness == .signed);
36126 const max_needed_bits = @as(u16, 16) + @intFromBool(info.signedness == .signed);
3612736127 // If it is u16 or bigger we know the alignment fits without resolving it.
3612836128 if (info.bits >= max_needed_bits) return true;
3612936129 const x = try sema.typeAbiAlignment(lazy_ty.toType());
3613036130 if (x == 0) return true;
36131 const actual_needed_bits = std.math.log2(x) + 1 + @boolToInt(info.signedness == .signed);
36131 const actual_needed_bits = std.math.log2(x) + 1 + @intFromBool(info.signedness == .signed);
3613236132 return info.bits >= actual_needed_bits;
3613336133 },
3613436134 .lazy_size => |lazy_ty| {
36135 const max_needed_bits = @as(u16, 64) + @boolToInt(info.signedness == .signed);
36135 const max_needed_bits = @as(u16, 64) + @intFromBool(info.signedness == .signed);
3613636136 // If it is u64 or bigger we know the size fits without resolving it.
3613736137 if (info.bits >= max_needed_bits) return true;
3613836138 const x = try sema.typeAbiSize(lazy_ty.toType());
3613936139 if (x == 0) return true;
36140 const actual_needed_bits = std.math.log2(x) + 1 + @boolToInt(info.signedness == .signed);
36140 const actual_needed_bits = std.math.log2(x) + 1 + @intFromBool(info.signedness == .signed);
3614136141 return info.bits >= actual_needed_bits;
3614236142 },
3614336143 },
......@@ -36146,7 +36146,7 @@ fn intFitsInType(
3614636146 return switch (aggregate.storage) {
3614736147 .bytes => |bytes| for (bytes, 0..) |byte, i| {
3614836148 if (byte == 0) continue;
36149 const actual_needed_bits = std.math.log2(byte) + 1 + @boolToInt(info.signedness == .signed);
36149 const actual_needed_bits = std.math.log2(byte) + 1 + @intFromBool(info.signedness == .signed);
3615036150 if (info.bits >= actual_needed_bits) continue;
3615136151 if (vector_index) |vi| vi.* = i;
3615236152 break false;
......@@ -36242,7 +36242,7 @@ fn intAddWithOverflowScalar(
3624236242 const overflowed = result_bigint.addWrap(lhs_bigint, rhs_bigint, info.signedness, info.bits);
3624336243 const result = try mod.intValue_big(ty, result_bigint.toConst());
3624436244 return Value.OverflowArithmeticResult{
36245 .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)),
36245 .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)),
3624636246 .wrapped_result = result,
3624736247 };
3624836248}
......@@ -36352,7 +36352,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type {
3635236352 break :blk .{
3635336353 .host_size = @intCast(u16, parent_ty.arrayLen(mod)),
3635436354 .alignment = @intCast(u16, parent_ty.abiAlignment(mod)),
36355 .vector_index = if (offset) |some| @intToEnum(VI, some) else .runtime,
36355 .vector_index = if (offset) |some| @enumFromInt(VI, some) else .runtime,
3635636356 };
3635736357 } else .{};
3635836358
src/TypedValue.zig+3-3
......@@ -41,8 +41,8 @@ pub fn hash(tv: TypedValue, hasher: *std.hash.Wyhash, mod: *Module) void {
4141 return tv.val.hash(tv.ty, hasher, mod);
4242}
4343
44pub fn enumToInt(tv: TypedValue, mod: *Module) Allocator.Error!Value {
45 return tv.val.enumToInt(tv.ty, mod);
44pub fn intFromEnum(tv: TypedValue, mod: *Module) Allocator.Error!Value {
45 return tv.val.intFromEnum(tv.ty, mod);
4646}
4747
4848const max_aggregate_items = 100;
......@@ -240,7 +240,7 @@ pub fn print(
240240 try writer.print(".{i}", .{enum_type.names[tag_index].fmt(ip)});
241241 return;
242242 }
243 try writer.writeAll("@intToEnum(");
243 try writer.writeAll("@enumFromInt(");
244244 try print(.{
245245 .ty = Type.type,
246246 .val = enum_tag.ty.toValue(),
src/Zir.zig+141-141
......@@ -74,7 +74,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en
7474 inline for (fields) |field| {
7575 @field(result, field.name) = switch (field.type) {
7676 u32 => code.extra[i],
77 Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]),
77 Inst.Ref => @enumFromInt(Inst.Ref, code.extra[i]),
7878 i32 => @bitCast(i32, code.extra[i]),
7979 Inst.Call.Flags => @bitCast(Inst.Call.Flags, code.extra[i]),
8080 Inst.BuiltinCall.Flags => @bitCast(Inst.BuiltinCall.Flags, code.extra[i]),
......@@ -105,7 +105,7 @@ pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref {
105105}
106106
107107pub fn hasCompileErrors(code: Zir) bool {
108 return code.extra[@enumToInt(ExtraIndex.compile_errors)] != 0;
108 return code.extra[@intFromEnum(ExtraIndex.compile_errors)] != 0;
109109}
110110
111111pub fn deinit(code: *Zir, gpa: Allocator) void {
......@@ -749,9 +749,9 @@ pub const Inst = struct {
749749 /// Implements the `@bitSizeOf` builtin. Uses `un_node`.
750750 bit_size_of,
751751
752 /// Implement builtin `@ptrToInt`. Uses `un_node`.
752 /// Implement builtin `@intFromPtr`. Uses `un_node`.
753753 /// Convert a pointer to a `usize` integer.
754 ptr_to_int,
754 int_from_ptr,
755755 /// Emit an error message and fail compilation.
756756 /// Uses the `un_node` field.
757757 compile_error,
......@@ -761,11 +761,11 @@ pub const Inst = struct {
761761 set_eval_branch_quota,
762762 /// Converts an enum value into an integer. Resulting type will be the tag type
763763 /// of the enum. Uses `un_node`.
764 enum_to_int,
764 int_from_enum,
765765 /// Implement builtin `@alignOf`. Uses `un_node`.
766766 align_of,
767 /// Implement builtin `@boolToInt`. Uses `un_node`.
768 bool_to_int,
767 /// Implement builtin `@intFromBool`. Uses `un_node`.
768 int_from_bool,
769769 /// Implement builtin `@embedFile`. Uses `un_node`.
770770 embed_file,
771771 /// Implement builtin `@errorName`. Uses `un_node`.
......@@ -814,18 +814,18 @@ pub const Inst = struct {
814814 /// Implement builtin `@frameSize`. Uses `un_node`.
815815 frame_size,
816816
817 /// Implements the `@floatToInt` builtin.
817 /// Implements the `@intFromFloat` builtin.
818818 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
819 float_to_int,
820 /// Implements the `@intToFloat` builtin.
819 int_from_float,
820 /// Implements the `@floatFromInt` builtin.
821821 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
822 int_to_float,
823 /// Implements the `@intToPtr` builtin.
822 float_from_int,
823 /// Implements the `@ptrFromInt` builtin.
824824 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
825 int_to_ptr,
825 ptr_from_int,
826826 /// Converts an integer into an enum value.
827827 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
828 int_to_enum,
828 enum_from_int,
829829 /// Convert a larger float type to any other float type, possibly causing
830830 /// a loss of precision.
831831 /// Uses the `pl_node` field. AST is the `@floatCast` syntax.
......@@ -1136,14 +1136,14 @@ pub const Inst = struct {
11361136 .union_init,
11371137 .field_type,
11381138 .field_type_ref,
1139 .int_to_enum,
1140 .enum_to_int,
1139 .enum_from_int,
1140 .int_from_enum,
11411141 .type_info,
11421142 .size_of,
11431143 .bit_size_of,
1144 .ptr_to_int,
1144 .int_from_ptr,
11451145 .align_of,
1146 .bool_to_int,
1146 .int_from_bool,
11471147 .embed_file,
11481148 .error_name,
11491149 .set_runtime_safety,
......@@ -1165,9 +1165,9 @@ pub const Inst = struct {
11651165 .type_name,
11661166 .frame_type,
11671167 .frame_size,
1168 .float_to_int,
1169 .int_to_float,
1170 .int_to_ptr,
1168 .int_from_float,
1169 .float_from_int,
1170 .ptr_from_int,
11711171 .float_cast,
11721172 .int_cast,
11731173 .ptr_cast,
......@@ -1419,14 +1419,14 @@ pub const Inst = struct {
14191419 .union_init,
14201420 .field_type,
14211421 .field_type_ref,
1422 .int_to_enum,
1423 .enum_to_int,
1422 .enum_from_int,
1423 .int_from_enum,
14241424 .type_info,
14251425 .size_of,
14261426 .bit_size_of,
1427 .ptr_to_int,
1427 .int_from_ptr,
14281428 .align_of,
1429 .bool_to_int,
1429 .int_from_bool,
14301430 .embed_file,
14311431 .error_name,
14321432 .sqrt,
......@@ -1447,9 +1447,9 @@ pub const Inst = struct {
14471447 .type_name,
14481448 .frame_type,
14491449 .frame_size,
1450 .float_to_int,
1451 .int_to_float,
1452 .int_to_ptr,
1450 .int_from_float,
1451 .float_from_int,
1452 .ptr_from_int,
14531453 .float_cast,
14541454 .int_cast,
14551455 .ptr_cast,
......@@ -1679,12 +1679,12 @@ pub const Inst = struct {
16791679 .size_of = .un_node,
16801680 .bit_size_of = .un_node,
16811681
1682 .ptr_to_int = .un_node,
1682 .int_from_ptr = .un_node,
16831683 .compile_error = .un_node,
16841684 .set_eval_branch_quota = .un_node,
1685 .enum_to_int = .un_node,
1685 .int_from_enum = .un_node,
16861686 .align_of = .un_node,
1687 .bool_to_int = .un_node,
1687 .int_from_bool = .un_node,
16881688 .embed_file = .un_node,
16891689 .error_name = .un_node,
16901690 .panic = .un_node,
......@@ -1709,10 +1709,10 @@ pub const Inst = struct {
17091709 .frame_type = .un_node,
17101710 .frame_size = .un_node,
17111711
1712 .float_to_int = .pl_node,
1713 .int_to_float = .pl_node,
1714 .int_to_ptr = .pl_node,
1715 .int_to_enum = .pl_node,
1712 .int_from_float = .pl_node,
1713 .float_from_int = .pl_node,
1714 .ptr_from_int = .pl_node,
1715 .enum_from_int = .pl_node,
17161716 .float_cast = .pl_node,
17171717 .int_cast = .pl_node,
17181718 .ptr_cast = .pl_node,
......@@ -1933,10 +1933,10 @@ pub const Inst = struct {
19331933 select,
19341934 /// Implement builtin `@errToInt`.
19351935 /// `operand` is payload index to `UnNode`.
1936 error_to_int,
1937 /// Implement builtin `@intToError`.
1936 int_from_error,
1937 /// Implement builtin `@errorFromInt`.
19381938 /// `operand` is payload index to `UnNode`.
1939 int_to_error,
1939 error_from_int,
19401940 /// Implement builtin `@Type`.
19411941 /// `operand` is payload index to `UnNode`.
19421942 /// `small` contains `NameStrategy`.
......@@ -2005,93 +2005,93 @@ pub const Inst = struct {
20052005 /// The tag type is specified so that it is safe to bitcast between `[]u32`
20062006 /// and `[]Ref`.
20072007 pub const Ref = enum(u32) {
2008 u1_type = @enumToInt(InternPool.Index.u1_type),
2009 u8_type = @enumToInt(InternPool.Index.u8_type),
2010 i8_type = @enumToInt(InternPool.Index.i8_type),
2011 u16_type = @enumToInt(InternPool.Index.u16_type),
2012 i16_type = @enumToInt(InternPool.Index.i16_type),
2013 u29_type = @enumToInt(InternPool.Index.u29_type),
2014 u32_type = @enumToInt(InternPool.Index.u32_type),
2015 i32_type = @enumToInt(InternPool.Index.i32_type),
2016 u64_type = @enumToInt(InternPool.Index.u64_type),
2017 i64_type = @enumToInt(InternPool.Index.i64_type),
2018 u80_type = @enumToInt(InternPool.Index.u80_type),
2019 u128_type = @enumToInt(InternPool.Index.u128_type),
2020 i128_type = @enumToInt(InternPool.Index.i128_type),
2021 usize_type = @enumToInt(InternPool.Index.usize_type),
2022 isize_type = @enumToInt(InternPool.Index.isize_type),
2023 c_char_type = @enumToInt(InternPool.Index.c_char_type),
2024 c_short_type = @enumToInt(InternPool.Index.c_short_type),
2025 c_ushort_type = @enumToInt(InternPool.Index.c_ushort_type),
2026 c_int_type = @enumToInt(InternPool.Index.c_int_type),
2027 c_uint_type = @enumToInt(InternPool.Index.c_uint_type),
2028 c_long_type = @enumToInt(InternPool.Index.c_long_type),
2029 c_ulong_type = @enumToInt(InternPool.Index.c_ulong_type),
2030 c_longlong_type = @enumToInt(InternPool.Index.c_longlong_type),
2031 c_ulonglong_type = @enumToInt(InternPool.Index.c_ulonglong_type),
2032 c_longdouble_type = @enumToInt(InternPool.Index.c_longdouble_type),
2033 f16_type = @enumToInt(InternPool.Index.f16_type),
2034 f32_type = @enumToInt(InternPool.Index.f32_type),
2035 f64_type = @enumToInt(InternPool.Index.f64_type),
2036 f80_type = @enumToInt(InternPool.Index.f80_type),
2037 f128_type = @enumToInt(InternPool.Index.f128_type),
2038 anyopaque_type = @enumToInt(InternPool.Index.anyopaque_type),
2039 bool_type = @enumToInt(InternPool.Index.bool_type),
2040 void_type = @enumToInt(InternPool.Index.void_type),
2041 type_type = @enumToInt(InternPool.Index.type_type),
2042 anyerror_type = @enumToInt(InternPool.Index.anyerror_type),
2043 comptime_int_type = @enumToInt(InternPool.Index.comptime_int_type),
2044 comptime_float_type = @enumToInt(InternPool.Index.comptime_float_type),
2045 noreturn_type = @enumToInt(InternPool.Index.noreturn_type),
2046 anyframe_type = @enumToInt(InternPool.Index.anyframe_type),
2047 null_type = @enumToInt(InternPool.Index.null_type),
2048 undefined_type = @enumToInt(InternPool.Index.undefined_type),
2049 enum_literal_type = @enumToInt(InternPool.Index.enum_literal_type),
2050 atomic_order_type = @enumToInt(InternPool.Index.atomic_order_type),
2051 atomic_rmw_op_type = @enumToInt(InternPool.Index.atomic_rmw_op_type),
2052 calling_convention_type = @enumToInt(InternPool.Index.calling_convention_type),
2053 address_space_type = @enumToInt(InternPool.Index.address_space_type),
2054 float_mode_type = @enumToInt(InternPool.Index.float_mode_type),
2055 reduce_op_type = @enumToInt(InternPool.Index.reduce_op_type),
2056 call_modifier_type = @enumToInt(InternPool.Index.call_modifier_type),
2057 prefetch_options_type = @enumToInt(InternPool.Index.prefetch_options_type),
2058 export_options_type = @enumToInt(InternPool.Index.export_options_type),
2059 extern_options_type = @enumToInt(InternPool.Index.extern_options_type),
2060 type_info_type = @enumToInt(InternPool.Index.type_info_type),
2061 manyptr_u8_type = @enumToInt(InternPool.Index.manyptr_u8_type),
2062 manyptr_const_u8_type = @enumToInt(InternPool.Index.manyptr_const_u8_type),
2063 manyptr_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.manyptr_const_u8_sentinel_0_type),
2064 single_const_pointer_to_comptime_int_type = @enumToInt(InternPool.Index.single_const_pointer_to_comptime_int_type),
2065 slice_const_u8_type = @enumToInt(InternPool.Index.slice_const_u8_type),
2066 slice_const_u8_sentinel_0_type = @enumToInt(InternPool.Index.slice_const_u8_sentinel_0_type),
2067 anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type),
2068 generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type),
2069 empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type),
2070 undef = @enumToInt(InternPool.Index.undef),
2071 zero = @enumToInt(InternPool.Index.zero),
2072 zero_usize = @enumToInt(InternPool.Index.zero_usize),
2073 zero_u8 = @enumToInt(InternPool.Index.zero_u8),
2074 one = @enumToInt(InternPool.Index.one),
2075 one_usize = @enumToInt(InternPool.Index.one_usize),
2076 one_u8 = @enumToInt(InternPool.Index.one_u8),
2077 four_u8 = @enumToInt(InternPool.Index.four_u8),
2078 negative_one = @enumToInt(InternPool.Index.negative_one),
2079 calling_convention_c = @enumToInt(InternPool.Index.calling_convention_c),
2080 calling_convention_inline = @enumToInt(InternPool.Index.calling_convention_inline),
2081 void_value = @enumToInt(InternPool.Index.void_value),
2082 unreachable_value = @enumToInt(InternPool.Index.unreachable_value),
2083 null_value = @enumToInt(InternPool.Index.null_value),
2084 bool_true = @enumToInt(InternPool.Index.bool_true),
2085 bool_false = @enumToInt(InternPool.Index.bool_false),
2086 empty_struct = @enumToInt(InternPool.Index.empty_struct),
2087 generic_poison = @enumToInt(InternPool.Index.generic_poison),
2008 u1_type = @intFromEnum(InternPool.Index.u1_type),
2009 u8_type = @intFromEnum(InternPool.Index.u8_type),
2010 i8_type = @intFromEnum(InternPool.Index.i8_type),
2011 u16_type = @intFromEnum(InternPool.Index.u16_type),
2012 i16_type = @intFromEnum(InternPool.Index.i16_type),
2013 u29_type = @intFromEnum(InternPool.Index.u29_type),
2014 u32_type = @intFromEnum(InternPool.Index.u32_type),
2015 i32_type = @intFromEnum(InternPool.Index.i32_type),
2016 u64_type = @intFromEnum(InternPool.Index.u64_type),
2017 i64_type = @intFromEnum(InternPool.Index.i64_type),
2018 u80_type = @intFromEnum(InternPool.Index.u80_type),
2019 u128_type = @intFromEnum(InternPool.Index.u128_type),
2020 i128_type = @intFromEnum(InternPool.Index.i128_type),
2021 usize_type = @intFromEnum(InternPool.Index.usize_type),
2022 isize_type = @intFromEnum(InternPool.Index.isize_type),
2023 c_char_type = @intFromEnum(InternPool.Index.c_char_type),
2024 c_short_type = @intFromEnum(InternPool.Index.c_short_type),
2025 c_ushort_type = @intFromEnum(InternPool.Index.c_ushort_type),
2026 c_int_type = @intFromEnum(InternPool.Index.c_int_type),
2027 c_uint_type = @intFromEnum(InternPool.Index.c_uint_type),
2028 c_long_type = @intFromEnum(InternPool.Index.c_long_type),
2029 c_ulong_type = @intFromEnum(InternPool.Index.c_ulong_type),
2030 c_longlong_type = @intFromEnum(InternPool.Index.c_longlong_type),
2031 c_ulonglong_type = @intFromEnum(InternPool.Index.c_ulonglong_type),
2032 c_longdouble_type = @intFromEnum(InternPool.Index.c_longdouble_type),
2033 f16_type = @intFromEnum(InternPool.Index.f16_type),
2034 f32_type = @intFromEnum(InternPool.Index.f32_type),
2035 f64_type = @intFromEnum(InternPool.Index.f64_type),
2036 f80_type = @intFromEnum(InternPool.Index.f80_type),
2037 f128_type = @intFromEnum(InternPool.Index.f128_type),
2038 anyopaque_type = @intFromEnum(InternPool.Index.anyopaque_type),
2039 bool_type = @intFromEnum(InternPool.Index.bool_type),
2040 void_type = @intFromEnum(InternPool.Index.void_type),
2041 type_type = @intFromEnum(InternPool.Index.type_type),
2042 anyerror_type = @intFromEnum(InternPool.Index.anyerror_type),
2043 comptime_int_type = @intFromEnum(InternPool.Index.comptime_int_type),
2044 comptime_float_type = @intFromEnum(InternPool.Index.comptime_float_type),
2045 noreturn_type = @intFromEnum(InternPool.Index.noreturn_type),
2046 anyframe_type = @intFromEnum(InternPool.Index.anyframe_type),
2047 null_type = @intFromEnum(InternPool.Index.null_type),
2048 undefined_type = @intFromEnum(InternPool.Index.undefined_type),
2049 enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type),
2050 atomic_order_type = @intFromEnum(InternPool.Index.atomic_order_type),
2051 atomic_rmw_op_type = @intFromEnum(InternPool.Index.atomic_rmw_op_type),
2052 calling_convention_type = @intFromEnum(InternPool.Index.calling_convention_type),
2053 address_space_type = @intFromEnum(InternPool.Index.address_space_type),
2054 float_mode_type = @intFromEnum(InternPool.Index.float_mode_type),
2055 reduce_op_type = @intFromEnum(InternPool.Index.reduce_op_type),
2056 call_modifier_type = @intFromEnum(InternPool.Index.call_modifier_type),
2057 prefetch_options_type = @intFromEnum(InternPool.Index.prefetch_options_type),
2058 export_options_type = @intFromEnum(InternPool.Index.export_options_type),
2059 extern_options_type = @intFromEnum(InternPool.Index.extern_options_type),
2060 type_info_type = @intFromEnum(InternPool.Index.type_info_type),
2061 manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type),
2062 manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type),
2063 manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type),
2064 single_const_pointer_to_comptime_int_type = @intFromEnum(InternPool.Index.single_const_pointer_to_comptime_int_type),
2065 slice_const_u8_type = @intFromEnum(InternPool.Index.slice_const_u8_type),
2066 slice_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.slice_const_u8_sentinel_0_type),
2067 anyerror_void_error_union_type = @intFromEnum(InternPool.Index.anyerror_void_error_union_type),
2068 generic_poison_type = @intFromEnum(InternPool.Index.generic_poison_type),
2069 empty_struct_type = @intFromEnum(InternPool.Index.empty_struct_type),
2070 undef = @intFromEnum(InternPool.Index.undef),
2071 zero = @intFromEnum(InternPool.Index.zero),
2072 zero_usize = @intFromEnum(InternPool.Index.zero_usize),
2073 zero_u8 = @intFromEnum(InternPool.Index.zero_u8),
2074 one = @intFromEnum(InternPool.Index.one),
2075 one_usize = @intFromEnum(InternPool.Index.one_usize),
2076 one_u8 = @intFromEnum(InternPool.Index.one_u8),
2077 four_u8 = @intFromEnum(InternPool.Index.four_u8),
2078 negative_one = @intFromEnum(InternPool.Index.negative_one),
2079 calling_convention_c = @intFromEnum(InternPool.Index.calling_convention_c),
2080 calling_convention_inline = @intFromEnum(InternPool.Index.calling_convention_inline),
2081 void_value = @intFromEnum(InternPool.Index.void_value),
2082 unreachable_value = @intFromEnum(InternPool.Index.unreachable_value),
2083 null_value = @intFromEnum(InternPool.Index.null_value),
2084 bool_true = @intFromEnum(InternPool.Index.bool_true),
2085 bool_false = @intFromEnum(InternPool.Index.bool_false),
2086 empty_struct = @intFromEnum(InternPool.Index.empty_struct),
2087 generic_poison = @intFromEnum(InternPool.Index.generic_poison),
20882088
20892089 /// This tag is here to match Air and InternPool, however it is unused
20902090 /// for ZIR purposes.
2091 var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
2091 var_args_param_type = @intFromEnum(InternPool.Index.var_args_param_type),
20922092 /// This Ref does not correspond to any ZIR instruction or constant
20932093 /// value and may instead be used as a sentinel to indicate null.
2094 none = @enumToInt(InternPool.Index.none),
2094 none = @intFromEnum(InternPool.Index.none),
20952095 _,
20962096 };
20972097
......@@ -2691,8 +2691,8 @@ pub const Inst = struct {
26912691 pub const ScalarCasesLen = u28;
26922692
26932693 pub fn specialProng(bits: Bits) SpecialProng {
2694 const has_else: u2 = @boolToInt(bits.has_else);
2695 const has_under: u2 = @boolToInt(bits.has_under);
2694 const has_else: u2 = @intFromBool(bits.has_else);
2695 const has_under: u2 = @intFromBool(bits.has_under);
26962696 return switch ((has_else << 1) | has_under) {
26972697 0b00 => .none,
26982698 0b01 => .under,
......@@ -3241,8 +3241,8 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
32413241 .struct_decl => {
32423242 const small = @bitCast(Inst.StructDecl.Small, extended.small);
32433243 var extra_index: usize = extended.operand;
3244 extra_index += @boolToInt(small.has_src_node);
3245 extra_index += @boolToInt(small.has_fields_len);
3244 extra_index += @intFromBool(small.has_src_node);
3245 extra_index += @intFromBool(small.has_fields_len);
32463246 const decls_len = if (small.has_decls_len) decls_len: {
32473247 const decls_len = zir.extra[extra_index];
32483248 extra_index += 1;
......@@ -3264,10 +3264,10 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
32643264 .enum_decl => {
32653265 const small = @bitCast(Inst.EnumDecl.Small, extended.small);
32663266 var extra_index: usize = extended.operand;
3267 extra_index += @boolToInt(small.has_src_node);
3268 extra_index += @boolToInt(small.has_tag_type);
3269 extra_index += @boolToInt(small.has_body_len);
3270 extra_index += @boolToInt(small.has_fields_len);
3267 extra_index += @intFromBool(small.has_src_node);
3268 extra_index += @intFromBool(small.has_tag_type);
3269 extra_index += @intFromBool(small.has_body_len);
3270 extra_index += @intFromBool(small.has_fields_len);
32713271 const decls_len = if (small.has_decls_len) decls_len: {
32723272 const decls_len = zir.extra[extra_index];
32733273 extra_index += 1;
......@@ -3279,10 +3279,10 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
32793279 .union_decl => {
32803280 const small = @bitCast(Inst.UnionDecl.Small, extended.small);
32813281 var extra_index: usize = extended.operand;
3282 extra_index += @boolToInt(small.has_src_node);
3283 extra_index += @boolToInt(small.has_tag_type);
3284 extra_index += @boolToInt(small.has_body_len);
3285 extra_index += @boolToInt(small.has_fields_len);
3282 extra_index += @intFromBool(small.has_src_node);
3283 extra_index += @intFromBool(small.has_tag_type);
3284 extra_index += @intFromBool(small.has_body_len);
3285 extra_index += @intFromBool(small.has_fields_len);
32863286 const decls_len = if (small.has_decls_len) decls_len: {
32873287 const decls_len = zir.extra[extra_index];
32883288 extra_index += 1;
......@@ -3294,7 +3294,7 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
32943294 .opaque_decl => {
32953295 const small = @bitCast(Inst.OpaqueDecl.Small, extended.small);
32963296 var extra_index: usize = extended.operand;
3297 extra_index += @boolToInt(small.has_src_node);
3297 extra_index += @intFromBool(small.has_src_node);
32983298 const decls_len = if (small.has_decls_len) decls_len: {
32993299 const decls_len = zir.extra[extra_index];
33003300 extra_index += 1;
......@@ -3367,7 +3367,7 @@ fn findDeclsInner(
33673367 const inst_data = datas[inst].pl_node;
33683368 const extra = zir.extraData(Inst.FuncFancy, inst_data.payload_index);
33693369 var extra_index: usize = extra.end;
3370 extra_index += @boolToInt(extra.data.bits.has_lib_name);
3370 extra_index += @intFromBool(extra.data.bits.has_lib_name);
33713371
33723372 if (extra.data.bits.has_align_body) {
33733373 const body_len = zir.extra[extra_index];
......@@ -3419,7 +3419,7 @@ fn findDeclsInner(
34193419 extra_index += 1;
34203420 }
34213421
3422 extra_index += @boolToInt(extra.data.bits.has_any_noalias);
3422 extra_index += @intFromBool(extra.data.bits.has_any_noalias);
34233423
34243424 const body = zir.extra[extra_index..][0..extra.data.body_len];
34253425 return zir.findDeclsBody(list, body);
......@@ -3598,7 +3598,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
35983598 ret_ty_ref = .void_type;
35993599 },
36003600 1 => {
3601 ret_ty_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]);
3601 ret_ty_ref = @enumFromInt(Inst.Ref, zir.extra[extra_index]);
36023602 extra_index += 1;
36033603 },
36043604 else => {
......@@ -3625,7 +3625,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
36253625 var ret_ty_ref: Inst.Ref = .void_type;
36263626 var ret_ty_body: []const Inst.Index = &.{};
36273627
3628 extra_index += @boolToInt(extra.data.bits.has_lib_name);
3628 extra_index += @intFromBool(extra.data.bits.has_lib_name);
36293629 if (extra.data.bits.has_align_body) {
36303630 extra_index += zir.extra[extra_index] + 1;
36313631 } else if (extra.data.bits.has_align_ref) {
......@@ -3652,11 +3652,11 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
36523652 ret_ty_body = zir.extra[extra_index..][0..body_len];
36533653 extra_index += ret_ty_body.len;
36543654 } else if (extra.data.bits.has_ret_ty_ref) {
3655 ret_ty_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]);
3655 ret_ty_ref = @enumFromInt(Inst.Ref, zir.extra[extra_index]);
36563656 extra_index += 1;
36573657 }
36583658
3659 extra_index += @boolToInt(extra.data.bits.has_any_noalias);
3659 extra_index += @intFromBool(extra.data.bits.has_any_noalias);
36603660
36613661 const body = zir.extra[extra_index..][0..extra.data.body_len];
36623662 extra_index += body.len;
......@@ -3696,12 +3696,12 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
36963696pub const ref_start_index: u32 = InternPool.static_len;
36973697
36983698pub fn indexToRef(inst: Inst.Index) Inst.Ref {
3699 return @intToEnum(Inst.Ref, ref_start_index + inst);
3699 return @enumFromInt(Inst.Ref, ref_start_index + inst);
37003700}
37013701
37023702pub fn refToIndex(inst: Inst.Ref) ?Inst.Index {
37033703 assert(inst != .none);
3704 const ref_int = @enumToInt(inst);
3704 const ref_int = @intFromEnum(inst);
37053705 if (ref_int >= ref_start_index) {
37063706 return ref_int - ref_start_index;
37073707 } else {
src/arch/aarch64/CodeGen.zig+17-17
......@@ -752,7 +752,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
752752 .fpext => try self.airFpext(inst),
753753 .intcast => try self.airIntCast(inst),
754754 .trunc => try self.airTrunc(inst),
755 .bool_to_int => try self.airBoolToInt(inst),
755 .int_from_bool => try self.airIntFromBool(inst),
756756 .is_non_null => try self.airIsNonNull(inst),
757757 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
758758 .is_null => try self.airIsNull(inst),
......@@ -764,7 +764,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
764764 .load => try self.airLoad(inst),
765765 .loop => try self.airLoop(inst),
766766 .not => try self.airNot(inst),
767 .ptrtoint => try self.airPtrToInt(inst),
767 .int_from_ptr => try self.airIntFromPtr(inst),
768768 .ret => try self.airRet(inst),
769769 .ret_load => try self.airRetLoad(inst),
770770 .store => try self.airStore(inst, false),
......@@ -772,8 +772,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
772772 .struct_field_ptr=> try self.airStructFieldPtr(inst),
773773 .struct_field_val=> try self.airStructFieldVal(inst),
774774 .array_to_slice => try self.airArrayToSlice(inst),
775 .int_to_float => try self.airIntToFloat(inst),
776 .float_to_int => try self.airFloatToInt(inst),
775 .float_from_int => try self.airFloatFromInt(inst),
776 .int_from_float => try self.airIntFromFloat(inst),
777777 .cmpxchg_strong => try self.airCmpxchg(inst),
778778 .cmpxchg_weak => try self.airCmpxchg(inst),
779779 .atomic_rmw => try self.airAtomicRmw(inst),
......@@ -885,7 +885,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
885885 .cmp_neq_optimized,
886886 .cmp_vector_optimized,
887887 .reduce_optimized,
888 .float_to_int_optimized,
888 .int_from_float_optimized,
889889 => return self.fail("TODO implement optimized float mode", .{}),
890890
891891 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
......@@ -951,7 +951,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
951951 const dies = @truncate(u1, tomb_bits) != 0;
952952 tomb_bits >>= 1;
953953 if (!dies) continue;
954 const op_int = @enumToInt(op);
954 const op_int = @intFromEnum(op);
955955 if (op_int < Air.ref_start_index) continue;
956956 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
957957 self.processDeath(op_index);
......@@ -1310,7 +1310,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
13101310 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
13111311}
13121312
1313fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {
1313fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
13141314 const un_op = self.air.instructions.items(.data)[inst].un_op;
13151315 const operand = try self.resolveInst(un_op);
13161316 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
......@@ -4026,7 +4026,7 @@ fn store(self: *Self, ptr: MCValue, value: MCValue, ptr_ty: Type, value_ty: Type
40264026 .tag = tag,
40274027 .data = .{
40284028 .payload = try self.addExtra(Mir.LoadMemoryPie{
4029 .register = @enumToInt(src_reg),
4029 .register = @intFromEnum(src_reg),
40304030 .atom_index = atom_index,
40314031 .sym_index = load_struct.sym_index,
40324032 }),
......@@ -4694,7 +4694,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
46944694 // that death now instead of later as this has an effect on
46954695 // whether it needs to be spilled in the branches
46964696 if (self.liveness.operandDies(inst, 0)) {
4697 const op_int = @enumToInt(pl_op.operand);
4697 const op_int = @intFromEnum(pl_op.operand);
46984698 if (op_int >= Air.ref_start_index) {
46994699 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
47004700 self.processDeath(op_index);
......@@ -5546,7 +5546,7 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
55465546 .tag = tag,
55475547 .data = .{
55485548 .payload = try self.addExtra(Mir.LoadMemoryPie{
5549 .register = @enumToInt(src_reg),
5549 .register = @intFromEnum(src_reg),
55505550 .atom_index = atom_index,
55515551 .sym_index = load_struct.sym_index,
55525552 }),
......@@ -5667,7 +5667,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
56675667 .tag = tag,
56685668 .data = .{
56695669 .payload = try self.addExtra(Mir.LoadMemoryPie{
5670 .register = @enumToInt(reg),
5670 .register = @intFromEnum(reg),
56715671 .atom_index = atom_index,
56725672 .sym_index = load_struct.sym_index,
56735673 }),
......@@ -5864,7 +5864,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I
58645864 .tag = tag,
58655865 .data = .{
58665866 .payload = try self.addExtra(Mir.LoadMemoryPie{
5867 .register = @enumToInt(src_reg),
5867 .register = @intFromEnum(src_reg),
58685868 .atom_index = atom_index,
58695869 .sym_index = load_struct.sym_index,
58705870 }),
......@@ -5903,7 +5903,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I
59035903 }
59045904}
59055905
5906fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {
5906fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
59075907 const un_op = self.air.instructions.items(.data)[inst].un_op;
59085908 const result = try self.resolveInst(un_op);
59095909 return self.finishAir(inst, result, .{ un_op, .none, .none });
......@@ -5950,17 +5950,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
59505950 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
59515951}
59525952
5953fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
5953fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
59545954 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
5955 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntToFloat for {}", .{
5955 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatFromInt for {}", .{
59565956 self.target.cpu.arch,
59575957 });
59585958 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
59595959}
59605960
5961fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
5961fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
59625962 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
5963 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatToInt for {}", .{
5963 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntFromFloat for {}", .{
59645964 self.target.cpu.arch,
59655965 });
59665966 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/aarch64/Emit.zig+3-3
......@@ -837,7 +837,7 @@ fn mirLoadMemoryPie(emit: *Emit, inst: Mir.Inst.Index) !void {
837837 const tag = emit.mir.instructions.items(.tag)[inst];
838838 const payload = emit.mir.instructions.items(.data)[inst].payload;
839839 const data = emit.mir.extraData(Mir.LoadMemoryPie, payload).data;
840 const reg = @intToEnum(Register, data.register);
840 const reg = @enumFromInt(Register, data.register);
841841
842842 // PC-relative displacement to the entry in memory.
843843 // adrp
......@@ -1245,7 +1245,7 @@ fn mirPushPopRegs(emit: *Emit, inst: Mir.Inst.Index) !void {
12451245 var count: u6 = 0;
12461246 var other_reg: ?Register = null;
12471247 while (i > 0) : (i -= 1) {
1248 const reg = @intToEnum(Register, i - 1);
1248 const reg = @enumFromInt(Register, i - 1);
12491249 if (regListIsSet(reg_list, reg)) {
12501250 if (count == 0 and odd_number_of_regs) {
12511251 try emit.writeInstruction(Instruction.ldr(
......@@ -1274,7 +1274,7 @@ fn mirPushPopRegs(emit: *Emit, inst: Mir.Inst.Index) !void {
12741274 var count: u6 = 0;
12751275 var other_reg: ?Register = null;
12761276 while (i < 32) : (i += 1) {
1277 const reg = @intToEnum(Register, i);
1277 const reg = @enumFromInt(Register, i);
12781278 if (regListIsSet(reg_list, reg)) {
12791279 if (count == number_of_regs - 1 and odd_number_of_regs) {
12801280 try emit.writeInstruction(Instruction.str(
src/arch/aarch64/bits.zig+123-123
......@@ -62,84 +62,84 @@ pub const Register = enum(u8) {
6262 // zig fmt: on
6363
6464 pub fn class(self: Register) RegisterClass {
65 return switch (@enumToInt(self)) {
66 @enumToInt(Register.x0)...@enumToInt(Register.xzr) => .general_purpose,
67 @enumToInt(Register.w0)...@enumToInt(Register.wzr) => .general_purpose,
68
69 @enumToInt(Register.sp) => .stack_pointer,
70 @enumToInt(Register.wsp) => .stack_pointer,
71
72 @enumToInt(Register.q0)...@enumToInt(Register.q31) => .floating_point,
73 @enumToInt(Register.d0)...@enumToInt(Register.d31) => .floating_point,
74 @enumToInt(Register.s0)...@enumToInt(Register.s31) => .floating_point,
75 @enumToInt(Register.h0)...@enumToInt(Register.h31) => .floating_point,
76 @enumToInt(Register.b0)...@enumToInt(Register.b31) => .floating_point,
65 return switch (@intFromEnum(self)) {
66 @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => .general_purpose,
67 @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => .general_purpose,
68
69 @intFromEnum(Register.sp) => .stack_pointer,
70 @intFromEnum(Register.wsp) => .stack_pointer,
71
72 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => .floating_point,
73 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => .floating_point,
74 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => .floating_point,
75 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => .floating_point,
76 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => .floating_point,
7777 else => unreachable,
7878 };
7979 }
8080
8181 pub fn id(self: Register) u6 {
82 return switch (@enumToInt(self)) {
83 @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.x0)),
84 @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.w0)),
85
86 @enumToInt(Register.sp) => 32,
87 @enumToInt(Register.wsp) => 32,
88
89 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.q0) + 33),
90 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.d0) + 33),
91 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.s0) + 33),
92 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.h0) + 33),
93 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intCast(u6, @enumToInt(self) - @enumToInt(Register.b0) + 33),
82 return switch (@intFromEnum(self)) {
83 @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.x0)),
84 @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.w0)),
85
86 @intFromEnum(Register.sp) => 32,
87 @intFromEnum(Register.wsp) => 32,
88
89 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.q0) + 33),
90 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.d0) + 33),
91 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.s0) + 33),
92 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.h0) + 33),
93 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @intCast(u6, @intFromEnum(self) - @intFromEnum(Register.b0) + 33),
9494 else => unreachable,
9595 };
9696 }
9797
9898 pub fn enc(self: Register) u5 {
99 return switch (@enumToInt(self)) {
100 @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.x0)),
101 @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.w0)),
102
103 @enumToInt(Register.sp) => 31,
104 @enumToInt(Register.wsp) => 31,
105
106 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.q0)),
107 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.d0)),
108 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.s0)),
109 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.h0)),
110 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intCast(u5, @enumToInt(self) - @enumToInt(Register.b0)),
99 return switch (@intFromEnum(self)) {
100 @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.x0)),
101 @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.w0)),
102
103 @intFromEnum(Register.sp) => 31,
104 @intFromEnum(Register.wsp) => 31,
105
106 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.q0)),
107 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.d0)),
108 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.s0)),
109 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.h0)),
110 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @intCast(u5, @intFromEnum(self) - @intFromEnum(Register.b0)),
111111 else => unreachable,
112112 };
113113 }
114114
115115 /// Returns the bit-width of the register.
116116 pub fn size(self: Register) u8 {
117 return switch (@enumToInt(self)) {
118 @enumToInt(Register.x0)...@enumToInt(Register.xzr) => 64,
119 @enumToInt(Register.w0)...@enumToInt(Register.wzr) => 32,
120
121 @enumToInt(Register.sp) => 64,
122 @enumToInt(Register.wsp) => 32,
123
124 @enumToInt(Register.q0)...@enumToInt(Register.q31) => 128,
125 @enumToInt(Register.d0)...@enumToInt(Register.d31) => 64,
126 @enumToInt(Register.s0)...@enumToInt(Register.s31) => 32,
127 @enumToInt(Register.h0)...@enumToInt(Register.h31) => 16,
128 @enumToInt(Register.b0)...@enumToInt(Register.b31) => 8,
117 return switch (@intFromEnum(self)) {
118 @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => 64,
119 @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => 32,
120
121 @intFromEnum(Register.sp) => 64,
122 @intFromEnum(Register.wsp) => 32,
123
124 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => 128,
125 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => 64,
126 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => 32,
127 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => 16,
128 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => 8,
129129 else => unreachable,
130130 };
131131 }
132132
133133 /// Convert from a general-purpose register to its 64 bit alias.
134134 pub fn toX(self: Register) Register {
135 return switch (@enumToInt(self)) {
136 @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intToEnum(
135 return switch (@intFromEnum(self)) {
136 @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @enumFromInt(
137137 Register,
138 @enumToInt(self) - @enumToInt(Register.x0) + @enumToInt(Register.x0),
138 @intFromEnum(self) - @intFromEnum(Register.x0) + @intFromEnum(Register.x0),
139139 ),
140 @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intToEnum(
140 @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @enumFromInt(
141141 Register,
142 @enumToInt(self) - @enumToInt(Register.w0) + @enumToInt(Register.x0),
142 @intFromEnum(self) - @intFromEnum(Register.w0) + @intFromEnum(Register.x0),
143143 ),
144144 else => unreachable,
145145 };
......@@ -147,14 +147,14 @@ pub const Register = enum(u8) {
147147
148148 /// Convert from a general-purpose register to its 32 bit alias.
149149 pub fn toW(self: Register) Register {
150 return switch (@enumToInt(self)) {
151 @enumToInt(Register.x0)...@enumToInt(Register.xzr) => @intToEnum(
150 return switch (@intFromEnum(self)) {
151 @intFromEnum(Register.x0)...@intFromEnum(Register.xzr) => @enumFromInt(
152152 Register,
153 @enumToInt(self) - @enumToInt(Register.x0) + @enumToInt(Register.w0),
153 @intFromEnum(self) - @intFromEnum(Register.x0) + @intFromEnum(Register.w0),
154154 ),
155 @enumToInt(Register.w0)...@enumToInt(Register.wzr) => @intToEnum(
155 @intFromEnum(Register.w0)...@intFromEnum(Register.wzr) => @enumFromInt(
156156 Register,
157 @enumToInt(self) - @enumToInt(Register.w0) + @enumToInt(Register.w0),
157 @intFromEnum(self) - @intFromEnum(Register.w0) + @intFromEnum(Register.w0),
158158 ),
159159 else => unreachable,
160160 };
......@@ -162,26 +162,26 @@ pub const Register = enum(u8) {
162162
163163 /// Convert from a floating-point register to its 128 bit alias.
164164 pub fn toQ(self: Register) Register {
165 return switch (@enumToInt(self)) {
166 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum(
165 return switch (@intFromEnum(self)) {
166 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt(
167167 Register,
168 @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.q0),
168 @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.q0),
169169 ),
170 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum(
170 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt(
171171 Register,
172 @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.q0),
172 @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.q0),
173173 ),
174 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum(
174 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt(
175175 Register,
176 @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.q0),
176 @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.q0),
177177 ),
178 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum(
178 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt(
179179 Register,
180 @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.q0),
180 @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.q0),
181181 ),
182 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum(
182 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt(
183183 Register,
184 @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.q0),
184 @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.q0),
185185 ),
186186 else => unreachable,
187187 };
......@@ -189,26 +189,26 @@ pub const Register = enum(u8) {
189189
190190 /// Convert from a floating-point register to its 64 bit alias.
191191 pub fn toD(self: Register) Register {
192 return switch (@enumToInt(self)) {
193 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum(
192 return switch (@intFromEnum(self)) {
193 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt(
194194 Register,
195 @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.d0),
195 @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.d0),
196196 ),
197 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum(
197 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt(
198198 Register,
199 @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.d0),
199 @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.d0),
200200 ),
201 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum(
201 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt(
202202 Register,
203 @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.d0),
203 @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.d0),
204204 ),
205 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum(
205 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt(
206206 Register,
207 @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.d0),
207 @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.d0),
208208 ),
209 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum(
209 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt(
210210 Register,
211 @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.d0),
211 @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.d0),
212212 ),
213213 else => unreachable,
214214 };
......@@ -216,26 +216,26 @@ pub const Register = enum(u8) {
216216
217217 /// Convert from a floating-point register to its 32 bit alias.
218218 pub fn toS(self: Register) Register {
219 return switch (@enumToInt(self)) {
220 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum(
219 return switch (@intFromEnum(self)) {
220 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt(
221221 Register,
222 @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.s0),
222 @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.s0),
223223 ),
224 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum(
224 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt(
225225 Register,
226 @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.s0),
226 @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.s0),
227227 ),
228 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum(
228 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt(
229229 Register,
230 @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.s0),
230 @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.s0),
231231 ),
232 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum(
232 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt(
233233 Register,
234 @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.s0),
234 @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.s0),
235235 ),
236 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum(
236 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt(
237237 Register,
238 @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.s0),
238 @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.s0),
239239 ),
240240 else => unreachable,
241241 };
......@@ -243,26 +243,26 @@ pub const Register = enum(u8) {
243243
244244 /// Convert from a floating-point register to its 16 bit alias.
245245 pub fn toH(self: Register) Register {
246 return switch (@enumToInt(self)) {
247 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum(
246 return switch (@intFromEnum(self)) {
247 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt(
248248 Register,
249 @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.h0),
249 @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.h0),
250250 ),
251 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum(
251 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt(
252252 Register,
253 @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.h0),
253 @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.h0),
254254 ),
255 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum(
255 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt(
256256 Register,
257 @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.h0),
257 @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.h0),
258258 ),
259 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum(
259 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt(
260260 Register,
261 @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.h0),
261 @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.h0),
262262 ),
263 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum(
263 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt(
264264 Register,
265 @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.h0),
265 @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.h0),
266266 ),
267267 else => unreachable,
268268 };
......@@ -270,26 +270,26 @@ pub const Register = enum(u8) {
270270
271271 /// Convert from a floating-point register to its 8 bit alias.
272272 pub fn toB(self: Register) Register {
273 return switch (@enumToInt(self)) {
274 @enumToInt(Register.q0)...@enumToInt(Register.q31) => @intToEnum(
273 return switch (@intFromEnum(self)) {
274 @intFromEnum(Register.q0)...@intFromEnum(Register.q31) => @enumFromInt(
275275 Register,
276 @enumToInt(self) - @enumToInt(Register.q0) + @enumToInt(Register.b0),
276 @intFromEnum(self) - @intFromEnum(Register.q0) + @intFromEnum(Register.b0),
277277 ),
278 @enumToInt(Register.d0)...@enumToInt(Register.d31) => @intToEnum(
278 @intFromEnum(Register.d0)...@intFromEnum(Register.d31) => @enumFromInt(
279279 Register,
280 @enumToInt(self) - @enumToInt(Register.d0) + @enumToInt(Register.b0),
280 @intFromEnum(self) - @intFromEnum(Register.d0) + @intFromEnum(Register.b0),
281281 ),
282 @enumToInt(Register.s0)...@enumToInt(Register.s31) => @intToEnum(
282 @intFromEnum(Register.s0)...@intFromEnum(Register.s31) => @enumFromInt(
283283 Register,
284 @enumToInt(self) - @enumToInt(Register.s0) + @enumToInt(Register.b0),
284 @intFromEnum(self) - @intFromEnum(Register.s0) + @intFromEnum(Register.b0),
285285 ),
286 @enumToInt(Register.h0)...@enumToInt(Register.h31) => @intToEnum(
286 @intFromEnum(Register.h0)...@intFromEnum(Register.h31) => @enumFromInt(
287287 Register,
288 @enumToInt(self) - @enumToInt(Register.h0) + @enumToInt(Register.b0),
288 @intFromEnum(self) - @intFromEnum(Register.h0) + @intFromEnum(Register.b0),
289289 ),
290 @enumToInt(Register.b0)...@enumToInt(Register.b31) => @intToEnum(
290 @intFromEnum(Register.b0)...@intFromEnum(Register.b31) => @enumFromInt(
291291 Register,
292 @enumToInt(self) - @enumToInt(Register.b0) + @enumToInt(Register.b0),
292 @intFromEnum(self) - @intFromEnum(Register.b0) + @intFromEnum(Register.b0),
293293 ),
294294 else => unreachable,
295295 };
......@@ -901,7 +901,7 @@ pub const Instruction = union(enum) {
901901 .rn = rn.enc(),
902902 .rt2 = rt2.enc(),
903903 .imm7 = imm7,
904 .load = @boolToInt(load),
904 .load = @intFromBool(load),
905905 .encoding = encoding,
906906 .opc = 0b00,
907907 },
......@@ -916,7 +916,7 @@ pub const Instruction = union(enum) {
916916 .rn = rn.enc(),
917917 .rt2 = rt2.enc(),
918918 .imm7 = imm7,
919 .load = @boolToInt(load),
919 .load = @intFromBool(load),
920920 .encoding = encoding,
921921 .opc = 0b10,
922922 },
......@@ -1010,7 +1010,7 @@ pub const Instruction = union(enum) {
10101010 .imm6 = amount,
10111011 .rm = rm.enc(),
10121012 .n = n,
1013 .shift = @enumToInt(shift),
1013 .shift = @intFromEnum(shift),
10141014 .opc = opc,
10151015 .sf = switch (rd.size()) {
10161016 32 => 0b0,
......@@ -1037,7 +1037,7 @@ pub const Instruction = union(enum) {
10371037 .rd = rd.enc(),
10381038 .rn = rn.enc(),
10391039 .imm12 = imm12,
1040 .sh = @boolToInt(shift),
1040 .sh = @intFromBool(shift),
10411041 .s = s,
10421042 .op = op,
10431043 .sf = switch (rd.size()) {
......@@ -1126,7 +1126,7 @@ pub const Instruction = union(enum) {
11261126 .rn = rn.enc(),
11271127 .imm6 = imm6,
11281128 .rm = rm.enc(),
1129 .shift = @enumToInt(shift),
1129 .shift = @intFromEnum(shift),
11301130 .s = s,
11311131 .op = op,
11321132 .sf = switch (rd.size()) {
......@@ -1163,7 +1163,7 @@ pub const Instruction = union(enum) {
11631163 .rd = rd.enc(),
11641164 .rn = rn.enc(),
11651165 .imm3 = imm3,
1166 .option = @enumToInt(extend),
1166 .option = @intFromEnum(extend),
11671167 .rm = rm.enc(),
11681168 .s = s,
11691169 .op = op,
......@@ -1186,7 +1186,7 @@ pub const Instruction = union(enum) {
11861186
11871187 return Instruction{
11881188 .conditional_branch = .{
1189 .cond = @enumToInt(cond),
1189 .cond = @intFromEnum(cond),
11901190 .o0 = o0,
11911191 .imm19 = @bitCast(u19, @intCast(i19, offset >> 2)),
11921192 .o1 = o1,
......@@ -1232,7 +1232,7 @@ pub const Instruction = union(enum) {
12321232 .rd = rd.enc(),
12331233 .rn = rn.enc(),
12341234 .op2 = op2,
1235 .cond = @enumToInt(cond),
1235 .cond = @intFromEnum(cond),
12361236 .rm = rm.enc(),
12371237 .s = s,
12381238 .op = op,
......@@ -1394,7 +1394,7 @@ pub const Instruction = union(enum) {
13941394 };
13951395
13961396 pub fn ldp(rt1: Register, rt2: Register, rn: Register, offset: LoadStorePairOffset) Instruction {
1397 return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @enumToInt(offset.encoding), true);
1397 return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @intFromEnum(offset.encoding), true);
13981398 }
13991399
14001400 pub fn ldnp(rt1: Register, rt2: Register, rn: Register, offset: i9) Instruction {
......@@ -1402,7 +1402,7 @@ pub const Instruction = union(enum) {
14021402 }
14031403
14041404 pub fn stp(rt1: Register, rt2: Register, rn: Register, offset: LoadStorePairOffset) Instruction {
1405 return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @enumToInt(offset.encoding), false);
1405 return loadStoreRegisterPair(rt1, rt2, rn, offset.offset, @intFromEnum(offset.encoding), false);
14061406 }
14071407
14081408 pub fn stnp(rt1: Register, rt2: Register, rn: Register, offset: i9) Instruction {
src/arch/arm/CodeGen.zig+13-13
......@@ -736,7 +736,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
736736 .fpext => try self.airFpext(inst),
737737 .intcast => try self.airIntCast(inst),
738738 .trunc => try self.airTrunc(inst),
739 .bool_to_int => try self.airBoolToInt(inst),
739 .int_from_bool => try self.airIntFromBool(inst),
740740 .is_non_null => try self.airIsNonNull(inst),
741741 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
742742 .is_null => try self.airIsNull(inst),
......@@ -748,7 +748,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
748748 .load => try self.airLoad(inst),
749749 .loop => try self.airLoop(inst),
750750 .not => try self.airNot(inst),
751 .ptrtoint => try self.airPtrToInt(inst),
751 .int_from_ptr => try self.airIntFromPtr(inst),
752752 .ret => try self.airRet(inst),
753753 .ret_load => try self.airRetLoad(inst),
754754 .store => try self.airStore(inst, false),
......@@ -756,8 +756,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
756756 .struct_field_ptr=> try self.airStructFieldPtr(inst),
757757 .struct_field_val=> try self.airStructFieldVal(inst),
758758 .array_to_slice => try self.airArrayToSlice(inst),
759 .int_to_float => try self.airIntToFloat(inst),
760 .float_to_int => try self.airFloatToInt(inst),
759 .float_from_int => try self.airFloatFromInt(inst),
760 .int_from_float => try self.airIntFromFloat(inst),
761761 .cmpxchg_strong => try self.airCmpxchg(inst),
762762 .cmpxchg_weak => try self.airCmpxchg(inst),
763763 .atomic_rmw => try self.airAtomicRmw(inst),
......@@ -869,7 +869,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
869869 .cmp_neq_optimized,
870870 .cmp_vector_optimized,
871871 .reduce_optimized,
872 .float_to_int_optimized,
872 .int_from_float_optimized,
873873 => return self.fail("TODO implement optimized float mode", .{}),
874874
875875 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
......@@ -937,7 +937,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
937937 const dies = @truncate(u1, tomb_bits) != 0;
938938 tomb_bits >>= 1;
939939 if (!dies) continue;
940 const op_int = @enumToInt(op);
940 const op_int = @intFromEnum(op);
941941 if (op_int < Air.ref_start_index) continue;
942942 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
943943 self.processDeath(op_index);
......@@ -1269,7 +1269,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
12691269 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
12701270}
12711271
1272fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {
1272fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
12731273 const un_op = self.air.instructions.items(.data)[inst].un_op;
12741274 const operand = try self.resolveInst(un_op);
12751275 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
......@@ -4649,7 +4649,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
46494649 // that death now instead of later as this has an effect on
46504650 // whether it needs to be spilled in the branches
46514651 if (self.liveness.operandDies(inst, 0)) {
4652 const op_int = @enumToInt(pl_op.operand);
4652 const op_int = @intFromEnum(pl_op.operand);
46534653 if (op_int >= Air.ref_start_index) {
46544654 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
46554655 self.processDeath(op_index);
......@@ -5857,7 +5857,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I
58575857 }
58585858}
58595859
5860fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {
5860fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
58615861 const un_op = self.air.instructions.items(.data)[inst].un_op;
58625862 const result = try self.resolveInst(un_op);
58635863 return self.finishAir(inst, result, .{ un_op, .none, .none });
......@@ -5903,17 +5903,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
59035903 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
59045904}
59055905
5906fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
5906fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
59075907 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
5908 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntToFloat for {}", .{
5908 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatFromInt for {}", .{
59095909 self.target.cpu.arch,
59105910 });
59115911 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
59125912}
59135913
5914fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
5914fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
59155915 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
5916 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatToInt for {}", .{
5916 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntFromFloat for {}", .{
59175917 self.target.cpu.arch,
59185918 });
59195919 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/arm/bits.zig+26-26
......@@ -159,7 +159,7 @@ pub const Register = enum(u5) {
159159 /// Returns the unique 4-bit ID of this register which is used in
160160 /// the machine code
161161 pub fn id(self: Register) u4 {
162 return @truncate(u4, @enumToInt(self));
162 return @truncate(u4, @intFromEnum(self));
163163 }
164164
165165 pub fn dwarfLocOp(self: Register) u8 {
......@@ -408,7 +408,7 @@ pub const Instruction = union(enum) {
408408 return Shift{
409409 .register = .{
410410 .rs = rs.id(),
411 .typ = @enumToInt(typ),
411 .typ = @intFromEnum(typ),
412412 },
413413 };
414414 }
......@@ -417,7 +417,7 @@ pub const Instruction = union(enum) {
417417 return Shift{
418418 .immediate = .{
419419 .amount = amount,
420 .typ = @enumToInt(typ),
420 .typ = @intFromEnum(typ),
421421 },
422422 };
423423 }
......@@ -633,9 +633,9 @@ pub const Instruction = union(enum) {
633633 ) Instruction {
634634 return Instruction{
635635 .data_processing = .{
636 .cond = @enumToInt(cond),
637 .i = @boolToInt(op2 == .immediate),
638 .opcode = @enumToInt(opcode),
636 .cond = @intFromEnum(cond),
637 .i = @intFromBool(op2 == .immediate),
638 .opcode = @intFromEnum(opcode),
639639 .s = s,
640640 .rn = rn.id(),
641641 .rd = rd.id(),
......@@ -652,7 +652,7 @@ pub const Instruction = union(enum) {
652652 ) Instruction {
653653 return Instruction{
654654 .data_processing = .{
655 .cond = @enumToInt(cond),
655 .cond = @intFromEnum(cond),
656656 .i = 1,
657657 .opcode = if (top) 0b1010 else 0b1000,
658658 .s = 0,
......@@ -673,8 +673,8 @@ pub const Instruction = union(enum) {
673673 ) Instruction {
674674 return Instruction{
675675 .multiply = .{
676 .cond = @enumToInt(cond),
677 .accumulate = @boolToInt(ra != null),
676 .cond = @intFromEnum(cond),
677 .accumulate = @intFromBool(ra != null),
678678 .set_cond = set_cond,
679679 .rd = rd.id(),
680680 .rn = rn.id(),
......@@ -696,7 +696,7 @@ pub const Instruction = union(enum) {
696696 ) Instruction {
697697 return Instruction{
698698 .multiply_long = .{
699 .cond = @enumToInt(cond),
699 .cond = @intFromEnum(cond),
700700 .unsigned = signed,
701701 .accumulate = accumulate,
702702 .set_cond = set_cond,
......@@ -723,7 +723,7 @@ pub const Instruction = union(enum) {
723723 .m = m,
724724 .rm = rm.id(),
725725 .rd = rd.id(),
726 .cond = @enumToInt(cond),
726 .cond = @intFromEnum(cond),
727727 },
728728 };
729729 }
......@@ -741,7 +741,7 @@ pub const Instruction = union(enum) {
741741 .rd = rd.id(),
742742 .rn = rn.id(),
743743 .opc = opc,
744 .cond = @enumToInt(cond),
744 .cond = @intFromEnum(cond),
745745 },
746746 };
747747 }
......@@ -762,7 +762,7 @@ pub const Instruction = union(enum) {
762762 .rd = rd.id(),
763763 .widthm1 = @intCast(u5, width - 1),
764764 .unsigned = unsigned,
765 .cond = @enumToInt(cond),
765 .cond = @intFromEnum(cond),
766766 },
767767 };
768768 }
......@@ -779,7 +779,7 @@ pub const Instruction = union(enum) {
779779 ) Instruction {
780780 return Instruction{
781781 .single_data_transfer = .{
782 .cond = @enumToInt(cond),
782 .cond = @intFromEnum(cond),
783783 .rn = rn.id(),
784784 .rd = rd.id(),
785785 .offset = offset.toU12(),
......@@ -789,12 +789,12 @@ pub const Instruction = union(enum) {
789789 .pre_index, .post_index => 0b1,
790790 },
791791 .byte_word = byte_word,
792 .up_down = @boolToInt(positive),
792 .up_down = @intFromBool(positive),
793793 .pre_post = switch (mode) {
794794 .offset, .pre_index => 0b1,
795795 .post_index => 0b0,
796796 },
797 .imm = @boolToInt(offset != .immediate),
797 .imm = @intFromBool(offset != .immediate),
798798 },
799799 };
800800 }
......@@ -830,13 +830,13 @@ pub const Instruction = union(enum) {
830830 .offset => 0b0,
831831 .pre_index, .post_index => 0b1,
832832 },
833 .imm = @boolToInt(offset == .immediate),
834 .up_down = @boolToInt(positive),
833 .imm = @intFromBool(offset == .immediate),
834 .up_down = @intFromBool(positive),
835835 .pre_index = switch (mode) {
836836 .offset, .pre_index => 0b1,
837837 .post_index => 0b0,
838838 },
839 .cond = @enumToInt(cond),
839 .cond = @intFromEnum(cond),
840840 },
841841 };
842842 }
......@@ -856,11 +856,11 @@ pub const Instruction = union(enum) {
856856 .register_list = @bitCast(u16, reg_list),
857857 .rn = rn.id(),
858858 .load_store = load_store,
859 .write_back = @boolToInt(write_back),
859 .write_back = @intFromBool(write_back),
860860 .psr_or_user = psr_or_user,
861861 .up_down = up_down,
862862 .pre_post = pre_post,
863 .cond = @enumToInt(cond),
863 .cond = @intFromEnum(cond),
864864 },
865865 };
866866 }
......@@ -868,7 +868,7 @@ pub const Instruction = union(enum) {
868868 fn branch(cond: Condition, offset: i26, link: u1) Instruction {
869869 return Instruction{
870870 .branch = .{
871 .cond = @enumToInt(cond),
871 .cond = @intFromEnum(cond),
872872 .link = link,
873873 .offset = @bitCast(u24, @intCast(i24, offset >> 2)),
874874 },
......@@ -878,7 +878,7 @@ pub const Instruction = union(enum) {
878878 fn branchExchange(cond: Condition, rn: Register, link: u1) Instruction {
879879 return Instruction{
880880 .branch_exchange = .{
881 .cond = @enumToInt(cond),
881 .cond = @intFromEnum(cond),
882882 .link = link,
883883 .rn = rn.id(),
884884 },
......@@ -888,7 +888,7 @@ pub const Instruction = union(enum) {
888888 fn supervisorCall(cond: Condition, comment: u24) Instruction {
889889 return Instruction{
890890 .supervisor_call = .{
891 .cond = @enumToInt(cond),
891 .cond = @intFromEnum(cond),
892892 .comment = comment,
893893 },
894894 };
......@@ -1060,7 +1060,7 @@ pub const Instruction = union(enum) {
10601060 pub fn mrs(cond: Condition, rd: Register, psr: Psr) Instruction {
10611061 return Instruction{
10621062 .data_processing = .{
1063 .cond = @enumToInt(cond),
1063 .cond = @intFromEnum(cond),
10641064 .i = 0,
10651065 .opcode = if (psr == .spsr) 0b1010 else 0b1000,
10661066 .s = 0,
......@@ -1074,7 +1074,7 @@ pub const Instruction = union(enum) {
10741074 pub fn msr(cond: Condition, psr: Psr, op: Operand) Instruction {
10751075 return Instruction{
10761076 .data_processing = .{
1077 .cond = @enumToInt(cond),
1077 .cond = @intFromEnum(cond),
10781078 .i = 0,
10791079 .opcode = if (psr == .spsr) 0b1011 else 0b1001,
10801080 .s = 0,
src/arch/riscv64/CodeGen.zig+12-12
......@@ -566,7 +566,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
566566 .fpext => try self.airFpext(inst),
567567 .intcast => try self.airIntCast(inst),
568568 .trunc => try self.airTrunc(inst),
569 .bool_to_int => try self.airBoolToInt(inst),
569 .int_from_bool => try self.airIntFromBool(inst),
570570 .is_non_null => try self.airIsNonNull(inst),
571571 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
572572 .is_null => try self.airIsNull(inst),
......@@ -578,7 +578,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
578578 .load => try self.airLoad(inst),
579579 .loop => try self.airLoop(inst),
580580 .not => try self.airNot(inst),
581 .ptrtoint => try self.airPtrToInt(inst),
581 .int_from_ptr => try self.airIntFromPtr(inst),
582582 .ret => try self.airRet(inst),
583583 .ret_load => try self.airRetLoad(inst),
584584 .store => try self.airStore(inst, false),
......@@ -586,8 +586,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
586586 .struct_field_ptr=> try self.airStructFieldPtr(inst),
587587 .struct_field_val=> try self.airStructFieldVal(inst),
588588 .array_to_slice => try self.airArrayToSlice(inst),
589 .int_to_float => try self.airIntToFloat(inst),
590 .float_to_int => try self.airFloatToInt(inst),
589 .float_from_int => try self.airFloatFromInt(inst),
590 .int_from_float => try self.airIntFromFloat(inst),
591591 .cmpxchg_strong => try self.airCmpxchg(inst),
592592 .cmpxchg_weak => try self.airCmpxchg(inst),
593593 .atomic_rmw => try self.airAtomicRmw(inst),
......@@ -699,7 +699,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
699699 .cmp_neq_optimized,
700700 .cmp_vector_optimized,
701701 .reduce_optimized,
702 .float_to_int_optimized,
702 .int_from_float_optimized,
703703 => return self.fail("TODO implement optimized float mode", .{}),
704704
705705 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
......@@ -755,7 +755,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
755755 const dies = @truncate(u1, tomb_bits) != 0;
756756 tomb_bits >>= 1;
757757 if (!dies) continue;
758 const op_int = @enumToInt(op);
758 const op_int = @intFromEnum(op);
759759 if (op_int < Air.ref_start_index) continue;
760760 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
761761 self.processDeath(op_index);
......@@ -920,7 +920,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
920920 // return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
921921}
922922
923fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {
923fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
924924 const un_op = self.air.instructions.items(.data)[inst].un_op;
925925 const operand = try self.resolveInst(un_op);
926926 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
......@@ -2361,7 +2361,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
23612361 }
23622362}
23632363
2364fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {
2364fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
23652365 const un_op = self.air.instructions.items(.data)[inst].un_op;
23662366 const result = try self.resolveInst(un_op);
23672367 return self.finishAir(inst, result, .{ un_op, .none, .none });
......@@ -2394,17 +2394,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
23942394 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
23952395}
23962396
2397fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
2397fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
23982398 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
2399 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntToFloat for {}", .{
2399 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatFromInt for {}", .{
24002400 self.target.cpu.arch,
24012401 });
24022402 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
24032403}
24042404
2405fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
2405fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
24062406 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
2407 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatToInt for {}", .{
2407 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntFromFloat for {}", .{
24082408 self.target.cpu.arch,
24092409 });
24102410 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/riscv64/bits.zig+1-1
......@@ -407,7 +407,7 @@ pub const Register = enum(u6) {
407407 /// Returns the unique 4-bit ID of this register which is used in
408408 /// the machine code
409409 pub fn id(self: Register) u5 {
410 return @truncate(u5, @enumToInt(self));
410 return @truncate(u5, @intFromEnum(self));
411411 }
412412
413413 pub fn dwarfLocOp(reg: Register) u8 {
src/arch/sparc64/CodeGen.zig+13-13
......@@ -583,7 +583,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
583583 .fpext => @panic("TODO try self.airFpext(inst)"),
584584 .intcast => try self.airIntCast(inst),
585585 .trunc => try self.airTrunc(inst),
586 .bool_to_int => try self.airBoolToInt(inst),
586 .int_from_bool => try self.airIntFromBool(inst),
587587 .is_non_null => try self.airIsNonNull(inst),
588588 .is_non_null_ptr => @panic("TODO try self.airIsNonNullPtr(inst)"),
589589 .is_null => try self.airIsNull(inst),
......@@ -595,7 +595,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
595595 .load => try self.airLoad(inst),
596596 .loop => try self.airLoop(inst),
597597 .not => try self.airNot(inst),
598 .ptrtoint => try self.airPtrToInt(inst),
598 .int_from_ptr => try self.airIntFromPtr(inst),
599599 .ret => try self.airRet(inst),
600600 .ret_load => try self.airRetLoad(inst),
601601 .store => try self.airStore(inst, false),
......@@ -603,8 +603,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
603603 .struct_field_ptr=> try self.airStructFieldPtr(inst),
604604 .struct_field_val=> try self.airStructFieldVal(inst),
605605 .array_to_slice => try self.airArrayToSlice(inst),
606 .int_to_float => try self.airIntToFloat(inst),
607 .float_to_int => try self.airFloatToInt(inst),
606 .float_from_int => try self.airFloatFromInt(inst),
607 .int_from_float => try self.airIntFromFloat(inst),
608608 .cmpxchg_strong,
609609 .cmpxchg_weak,
610610 => try self.airCmpxchg(inst),
......@@ -717,7 +717,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
717717 .cmp_neq_optimized,
718718 .cmp_vector_optimized,
719719 .reduce_optimized,
720 .float_to_int_optimized,
720 .int_from_float_optimized,
721721 => @panic("TODO implement optimized float mode"),
722722
723723 .is_named_enum_value => @panic("TODO implement is_named_enum_value"),
......@@ -1078,7 +1078,7 @@ fn airBinOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
10781078 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
10791079}
10801080
1081fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {
1081fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
10821082 const un_op = self.air.instructions.items(.data)[inst].un_op;
10831083 const operand = try self.resolveInst(un_op);
10841084 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
......@@ -1513,7 +1513,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
15131513 // that death now instead of later as this has an effect on
15141514 // whether it needs to be spilled in the branches
15151515 if (self.liveness.operandDies(inst, 0)) {
1516 const op_int = @enumToInt(pl_op.operand);
1516 const op_int = @intFromEnum(pl_op.operand);
15171517 if (op_int >= Air.ref_start_index) {
15181518 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
15191519 self.processDeath(op_index);
......@@ -1736,9 +1736,9 @@ fn airFence(self: *Self, inst: Air.Inst.Index) !void {
17361736 return self.finishAir(inst, .dead, .{ .none, .none, .none });
17371737}
17381738
1739fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
1739fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
17401740 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1741 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatToInt for {}", .{
1741 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntFromFloat for {}", .{
17421742 self.target.cpu.arch,
17431743 });
17441744 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
......@@ -1769,9 +1769,9 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
17691769 return self.fail("TODO implement intCast for {}", .{self.target.cpu.arch});
17701770}
17711771
1772fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
1772fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
17731773 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1774 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airIntToFloat for {}", .{
1774 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFloatFromInt for {}", .{
17751775 self.target.cpu.arch,
17761776 });
17771777 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
......@@ -2276,7 +2276,7 @@ fn airPtrSlicePtrPtr(self: *Self, inst: Air.Inst.Index) !void {
22762276 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
22772277}
22782278
2279fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {
2279fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
22802280 const un_op = self.air.instructions.items(.data)[inst].un_op;
22812281 const result = try self.resolveInst(un_op);
22822282 return self.finishAir(inst, result, .{ un_op, .none, .none });
......@@ -3568,7 +3568,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
35683568 const dies = @truncate(u1, tomb_bits) != 0;
35693569 tomb_bits >>= 1;
35703570 if (!dies) continue;
3571 const op_int = @enumToInt(op);
3571 const op_int = @intFromEnum(op);
35723572 if (op_int < Air.ref_start_index) continue;
35733573 const op_index = @intCast(Air.Inst.Index, op_int - Air.ref_start_index);
35743574 self.processDeath(op_index);
src/arch/sparc64/bits.zig+36-36
......@@ -16,7 +16,7 @@ pub const Register = enum(u6) {
1616 // zig fmt: on
1717
1818 pub fn id(self: Register) u5 {
19 return @truncate(u5, @enumToInt(self));
19 return @truncate(u5, @intFromEnum(self));
2020 }
2121
2222 pub fn enc(self: Register) u5 {
......@@ -96,9 +96,9 @@ pub const FloatingPointRegister = enum(u7) {
9696
9797 pub fn id(self: FloatingPointRegister) u6 {
9898 return switch (self.size()) {
99 32 => @truncate(u6, @enumToInt(self)),
100 64 => @truncate(u6, (@enumToInt(self) - 32) * 2),
101 128 => @truncate(u6, (@enumToInt(self) - 64) * 4),
99 32 => @truncate(u6, @intFromEnum(self)),
100 64 => @truncate(u6, (@intFromEnum(self) - 32) * 2),
101 128 => @truncate(u6, (@intFromEnum(self) - 64) * 4),
102102 else => unreachable,
103103 };
104104 }
......@@ -114,7 +114,7 @@ pub const FloatingPointRegister = enum(u7) {
114114
115115 /// Returns the bit-width of the register.
116116 pub fn size(self: FloatingPointRegister) u8 {
117 return switch (@enumToInt(self)) {
117 return switch (@intFromEnum(self)) {
118118 0...31 => 32,
119119 32...63 => 64,
120120 64...79 => 128,
......@@ -696,8 +696,8 @@ pub const Instruction = union(enum) {
696696 /// Encodes the condition into the instruction bit pattern.
697697 pub fn enc(cond: Condition) u4 {
698698 return switch (cond) {
699 .icond => |c| @enumToInt(c),
700 .fcond => |c| @enumToInt(c),
699 .icond => |c| @intFromEnum(c),
700 .fcond => |c| @intFromEnum(c),
701701 };
702702 }
703703
......@@ -786,7 +786,7 @@ pub const Instruction = union(enum) {
786786 const udisp_truncated = @truncate(u22, udisp >> 2);
787787 return Instruction{
788788 .format_2b = .{
789 .a = @boolToInt(annul),
789 .a = @intFromBool(annul),
790790 .cond = cond.enc(),
791791 .op2 = op2,
792792 .disp22 = udisp_truncated,
......@@ -803,16 +803,16 @@ pub const Instruction = union(enum) {
803803 // Discard the last two bits since those are implicitly zero.
804804 const udisp_truncated = @truncate(u19, udisp >> 2);
805805
806 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
807 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
806 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
807 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
808808 return Instruction{
809809 .format_2c = .{
810 .a = @boolToInt(annul),
810 .a = @intFromBool(annul),
811811 .cond = cond.enc(),
812812 .op2 = op2,
813813 .cc1 = ccr_cc1,
814814 .cc0 = ccr_cc0,
815 .p = @boolToInt(pt),
815 .p = @intFromBool(pt),
816816 .disp19 = udisp_truncated,
817817 },
818818 };
......@@ -831,10 +831,10 @@ pub const Instruction = union(enum) {
831831 const udisp_lo = @truncate(u14, udisp_truncated & 0b0011_1111_1111_1111);
832832 return Instruction{
833833 .format_2d = .{
834 .a = @boolToInt(annul),
835 .rcond = @enumToInt(rcond),
834 .a = @intFromBool(annul),
835 .rcond = @intFromEnum(rcond),
836836 .op2 = op2,
837 .p = @boolToInt(pt),
837 .p = @intFromBool(pt),
838838 .rs1 = rs1.enc(),
839839 .d16hi = udisp_hi,
840840 .d16lo = udisp_lo,
......@@ -891,7 +891,7 @@ pub const Instruction = union(enum) {
891891 .rd = rd.enc(),
892892 .op3 = op3,
893893 .rs1 = rs1.enc(),
894 .rcond = @enumToInt(rcond),
894 .rcond = @intFromEnum(rcond),
895895 .rs2 = rs2.enc(),
896896 },
897897 };
......@@ -903,7 +903,7 @@ pub const Instruction = union(enum) {
903903 .rd = rd.enc(),
904904 .op3 = op3,
905905 .rs1 = rs1.enc(),
906 .rcond = @enumToInt(rcond),
906 .rcond = @intFromEnum(rcond),
907907 .simm10 = @bitCast(u10, imm),
908908 },
909909 };
......@@ -934,7 +934,7 @@ pub const Instruction = union(enum) {
934934 .rd = rd.enc(),
935935 .op3 = op3,
936936 .rs1 = rs1.enc(),
937 .imm_asi = @enumToInt(asi),
937 .imm_asi = @intFromEnum(asi),
938938 .rs2 = rs2.enc(),
939939 },
940940 };
......@@ -956,7 +956,7 @@ pub const Instruction = union(enum) {
956956 .rd = rd.enc(),
957957 .op3 = op3,
958958 .rs1 = rs1.enc(),
959 .x = @enumToInt(sw),
959 .x = @intFromEnum(sw),
960960 .rs2 = rs2.enc(),
961961 },
962962 };
......@@ -995,8 +995,8 @@ pub const Instruction = union(enum) {
995995 };
996996 }
997997 fn format3o(op: u2, op3: u6, opf: u9, ccr: CCR, rs1: Register, rs2: Register) Instruction {
998 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
999 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
998 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
999 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
10001000 return Instruction{
10011001 .format_3o = .{
10021002 .op = op,
......@@ -1051,8 +1051,8 @@ pub const Instruction = union(enum) {
10511051 }
10521052
10531053 fn format4a(op3: u6, ccr: CCR, rs1: Register, rs2: Register, rd: Register) Instruction {
1054 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
1055 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
1054 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
1055 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
10561056 return Instruction{
10571057 .format_4a = .{
10581058 .rd = rd.enc(),
......@@ -1066,8 +1066,8 @@ pub const Instruction = union(enum) {
10661066 }
10671067
10681068 fn format4b(op3: u6, ccr: CCR, rs1: Register, imm: i11, rd: Register) Instruction {
1069 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
1070 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
1069 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
1070 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
10711071 return Instruction{
10721072 .format_4b = .{
10731073 .rd = rd.enc(),
......@@ -1081,9 +1081,9 @@ pub const Instruction = union(enum) {
10811081 }
10821082
10831083 fn format4c(op3: u6, cond: Condition, ccr: CCR, rs2: Register, rd: Register) Instruction {
1084 const ccr_cc2 = @truncate(u1, @enumToInt(ccr) >> 2);
1085 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
1086 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
1084 const ccr_cc2 = @truncate(u1, @intFromEnum(ccr) >> 2);
1085 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
1086 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
10871087 return Instruction{
10881088 .format_4c = .{
10891089 .rd = rd.enc(),
......@@ -1098,9 +1098,9 @@ pub const Instruction = union(enum) {
10981098 }
10991099
11001100 fn format4d(op3: u6, cond: Condition, ccr: CCR, imm: i11, rd: Register) Instruction {
1101 const ccr_cc2 = @truncate(u1, @enumToInt(ccr) >> 2);
1102 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
1103 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
1101 const ccr_cc2 = @truncate(u1, @intFromEnum(ccr) >> 2);
1102 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
1103 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
11041104 return Instruction{
11051105 .format_4d = .{
11061106 .rd = rd.enc(),
......@@ -1115,8 +1115,8 @@ pub const Instruction = union(enum) {
11151115 }
11161116
11171117 fn format4e(op3: u6, ccr: CCR, rs1: Register, rd: Register, sw_trap: u7) Instruction {
1118 const ccr_cc1 = @truncate(u1, @enumToInt(ccr) >> 1);
1119 const ccr_cc0 = @truncate(u1, @enumToInt(ccr));
1118 const ccr_cc1 = @truncate(u1, @intFromEnum(ccr) >> 1);
1119 const ccr_cc0 = @truncate(u1, @intFromEnum(ccr));
11201120 return Instruction{
11211121 .format_4e = .{
11221122 .rd = rd.enc(),
......@@ -1142,7 +1142,7 @@ pub const Instruction = union(enum) {
11421142 .rd = rd.enc(),
11431143 .op3 = op3,
11441144 .rs1 = rs1.enc(),
1145 .rcond = @enumToInt(rcond),
1145 .rcond = @intFromEnum(rcond),
11461146 .opf_low = opf_low,
11471147 .rs2 = rs2.enc(),
11481148 },
......@@ -1468,8 +1468,8 @@ pub const Instruction = union(enum) {
14681468 pub fn trap(comptime s2: type, cond: ICondition, ccr: CCR, rs1: Register, rs2: s2) Instruction {
14691469 // Tcc instructions abuse the rd field to store the conditionals.
14701470 return switch (s2) {
1471 Register => format4a(0b11_1010, ccr, rs1, rs2, @intToEnum(Register, @enumToInt(cond))),
1472 u7 => format4e(0b11_1010, ccr, rs1, @intToEnum(Register, @enumToInt(cond)), rs2),
1471 Register => format4a(0b11_1010, ccr, rs1, rs2, @enumFromInt(Register, @intFromEnum(cond))),
1472 u7 => format4e(0b11_1010, ccr, rs1, @enumFromInt(Register, @intFromEnum(cond)), rs2),
14731473 else => unreachable,
14741474 };
14751475 }
src/arch/wasm/CodeGen.zig+18-18
......@@ -116,11 +116,11 @@ const WValue = union(enum) {
116116 fn free(value: *WValue, gen: *CodeGen) void {
117117 if (value.* != .local) return;
118118 const local_value = value.local.value;
119 const reserved = gen.args.len + @boolToInt(gen.return_value != .none);
119 const reserved = gen.args.len + @intFromBool(gen.return_value != .none);
120120 if (local_value < reserved + 2) return; // reserved locals may never be re-used. Also accounts for 2 stack locals.
121121
122122 const index = local_value - reserved;
123 const valtype = @intToEnum(wasm.Valtype, gen.locals.items[index]);
123 const valtype = @enumFromInt(wasm.Valtype, gen.locals.items[index]);
124124 switch (valtype) {
125125 .i32 => gen.free_locals_i32.append(gen.gpa, local_value) catch return, // It's ok to fail any of those, a new local can be allocated instead
126126 .i64 => gen.free_locals_i64.append(gen.gpa, local_value) catch return,
......@@ -889,7 +889,7 @@ fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void {
889889 // TODO: Upon branch consolidation free any locals if needed.
890890 const value = func.currentBranch().values.getPtr(ref) orelse return;
891891 if (value.* != .local) return;
892 const reserved_indexes = func.args.len + @boolToInt(func.return_value != .none);
892 const reserved_indexes = func.args.len + @intFromBool(func.return_value != .none);
893893 if (value.local.value < reserved_indexes) {
894894 return; // function arguments can never be re-used
895895 }
......@@ -911,7 +911,7 @@ fn addTag(func: *CodeGen, tag: Mir.Inst.Tag) error{OutOfMemory}!void {
911911
912912fn addExtended(func: *CodeGen, opcode: wasm.MiscOpcode) error{OutOfMemory}!void {
913913 const extra_index = @intCast(u32, func.mir_extra.items.len);
914 try func.mir_extra.append(func.gpa, @enumToInt(opcode));
914 try func.mir_extra.append(func.gpa, @intFromEnum(opcode));
915915 try func.addInst(.{ .tag = .misc_prefix, .data = .{ .payload = extra_index } });
916916}
917917
......@@ -1902,13 +1902,13 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
19021902 .trap => func.airTrap(inst),
19031903 .breakpoint => func.airBreakpoint(inst),
19041904 .br => func.airBr(inst),
1905 .bool_to_int => func.airBoolToInt(inst),
1905 .int_from_bool => func.airIntFromBool(inst),
19061906 .cond_br => func.airCondBr(inst),
19071907 .intcast => func.airIntcast(inst),
19081908 .fptrunc => func.airFptrunc(inst),
19091909 .fpext => func.airFpext(inst),
1910 .float_to_int => func.airFloatToInt(inst),
1911 .int_to_float => func.airIntToFloat(inst),
1910 .int_from_float => func.airIntFromFloat(inst),
1911 .float_from_int => func.airFloatFromInt(inst),
19121912 .get_union_tag => func.airGetUnionTag(inst),
19131913
19141914 .@"try" => func.airTry(inst),
......@@ -1951,7 +1951,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
19511951 .ptr_sub => func.airPtrBinOp(inst, .sub),
19521952 .ptr_elem_ptr => func.airPtrElemPtr(inst),
19531953 .ptr_elem_val => func.airPtrElemVal(inst),
1954 .ptrtoint => func.airPtrToInt(inst),
1954 .int_from_ptr => func.airIntFromPtr(inst),
19551955 .ret => func.airRet(inst),
19561956 .ret_ptr => func.airRetPtr(inst),
19571957 .ret_load => func.airRetLoad(inst),
......@@ -2061,7 +2061,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
20612061 .cmp_neq_optimized,
20622062 .cmp_vector_optimized,
20632063 .reduce_optimized,
2064 .float_to_int_optimized,
2064 .int_from_float_optimized,
20652065 => return func.fail("TODO implement optimized float mode", .{}),
20662066
20672067 .work_item_id,
......@@ -3218,7 +3218,7 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue {
32183218 return WValue{ .imm32 = 0 };
32193219 }
32203220 } else {
3221 return WValue{ .imm32 = @boolToInt(!val.isNull(mod)) };
3221 return WValue{ .imm32 = @intFromBool(!val.isNull(mod)) };
32223222 },
32233223 .aggregate => switch (mod.intern_pool.indexToKey(ty.ip_index)) {
32243224 .array_type => return func.fail("Wasm TODO: LowerConstant for {}", .{ty.fmt(mod)}),
......@@ -3904,7 +3904,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
39043904 }
39053905
39063906 // Account for default branch so always add '1'
3907 const depth = @intCast(u32, highest - lowest + @boolToInt(has_else_body)) + 1;
3907 const depth = @intCast(u32, highest - lowest + @intFromBool(has_else_body)) + 1;
39083908 const jump_table: Mir.JumpTable = .{ .length = depth };
39093909 const table_extra_index = try func.addExtra(jump_table);
39103910 try func.addInst(.{ .tag = .br_table, .data = .{ .payload = table_extra_index } });
......@@ -3939,7 +3939,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
39393939 break :blk target_ty.intInfo(mod).signedness;
39403940 };
39413941
3942 try func.branches.ensureUnusedCapacity(func.gpa, case_list.items.len + @boolToInt(has_else_body));
3942 try func.branches.ensureUnusedCapacity(func.gpa, case_list.items.len + @intFromBool(has_else_body));
39433943 for (case_list.items, 0..) |case, index| {
39443944 // when sparse, we use if/else-chain, so emit conditional checks
39453945 if (is_sparse) {
......@@ -4480,7 +4480,7 @@ fn trunc(func: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) Inner
44804480 return result;
44814481}
44824482
4483fn airBoolToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4483fn airIntFromBool(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
44844484 const un_op = func.air.instructions.items(.data)[inst].un_op;
44854485 const operand = try func.resolveInst(un_op);
44864486 const result = func.reuseOperand(un_op, operand);
......@@ -4511,7 +4511,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
45114511 func.finishAir(inst, slice_local, &.{ty_op.operand});
45124512}
45134513
4514fn airPtrToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4514fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
45154515 const mod = func.bin_file.base.options.module.?;
45164516 const un_op = func.air.instructions.items(.data)[inst].un_op;
45174517 const operand = try func.resolveInst(un_op);
......@@ -4812,7 +4812,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48124812 func.finishAir(inst, elem_result, &.{ bin_op.lhs, bin_op.rhs });
48134813}
48144814
4815fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4815fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48164816 const mod = func.bin_file.base.options.module.?;
48174817 const ty_op = func.air.instructions.items(.data)[inst].ty_op;
48184818
......@@ -4821,7 +4821,7 @@ fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48214821 const op_ty = func.typeOf(ty_op.operand);
48224822
48234823 if (op_ty.abiSize(mod) > 8) {
4824 return func.fail("TODO: floatToInt for integers/floats with bitsize larger than 64 bits", .{});
4824 return func.fail("TODO: intFromFloat for integers/floats with bitsize larger than 64 bits", .{});
48254825 }
48264826
48274827 try func.emitWValue(operand);
......@@ -4837,7 +4837,7 @@ fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48374837 func.finishAir(inst, result, &.{ty_op.operand});
48384838}
48394839
4840fn airIntToFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4840fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48414841 const mod = func.bin_file.base.options.module.?;
48424842 const ty_op = func.air.instructions.items(.data)[inst].ty_op;
48434843
......@@ -4846,7 +4846,7 @@ fn airIntToFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48464846 const op_ty = func.typeOf(ty_op.operand);
48474847
48484848 if (op_ty.abiSize(mod) > 8) {
4849 return func.fail("TODO: intToFloat for integers/floats with bitsize larger than 64 bits", .{});
4849 return func.fail("TODO: floatFromInt for integers/floats with bitsize larger than 64 bits", .{});
48504850 }
48514851
48524852 try func.emitWValue(operand);
src/arch/wasm/Emit.zig+8-8
......@@ -269,12 +269,12 @@ fn emitLocals(emit: *Emit) !void {
269269}
270270
271271fn emitTag(emit: *Emit, tag: Mir.Inst.Tag) !void {
272 try emit.code.append(@enumToInt(tag));
272 try emit.code.append(@intFromEnum(tag));
273273}
274274
275275fn emitBlock(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
276276 const block_type = emit.mir.instructions.items(.data)[inst].block_type;
277 try emit.code.append(@enumToInt(tag));
277 try emit.code.append(@intFromEnum(tag));
278278 try emit.code.append(block_type);
279279}
280280
......@@ -293,13 +293,13 @@ fn emitBrTable(emit: *Emit, inst: Mir.Inst.Index) !void {
293293
294294fn emitLabel(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
295295 const label = emit.mir.instructions.items(.data)[inst].label;
296 try emit.code.append(@enumToInt(tag));
296 try emit.code.append(@intFromEnum(tag));
297297 try leb128.writeULEB128(emit.code.writer(), label);
298298}
299299
300300fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
301301 const label = emit.mir.instructions.items(.data)[inst].label;
302 try emit.code.append(@enumToInt(tag));
302 try emit.code.append(@intFromEnum(tag));
303303 var buf: [5]u8 = undefined;
304304 leb128.writeUnsignedFixed(5, &buf, label);
305305 const global_offset = emit.offset();
......@@ -343,7 +343,7 @@ fn emitFloat64(emit: *Emit, inst: Mir.Inst.Index) !void {
343343fn emitMemArg(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
344344 const extra_index = emit.mir.instructions.items(.data)[inst].payload;
345345 const mem_arg = emit.mir.extraData(Mir.MemArg, extra_index).data;
346 try emit.code.append(@enumToInt(tag));
346 try emit.code.append(@intFromEnum(tag));
347347 try encodeMemArg(mem_arg, emit.code.writer());
348348}
349349
......@@ -436,7 +436,7 @@ fn emitExtended(emit: *Emit, inst: Mir.Inst.Index) !void {
436436 const writer = emit.code.writer();
437437 try emit.code.append(std.wasm.opcode(.misc_prefix));
438438 try leb128.writeULEB128(writer, opcode);
439 switch (@intToEnum(std.wasm.MiscOpcode, opcode)) {
439 switch (@enumFromInt(std.wasm.MiscOpcode, opcode)) {
440440 // bulk-memory opcodes
441441 .data_drop => {
442442 const segment = emit.mir.extra[extra_index + 1];
......@@ -475,7 +475,7 @@ fn emitSimd(emit: *Emit, inst: Mir.Inst.Index) !void {
475475 const writer = emit.code.writer();
476476 try emit.code.append(std.wasm.opcode(.simd_prefix));
477477 try leb128.writeULEB128(writer, opcode);
478 switch (@intToEnum(std.wasm.SimdOpcode, opcode)) {
478 switch (@enumFromInt(std.wasm.SimdOpcode, opcode)) {
479479 .v128_store,
480480 .v128_load,
481481 .v128_load8_splat,
......@@ -526,7 +526,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void {
526526 const writer = emit.code.writer();
527527 try emit.code.append(std.wasm.opcode(.atomics_prefix));
528528 try leb128.writeULEB128(writer, opcode);
529 switch (@intToEnum(std.wasm.AtomicsOpcode, opcode)) {
529 switch (@enumFromInt(std.wasm.AtomicsOpcode, opcode)) {
530530 .i32_atomic_load,
531531 .i64_atomic_load,
532532 .i32_atomic_load8_u,
src/arch/wasm/Mir.zig+2-2
......@@ -544,12 +544,12 @@ pub const Inst = struct {
544544
545545 /// From a given wasm opcode, returns a MIR tag.
546546 pub fn fromOpcode(opcode: std.wasm.Opcode) Tag {
547 return @intToEnum(Tag, @enumToInt(opcode)); // Given `Opcode` is not present as a tag for MIR yet
547 return @enumFromInt(Tag, @intFromEnum(opcode)); // Given `Opcode` is not present as a tag for MIR yet
548548 }
549549
550550 /// Returns a wasm opcode from a given MIR tag.
551551 pub fn toOpcode(self: Tag) std.wasm.Opcode {
552 return @intToEnum(std.wasm.Opcode, @enumToInt(self));
552 return @enumFromInt(std.wasm.Opcode, @intFromEnum(self));
553553 }
554554 };
555555
src/arch/x86/bits.zig+5-5
......@@ -14,7 +14,7 @@ pub const Register = enum(u8) {
1414
1515 /// Returns the bit-width of the register.
1616 pub fn size(self: Register) u7 {
17 return switch (@enumToInt(self)) {
17 return switch (@intFromEnum(self)) {
1818 0...7 => 32,
1919 8...15 => 16,
2020 16...23 => 8,
......@@ -26,22 +26,22 @@ pub const Register = enum(u8) {
2626 /// x86 has. It is embedded in some instructions, such as the `B8 +rd` move
2727 /// instruction, and is used in the R/M byte.
2828 pub fn id(self: Register) u3 {
29 return @truncate(u3, @enumToInt(self));
29 return @truncate(u3, @intFromEnum(self));
3030 }
3131
3232 /// Convert from any register to its 32 bit alias.
3333 pub fn to32(self: Register) Register {
34 return @intToEnum(Register, @as(u8, self.id()));
34 return @enumFromInt(Register, @as(u8, self.id()));
3535 }
3636
3737 /// Convert from any register to its 16 bit alias.
3838 pub fn to16(self: Register) Register {
39 return @intToEnum(Register, @as(u8, self.id()) + 8);
39 return @enumFromInt(Register, @as(u8, self.id()) + 8);
4040 }
4141
4242 /// Convert from any register to its 8 bit alias.
4343 pub fn to8(self: Register) Register {
44 return @intToEnum(Register, @as(u8, self.id()) + 16);
44 return @enumFromInt(Register, @as(u8, self.id()) + 16);
4545 }
4646
4747 pub fn dwarfLocOp(reg: Register) u8 {
src/arch/x86_64/CodeGen.zig+45-45
......@@ -690,7 +690,7 @@ pub fn generate(
690690
691691 try function.frame_allocs.resize(gpa, FrameIndex.named_count);
692692 function.frame_allocs.set(
693 @enumToInt(FrameIndex.stack_frame),
693 @intFromEnum(FrameIndex.stack_frame),
694694 FrameAlloc.init(.{
695695 .size = 0,
696696 .alignment = if (mod.align_stack_fns.get(module_fn_index)) |set_align_stack|
......@@ -700,7 +700,7 @@ pub fn generate(
700700 }),
701701 );
702702 function.frame_allocs.set(
703 @enumToInt(FrameIndex.call_frame),
703 @intFromEnum(FrameIndex.call_frame),
704704 FrameAlloc.init(.{ .size = 0, .alignment = 1 }),
705705 );
706706
......@@ -721,16 +721,16 @@ pub fn generate(
721721
722722 function.args = call_info.args;
723723 function.ret_mcv = call_info.return_value;
724 function.frame_allocs.set(@enumToInt(FrameIndex.ret_addr), FrameAlloc.init(.{
724 function.frame_allocs.set(@intFromEnum(FrameIndex.ret_addr), FrameAlloc.init(.{
725725 .size = Type.usize.abiSize(mod),
726726 .alignment = @min(Type.usize.abiAlignment(mod), call_info.stack_align),
727727 }));
728 function.frame_allocs.set(@enumToInt(FrameIndex.base_ptr), FrameAlloc.init(.{
728 function.frame_allocs.set(@intFromEnum(FrameIndex.base_ptr), FrameAlloc.init(.{
729729 .size = Type.usize.abiSize(mod),
730730 .alignment = @min(Type.usize.abiAlignment(mod) * 2, call_info.stack_align),
731731 }));
732732 function.frame_allocs.set(
733 @enumToInt(FrameIndex.args_frame),
733 @intFromEnum(FrameIndex.args_frame),
734734 FrameAlloc.init(.{ .size = call_info.stack_byte_count, .alignment = call_info.stack_align }),
735735 );
736736
......@@ -1835,7 +1835,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
18351835 .fpext => try self.airFpext(inst),
18361836 .intcast => try self.airIntCast(inst),
18371837 .trunc => try self.airTrunc(inst),
1838 .bool_to_int => try self.airBoolToInt(inst),
1838 .int_from_bool => try self.airIntFromBool(inst),
18391839 .is_non_null => try self.airIsNonNull(inst),
18401840 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
18411841 .is_null => try self.airIsNull(inst),
......@@ -1846,7 +1846,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
18461846 .is_err_ptr => try self.airIsErrPtr(inst),
18471847 .load => try self.airLoad(inst),
18481848 .loop => try self.airLoop(inst),
1849 .ptrtoint => try self.airPtrToInt(inst),
1849 .int_from_ptr => try self.airIntFromPtr(inst),
18501850 .ret => try self.airRet(inst),
18511851 .ret_load => try self.airRetLoad(inst),
18521852 .store => try self.airStore(inst, false),
......@@ -1854,8 +1854,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
18541854 .struct_field_ptr=> try self.airStructFieldPtr(inst),
18551855 .struct_field_val=> try self.airStructFieldVal(inst),
18561856 .array_to_slice => try self.airArrayToSlice(inst),
1857 .int_to_float => try self.airIntToFloat(inst),
1858 .float_to_int => try self.airFloatToInt(inst),
1857 .float_from_int => try self.airFloatFromInt(inst),
1858 .int_from_float => try self.airIntFromFloat(inst),
18591859 .cmpxchg_strong => try self.airCmpxchg(inst),
18601860 .cmpxchg_weak => try self.airCmpxchg(inst),
18611861 .atomic_rmw => try self.airAtomicRmw(inst),
......@@ -1967,7 +1967,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
19671967 .cmp_neq_optimized,
19681968 .cmp_vector_optimized,
19691969 .reduce_optimized,
1970 .float_to_int_optimized,
1970 .int_from_float_optimized,
19711971 => return self.fail("TODO implement optimized float mode", .{}),
19721972
19731973 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
......@@ -2147,7 +2147,7 @@ fn setFrameLoc(
21472147 offset: *i32,
21482148 comptime aligned: bool,
21492149) void {
2150 const frame_i = @enumToInt(frame_index);
2150 const frame_i = @intFromEnum(frame_index);
21512151 if (aligned) {
21522152 const alignment = @as(i32, 1) << self.frame_allocs.items(.abi_align)[frame_i];
21532153 offset.* = mem.alignForward(i32, offset.*, alignment);
......@@ -2167,21 +2167,21 @@ fn computeFrameLayout(self: *Self) !FrameLayout {
21672167 const frame_offset = self.frame_locs.items(.disp);
21682168
21692169 for (stack_frame_order, FrameIndex.named_count..) |*frame_order, frame_index|
2170 frame_order.* = @intToEnum(FrameIndex, frame_index);
2170 frame_order.* = @enumFromInt(FrameIndex, frame_index);
21712171 {
21722172 const SortContext = struct {
21732173 frame_align: @TypeOf(frame_align),
21742174 pub fn lessThan(context: @This(), lhs: FrameIndex, rhs: FrameIndex) bool {
2175 return context.frame_align[@enumToInt(lhs)] > context.frame_align[@enumToInt(rhs)];
2175 return context.frame_align[@intFromEnum(lhs)] > context.frame_align[@intFromEnum(rhs)];
21762176 }
21772177 };
21782178 const sort_context = SortContext{ .frame_align = frame_align };
21792179 mem.sort(FrameIndex, stack_frame_order, sort_context, SortContext.lessThan);
21802180 }
21812181
2182 const call_frame_align = frame_align[@enumToInt(FrameIndex.call_frame)];
2183 const stack_frame_align = frame_align[@enumToInt(FrameIndex.stack_frame)];
2184 const args_frame_align = frame_align[@enumToInt(FrameIndex.args_frame)];
2182 const call_frame_align = frame_align[@intFromEnum(FrameIndex.call_frame)];
2183 const stack_frame_align = frame_align[@intFromEnum(FrameIndex.stack_frame)];
2184 const args_frame_align = frame_align[@intFromEnum(FrameIndex.args_frame)];
21852185 const needed_align = @max(call_frame_align, stack_frame_align);
21862186 const need_align_stack = needed_align > args_frame_align;
21872187
......@@ -2200,7 +2200,7 @@ fn computeFrameLayout(self: *Self) !FrameLayout {
22002200 self.setFrameLoc(.ret_addr, .rbp, &rbp_offset, false);
22012201 self.setFrameLoc(.args_frame, .rbp, &rbp_offset, false);
22022202 const stack_frame_align_offset =
2203 if (need_align_stack) 0 else frame_offset[@enumToInt(FrameIndex.args_frame)];
2203 if (need_align_stack) 0 else frame_offset[@intFromEnum(FrameIndex.args_frame)];
22042204
22052205 var rsp_offset: i32 = 0;
22062206 self.setFrameLoc(.call_frame, .rsp, &rsp_offset, true);
......@@ -2209,23 +2209,23 @@ fn computeFrameLayout(self: *Self) !FrameLayout {
22092209 rsp_offset += stack_frame_align_offset;
22102210 rsp_offset = mem.alignForward(i32, rsp_offset, @as(i32, 1) << needed_align);
22112211 rsp_offset -= stack_frame_align_offset;
2212 frame_size[@enumToInt(FrameIndex.call_frame)] =
2213 @intCast(u31, rsp_offset - frame_offset[@enumToInt(FrameIndex.stack_frame)]);
2212 frame_size[@intFromEnum(FrameIndex.call_frame)] =
2213 @intCast(u31, rsp_offset - frame_offset[@intFromEnum(FrameIndex.stack_frame)]);
22142214
22152215 return .{
22162216 .stack_mask = @as(u32, math.maxInt(u32)) << (if (need_align_stack) needed_align else 0),
2217 .stack_adjust = @intCast(u32, rsp_offset - frame_offset[@enumToInt(FrameIndex.call_frame)]),
2217 .stack_adjust = @intCast(u32, rsp_offset - frame_offset[@intFromEnum(FrameIndex.call_frame)]),
22182218 .save_reg_list = save_reg_list,
22192219 };
22202220}
22212221
22222222fn getFrameAddrAlignment(self: *Self, frame_addr: FrameAddr) u32 {
2223 const alloc_align = @as(u32, 1) << self.frame_allocs.get(@enumToInt(frame_addr.index)).abi_align;
2223 const alloc_align = @as(u32, 1) << self.frame_allocs.get(@intFromEnum(frame_addr.index)).abi_align;
22242224 return @min(alloc_align, @bitCast(u32, frame_addr.off) & (alloc_align - 1));
22252225}
22262226
22272227fn getFrameAddrSize(self: *Self, frame_addr: FrameAddr) u32 {
2228 return self.frame_allocs.get(@enumToInt(frame_addr.index)).abi_size - @intCast(u31, frame_addr.off);
2228 return self.frame_allocs.get(@intFromEnum(frame_addr.index)).abi_size - @intCast(u31, frame_addr.off);
22292229}
22302230
22312231fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex {
......@@ -2233,19 +2233,19 @@ fn allocFrameIndex(self: *Self, alloc: FrameAlloc) !FrameIndex {
22332233 const frame_size = frame_allocs_slice.items(.abi_size);
22342234 const frame_align = frame_allocs_slice.items(.abi_align);
22352235
2236 const stack_frame_align = &frame_align[@enumToInt(FrameIndex.stack_frame)];
2236 const stack_frame_align = &frame_align[@intFromEnum(FrameIndex.stack_frame)];
22372237 stack_frame_align.* = @max(stack_frame_align.*, alloc.abi_align);
22382238
22392239 for (self.free_frame_indices.keys(), 0..) |frame_index, free_i| {
2240 const abi_size = frame_size[@enumToInt(frame_index)];
2240 const abi_size = frame_size[@intFromEnum(frame_index)];
22412241 if (abi_size != alloc.abi_size) continue;
2242 const abi_align = &frame_align[@enumToInt(frame_index)];
2242 const abi_align = &frame_align[@intFromEnum(frame_index)];
22432243 abi_align.* = @max(abi_align.*, alloc.abi_align);
22442244
22452245 _ = self.free_frame_indices.swapRemoveAt(free_i);
22462246 return frame_index;
22472247 }
2248 const frame_index = @intToEnum(FrameIndex, self.frame_allocs.len);
2248 const frame_index = @enumFromInt(FrameIndex, self.frame_allocs.len);
22492249 try self.frame_allocs.append(self.gpa, alloc);
22502250 return frame_index;
22512251}
......@@ -2806,7 +2806,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
28062806 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
28072807}
28082808
2809fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {
2809fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
28102810 const un_op = self.air.instructions.items(.data)[inst].un_op;
28112811 const ty = self.typeOfIndex(inst);
28122812
......@@ -2876,7 +2876,7 @@ fn activeIntBits(self: *Self, dst_air: Air.Inst.Ref) u16 {
28762876 var space: Value.BigIntSpace = undefined;
28772877 const src_int = src_val.toBigInt(&space, mod);
28782878 return @intCast(u16, src_int.bitCountTwosComp()) +
2879 @boolToInt(src_int.positive and dst_info.signedness == .signed);
2879 @intFromBool(src_int.positive and dst_info.signedness == .signed);
28802880 },
28812881 .intcast => {
28822882 const src_ty = self.typeOf(air_data[inst].ty_op.operand);
......@@ -8034,10 +8034,10 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
80348034 FrameAlloc.init(.{ .size = info.stack_byte_count, .alignment = info.stack_align });
80358035 const frame_allocs_slice = self.frame_allocs.slice();
80368036 const stack_frame_size =
8037 &frame_allocs_slice.items(.abi_size)[@enumToInt(FrameIndex.call_frame)];
8037 &frame_allocs_slice.items(.abi_size)[@intFromEnum(FrameIndex.call_frame)];
80388038 stack_frame_size.* = @max(stack_frame_size.*, needed_call_frame.abi_size);
80398039 const stack_frame_align =
8040 &frame_allocs_slice.items(.abi_align)[@enumToInt(FrameIndex.call_frame)];
8040 &frame_allocs_slice.items(.abi_align)[@intFromEnum(FrameIndex.call_frame)];
80418041 stack_frame_align.* = @max(stack_frame_align.*, needed_call_frame.abi_align);
80428042 }
80438043
......@@ -10147,7 +10147,7 @@ fn genLazySymbolRef(
1014710147 }
1014810148}
1014910149
10150fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {
10150fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
1015110151 const un_op = self.air.instructions.items(.data)[inst].un_op;
1015210152 const result = result: {
1015310153 // TODO: handle case where the operand is a slice not a raw pointer
......@@ -10246,7 +10246,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
1024610246 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
1024710247}
1024810248
10249fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
10249fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
1025010250 const mod = self.bin_file.options.module.?;
1025110251 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1025210252
......@@ -10260,7 +10260,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
1026010260 .signed => src_bits,
1026110261 .unsigned => src_bits + 1,
1026210262 }, 32), 8) catch unreachable;
10263 if (src_size > 8) return self.fail("TODO implement airIntToFloat from {} to {}", .{
10263 if (src_size > 8) return self.fail("TODO implement airFloatFromInt from {} to {}", .{
1026410264 src_ty.fmt(mod), dst_ty.fmt(mod),
1026510265 });
1026610266
......@@ -10287,7 +10287,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
1028710287 else => unreachable,
1028810288 },
1028910289 else => null,
10290 })) |tag| tag else return self.fail("TODO implement airIntToFloat from {} to {}", .{
10290 })) |tag| tag else return self.fail("TODO implement airFloatFromInt from {} to {}", .{
1029110291 src_ty.fmt(mod), dst_ty.fmt(mod),
1029210292 });
1029310293 const dst_alias = dst_reg.to128();
......@@ -10300,7 +10300,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
1030010300 return self.finishAir(inst, dst_mcv, .{ ty_op.operand, .none, .none });
1030110301}
1030210302
10303fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
10303fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
1030410304 const mod = self.bin_file.options.module.?;
1030510305 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
1030610306
......@@ -10314,7 +10314,7 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
1031410314 .signed => dst_bits,
1031510315 .unsigned => dst_bits + 1,
1031610316 }, 32), 8) catch unreachable;
10317 if (dst_size > 8) return self.fail("TODO implement airFloatToInt from {} to {}", .{
10317 if (dst_size > 8) return self.fail("TODO implement airIntFromFloat from {} to {}", .{
1031810318 src_ty.fmt(self.bin_file.options.module.?), dst_ty.fmt(self.bin_file.options.module.?),
1031910319 });
1032010320
......@@ -10340,7 +10340,7 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
1034010340 else => unreachable,
1034110341 },
1034210342 else => null,
10343 })) |tag| tag else return self.fail("TODO implement airFloatToInt from {} to {}", .{
10343 })) |tag| tag else return self.fail("TODO implement airIntFromFloat from {} to {}", .{
1034410344 src_ty.fmt(self.bin_file.options.module.?), dst_ty.fmt(self.bin_file.options.module.?),
1034510345 }),
1034610346 registerAlias(dst_reg, dst_size),
......@@ -10915,10 +10915,10 @@ fn airTagName(self: *Self, inst: Air.Inst.Index) !void {
1091510915 });
1091610916 const frame_allocs_slice = self.frame_allocs.slice();
1091710917 const stack_frame_size =
10918 &frame_allocs_slice.items(.abi_size)[@enumToInt(FrameIndex.call_frame)];
10918 &frame_allocs_slice.items(.abi_size)[@intFromEnum(FrameIndex.call_frame)];
1091910919 stack_frame_size.* = @max(stack_frame_size.*, needed_call_frame.abi_size);
1092010920 const stack_frame_align =
10921 &frame_allocs_slice.items(.abi_align)[@enumToInt(FrameIndex.call_frame)];
10921 &frame_allocs_slice.items(.abi_align)[@intFromEnum(FrameIndex.call_frame)];
1092210922 stack_frame_align.* = @max(stack_frame_align.*, needed_call_frame.abi_align);
1092310923 }
1092410924
......@@ -11413,7 +11413,7 @@ fn airUnionInit(self: *Self, inst: Air.Inst.Index) !void {
1141311413 const tag_ty = union_obj.tag_ty;
1141411414 const field_index = tag_ty.enumFieldIndex(field_name, mod).?;
1141511415 const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index);
11416 const tag_int_val = try tag_val.enumToInt(tag_ty, mod);
11416 const tag_int_val = try tag_val.intFromEnum(tag_ty, mod);
1141711417 const tag_int = tag_int_val.toUnsignedInt(mod);
1141811418 const tag_off = if (layout.tag_align < layout.payload_align)
1141911419 @intCast(i32, layout.payload_size)
......@@ -11637,7 +11637,7 @@ fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCV
1163711637 switch (mcv) {
1163811638 .immediate => |imm| {
1163911639 // This immediate is unsigned.
11640 const U = std.meta.Int(.unsigned, ti.bits - @boolToInt(ti.signedness == .signed));
11640 const U = std.meta.Int(.unsigned, ti.bits - @intFromBool(ti.signedness == .signed));
1164111641 if (imm >= math.maxInt(U)) {
1164211642 return MCValue{ .register = try self.copyToTmpRegister(Type.usize, mcv) };
1164311643 }
......@@ -11782,17 +11782,17 @@ fn resolveCallingConventionValues(
1178211782 },
1178311783 .float, .sse => switch (self.target.os.tag) {
1178411784 .windows => if (param_reg_i < 4) {
11785 arg.* = .{ .register = @intToEnum(
11785 arg.* = .{ .register = @enumFromInt(
1178611786 Register,
11787 @enumToInt(Register.xmm0) + param_reg_i,
11787 @intFromEnum(Register.xmm0) + param_reg_i,
1178811788 ) };
1178911789 param_reg_i += 1;
1179011790 continue;
1179111791 },
1179211792 else => if (param_sse_reg_i < 8) {
11793 arg.* = .{ .register = @intToEnum(
11793 arg.* = .{ .register = @enumFromInt(
1179411794 Register,
11795 @enumToInt(Register.xmm0) + param_sse_reg_i,
11795 @intFromEnum(Register.xmm0) + param_sse_reg_i,
1179611796 ) };
1179711797 param_sse_reg_i += 1;
1179811798 continue;
src/arch/x86_64/Encoding.zig+4-4
......@@ -56,7 +56,7 @@ pub fn findByMnemonic(
5656
5757 var shortest_enc: ?Encoding = null;
5858 var shortest_len: ?usize = null;
59 next: for (mnemonic_to_encodings_map[@enumToInt(mnemonic)]) |data| {
59 next: for (mnemonic_to_encodings_map[@intFromEnum(mnemonic)]) |data| {
6060 switch (data.mode) {
6161 .none, .short => if (rex_required) continue,
6262 .rex, .rex_short => if (!rex_required) continue,
......@@ -85,7 +85,7 @@ pub fn findByOpcode(opc: []const u8, prefixes: struct {
8585 rex: Rex,
8686}, modrm_ext: ?u3) ?Encoding {
8787 for (mnemonic_to_encodings_map, 0..) |encs, mnemonic_int| for (encs) |data| {
88 const enc = Encoding{ .mnemonic = @intToEnum(Mnemonic, mnemonic_int), .data = data };
88 const enc = Encoding{ .mnemonic = @enumFromInt(Mnemonic, mnemonic_int), .data = data };
8989 if (modrm_ext) |ext| if (ext != data.modrm_ext) continue;
9090 if (!std.mem.eql(u8, opc, enc.opcode())) continue;
9191 if (prefixes.rex.w) {
......@@ -772,7 +772,7 @@ const mnemonic_to_encodings_map = init: {
772772 var entries = encodings.table;
773773 std.mem.sort(encodings.Entry, &entries, {}, struct {
774774 fn lessThan(_: void, lhs: encodings.Entry, rhs: encodings.Entry) bool {
775 return @enumToInt(lhs[0]) < @enumToInt(rhs[0]);
775 return @intFromEnum(lhs[0]) < @intFromEnum(rhs[0]);
776776 }
777777 }.lessThan);
778778 var data_storage: [entries.len]Data = undefined;
......@@ -794,7 +794,7 @@ const mnemonic_to_encodings_map = init: {
794794 std.mem.copyForwards(Op, &data.ops, entry[2]);
795795 std.mem.copyForwards(u8, &data.opc, entry[3]);
796796
797 while (mnemonic_int < @enumToInt(entry[0])) : (mnemonic_int += 1) {
797 while (mnemonic_int < @intFromEnum(entry[0])) : (mnemonic_int += 1) {
798798 mnemonic_map[mnemonic_int] = data_storage[mnemonic_start..data_index];
799799 mnemonic_start = data_index;
800800 }
src/arch/x86_64/Mir.zig+16-16
......@@ -1053,16 +1053,16 @@ pub const MemorySib = struct {
10531053 const sib = mem.sib;
10541054 assert(sib.scale_index.scale == 0 or std.math.isPowerOfTwo(sib.scale_index.scale));
10551055 return .{
1056 .ptr_size = @enumToInt(sib.ptr_size),
1057 .base_tag = @enumToInt(@as(Memory.Base.Tag, sib.base)),
1056 .ptr_size = @intFromEnum(sib.ptr_size),
1057 .base_tag = @intFromEnum(@as(Memory.Base.Tag, sib.base)),
10581058 .base = switch (sib.base) {
10591059 .none => undefined,
1060 .reg => |r| @enumToInt(r),
1061 .frame => |fi| @enumToInt(fi),
1060 .reg => |r| @intFromEnum(r),
1061 .frame => |fi| @intFromEnum(fi),
10621062 },
10631063 .scale_index = @as(u32, sib.scale_index.scale) << 0 |
10641064 @as(u32, if (sib.scale_index.scale > 0)
1065 @enumToInt(sib.scale_index.index)
1065 @intFromEnum(sib.scale_index.index)
10661066 else
10671067 undefined) << 4,
10681068 .disp = sib.disp,
......@@ -1073,15 +1073,15 @@ pub const MemorySib = struct {
10731073 const scale = @truncate(u4, msib.scale_index);
10741074 assert(scale == 0 or std.math.isPowerOfTwo(scale));
10751075 return .{ .sib = .{
1076 .ptr_size = @intToEnum(Memory.PtrSize, msib.ptr_size),
1077 .base = switch (@intToEnum(Memory.Base.Tag, msib.base_tag)) {
1076 .ptr_size = @enumFromInt(Memory.PtrSize, msib.ptr_size),
1077 .base = switch (@enumFromInt(Memory.Base.Tag, msib.base_tag)) {
10781078 .none => .none,
1079 .reg => .{ .reg = @intToEnum(Register, msib.base) },
1080 .frame => .{ .frame = @intToEnum(bits.FrameIndex, msib.base) },
1079 .reg => .{ .reg = @enumFromInt(Register, msib.base) },
1080 .frame => .{ .frame = @enumFromInt(bits.FrameIndex, msib.base) },
10811081 },
10821082 .scale_index = .{
10831083 .scale = scale,
1084 .index = if (scale > 0) @intToEnum(Register, msib.scale_index >> 4) else undefined,
1084 .index = if (scale > 0) @enumFromInt(Register, msib.scale_index >> 4) else undefined,
10851085 },
10861086 .disp = msib.disp,
10871087 } };
......@@ -1096,14 +1096,14 @@ pub const MemoryRip = struct {
10961096
10971097 pub fn encode(mem: Memory) MemoryRip {
10981098 return .{
1099 .ptr_size = @enumToInt(mem.rip.ptr_size),
1099 .ptr_size = @intFromEnum(mem.rip.ptr_size),
11001100 .disp = mem.rip.disp,
11011101 };
11021102 }
11031103
11041104 pub fn decode(mrip: MemoryRip) Memory {
11051105 return .{ .rip = .{
1106 .ptr_size = @intToEnum(Memory.PtrSize, mrip.ptr_size),
1106 .ptr_size = @enumFromInt(Memory.PtrSize, mrip.ptr_size),
11071107 .disp = mrip.disp,
11081108 } };
11091109 }
......@@ -1119,7 +1119,7 @@ pub const MemoryMoffs = struct {
11191119
11201120 pub fn encode(seg: Register, offset: u64) MemoryMoffs {
11211121 return .{
1122 .seg = @enumToInt(seg),
1122 .seg = @intFromEnum(seg),
11231123 .msb = @truncate(u32, offset >> 32),
11241124 .lsb = @truncate(u32, offset >> 0),
11251125 };
......@@ -1127,7 +1127,7 @@ pub const MemoryMoffs = struct {
11271127
11281128 pub fn decode(moffs: MemoryMoffs) Memory {
11291129 return .{ .moffs = .{
1130 .seg = @intToEnum(Register, moffs.seg),
1130 .seg = @enumFromInt(Register, moffs.seg),
11311131 .offset = @as(u64, moffs.msb) << 32 | @as(u64, moffs.lsb) << 0,
11321132 } };
11331133 }
......@@ -1168,8 +1168,8 @@ pub fn resolveFrameLoc(mir: Mir, mem: Memory) Memory {
11681168 .sib => |sib| switch (sib.base) {
11691169 .none, .reg => mem,
11701170 .frame => |index| if (mir.frame_locs.len > 0) Memory.sib(sib.ptr_size, .{
1171 .base = .{ .reg = mir.frame_locs.items(.base)[@enumToInt(index)] },
1172 .disp = mir.frame_locs.items(.disp)[@enumToInt(index)] + sib.disp,
1171 .base = .{ .reg = mir.frame_locs.items(.base)[@intFromEnum(index)] },
1172 .disp = mir.frame_locs.items(.disp)[@intFromEnum(index)] + sib.disp,
11731173 .scale_index = mem.scaleIndex(),
11741174 }) else mem,
11751175 },
src/arch/x86_64/bits.zig+70-70
......@@ -193,20 +193,20 @@ pub const Register = enum(u7) {
193193 };
194194
195195 pub fn class(reg: Register) Class {
196 return switch (@enumToInt(reg)) {
196 return switch (@intFromEnum(reg)) {
197197 // zig fmt: off
198 @enumToInt(Register.rax) ... @enumToInt(Register.r15) => .general_purpose,
199 @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => .general_purpose,
200 @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => .general_purpose,
201 @enumToInt(Register.al) ... @enumToInt(Register.r15b) => .general_purpose,
202 @enumToInt(Register.ah) ... @enumToInt(Register.bh) => .general_purpose,
198 @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => .general_purpose,
199 @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => .general_purpose,
200 @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => .general_purpose,
201 @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => .general_purpose,
202 @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => .general_purpose,
203203
204 @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => .sse,
205 @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => .sse,
206 @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => .mmx,
207 @enumToInt(Register.st0) ... @enumToInt(Register.st7) => .x87,
204 @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => .sse,
205 @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => .sse,
206 @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => .mmx,
207 @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => .x87,
208208
209 @enumToInt(Register.es) ... @enumToInt(Register.gs) => .segment,
209 @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => .segment,
210210
211211 else => unreachable,
212212 // zig fmt: on
......@@ -214,42 +214,42 @@ pub const Register = enum(u7) {
214214 }
215215
216216 pub fn id(reg: Register) u6 {
217 const base = switch (@enumToInt(reg)) {
217 const base = switch (@intFromEnum(reg)) {
218218 // zig fmt: off
219 @enumToInt(Register.rax) ... @enumToInt(Register.r15) => @enumToInt(Register.rax),
220 @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => @enumToInt(Register.eax),
221 @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => @enumToInt(Register.ax),
222 @enumToInt(Register.al) ... @enumToInt(Register.r15b) => @enumToInt(Register.al),
223 @enumToInt(Register.ah) ... @enumToInt(Register.bh) => @enumToInt(Register.ah) - 4,
219 @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax),
220 @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => @intFromEnum(Register.eax),
221 @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => @intFromEnum(Register.ax),
222 @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al),
223 @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah) - 4,
224224
225 @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => @enumToInt(Register.ymm0) - 16,
226 @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => @enumToInt(Register.xmm0) - 16,
227 @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => @enumToInt(Register.mm0) - 32,
228 @enumToInt(Register.st0) ... @enumToInt(Register.st7) => @enumToInt(Register.st0) - 40,
225 @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0) - 16,
226 @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0) - 16,
227 @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => @intFromEnum(Register.mm0) - 32,
228 @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => @intFromEnum(Register.st0) - 40,
229229
230 @enumToInt(Register.es) ... @enumToInt(Register.gs) => @enumToInt(Register.es) - 48,
230 @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => @intFromEnum(Register.es) - 48,
231231
232232 else => unreachable,
233233 // zig fmt: on
234234 };
235 return @intCast(u6, @enumToInt(reg) - base);
235 return @intCast(u6, @intFromEnum(reg) - base);
236236 }
237237
238238 pub fn bitSize(reg: Register) u64 {
239 return switch (@enumToInt(reg)) {
239 return switch (@intFromEnum(reg)) {
240240 // zig fmt: off
241 @enumToInt(Register.rax) ... @enumToInt(Register.r15) => 64,
242 @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => 32,
243 @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => 16,
244 @enumToInt(Register.al) ... @enumToInt(Register.r15b) => 8,
245 @enumToInt(Register.ah) ... @enumToInt(Register.bh) => 8,
241 @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => 64,
242 @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => 32,
243 @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => 16,
244 @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => 8,
245 @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => 8,
246246
247 @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => 256,
248 @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => 128,
249 @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => 64,
250 @enumToInt(Register.st0) ... @enumToInt(Register.st7) => 80,
247 @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => 256,
248 @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => 128,
249 @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => 64,
250 @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => 80,
251251
252 @enumToInt(Register.es) ... @enumToInt(Register.gs) => 16,
252 @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => 16,
253253
254254 else => unreachable,
255255 // zig fmt: on
......@@ -257,15 +257,15 @@ pub const Register = enum(u7) {
257257 }
258258
259259 pub fn isExtended(reg: Register) bool {
260 return switch (@enumToInt(reg)) {
260 return switch (@intFromEnum(reg)) {
261261 // zig fmt: off
262 @enumToInt(Register.r8) ... @enumToInt(Register.r15) => true,
263 @enumToInt(Register.r8d) ... @enumToInt(Register.r15d) => true,
264 @enumToInt(Register.r8w) ... @enumToInt(Register.r15w) => true,
265 @enumToInt(Register.r8b) ... @enumToInt(Register.r15b) => true,
262 @intFromEnum(Register.r8) ... @intFromEnum(Register.r15) => true,
263 @intFromEnum(Register.r8d) ... @intFromEnum(Register.r15d) => true,
264 @intFromEnum(Register.r8w) ... @intFromEnum(Register.r15w) => true,
265 @intFromEnum(Register.r8b) ... @intFromEnum(Register.r15b) => true,
266266
267 @enumToInt(Register.ymm8) ... @enumToInt(Register.ymm15) => true,
268 @enumToInt(Register.xmm8) ... @enumToInt(Register.xmm15) => true,
267 @intFromEnum(Register.ymm8) ... @intFromEnum(Register.ymm15) => true,
268 @intFromEnum(Register.xmm8) ... @intFromEnum(Register.xmm15) => true,
269269
270270 else => false,
271271 // zig fmt: on
......@@ -273,25 +273,25 @@ pub const Register = enum(u7) {
273273 }
274274
275275 pub fn enc(reg: Register) u4 {
276 const base = switch (@enumToInt(reg)) {
276 const base = switch (@intFromEnum(reg)) {
277277 // zig fmt: off
278 @enumToInt(Register.rax) ... @enumToInt(Register.r15) => @enumToInt(Register.rax),
279 @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => @enumToInt(Register.eax),
280 @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => @enumToInt(Register.ax),
281 @enumToInt(Register.al) ... @enumToInt(Register.r15b) => @enumToInt(Register.al),
282 @enumToInt(Register.ah) ... @enumToInt(Register.bh) => @enumToInt(Register.ah) - 4,
278 @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax),
279 @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => @intFromEnum(Register.eax),
280 @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => @intFromEnum(Register.ax),
281 @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al),
282 @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah) - 4,
283283
284 @enumToInt(Register.ymm0) ... @enumToInt(Register.ymm15) => @enumToInt(Register.ymm0),
285 @enumToInt(Register.xmm0) ... @enumToInt(Register.xmm15) => @enumToInt(Register.xmm0),
286 @enumToInt(Register.mm0) ... @enumToInt(Register.mm7) => @enumToInt(Register.mm0),
287 @enumToInt(Register.st0) ... @enumToInt(Register.st7) => @enumToInt(Register.st0),
284 @intFromEnum(Register.ymm0) ... @intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0),
285 @intFromEnum(Register.xmm0) ... @intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0),
286 @intFromEnum(Register.mm0) ... @intFromEnum(Register.mm7) => @intFromEnum(Register.mm0),
287 @intFromEnum(Register.st0) ... @intFromEnum(Register.st7) => @intFromEnum(Register.st0),
288288
289 @enumToInt(Register.es) ... @enumToInt(Register.gs) => @enumToInt(Register.es),
289 @intFromEnum(Register.es) ... @intFromEnum(Register.gs) => @intFromEnum(Register.es),
290290
291291 else => unreachable,
292292 // zig fmt: on
293293 };
294 return @truncate(u4, @enumToInt(reg) - base);
294 return @truncate(u4, @intFromEnum(reg) - base);
295295 }
296296
297297 pub fn lowEnc(reg: Register) u3 {
......@@ -312,49 +312,49 @@ pub const Register = enum(u7) {
312312
313313 fn gpBase(reg: Register) u7 {
314314 assert(reg.class() == .general_purpose);
315 return switch (@enumToInt(reg)) {
315 return switch (@intFromEnum(reg)) {
316316 // zig fmt: off
317 @enumToInt(Register.rax) ... @enumToInt(Register.r15) => @enumToInt(Register.rax),
318 @enumToInt(Register.eax) ... @enumToInt(Register.r15d) => @enumToInt(Register.eax),
319 @enumToInt(Register.ax) ... @enumToInt(Register.r15w) => @enumToInt(Register.ax),
320 @enumToInt(Register.al) ... @enumToInt(Register.r15b) => @enumToInt(Register.al),
321 @enumToInt(Register.ah) ... @enumToInt(Register.bh) => @enumToInt(Register.ah) - 4,
317 @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => @intFromEnum(Register.rax),
318 @intFromEnum(Register.eax) ... @intFromEnum(Register.r15d) => @intFromEnum(Register.eax),
319 @intFromEnum(Register.ax) ... @intFromEnum(Register.r15w) => @intFromEnum(Register.ax),
320 @intFromEnum(Register.al) ... @intFromEnum(Register.r15b) => @intFromEnum(Register.al),
321 @intFromEnum(Register.ah) ... @intFromEnum(Register.bh) => @intFromEnum(Register.ah) - 4,
322322 else => unreachable,
323323 // zig fmt: on
324324 };
325325 }
326326
327327 pub fn to64(reg: Register) Register {
328 return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.rax));
328 return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.rax));
329329 }
330330
331331 pub fn to32(reg: Register) Register {
332 return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.eax));
332 return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.eax));
333333 }
334334
335335 pub fn to16(reg: Register) Register {
336 return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.ax));
336 return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.ax));
337337 }
338338
339339 pub fn to8(reg: Register) Register {
340 return @intToEnum(Register, @enumToInt(reg) - reg.gpBase() + @enumToInt(Register.al));
340 return @enumFromInt(Register, @intFromEnum(reg) - reg.gpBase() + @intFromEnum(Register.al));
341341 }
342342
343343 fn sseBase(reg: Register) u7 {
344344 assert(reg.class() == .sse);
345 return switch (@enumToInt(reg)) {
346 @enumToInt(Register.ymm0)...@enumToInt(Register.ymm15) => @enumToInt(Register.ymm0),
347 @enumToInt(Register.xmm0)...@enumToInt(Register.xmm15) => @enumToInt(Register.xmm0),
345 return switch (@intFromEnum(reg)) {
346 @intFromEnum(Register.ymm0)...@intFromEnum(Register.ymm15) => @intFromEnum(Register.ymm0),
347 @intFromEnum(Register.xmm0)...@intFromEnum(Register.xmm15) => @intFromEnum(Register.xmm0),
348348 else => unreachable,
349349 };
350350 }
351351
352352 pub fn to256(reg: Register) Register {
353 return @intToEnum(Register, @enumToInt(reg) - reg.sseBase() + @enumToInt(Register.ymm0));
353 return @enumFromInt(Register, @intFromEnum(reg) - reg.sseBase() + @intFromEnum(Register.ymm0));
354354 }
355355
356356 pub fn to128(reg: Register) Register {
357 return @intToEnum(Register, @enumToInt(reg) - reg.sseBase() + @enumToInt(Register.xmm0));
357 return @enumFromInt(Register, @intFromEnum(reg) - reg.sseBase() + @intFromEnum(Register.xmm0));
358358 }
359359
360360 /// DWARF register encoding
......@@ -421,7 +421,7 @@ pub const FrameIndex = enum(u32) {
421421 pub const named_count = @typeInfo(FrameIndex).Enum.fields.len;
422422
423423 pub fn isNamed(fi: FrameIndex) bool {
424 return @enumToInt(fi) < named_count;
424 return @intFromEnum(fi) < named_count;
425425 }
426426
427427 pub fn format(
......@@ -436,7 +436,7 @@ pub const FrameIndex = enum(u32) {
436436 try writer.writeAll(@tagName(fi));
437437 } else {
438438 try writer.writeByte('(');
439 try std.fmt.formatType(@enumToInt(fi), fmt, options, writer, 0);
439 try std.fmt.formatType(@intFromEnum(fi), fmt, options, writer, 0);
440440 try writer.writeByte(')');
441441 }
442442 }
src/arch/x86_64/encoder.zig+11-11
......@@ -267,7 +267,7 @@ pub const Instruction = struct {
267267
268268 fn encodeOpcode(inst: Instruction, encoder: anytype) !void {
269269 const opcode = inst.encoding.opcode();
270 const first = @boolToInt(inst.encoding.mandatoryPrefix() != null);
270 const first = @intFromBool(inst.encoding.mandatoryPrefix() != null);
271271 const final = opcode.len - 1;
272272 for (opcode[first..final]) |byte| try encoder.opcode_1byte(byte);
273273 switch (inst.encoding.data.op_en) {
......@@ -647,25 +647,25 @@ fn Encoder(comptime T: type, comptime opts: Options) type {
647647 try self.writer.writeByte(0b1100_0100);
648648
649649 try self.writer.writeByte(
650 @as(u8, ~@boolToInt(fields.r)) << 7 |
651 @as(u8, ~@boolToInt(fields.x)) << 6 |
652 @as(u8, ~@boolToInt(fields.b)) << 5 |
653 @as(u8, @enumToInt(fields.m)) << 0,
650 @as(u8, ~@intFromBool(fields.r)) << 7 |
651 @as(u8, ~@intFromBool(fields.x)) << 6 |
652 @as(u8, ~@intFromBool(fields.b)) << 5 |
653 @as(u8, @intFromEnum(fields.m)) << 0,
654654 );
655655
656656 try self.writer.writeByte(
657 @as(u8, @boolToInt(fields.w)) << 7 |
657 @as(u8, @intFromBool(fields.w)) << 7 |
658658 @as(u8, ~fields.v.enc()) << 3 |
659 @as(u8, @boolToInt(fields.l)) << 2 |
660 @as(u8, @enumToInt(fields.p)) << 0,
659 @as(u8, @intFromBool(fields.l)) << 2 |
660 @as(u8, @intFromEnum(fields.p)) << 0,
661661 );
662662 } else {
663663 try self.writer.writeByte(0b1100_0101);
664664 try self.writer.writeByte(
665 @as(u8, ~@boolToInt(fields.r)) << 7 |
665 @as(u8, ~@intFromBool(fields.r)) << 7 |
666666 @as(u8, ~fields.v.enc()) << 3 |
667 @as(u8, @boolToInt(fields.l)) << 2 |
668 @as(u8, @enumToInt(fields.p)) << 0,
667 @as(u8, @intFromBool(fields.l)) << 2 |
668 @as(u8, @intFromEnum(fields.p)) << 0,
669669 );
670670 }
671671 }
src/clang.zig+1-1
......@@ -1448,7 +1448,7 @@ pub const CK = enum(c_int) {
14481448 IntegralToBoolean,
14491449 IntegralToFloating,
14501450 FloatingToFixedPoint,
1451 FixedPointToFloating,
1451 FixedPofloatFromInting,
14521452 FixedPointCast,
14531453 FixedPointToIntegral,
14541454 IntegralToFixedPoint,
src/codegen.zig+4-4
......@@ -381,7 +381,7 @@ pub fn generateSymbol(
381381 .fail => |em| return Result{ .fail = em },
382382 }
383383 }
384 try code.writer().writeByte(@boolToInt(payload_val != null));
384 try code.writer().writeByte(@intFromBool(payload_val != null));
385385 try code.writer().writeByteNTimes(0, padding);
386386 }
387387 },
......@@ -391,7 +391,7 @@ pub fn generateSymbol(
391391 .elems, .repeated_elem => {
392392 var index: u64 = 0;
393393 var len_including_sentinel =
394 array_type.len + @boolToInt(array_type.sentinel != .none);
394 array_type.len + @intFromBool(array_type.sentinel != .none);
395395 while (index < len_including_sentinel) : (index += 1) {
396396 switch (try generateSymbol(bin_file, src_loc, .{
397397 .ty = array_type.child.toType(),
......@@ -952,7 +952,7 @@ pub fn genTypedValue(
952952 }
953953 },
954954 .Bool => {
955 return GenResult.mcv(.{ .immediate = @boolToInt(typed_value.val.toBool()) });
955 return GenResult.mcv(.{ .immediate = @intFromBool(typed_value.val.toBool()) });
956956 },
957957 .Optional => {
958958 if (typed_value.ty.isPtrLikeOptional(mod)) {
......@@ -961,7 +961,7 @@ pub fn genTypedValue(
961961 .val = typed_value.val.optionalValue(mod) orelse return GenResult.mcv(.{ .immediate = 0 }),
962962 }, owner_decl_index);
963963 } else if (typed_value.ty.abiSize(mod) == 1) {
964 return GenResult.mcv(.{ .immediate = @boolToInt(!typed_value.val.isNull(mod)) });
964 return GenResult.mcv(.{ .immediate = @intFromBool(!typed_value.val.isNull(mod)) });
965965 }
966966 },
967967 .Enum => {
src/codegen/c.zig+15-15
......@@ -462,7 +462,7 @@ pub const Function = struct {
462462 => |owner_decl| try std.fmt.allocPrint(arena, "zig_{s}_{}__{d}", .{
463463 @tagName(key),
464464 fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(owner_decl).name)),
465 @enumToInt(owner_decl),
465 @intFromEnum(owner_decl),
466466 }),
467467 },
468468 .data = switch (key) {
......@@ -1865,7 +1865,7 @@ pub const DeclGen = struct {
18651865 };
18661866 try writer.print("{}__{d}", .{
18671867 fmtIdent(name_stream.getWritten()),
1868 @enumToInt(decl_index),
1868 @intFromEnum(decl_index),
18691869 });
18701870 }
18711871 }
......@@ -1991,7 +1991,7 @@ fn renderTypeName(
19911991 @tagName(tag)["fwd_".len..],
19921992 attributes,
19931993 fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(owner_decl).name)),
1994 @enumToInt(owner_decl),
1994 @intFromEnum(owner_decl),
19951995 });
19961996 },
19971997 }
......@@ -2100,7 +2100,7 @@ fn renderTypePrefix(
21002100 .fwd_anon_struct,
21012101 .fwd_anon_union,
21022102 => if (decl.unwrap()) |decl_index|
2103 try w.print("anon__{d}_{d}", .{ @enumToInt(decl_index), idx })
2103 try w.print("anon__{d}_{d}", .{ @intFromEnum(decl_index), idx })
21042104 else
21052105 try renderTypeName(mod, w, idx, cty, ""),
21062106
......@@ -2514,7 +2514,7 @@ pub fn genLazyFn(o: *Object, lazy_fn: LazyFnMap.Entry) !void {
25142514 const name = mod.intern_pool.stringToSlice(name_ip);
25152515 const tag_val = try mod.enumValueFieldIndex(enum_ty, index);
25162516
2517 const int_val = try tag_val.enumToInt(enum_ty, mod);
2517 const int_val = try tag_val.intFromEnum(enum_ty, mod);
25182518
25192519 const name_ty = try mod.arrayType(.{
25202520 .len = name.len,
......@@ -2943,7 +2943,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
29432943 .dbg_stmt => try airDbgStmt(f, inst),
29442944 .intcast => try airIntCast(f, inst),
29452945 .trunc => try airTrunc(f, inst),
2946 .bool_to_int => try airBoolToInt(f, inst),
2946 .int_from_bool => try airIntFromBool(f, inst),
29472947 .load => try airLoad(f, inst),
29482948 .ret => try airRet(f, inst, false),
29492949 .ret_load => try airRet(f, inst, true),
......@@ -3000,13 +3000,13 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
30003000 .call_never_tail => try airCall(f, inst, .never_tail),
30013001 .call_never_inline => try airCall(f, inst, .never_inline),
30023002
3003 .int_to_float,
3004 .float_to_int,
3003 .float_from_int,
3004 .int_from_float,
30053005 .fptrunc,
30063006 .fpext,
30073007 => try airFloatCast(f, inst),
30083008
3009 .ptrtoint => try airPtrToInt(f, inst),
3009 .int_from_ptr => try airIntFromPtr(f, inst),
30103010
30113011 .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)),
30123012 .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)),
......@@ -3068,7 +3068,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
30683068 .cmp_neq_optimized,
30693069 .cmp_vector_optimized,
30703070 .reduce_optimized,
3071 .float_to_int_optimized,
3071 .int_from_float_optimized,
30723072 => return f.fail("TODO implement optimized float mode", .{}),
30733073
30743074 .is_named_enum_value => return f.fail("TODO: C backend: implement is_named_enum_value", .{}),
......@@ -3562,7 +3562,7 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue {
35623562 return local;
35633563}
35643564
3565fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue {
3565fn airIntFromBool(f: *Function, inst: Air.Inst.Index) !CValue {
35663566 const un_op = f.air.instructions.items(.data)[inst].un_op;
35673567 const operand = try f.resolveInst(un_op);
35683568 try reap(f, inst, &.{un_op});
......@@ -4701,7 +4701,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
47014701
47024702 // On the final iteration we do not need to fix any state. This is because, like in the `else`
47034703 // branch of a `cond_br`, our parent has to do it for this entire body anyway.
4704 const last_case_i = switch_br.data.cases_len - @boolToInt(switch_br.data.else_body_len == 0);
4704 const last_case_i = switch_br.data.cases_len - @intFromBool(switch_br.data.else_body_len == 0);
47054705
47064706 var extra_index: usize = switch_br.end;
47074707 for (0..switch_br.data.cases_len) |case_i| {
......@@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue {
58345834 return local;
58355835}
58365836
5837fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue {
5837fn airIntFromPtr(f: *Function, inst: Air.Inst.Index) !CValue {
58385838 const mod = f.object.dg.module;
58395839 const un_op = f.air.instructions.items(.data)[inst].un_op;
58405840
......@@ -6894,7 +6894,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
68946894
68956895 const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index);
68966896
6897 const int_val = try tag_val.enumToInt(tag_ty, mod);
6897 const int_val = try tag_val.intFromEnum(tag_ty, mod);
68986898
68996899 const a = try Assignment.start(f, writer, tag_ty);
69006900 try f.writeCValueMember(writer, local, .{ .identifier = "tag" });
......@@ -6924,7 +6924,7 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue {
69246924 .data => {
69256925 try writer.writeAll("zig_prefetch(");
69266926 try f.writeCValue(writer, ptr, .FunctionArgument);
6927 try writer.print(", {d}, {d});\n", .{ @enumToInt(prefetch.rw), prefetch.locality });
6927 try writer.print(", {d}, {d});\n", .{ @intFromEnum(prefetch.rw), prefetch.locality });
69286928 },
69296929 // The available prefetch intrinsics do not accept a cache argument; only
69306930 // address, rw, and locality.
src/codegen/c/type.zig+5-5
......@@ -129,15 +129,15 @@ pub const CType = extern union {
129129 varargs_function,
130130
131131 pub const last_no_payload_tag = Tag.zig_c_longdouble;
132 pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
132 pub const no_payload_count = @intFromEnum(last_no_payload_tag) + 1;
133133
134134 pub fn hasPayload(self: Tag) bool {
135 return @enumToInt(self) >= no_payload_count;
135 return @intFromEnum(self) >= no_payload_count;
136136 }
137137
138138 pub fn toIndex(self: Tag) Index {
139139 assert(!self.hasPayload());
140 return @intCast(Index, @enumToInt(self));
140 return @intCast(Index, @intFromEnum(self));
141141 }
142142
143143 pub fn Type(comptime self: Tag) type {
......@@ -334,7 +334,7 @@ pub const CType = extern union {
334334 map: Map = .{},
335335
336336 pub fn indexToCType(self: Set, index: Index) CType {
337 if (index < Tag.no_payload_count) return initTag(@intToEnum(Tag, index));
337 if (index < Tag.no_payload_count) return initTag(@enumFromInt(Tag, index));
338338 return self.map.keys()[index - Tag.no_payload_count];
339339 }
340340
......@@ -370,7 +370,7 @@ pub const CType = extern union {
370370
371371 pub fn cTypeToIndex(self: *Promoted, cty: CType) Allocator.Error!Index {
372372 const t = cty.tag();
373 if (@enumToInt(t) < Tag.no_payload_count) return @intCast(Index, @enumToInt(t));
373 if (@intFromEnum(t) < Tag.no_payload_count) return @intCast(Index, @intFromEnum(t));
374374
375375 const gop = try self.set.map.getOrPutContext(self.gpa(), cty, .{ .store = &self.set });
376376 if (!gop.found_existing) gop.key_ptr.* = cty;
src/codegen/llvm.zig+50-50
......@@ -949,7 +949,7 @@ pub const Object = struct {
949949 mod.comp.bin_file.options.error_return_tracing;
950950
951951 const err_ret_trace = if (err_return_tracing)
952 llvm_func.getParam(@boolToInt(ret_ptr != null))
952 llvm_func.getParam(@intFromBool(ret_ptr != null))
953953 else
954954 null;
955955
......@@ -960,7 +960,7 @@ pub const Object = struct {
960960 defer args.deinit();
961961
962962 {
963 var llvm_arg_i = @as(c_uint, @boolToInt(ret_ptr != null)) + @boolToInt(err_return_tracing);
963 var llvm_arg_i = @as(c_uint, @intFromBool(ret_ptr != null)) + @intFromBool(err_return_tracing);
964964 var it = iterateParamTypes(&dg, fn_info);
965965 while (it.next()) |lowering| switch (lowering) {
966966 .no_bits => continue,
......@@ -2570,7 +2570,7 @@ pub const DeclGen = struct {
25702570 mod.comp.bin_file.options.error_return_tracing;
25712571
25722572 if (err_return_tracing) {
2573 dg.addArgAttr(llvm_fn, @boolToInt(sret), "nonnull");
2573 dg.addArgAttr(llvm_fn, @intFromBool(sret), "nonnull");
25742574 }
25752575
25762576 switch (fn_info.cc) {
......@@ -2604,8 +2604,8 @@ pub const DeclGen = struct {
26042604 // because functions with bodies are handled in `updateFunc`.
26052605 if (is_extern) {
26062606 var it = iterateParamTypes(dg, fn_info);
2607 it.llvm_index += @boolToInt(sret);
2608 it.llvm_index += @boolToInt(err_return_tracing);
2607 it.llvm_index += @intFromBool(sret);
2608 it.llvm_index += @intFromBool(err_return_tracing);
26092609 while (it.next()) |lowering| switch (lowering) {
26102610 .byval => {
26112611 const param_index = it.zig_index - 1;
......@@ -2812,7 +2812,7 @@ pub const DeclGen = struct {
28122812 const elem_ty = t.childType(mod);
28132813 if (std.debug.runtime_safety) assert((try elem_ty.onePossibleValue(mod)) == null);
28142814 const elem_llvm_ty = try dg.lowerType(elem_ty);
2815 const total_len = t.arrayLen(mod) + @boolToInt(t.sentinel(mod) != null);
2815 const total_len = t.arrayLen(mod) + @intFromBool(t.sentinel(mod) != null);
28162816 return elem_llvm_ty.arrayType(@intCast(c_uint, total_len));
28172817 },
28182818 .Vector => {
......@@ -3307,7 +3307,7 @@ pub const DeclGen = struct {
33073307 }
33083308 },
33093309 .enum_tag => {
3310 const int_val = try tv.enumToInt(mod);
3310 const int_val = try tv.intFromEnum(mod);
33113311
33123312 var bigint_space: Value.BigIntSpace = undefined;
33133313 const bigint = int_val.toBigInt(&bigint_space, mod);
......@@ -3476,7 +3476,7 @@ pub const DeclGen = struct {
34763476 const elem_ty = tv.ty.childType(mod);
34773477 const sentinel = tv.ty.sentinel(mod);
34783478 const len = @intCast(usize, tv.ty.arrayLen(mod));
3479 const len_including_sent = len + @boolToInt(sentinel != null);
3479 const len_including_sent = len + @intFromBool(sentinel != null);
34803480 const gpa = dg.gpa;
34813481 const llvm_elems = try gpa.alloc(*llvm.Value, len_including_sent);
34823482 defer gpa.free(llvm_elems);
......@@ -3923,7 +3923,7 @@ pub const DeclGen = struct {
39233923 const llvm_pl_index = if (layout.tag_size == 0)
39243924 0
39253925 else
3926 @boolToInt(layout.tag_align >= layout.payload_align);
3926 @intFromBool(layout.tag_align >= layout.payload_align);
39273927 const indices: [2]*llvm.Value = .{
39283928 llvm_u32.constInt(0, .False),
39293929 llvm_u32.constInt(llvm_pl_index, .False),
......@@ -3959,7 +3959,7 @@ pub const DeclGen = struct {
39593959 };
39603960 return parent_llvm_ty.constInBoundsGEP(parent_llvm_ptr, &indices, indices.len);
39613961 } else {
3962 const llvm_index = llvm_u32.constInt(@boolToInt(parent_ty.hasRuntimeBitsIgnoreComptime(mod)), .False);
3962 const llvm_index = llvm_u32.constInt(@intFromBool(parent_ty.hasRuntimeBitsIgnoreComptime(mod)), .False);
39633963 const indices: [1]*llvm.Value = .{llvm_index};
39643964 return parent_llvm_ty.constInBoundsGEP(parent_llvm_ptr, &indices, indices.len);
39653965 }
......@@ -4417,7 +4417,7 @@ pub const FuncGen = struct {
44174417 .ret_ptr => try self.airRetPtr(inst),
44184418 .arg => try self.airArg(inst),
44194419 .bitcast => try self.airBitCast(inst),
4420 .bool_to_int => try self.airBoolToInt(inst),
4420 .int_from_bool => try self.airIntFromBool(inst),
44214421 .block => try self.airBlock(inst),
44224422 .br => try self.airBr(inst),
44234423 .switch_br => try self.airSwitchBr(inst),
......@@ -4432,7 +4432,7 @@ pub const FuncGen = struct {
44324432 .trunc => try self.airTrunc(inst),
44334433 .fptrunc => try self.airFptrunc(inst),
44344434 .fpext => try self.airFpext(inst),
4435 .ptrtoint => try self.airPtrToInt(inst),
4435 .int_from_ptr => try self.airIntFromPtr(inst),
44364436 .load => try self.airLoad(body[i..]),
44374437 .loop => try self.airLoop(inst),
44384438 .not => try self.airNot(inst),
......@@ -4452,11 +4452,11 @@ pub const FuncGen = struct {
44524452 .ptr_slice_ptr_ptr => try self.airPtrSliceFieldPtr(inst, 0),
44534453 .ptr_slice_len_ptr => try self.airPtrSliceFieldPtr(inst, 1),
44544454
4455 .float_to_int => try self.airFloatToInt(inst, false),
4456 .float_to_int_optimized => try self.airFloatToInt(inst, true),
4455 .int_from_float => try self.airIntFromFloat(inst, false),
4456 .int_from_float_optimized => try self.airIntFromFloat(inst, true),
44574457
44584458 .array_to_slice => try self.airArrayToSlice(inst),
4459 .int_to_float => try self.airIntToFloat(inst),
4459 .float_from_int => try self.airFloatFromInt(inst),
44604460 .cmpxchg_weak => try self.airCmpxchg(inst, true),
44614461 .cmpxchg_strong => try self.airCmpxchg(inst, false),
44624462 .fence => try self.airFence(inst),
......@@ -4762,8 +4762,8 @@ pub const FuncGen = struct {
47624762 if (callee_ty.zigTypeTag(mod) == .Pointer) {
47634763 // Add argument attributes for function pointer calls.
47644764 it = iterateParamTypes(self.dg, fn_info);
4765 it.llvm_index += @boolToInt(sret);
4766 it.llvm_index += @boolToInt(err_return_tracing);
4765 it.llvm_index += @intFromBool(sret);
4766 it.llvm_index += @intFromBool(err_return_tracing);
47674767 while (it.next()) |lowering| switch (lowering) {
47684768 .byval => {
47694769 const param_index = it.zig_index - 1;
......@@ -5456,7 +5456,7 @@ pub const FuncGen = struct {
54565456 return self.builder.buildInsertValue(partial, len, 1, "");
54575457 }
54585458
5459 fn airIntToFloat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
5459 fn airFloatFromInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
54605460 const mod = self.dg.module;
54615461 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
54625462
......@@ -5513,7 +5513,7 @@ pub const FuncGen = struct {
55135513 return self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
55145514 }
55155515
5516 fn airFloatToInt(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
5516 fn airIntFromFloat(self: *FuncGen, inst: Air.Inst.Index, want_fast_math: bool) !?*llvm.Value {
55175517 self.builder.setFastMath(want_fast_math);
55185518
55195519 const mod = self.dg.module;
......@@ -5857,7 +5857,7 @@ pub const FuncGen = struct {
58575857 .Union => {
58585858 const union_llvm_ty = try self.dg.lowerType(struct_ty);
58595859 const layout = struct_ty.unionGetLayout(mod);
5860 const payload_index = @boolToInt(layout.tag_align >= layout.payload_align);
5860 const payload_index = @intFromBool(layout.tag_align >= layout.payload_align);
58615861 const field_ptr = self.builder.buildStructGEP(union_llvm_ty, struct_llvm_val, payload_index, "");
58625862 const llvm_field_ty = try self.dg.lowerType(field_ty);
58635863 if (isByRef(field_ty, mod)) {
......@@ -7788,7 +7788,7 @@ pub const FuncGen = struct {
77887788 }
77897789 }
77907790
7791 fn airPtrToInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
7791 fn airIntFromPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
77927792 const un_op = self.air.instructions.items(.data)[inst].un_op;
77937793 const operand = try self.resolveInst(un_op);
77947794 const ptr_ty = self.typeOf(un_op);
......@@ -7922,7 +7922,7 @@ pub const FuncGen = struct {
79227922 return self.builder.buildBitCast(operand, llvm_dest_ty, "");
79237923 }
79247924
7925 fn airBoolToInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
7925 fn airIntFromBool(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
79267926 const un_op = self.air.instructions.items(.data)[inst].un_op;
79277927 const operand = try self.resolveInst(un_op);
79287928 return operand;
......@@ -8444,7 +8444,7 @@ pub const FuncGen = struct {
84448444 return null;
84458445 }
84468446 const un_llvm_ty = try self.dg.lowerType(un_ty);
8447 const tag_index = @boolToInt(layout.tag_align < layout.payload_align);
8447 const tag_index = @intFromBool(layout.tag_align < layout.payload_align);
84488448 const tag_field_ptr = self.builder.buildStructGEP(un_llvm_ty, union_ptr, tag_index, "");
84498449 // TODO alignment on this store
84508450 _ = self.builder.buildStore(new_tag, tag_field_ptr);
......@@ -8463,14 +8463,14 @@ pub const FuncGen = struct {
84638463 if (layout.payload_size == 0) {
84648464 return self.builder.buildLoad(llvm_un_ty, union_handle, "");
84658465 }
8466 const tag_index = @boolToInt(layout.tag_align < layout.payload_align);
8466 const tag_index = @intFromBool(layout.tag_align < layout.payload_align);
84678467 const tag_field_ptr = self.builder.buildStructGEP(llvm_un_ty, union_handle, tag_index, "");
84688468 return self.builder.buildLoad(llvm_un_ty.structGetTypeAtIndex(tag_index), tag_field_ptr, "");
84698469 } else {
84708470 if (layout.payload_size == 0) {
84718471 return union_handle;
84728472 }
8473 const tag_index = @boolToInt(layout.tag_align < layout.payload_align);
8473 const tag_index = @intFromBool(layout.tag_align < layout.payload_align);
84748474 return self.builder.buildExtractValue(union_handle, tag_index, "");
84758475 }
84768476 }
......@@ -9206,7 +9206,7 @@ pub const FuncGen = struct {
92069206 const union_field_name = union_obj.fields.keys()[extra.field_index];
92079207 const enum_field_index = tag_ty.enumFieldIndex(union_field_name, mod).?;
92089208 const tag_val = try mod.enumValueFieldIndex(tag_ty, enum_field_index);
9209 const tag_int_val = try tag_val.enumToInt(tag_ty, mod);
9209 const tag_int_val = try tag_val.intFromEnum(tag_ty, mod);
92109210 break :blk tag_int_val.toUnsignedInt(mod);
92119211 };
92129212 if (layout.payload_size == 0) {
......@@ -9288,7 +9288,7 @@ pub const FuncGen = struct {
92889288 {
92899289 const indices: [3]*llvm.Value = .{
92909290 index_type.constNull(),
9291 index_type.constInt(@boolToInt(layout.tag_align >= layout.payload_align), .False),
9291 index_type.constInt(@intFromBool(layout.tag_align >= layout.payload_align), .False),
92929292 index_type.constNull(),
92939293 };
92949294 const len: c_uint = if (field_size == layout.payload_size) 2 else 3;
......@@ -9298,7 +9298,7 @@ pub const FuncGen = struct {
92989298 {
92999299 const indices: [2]*llvm.Value = .{
93009300 index_type.constNull(),
9301 index_type.constInt(@boolToInt(layout.tag_align < layout.payload_align), .False),
9301 index_type.constInt(@intFromBool(layout.tag_align < layout.payload_align), .False),
93029302 };
93039303 const field_ptr = self.builder.buildInBoundsGEP(llvm_union_ty, result_ptr, &indices, indices.len, "");
93049304 const tag_llvm_ty = try self.dg.lowerType(union_obj.tag_ty);
......@@ -9313,15 +9313,15 @@ pub const FuncGen = struct {
93139313 fn airPrefetch(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
93149314 const prefetch = self.air.instructions.items(.data)[inst].prefetch;
93159315
9316 comptime assert(@enumToInt(std.builtin.PrefetchOptions.Rw.read) == 0);
9317 comptime assert(@enumToInt(std.builtin.PrefetchOptions.Rw.write) == 1);
9316 comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Rw.read) == 0);
9317 comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Rw.write) == 1);
93189318
93199319 // TODO these two asserts should be able to be comptime because the type is a u2
93209320 assert(prefetch.locality >= 0);
93219321 assert(prefetch.locality <= 3);
93229322
9323 comptime assert(@enumToInt(std.builtin.PrefetchOptions.Cache.instruction) == 0);
9324 comptime assert(@enumToInt(std.builtin.PrefetchOptions.Cache.data) == 1);
9323 comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Cache.instruction) == 0);
9324 comptime assert(@intFromEnum(std.builtin.PrefetchOptions.Cache.data) == 1);
93259325
93269326 // LLVM fails during codegen of instruction cache prefetchs for these architectures.
93279327 // This is an LLVM bug as the prefetch intrinsic should be a noop if not supported
......@@ -9368,9 +9368,9 @@ pub const FuncGen = struct {
93689368
93699369 const params = [_]*llvm.Value{
93709370 ptr,
9371 llvm_u32.constInt(@enumToInt(prefetch.rw), .False),
9371 llvm_u32.constInt(@intFromEnum(prefetch.rw), .False),
93729372 llvm_u32.constInt(prefetch.locality, .False),
9373 llvm_u32.constInt(@enumToInt(prefetch.cache), .False),
9373 llvm_u32.constInt(@intFromEnum(prefetch.cache), .False),
93749374 };
93759375 _ = self.builder.buildCall(fn_val.globalGetValueType(), fn_val, &params, params.len, .C, .Auto, "");
93769376 return null;
......@@ -9596,7 +9596,7 @@ pub const FuncGen = struct {
95969596 // the index to the element at index `1` to get a pointer to the end of
95979597 // the struct.
95989598 const llvm_u32 = self.context.intType(32);
9599 const llvm_index = llvm_u32.constInt(@boolToInt(struct_ty.hasRuntimeBitsIgnoreComptime(mod)), .False);
9599 const llvm_index = llvm_u32.constInt(@intFromBool(struct_ty.hasRuntimeBitsIgnoreComptime(mod)), .False);
96009600 const indices: [1]*llvm.Value = .{llvm_index};
96019601 return self.builder.buildInBoundsGEP(struct_llvm_ty, struct_ptr, &indices, indices.len, "");
96029602 }
......@@ -9605,7 +9605,7 @@ pub const FuncGen = struct {
96059605 .Union => {
96069606 const layout = struct_ty.unionGetLayout(mod);
96079607 if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .Packed) return struct_ptr;
9608 const payload_index = @boolToInt(layout.tag_align >= layout.payload_align);
9608 const payload_index = @intFromBool(layout.tag_align >= layout.payload_align);
96099609 const union_llvm_ty = try self.dg.lowerType(struct_ty);
96109610 const union_field_ptr = self.builder.buildStructGEP(union_llvm_ty, struct_ptr, payload_index, "");
96119611 return union_field_ptr;
......@@ -9658,7 +9658,7 @@ pub const FuncGen = struct {
96589658
96599659 assert(info.vector_index != .runtime);
96609660 if (info.vector_index != .none) {
9661 const index_u32 = self.context.intType(32).constInt(@enumToInt(info.vector_index), .False);
9661 const index_u32 = self.context.intType(32).constInt(@intFromEnum(info.vector_index), .False);
96629662 const vec_elem_ty = try self.dg.lowerType(info.pointee_type);
96639663 const vec_ty = vec_elem_ty.vectorType(info.host_size);
96649664
......@@ -9734,7 +9734,7 @@ pub const FuncGen = struct {
97349734
97359735 assert(info.vector_index != .runtime);
97369736 if (info.vector_index != .none) {
9737 const index_u32 = self.context.intType(32).constInt(@enumToInt(info.vector_index), .False);
9737 const index_u32 = self.context.intType(32).constInt(@intFromEnum(info.vector_index), .False);
97389738 const vec_elem_ty = try self.dg.lowerType(elem_ty);
97399739 const vec_ty = vec_elem_ty.vectorType(info.host_size);
97409740
......@@ -11025,29 +11025,29 @@ const AnnotatedDITypePtr = enum(usize) {
1102511025 _,
1102611026
1102711027 fn initFwd(di_type: *llvm.DIType) AnnotatedDITypePtr {
11028 const addr = @ptrToInt(di_type);
11028 const addr = @intFromPtr(di_type);
1102911029 assert(@truncate(u1, addr) == 0);
11030 return @intToEnum(AnnotatedDITypePtr, addr | 1);
11030 return @enumFromInt(AnnotatedDITypePtr, addr | 1);
1103111031 }
1103211032
1103311033 fn initFull(di_type: *llvm.DIType) AnnotatedDITypePtr {
11034 const addr = @ptrToInt(di_type);
11035 return @intToEnum(AnnotatedDITypePtr, addr);
11034 const addr = @intFromPtr(di_type);
11035 return @enumFromInt(AnnotatedDITypePtr, addr);
1103611036 }
1103711037
1103811038 fn init(di_type: *llvm.DIType, resolve: Object.DebugResolveStatus) AnnotatedDITypePtr {
11039 const addr = @ptrToInt(di_type);
11040 const bit = @boolToInt(resolve == .fwd);
11041 return @intToEnum(AnnotatedDITypePtr, addr | bit);
11039 const addr = @intFromPtr(di_type);
11040 const bit = @intFromBool(resolve == .fwd);
11041 return @enumFromInt(AnnotatedDITypePtr, addr | bit);
1104211042 }
1104311043
1104411044 fn toDIType(self: AnnotatedDITypePtr) *llvm.DIType {
11045 const fixed_addr = @enumToInt(self) & ~@as(usize, 1);
11046 return @intToPtr(*llvm.DIType, fixed_addr);
11045 const fixed_addr = @intFromEnum(self) & ~@as(usize, 1);
11046 return @ptrFromInt(*llvm.DIType, fixed_addr);
1104711047 }
1104811048
1104911049 fn isFwdOnly(self: AnnotatedDITypePtr) bool {
11050 return @truncate(u1, @enumToInt(self)) != 0;
11050 return @truncate(u1, @intFromEnum(self)) != 0;
1105111051 }
1105211052};
1105311053
......@@ -11118,11 +11118,11 @@ fn buildAllocaInner(
1111811118}
1111911119
1112011120fn errUnionPayloadOffset(payload_ty: Type, mod: *Module) u1 {
11121 return @boolToInt(Type.anyerror.abiAlignment(mod) > payload_ty.abiAlignment(mod));
11121 return @intFromBool(Type.anyerror.abiAlignment(mod) > payload_ty.abiAlignment(mod));
1112211122}
1112311123
1112411124fn errUnionErrorOffset(payload_ty: Type, mod: *Module) u1 {
11125 return @boolToInt(Type.anyerror.abiAlignment(mod) <= payload_ty.abiAlignment(mod));
11125 return @intFromBool(Type.anyerror.abiAlignment(mod) <= payload_ty.abiAlignment(mod));
1112611126}
1112711127
1112811128/// Returns true for asm constraint (e.g. "=*m", "=r") if it accepts a memory location
src/codegen/llvm/bindings.zig+1-1
......@@ -8,7 +8,7 @@ pub const Bool = enum(c_int) {
88 _,
99
1010 pub fn fromBool(b: bool) Bool {
11 return @intToEnum(Bool, @boolToInt(b));
11 return @enumFromInt(Bool, @intFromBool(b));
1212 }
1313
1414 pub fn toBool(b: Bool) bool {
src/codegen/spirv.zig+16-16
......@@ -387,7 +387,7 @@ pub const DeclGen = struct {
387387 switch (repr) {
388388 .indirect => {
389389 const int_ty_ref = try self.intType(.unsigned, 1);
390 return self.spv.constInt(int_ty_ref, @boolToInt(value));
390 return self.spv.constInt(int_ty_ref, @intFromBool(value));
391391 },
392392 .direct => {
393393 const bool_ty_ref = try self.resolveType(Type.bool, .direct);
......@@ -532,7 +532,7 @@ pub const DeclGen = struct {
532532 }
533533
534534 fn addConstBool(self: *@This(), value: bool) !void {
535 try self.addByte(@boolToInt(value)); // TODO: Keep in sync with something?
535 try self.addByte(@intFromBool(value)); // TODO: Keep in sync with something?
536536 }
537537
538538 fn addInt(self: *@This(), ty: Type, val: Value) !void {
......@@ -697,7 +697,7 @@ pub const DeclGen = struct {
697697 try self.addUndef(padding);
698698 },
699699 .enum_tag => {
700 const int_val = try val.enumToInt(ty, mod);
700 const int_val = try val.intFromEnum(ty, mod);
701701
702702 const int_ty = ty.intTagType(mod);
703703
......@@ -873,7 +873,7 @@ pub const DeclGen = struct {
873873 assert(storage_class != .Generic and storage_class != .Function);
874874
875875 const var_id = self.spv.allocId();
876 log.debug("lowerIndirectConstant: id = {}, index = {}, ty = {}, val = {}", .{ var_id.id, @enumToInt(spv_decl_index), ty.fmt(self.module), val.fmtDebug() });
876 log.debug("lowerIndirectConstant: id = {}, index = {}, ty = {}, val = {}", .{ var_id.id, @intFromEnum(spv_decl_index), ty.fmt(self.module), val.fmtDebug() });
877877
878878 const section = &self.spv.globals.section;
879879
......@@ -1010,7 +1010,7 @@ pub const DeclGen = struct {
10101010 false,
10111011 alignment,
10121012 );
1013 log.debug("indirect constant: index = {}", .{@enumToInt(spv_decl_index)});
1013 log.debug("indirect constant: index = {}", .{@intFromEnum(spv_decl_index)});
10141014 try self.func.decl_deps.put(self.spv.gpa, spv_decl_index, {});
10151015
10161016 try self.func.body.emit(self.spv.gpa, .OpLoad, .{
......@@ -1578,7 +1578,7 @@ pub const DeclGen = struct {
15781578 }
15791579 }
15801580
1581 fn boolToInt(self: *DeclGen, result_ty_ref: CacheRef, condition_id: IdRef) !IdRef {
1581 fn intFromBool(self: *DeclGen, result_ty_ref: CacheRef, condition_id: IdRef) !IdRef {
15821582 const zero_id = try self.spv.constInt(result_ty_ref, 0);
15831583 const one_id = try self.spv.constInt(result_ty_ref, 1);
15841584 const result_id = self.spv.allocId();
......@@ -1621,7 +1621,7 @@ pub const DeclGen = struct {
16211621 return switch (ty.zigTypeTag(mod)) {
16221622 .Bool => blk: {
16231623 const indirect_bool_ty_ref = try self.resolveType(ty, .indirect);
1624 break :blk self.boolToInt(indirect_bool_ty_ref, operand_id);
1624 break :blk self.intFromBool(indirect_bool_ty_ref, operand_id);
16251625 },
16261626 else => operand_id,
16271627 };
......@@ -1721,9 +1721,9 @@ pub const DeclGen = struct {
17211721
17221722 .bitcast => try self.airBitCast(inst),
17231723 .intcast, .trunc => try self.airIntCast(inst),
1724 .ptrtoint => try self.airPtrToInt(inst),
1725 .int_to_float => try self.airIntToFloat(inst),
1726 .float_to_int => try self.airFloatToInt(inst),
1724 .int_from_ptr => try self.airIntFromPtr(inst),
1725 .float_from_int => try self.airFloatFromInt(inst),
1726 .int_from_float => try self.airIntFromFloat(inst),
17271727 .not => try self.airNot(inst),
17281728
17291729 .slice_ptr => try self.airSliceField(inst, 0),
......@@ -2011,7 +2011,7 @@ pub const DeclGen = struct {
20112011
20122012 // Construct the struct that Zig wants as result.
20132013 // The value should already be the correct type.
2014 const ov_id = try self.boolToInt(ov_ty_ref, overflowed_id);
2014 const ov_id = try self.intFromBool(ov_ty_ref, overflowed_id);
20152015 const result_ty_ref = try self.resolveType(result_ty, .direct);
20162016 return try self.constructStruct(result_ty_ref, &.{
20172017 value_id,
......@@ -2329,7 +2329,7 @@ pub const DeclGen = struct {
23292329 return result_id;
23302330 }
23312331
2332 fn airPtrToInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2332 fn airIntFromPtr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
23332333 if (self.liveness.isUnused(inst)) return null;
23342334
23352335 const un_op = self.air.instructions.items(.data)[inst].un_op;
......@@ -2345,7 +2345,7 @@ pub const DeclGen = struct {
23452345 return result_id;
23462346 }
23472347
2348 fn airIntToFloat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2348 fn airFloatFromInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
23492349 if (self.liveness.isUnused(inst)) return null;
23502350
23512351 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -2371,7 +2371,7 @@ pub const DeclGen = struct {
23712371 return result_id;
23722372 }
23732373
2374 fn airFloatToInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2374 fn airIntFromFloat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
23752375 if (self.liveness.isUnused(inst)) return null;
23762376
23772377 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
......@@ -2515,7 +2515,7 @@ pub const DeclGen = struct {
25152515 if (layout.payload_size == 0) return union_handle;
25162516
25172517 const tag_ty = un_ty.unionTagTypeSafety().?;
2518 const tag_index = @boolToInt(layout.tag_align < layout.payload_align);
2518 const tag_index = @intFromBool(layout.tag_align < layout.payload_align);
25192519 return try self.extractField(tag_ty, union_handle, tag_index);
25202520 }
25212521
......@@ -3105,7 +3105,7 @@ pub const DeclGen = struct {
31053105 .Int => if (cond_ty.isSignedInt(mod)) @bitCast(u64, value.toSignedInt(mod)) else value.toUnsignedInt(mod),
31063106 .Enum => blk: {
31073107 // TODO: figure out of cond_ty is correct (something with enum literals)
3108 break :blk (try value.enumToInt(cond_ty, mod)).toUnsignedInt(mod); // TODO: composite integer constants
3108 break :blk (try value.intFromEnum(cond_ty, mod)).toUnsignedInt(mod); // TODO: composite integer constants
31093109 },
31103110 else => unreachable,
31113111 };
src/codegen/spirv/Assembler.zig+4-4
......@@ -306,7 +306,7 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
306306 },
307307 .OpTypePointer => try self.spv.ptrType(
308308 try self.resolveTypeRef(operands[2].ref_id),
309 @intToEnum(spec.StorageClass, operands[1].value),
309 @enumFromInt(spec.StorageClass, operands[1].value),
310310 ),
311311 .OpTypeFunction => blk: {
312312 const param_operands = operands[2..];
......@@ -340,7 +340,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
340340 else => switch (self.inst.opcode) {
341341 .OpEntryPoint => unreachable,
342342 .OpExecutionMode, .OpExecutionModeId => &self.spv.sections.execution_modes,
343 .OpVariable => switch (@intToEnum(spec.StorageClass, operands[2].value)) {
343 .OpVariable => switch (@enumFromInt(spec.StorageClass, operands[2].value)) {
344344 .Function => &self.func.prologue,
345345 else => {
346346 // This is currently disabled because global variables are required to be
......@@ -391,7 +391,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue {
391391 }
392392
393393 const actual_word_count = section.instructions.items.len - first_word;
394 section.instructions.items[first_word] |= @as(u32, @intCast(u16, actual_word_count)) << 16 | @enumToInt(self.inst.opcode);
394 section.instructions.items[first_word] |= @as(u32, @intCast(u16, actual_word_count)) << 16 | @intFromEnum(self.inst.opcode);
395395
396396 if (maybe_result_id) |result| {
397397 return AsmValue{ .value = result };
......@@ -695,7 +695,7 @@ fn parseContextDependentInt(self: *Assembler, signedness: std.builtin.Signedness
695695 .unsigned => 0,
696696 .signed => -(@as(i128, 1) << (@intCast(u7, width) - 1)),
697697 };
698 const max = (@as(i128, 1) << (@intCast(u7, width) - @boolToInt(signedness == .signed))) - 1;
698 const max = (@as(i128, 1) << (@intCast(u7, width) - @intFromBool(signedness == .signed))) - 1;
699699 if (int < min or int > max) {
700700 break :invalid;
701701 }
src/codegen/spirv/Cache.zig+30-30
......@@ -411,7 +411,7 @@ pub const Key = union(enum) {
411411
412412 pub fn eql(ctx: @This(), a: Key, b_void: void, b_index: usize) bool {
413413 _ = b_void;
414 return ctx.self.lookup(@intToEnum(Ref, b_index)).eql(a);
414 return ctx.self.lookup(@enumFromInt(Ref, b_index)).eql(a);
415415 }
416416
417417 pub fn hash(ctx: @This(), a: Key) u32 {
......@@ -445,7 +445,7 @@ pub fn materialize(self: *const Self, spv: *Module) !Section {
445445 var section = Section{};
446446 errdefer section.deinit(spv.gpa);
447447 for (self.items.items(.result_id), 0..) |result_id, index| {
448 try self.emit(spv, result_id, @intToEnum(Ref, index), &section);
448 try self.emit(spv, result_id, @enumFromInt(Ref, index), &section);
449449 }
450450 return section;
451451}
......@@ -603,14 +603,14 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
603603 const adapter: Key.Adapter = .{ .self = self };
604604 const entry = try self.map.getOrPutAdapted(spv.gpa, key, adapter);
605605 if (entry.found_existing) {
606 return @intToEnum(Ref, entry.index);
606 return @enumFromInt(Ref, entry.index);
607607 }
608608 const result_id = spv.allocId();
609609 const item: Item = switch (key) {
610610 inline .void_type, .bool_type => .{
611611 .tag = .type_simple,
612612 .result_id = result_id,
613 .data = @enumToInt(key.toSimpleType()),
613 .data = @intFromEnum(key.toSimpleType()),
614614 },
615615 .int_type => |int| blk: {
616616 const t: Tag = switch (int.signedness) {
......@@ -654,17 +654,17 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
654654 .Generic => Item{
655655 .tag = .type_ptr_generic,
656656 .result_id = result_id,
657 .data = @enumToInt(ptr.child_type),
657 .data = @intFromEnum(ptr.child_type),
658658 },
659659 .CrossWorkgroup => Item{
660660 .tag = .type_ptr_crosswgp,
661661 .result_id = result_id,
662 .data = @enumToInt(ptr.child_type),
662 .data = @intFromEnum(ptr.child_type),
663663 },
664664 .Function => Item{
665665 .tag = .type_ptr_function,
666666 .result_id = result_id,
667 .data = @enumToInt(ptr.child_type),
667 .data = @intFromEnum(ptr.child_type),
668668 },
669669 else => |storage_class| Item{
670670 .tag = .type_ptr_simple,
......@@ -770,12 +770,12 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
770770 .undef => |undef| .{
771771 .tag = .undef,
772772 .result_id = result_id,
773 .data = @enumToInt(undef.ty),
773 .data = @intFromEnum(undef.ty),
774774 },
775775 .null => |null_info| .{
776776 .tag = .null,
777777 .result_id = result_id,
778 .data = @enumToInt(null_info.ty),
778 .data = @intFromEnum(null_info.ty),
779779 },
780780 .bool => |bool_info| .{
781781 .tag = switch (bool_info.value) {
......@@ -783,21 +783,21 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
783783 false => Tag.bool_false,
784784 },
785785 .result_id = result_id,
786 .data = @enumToInt(bool_info.ty),
786 .data = @intFromEnum(bool_info.ty),
787787 },
788788 };
789789 try self.items.append(spv.gpa, item);
790790
791 return @intToEnum(Ref, entry.index);
791 return @enumFromInt(Ref, entry.index);
792792}
793793
794794/// Turn a Ref back into a Key.
795795/// The Key is valid until the next call to resolve().
796796pub fn lookup(self: *const Self, ref: Ref) Key {
797 const item = self.items.get(@enumToInt(ref));
797 const item = self.items.get(@intFromEnum(ref));
798798 const data = item.data;
799799 return switch (item.tag) {
800 .type_simple => switch (@intToEnum(Tag.SimpleType, data)) {
800 .type_simple => switch (@enumFromInt(Tag.SimpleType, data)) {
801801 .void => .void_type,
802802 .bool => .bool_type,
803803 },
......@@ -826,19 +826,19 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
826826 .type_ptr_generic => .{
827827 .ptr_type = .{
828828 .storage_class = .Generic,
829 .child_type = @intToEnum(Ref, data),
829 .child_type = @enumFromInt(Ref, data),
830830 },
831831 },
832832 .type_ptr_crosswgp => .{
833833 .ptr_type = .{
834834 .storage_class = .CrossWorkgroup,
835 .child_type = @intToEnum(Ref, data),
835 .child_type = @enumFromInt(Ref, data),
836836 },
837837 },
838838 .type_ptr_function => .{
839839 .ptr_type = .{
840840 .storage_class = .Function,
841 .child_type = @intToEnum(Ref, data),
841 .child_type = @enumFromInt(Ref, data),
842842 },
843843 },
844844 .type_ptr_simple => {
......@@ -923,17 +923,17 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
923923 } };
924924 },
925925 .undef => .{ .undef = .{
926 .ty = @intToEnum(Ref, data),
926 .ty = @enumFromInt(Ref, data),
927927 } },
928928 .null => .{ .null = .{
929 .ty = @intToEnum(Ref, data),
929 .ty = @enumFromInt(Ref, data),
930930 } },
931931 .bool_true => .{ .bool = .{
932 .ty = @intToEnum(Ref, data),
932 .ty = @enumFromInt(Ref, data),
933933 .value = true,
934934 } },
935935 .bool_false => .{ .bool = .{
936 .ty = @intToEnum(Ref, data),
936 .ty = @enumFromInt(Ref, data),
937937 .value = false,
938938 } },
939939 };
......@@ -942,14 +942,14 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
942942/// Look op the result-id that corresponds to a particular
943943/// ref.
944944pub fn resultId(self: Self, ref: Ref) IdResult {
945 return self.items.items(.result_id)[@enumToInt(ref)];
945 return self.items.items(.result_id)[@intFromEnum(ref)];
946946}
947947
948948/// Get the ref for a key that has already been added to the cache.
949949fn get(self: *const Self, key: Key) Ref {
950950 const adapter: Key.Adapter = .{ .self = self };
951951 const index = self.map.getIndexAdapted(key, adapter).?;
952 return @intToEnum(Ref, index);
952 return @enumFromInt(Ref, index);
953953}
954954
955955fn addExtra(self: *Self, spv: *Module, extra: anytype) !u32 {
......@@ -965,9 +965,9 @@ fn addExtraAssumeCapacity(self: *Self, extra: anytype) !u32 {
965965 const word = switch (field.type) {
966966 u32 => field_val,
967967 i32 => @bitCast(u32, field_val),
968 Ref => @enumToInt(field_val),
969 StorageClass => @enumToInt(field_val),
970 String => @enumToInt(field_val),
968 Ref => @intFromEnum(field_val),
969 StorageClass => @intFromEnum(field_val),
970 String => @intFromEnum(field_val),
971971 else => @compileError("Invalid type: " ++ @typeName(field.type)),
972972 };
973973 self.extra.appendAssumeCapacity(word);
......@@ -987,9 +987,9 @@ fn extraDataTrail(self: Self, comptime T: type, offset: u32) struct { data: T, t
987987 @field(result, field.name) = switch (field.type) {
988988 u32 => word,
989989 i32 => @bitCast(i32, word),
990 Ref => @intToEnum(Ref, word),
991 StorageClass => @intToEnum(StorageClass, word),
992 String => @intToEnum(String, word),
990 Ref => @enumFromInt(Ref, word),
991 StorageClass => @enumFromInt(StorageClass, word),
992 String => @enumFromInt(String, word),
993993 else => @compileError("Invalid type: " ++ @typeName(field.type)),
994994 };
995995 }
......@@ -1035,12 +1035,12 @@ pub fn addString(self: *Self, spv: *Module, str: []const u8) !String {
10351035 entry.value_ptr.* = @intCast(u32, offset);
10361036 }
10371037
1038 return @intToEnum(String, entry.index);
1038 return @enumFromInt(String, entry.index);
10391039}
10401040
10411041pub fn getString(self: *const Self, ref: String) ?[]const u8 {
10421042 return switch (ref) {
10431043 .none => null,
1044 else => std.mem.sliceTo(self.string_bytes.items[self.strings.values()[@enumToInt(ref)]..], 0),
1044 else => std.mem.sliceTo(self.string_bytes.items[self.strings.values()[@intFromEnum(ref)]..], 0),
10451045 };
10461046}
src/codegen/spirv/Module.zig+7-7
......@@ -246,10 +246,10 @@ fn orderGlobalsInto(
246246 const global = self.globalPtr(decl_index).?;
247247 const insts = self.globals.section.instructions.items[global.begin_inst..global.end_inst];
248248
249 seen.set(@enumToInt(decl_index));
249 seen.set(@intFromEnum(decl_index));
250250
251251 for (deps) |dep| {
252 if (!seen.isSet(@enumToInt(dep))) {
252 if (!seen.isSet(@intFromEnum(dep))) {
253253 try self.orderGlobalsInto(dep, section, seen);
254254 }
255255 }
......@@ -267,7 +267,7 @@ fn orderGlobals(self: *Module) !Section {
267267 errdefer ordered_globals.deinit(self.gpa);
268268
269269 for (globals) |decl_index| {
270 if (!seen.isSet(@enumToInt(decl_index))) {
270 if (!seen.isSet(@intFromEnum(decl_index))) {
271271 try self.orderGlobalsInto(decl_index, &ordered_globals, &seen);
272272 }
273273 }
......@@ -284,14 +284,14 @@ fn addEntryPointDeps(
284284 const decl = self.declPtr(decl_index);
285285 const deps = self.decl_deps.items[decl.begin_dep..decl.end_dep];
286286
287 seen.set(@enumToInt(decl_index));
287 seen.set(@intFromEnum(decl_index));
288288
289289 if (self.globalPtr(decl_index)) |global| {
290290 try interface.append(global.result_id);
291291 }
292292
293293 for (deps) |dep| {
294 if (!seen.isSet(@enumToInt(dep))) {
294 if (!seen.isSet(@intFromEnum(dep))) {
295295 try self.addEntryPointDeps(dep, seen, interface);
296296 }
297297 }
......@@ -516,7 +516,7 @@ pub fn allocDecl(self: *Module, kind: DeclKind) !Decl.Index {
516516 .begin_dep = undefined,
517517 .end_dep = undefined,
518518 });
519 const index = @intToEnum(Decl.Index, @intCast(u32, self.decls.items.len - 1));
519 const index = @enumFromInt(Decl.Index, @intCast(u32, self.decls.items.len - 1));
520520 switch (kind) {
521521 .func => {},
522522 // If the decl represents a global, also allocate a global node.
......@@ -531,7 +531,7 @@ pub fn allocDecl(self: *Module, kind: DeclKind) !Decl.Index {
531531}
532532
533533pub fn declPtr(self: *Module, index: Decl.Index) *Decl {
534 return &self.decls.items[@enumToInt(index)];
534 return &self.decls.items[@intFromEnum(index)];
535535}
536536
537537pub fn globalPtr(self: *Module, index: Decl.Index) ?*Global {
src/codegen/spirv/Section.zig+12-12
......@@ -50,7 +50,7 @@ pub fn emitRaw(
5050) !void {
5151 const word_count = 1 + operand_words;
5252 try section.instructions.ensureUnusedCapacity(allocator, word_count);
53 section.writeWord((@intCast(Word, word_count << 16)) | @enumToInt(opcode));
53 section.writeWord((@intCast(Word, word_count << 16)) | @intFromEnum(opcode));
5454}
5555
5656pub fn emit(
......@@ -61,7 +61,7 @@ pub fn emit(
6161) !void {
6262 const word_count = instructionSize(opcode, operands);
6363 try section.instructions.ensureUnusedCapacity(allocator, word_count);
64 section.writeWord(@intCast(Word, word_count << 16) | @enumToInt(opcode));
64 section.writeWord(@intCast(Word, word_count << 16) | @intFromEnum(opcode));
6565 section.writeOperands(opcode.Operands(), operands);
6666}
6767
......@@ -126,14 +126,14 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
126126 // TODO: Where this type is used (OpSpecConstantOp) is currently not correct in the spec json,
127127 // so it most likely needs to be altered into something that can actually describe the entire
128128 // instruction in which it is used.
129 spec.LiteralSpecConstantOpInteger => section.writeWord(@enumToInt(operand.opcode)),
129 spec.LiteralSpecConstantOpInteger => section.writeWord(@intFromEnum(operand.opcode)),
130130
131131 spec.PairLiteralIntegerIdRef => section.writeWords(&.{ operand.value, operand.label.id }),
132132 spec.PairIdRefLiteralInteger => section.writeWords(&.{ operand.target.id, operand.member }),
133133 spec.PairIdRefIdRef => section.writeWords(&.{ operand[0].id, operand[1].id }),
134134
135135 else => switch (@typeInfo(Operand)) {
136 .Enum => section.writeWord(@enumToInt(operand)),
136 .Enum => section.writeWord(@intFromEnum(operand)),
137137 .Optional => |info| if (operand) |child| {
138138 section.writeOperand(info.child, child);
139139 },
......@@ -217,7 +217,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand
217217
218218fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operand) void {
219219 const tag = std.meta.activeTag(operand);
220 section.writeWord(@enumToInt(tag));
220 section.writeWord(@intFromEnum(tag));
221221
222222 inline for (@typeInfo(Operand).Union.fields) |field| {
223223 if (@field(Operand, field.name) == tag) {
......@@ -327,7 +327,7 @@ test "SPIR-V Section emit() - no operands" {
327327
328328 try section.emit(std.testing.allocator, .OpNop, {});
329329
330 try testing.expect(section.instructions.items[0] == (@as(Word, 1) << 16) | @enumToInt(Opcode.OpNop));
330 try testing.expect(section.instructions.items[0] == (@as(Word, 1) << 16) | @intFromEnum(Opcode.OpNop));
331331}
332332
333333test "SPIR-V Section emit() - simple" {
......@@ -340,7 +340,7 @@ test "SPIR-V Section emit() - simple" {
340340 });
341341
342342 try testing.expectEqualSlices(Word, &.{
343 (@as(Word, 3) << 16) | @enumToInt(Opcode.OpUndef),
343 (@as(Word, 3) << 16) | @intFromEnum(Opcode.OpUndef),
344344 0,
345345 1,
346346 }, section.instructions.items);
......@@ -358,8 +358,8 @@ test "SPIR-V Section emit() - string" {
358358 });
359359
360360 try testing.expectEqualSlices(Word, &.{
361 (@as(Word, 10) << 16) | @enumToInt(Opcode.OpSource),
362 @enumToInt(spec.SourceLanguage.Unknown),
361 (@as(Word, 10) << 16) | @intFromEnum(Opcode.OpSource),
362 @intFromEnum(spec.SourceLanguage.Unknown),
363363 123,
364364 456,
365365 std.mem.bytesToValue(Word, "pub "),
......@@ -389,7 +389,7 @@ test "SPIR-V Section emit() - extended mask" {
389389 });
390390
391391 try testing.expectEqualSlices(Word, &.{
392 (@as(Word, 5) << 16) | @enumToInt(Opcode.OpLoopMerge),
392 (@as(Word, 5) << 16) | @intFromEnum(Opcode.OpLoopMerge),
393393 10,
394394 20,
395395 @bitCast(Word, spec.LoopControl{ .Unroll = true, .DependencyLength = true }),
......@@ -409,9 +409,9 @@ test "SPIR-V Section emit() - extended union" {
409409 });
410410
411411 try testing.expectEqualSlices(Word, &.{
412 (@as(Word, 6) << 16) | @enumToInt(Opcode.OpExecutionMode),
412 (@as(Word, 6) << 16) | @intFromEnum(Opcode.OpExecutionMode),
413413 888,
414 @enumToInt(spec.ExecutionMode.LocalSize),
414 @intFromEnum(spec.ExecutionMode.LocalSize),
415415 4,
416416 8,
417417 16,
src/crash_report.zig+6-6
......@@ -186,11 +186,11 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
186186 PanicSwitch.preDispatch();
187187
188188 const addr = switch (builtin.os.tag) {
189 .linux => @ptrToInt(info.fields.sigfault.addr),
190 .freebsd, .macos => @ptrToInt(info.addr),
191 .netbsd => @ptrToInt(info.info.reason.fault.addr),
192 .openbsd => @ptrToInt(info.data.fault.addr),
193 .solaris => @ptrToInt(info.reason.fault.addr),
189 .linux => @intFromPtr(info.fields.sigfault.addr),
190 .freebsd, .macos => @intFromPtr(info.addr),
191 .netbsd => @intFromPtr(info.info.reason.fault.addr),
192 .openbsd => @intFromPtr(info.data.fault.addr),
193 .solaris => @intFromPtr(info.reason.fault.addr),
194194 else => @compileError("TODO implement handleSegfaultPosix for new POSIX OS"),
195195 };
196196
......@@ -279,7 +279,7 @@ fn handleSegfaultWindowsExtra(info: *os.windows.EXCEPTION_POINTERS, comptime msg
279279 const regs = info.ContextRecord.getRegs();
280280 break :ctx StackContext{ .exception = .{ .bp = regs.bp, .ip = regs.ip } };
281281 } else ctx: {
282 const addr = @ptrToInt(info.ExceptionRecord.ExceptionAddress);
282 const addr = @intFromPtr(info.ExceptionRecord.ExceptionAddress);
283283 break :ctx StackContext{ .current = .{ .ret_addr = addr } };
284284 };
285285
src/libcxx.zig+4-4
......@@ -128,10 +128,10 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
128128 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
129129 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
130130 const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
131 @enumToInt(comp.libcxx_abi_version),
131 @intFromEnum(comp.libcxx_abi_version),
132132 });
133133 const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
134 @enumToInt(comp.libcxx_abi_version),
134 @intFromEnum(comp.libcxx_abi_version),
135135 });
136136 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);
137137
......@@ -302,10 +302,10 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
302302 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
303303 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
304304 const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
305 @enumToInt(comp.libcxx_abi_version),
305 @intFromEnum(comp.libcxx_abi_version),
306306 });
307307 const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
308 @enumToInt(comp.libcxx_abi_version),
308 @intFromEnum(comp.libcxx_abi_version),
309309 });
310310 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);
311311
src/link/Coff.zig+17-17
......@@ -538,7 +538,7 @@ fn allocateAtom(self: *Coff, atom_index: Atom.Index, new_atom_size: u32, alignme
538538 defer tracy.end();
539539
540540 const atom = self.getAtom(atom_index);
541 const sect_id = @enumToInt(atom.getSymbol(self).section_number) - 1;
541 const sect_id = @intFromEnum(atom.getSymbol(self).section_number) - 1;
542542 const header = &self.sections.items(.header)[sect_id];
543543 const free_list = &self.sections.items(.free_list)[sect_id];
544544 const maybe_last_atom_index = &self.sections.items(.last_atom_index)[sect_id];
......@@ -739,7 +739,7 @@ fn shrinkAtom(self: *Coff, atom_index: Atom.Index, new_block_size: u32) void {
739739fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void {
740740 const atom = self.getAtom(atom_index);
741741 const sym = atom.getSymbol(self);
742 const section = self.sections.get(@enumToInt(sym.section_number) - 1);
742 const section = self.sections.get(@intFromEnum(sym.section_number) - 1);
743743 const file_offset = section.header.pointer_to_raw_data + sym.value - section.header.virtual_address;
744744
745745 log.debug("writing atom for symbol {s} at file offset 0x{x} to 0x{x}", .{
......@@ -769,14 +769,14 @@ fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void {
769769
770770 if (is_hot_update_compatible) {
771771 if (self.base.child_pid) |handle| {
772 const slide = @ptrToInt(self.hot_state.loaded_base_address.?);
772 const slide = @intFromPtr(self.hot_state.loaded_base_address.?);
773773
774774 const mem_code = try gpa.dupe(u8, code);
775775 defer gpa.free(mem_code);
776776 self.resolveRelocs(atom_index, relocs.items, mem_code, slide);
777777
778778 const vaddr = sym.value + slide;
779 const pvaddr = @intToPtr(*anyopaque, vaddr);
779 const pvaddr = @ptrFromInt(*anyopaque, vaddr);
780780
781781 log.debug("writing to memory at address {x}", .{vaddr});
782782
......@@ -860,9 +860,9 @@ fn writeOffsetTableEntry(self: *Coff, index: usize) !void {
860860 if (is_hot_update_compatible) {
861861 if (self.base.child_pid) |handle| {
862862 const gpa = self.base.allocator;
863 const slide = @ptrToInt(self.hot_state.loaded_base_address.?);
863 const slide = @intFromPtr(self.hot_state.loaded_base_address.?);
864864 const actual_vmaddr = vmaddr + slide;
865 const pvaddr = @intToPtr(*anyopaque, actual_vmaddr);
865 const pvaddr = @ptrFromInt(*anyopaque, actual_vmaddr);
866866 log.debug("writing GOT entry to memory at address {x}", .{actual_vmaddr});
867867 if (build_options.enable_logging) {
868868 switch (self.ptr_width) {
......@@ -970,7 +970,7 @@ fn freeAtom(self: *Coff, atom_index: Atom.Index) void {
970970
971971 const atom = self.getAtom(atom_index);
972972 const sym = atom.getSymbol(self);
973 const sect_id = @enumToInt(sym.section_number) - 1;
973 const sect_id = @intFromEnum(sym.section_number) - 1;
974974 const free_list = &self.sections.items(.free_list)[sect_id];
975975 var already_have_free_list_node = false;
976976 {
......@@ -1107,7 +1107,7 @@ pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.In
11071107 const atom = self.getAtom(atom_index);
11081108 const sym = atom.getSymbolPtr(self);
11091109 try self.setSymbolName(sym, sym_name);
1110 sym.section_number = @intToEnum(coff.SectionNumber, self.rdata_section_index.? + 1);
1110 sym.section_number = @enumFromInt(coff.SectionNumber, self.rdata_section_index.? + 1);
11111111 }
11121112
11131113 const res = try codegen.generateSymbol(&self.base, decl.srcLoc(mod), tv, &code_buffer, .none, .{
......@@ -1244,7 +1244,7 @@ fn updateLazySymbolAtom(
12441244 const code_len = @intCast(u32, code.len);
12451245 const symbol = atom.getSymbolPtr(self);
12461246 try self.setSymbolName(symbol, name);
1247 symbol.section_number = @intToEnum(coff.SectionNumber, section_index + 1);
1247 symbol.section_number = @enumFromInt(coff.SectionNumber, section_index + 1);
12481248 symbol.type = .{ .complex_type = .NULL, .base_type = .NULL };
12491249
12501250 const vaddr = try self.allocateAtom(atom_index, code_len, required_alignment);
......@@ -1341,7 +1341,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple
13411341 if (atom.size != 0) {
13421342 const sym = atom.getSymbolPtr(self);
13431343 try self.setSymbolName(sym, decl_name);
1344 sym.section_number = @intToEnum(coff.SectionNumber, sect_index + 1);
1344 sym.section_number = @enumFromInt(coff.SectionNumber, sect_index + 1);
13451345 sym.type = .{ .complex_type = complex_type, .base_type = .NULL };
13461346
13471347 const capacity = atom.capacity(self);
......@@ -1365,7 +1365,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple
13651365 } else {
13661366 const sym = atom.getSymbolPtr(self);
13671367 try self.setSymbolName(sym, decl_name);
1368 sym.section_number = @intToEnum(coff.SectionNumber, sect_index + 1);
1368 sym.section_number = @enumFromInt(coff.SectionNumber, sect_index + 1);
13691369 sym.type = .{ .complex_type = complex_type, .base_type = .NULL };
13701370
13711371 const vaddr = try self.allocateAtom(atom_index, code_len, required_alignment);
......@@ -1502,7 +1502,7 @@ pub fn updateDeclExports(
15021502 const sym = self.getSymbolPtr(sym_loc);
15031503 try self.setSymbolName(sym, mod.intern_pool.stringToSlice(exp.opts.name));
15041504 sym.value = decl_sym.value;
1505 sym.section_number = @intToEnum(coff.SectionNumber, self.text_section_index.? + 1);
1505 sym.section_number = @enumFromInt(coff.SectionNumber, self.text_section_index.? + 1);
15061506 sym.type = .{ .complex_type = .FUNCTION, .base_type = .NULL };
15071507
15081508 switch (exp.opts.linkage) {
......@@ -1668,7 +1668,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
16681668
16691669 const atom = self.getAtom(atom_index);
16701670 const sym = atom.getSymbol(self);
1671 const section = self.sections.get(@enumToInt(sym.section_number) - 1).header;
1671 const section = self.sections.get(@intFromEnum(sym.section_number) - 1).header;
16721672 const file_offset = section.pointer_to_raw_data + sym.value - section.virtual_address;
16731673
16741674 var code = std.ArrayList(u8).init(gpa);
......@@ -1878,7 +1878,7 @@ fn writeBaseRelocations(self: *Coff) !void {
18781878
18791879 try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data);
18801880
1881 self.data_directories[@enumToInt(coff.DirectoryEntry.BASERELOC)] = .{
1881 self.data_directories[@intFromEnum(coff.DirectoryEntry.BASERELOC)] = .{
18821882 .virtual_address = header.virtual_address,
18831883 .size = needed_size,
18841884 };
......@@ -2011,11 +2011,11 @@ fn writeImportTables(self: *Coff) !void {
20112011
20122012 try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data);
20132013
2014 self.data_directories[@enumToInt(coff.DirectoryEntry.IMPORT)] = .{
2014 self.data_directories[@intFromEnum(coff.DirectoryEntry.IMPORT)] = .{
20152015 .virtual_address = header.virtual_address + iat_size,
20162016 .size = dir_table_size,
20172017 };
2018 self.data_directories[@enumToInt(coff.DirectoryEntry.IAT)] = .{
2018 self.data_directories[@intFromEnum(coff.DirectoryEntry.IAT)] = .{
20192019 .virtual_address = header.virtual_address,
20202020 .size = iat_size,
20212021 };
......@@ -2469,7 +2469,7 @@ fn logSymtab(self: *Coff) void {
24692469 .UNDEFINED => 0, // TODO
24702470 .ABSOLUTE => unreachable, // TODO
24712471 .DEBUG => unreachable, // TODO
2472 else => @enumToInt(sym.section_number),
2472 else => @intFromEnum(sym.section_number),
24732473 };
24742474 log.debug(" %{d}: {?s} @{x} in {s}({d}), {s}", .{
24752475 sym_id,
src/link/Dwarf.zig+65-65
......@@ -171,11 +171,11 @@ pub const DeclState = struct {
171171 switch (ty.zigTypeTag(mod)) {
172172 .NoReturn => unreachable,
173173 .Void => {
174 try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1));
174 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.pad1));
175175 },
176176 .Bool => {
177177 try dbg_info_buffer.ensureUnusedCapacity(12);
178 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type));
178 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type));
179179 // DW.AT.encoding, DW.FORM.data1
180180 dbg_info_buffer.appendAssumeCapacity(DW.ATE.boolean);
181181 // DW.AT.byte_size, DW.FORM.udata
......@@ -186,7 +186,7 @@ pub const DeclState = struct {
186186 .Int => {
187187 const info = ty.intInfo(mod);
188188 try dbg_info_buffer.ensureUnusedCapacity(12);
189 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type));
189 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type));
190190 // DW.AT.encoding, DW.FORM.data1
191191 dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) {
192192 .signed => DW.ATE.signed,
......@@ -200,7 +200,7 @@ pub const DeclState = struct {
200200 .Optional => {
201201 if (ty.isPtrLikeOptional(mod)) {
202202 try dbg_info_buffer.ensureUnusedCapacity(12);
203 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type));
203 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type));
204204 // DW.AT.encoding, DW.FORM.data1
205205 dbg_info_buffer.appendAssumeCapacity(DW.ATE.address);
206206 // DW.AT.byte_size, DW.FORM.udata
......@@ -211,7 +211,7 @@ pub const DeclState = struct {
211211 // Non-pointer optionals are structs: struct { .maybe = *, .val = * }
212212 const payload_ty = ty.optionalChild(mod);
213213 // DW.AT.structure_type
214 try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type));
214 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type));
215215 // DW.AT.byte_size, DW.FORM.udata
216216 const abi_size = ty.abiSize(mod);
217217 try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size);
......@@ -219,7 +219,7 @@ pub const DeclState = struct {
219219 try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
220220 // DW.AT.member
221221 try dbg_info_buffer.ensureUnusedCapacity(7);
222 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
222 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
223223 // DW.AT.name, DW.FORM.string
224224 dbg_info_buffer.appendSliceAssumeCapacity("maybe");
225225 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -231,7 +231,7 @@ pub const DeclState = struct {
231231 try dbg_info_buffer.ensureUnusedCapacity(6);
232232 dbg_info_buffer.appendAssumeCapacity(0);
233233 // DW.AT.member
234 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
234 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
235235 // DW.AT.name, DW.FORM.string
236236 dbg_info_buffer.appendSliceAssumeCapacity("val");
237237 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -253,14 +253,14 @@ pub const DeclState = struct {
253253 const ptr_bytes = @intCast(u8, @divExact(ptr_bits, 8));
254254 // DW.AT.structure_type
255255 try dbg_info_buffer.ensureUnusedCapacity(2);
256 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_type));
256 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_type));
257257 // DW.AT.byte_size, DW.FORM.udata
258258 try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
259259 // DW.AT.name, DW.FORM.string
260260 try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
261261 // DW.AT.member
262262 try dbg_info_buffer.ensureUnusedCapacity(5);
263 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
263 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
264264 // DW.AT.name, DW.FORM.string
265265 dbg_info_buffer.appendSliceAssumeCapacity("ptr");
266266 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -273,7 +273,7 @@ pub const DeclState = struct {
273273 try dbg_info_buffer.ensureUnusedCapacity(6);
274274 dbg_info_buffer.appendAssumeCapacity(0);
275275 // DW.AT.member
276 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
276 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
277277 // DW.AT.name, DW.FORM.string
278278 dbg_info_buffer.appendSliceAssumeCapacity("len");
279279 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -288,7 +288,7 @@ pub const DeclState = struct {
288288 dbg_info_buffer.appendAssumeCapacity(0);
289289 } else {
290290 try dbg_info_buffer.ensureUnusedCapacity(5);
291 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.ptr_type));
291 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.ptr_type));
292292 // DW.AT.type, DW.FORM.ref4
293293 const index = dbg_info_buffer.items.len;
294294 try dbg_info_buffer.resize(index + 4);
......@@ -297,7 +297,7 @@ pub const DeclState = struct {
297297 },
298298 .Array => {
299299 // DW.AT.array_type
300 try dbg_info_buffer.append(@enumToInt(AbbrevKind.array_type));
300 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.array_type));
301301 // DW.AT.name, DW.FORM.string
302302 try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
303303 // DW.AT.type, DW.FORM.ref4
......@@ -305,7 +305,7 @@ pub const DeclState = struct {
305305 try dbg_info_buffer.resize(index + 4);
306306 try self.addTypeRelocGlobal(atom_index, ty.childType(mod), @intCast(u32, index));
307307 // DW.AT.subrange_type
308 try dbg_info_buffer.append(@enumToInt(AbbrevKind.array_dim));
308 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.array_dim));
309309 // DW.AT.type, DW.FORM.ref4
310310 index = dbg_info_buffer.items.len;
311311 try dbg_info_buffer.resize(index + 4);
......@@ -318,7 +318,7 @@ pub const DeclState = struct {
318318 },
319319 .Struct => blk: {
320320 // DW.AT.structure_type
321 try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type));
321 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type));
322322 // DW.AT.byte_size, DW.FORM.udata
323323 try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
324324
......@@ -329,7 +329,7 @@ pub const DeclState = struct {
329329
330330 for (fields.types, 0..) |field_ty, field_index| {
331331 // DW.AT.member
332 try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member));
332 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_member));
333333 // DW.AT.name, DW.FORM.string
334334 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});
335335 // DW.AT.type, DW.FORM.ref4
......@@ -363,7 +363,7 @@ pub const DeclState = struct {
363363 const field_name = mod.intern_pool.stringToSlice(field_name_ip);
364364 // DW.AT.member
365365 try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2);
366 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
366 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
367367 // DW.AT.name, DW.FORM.string
368368 dbg_info_buffer.appendSliceAssumeCapacity(field_name);
369369 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -384,7 +384,7 @@ pub const DeclState = struct {
384384 },
385385 .Enum => {
386386 // DW.AT.enumeration_type
387 try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type));
387 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.enum_type));
388388 // DW.AT.byte_size, DW.FORM.udata
389389 try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
390390 // DW.AT.name, DW.FORM.string
......@@ -398,7 +398,7 @@ pub const DeclState = struct {
398398 const field_name = mod.intern_pool.stringToSlice(field_name_index);
399399 // DW.AT.enumerator
400400 try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2 + @sizeOf(u64));
401 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant));
401 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant));
402402 // DW.AT.name, DW.FORM.string
403403 dbg_info_buffer.appendSliceAssumeCapacity(field_name);
404404 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -408,7 +408,7 @@ pub const DeclState = struct {
408408 const value = enum_type.values[field_i];
409409 // TODO do not assume a 64bit enum value - could be bigger.
410410 // See https://github.com/ziglang/zig/issues/645
411 const field_int_val = try value.toValue().enumToInt(ty, mod);
411 const field_int_val = try value.toValue().intFromEnum(ty, mod);
412412 break :value @bitCast(u64, field_int_val.toSignedInt(mod));
413413 };
414414 mem.writeInt(u64, dbg_info_buffer.addManyAsArrayAssumeCapacity(8), value, target_endian);
......@@ -430,7 +430,7 @@ pub const DeclState = struct {
430430 // for untagged unions.
431431 if (is_tagged) {
432432 // DW.AT.structure_type
433 try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type));
433 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type));
434434 // DW.AT.byte_size, DW.FORM.udata
435435 try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size);
436436 // DW.AT.name, DW.FORM.string
......@@ -440,7 +440,7 @@ pub const DeclState = struct {
440440
441441 // DW.AT.member
442442 try dbg_info_buffer.ensureUnusedCapacity(9);
443 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
443 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
444444 // DW.AT.name, DW.FORM.string
445445 dbg_info_buffer.appendSliceAssumeCapacity("payload");
446446 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -453,7 +453,7 @@ pub const DeclState = struct {
453453 }
454454
455455 // DW.AT.union_type
456 try dbg_info_buffer.append(@enumToInt(AbbrevKind.union_type));
456 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.union_type));
457457 // DW.AT.byte_size, DW.FORM.udata,
458458 try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size);
459459 // DW.AT.name, DW.FORM.string
......@@ -468,7 +468,7 @@ pub const DeclState = struct {
468468 const field = fields.get(field_name).?;
469469 if (!field.ty.hasRuntimeBits(mod)) continue;
470470 // DW.AT.member
471 try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member));
471 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_member));
472472 // DW.AT.name, DW.FORM.string
473473 try dbg_info_buffer.appendSlice(mod.intern_pool.stringToSlice(field_name));
474474 try dbg_info_buffer.append(0);
......@@ -485,7 +485,7 @@ pub const DeclState = struct {
485485 if (is_tagged) {
486486 // DW.AT.member
487487 try dbg_info_buffer.ensureUnusedCapacity(5);
488 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
488 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
489489 // DW.AT.name, DW.FORM.string
490490 dbg_info_buffer.appendSliceAssumeCapacity("tag");
491491 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -519,7 +519,7 @@ pub const DeclState = struct {
519519 const error_off = if (error_align >= payload_align) 0 else payload_ty.abiSize(mod);
520520
521521 // DW.AT.structure_type
522 try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type));
522 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type));
523523 // DW.AT.byte_size, DW.FORM.udata
524524 try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size);
525525 // DW.AT.name, DW.FORM.string
......@@ -529,7 +529,7 @@ pub const DeclState = struct {
529529 if (!payload_ty.isNoReturn(mod)) {
530530 // DW.AT.member
531531 try dbg_info_buffer.ensureUnusedCapacity(7);
532 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
532 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
533533 // DW.AT.name, DW.FORM.string
534534 dbg_info_buffer.appendSliceAssumeCapacity("value");
535535 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -544,7 +544,7 @@ pub const DeclState = struct {
544544 {
545545 // DW.AT.member
546546 try dbg_info_buffer.ensureUnusedCapacity(5);
547 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member));
547 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member));
548548 // DW.AT.name, DW.FORM.string
549549 dbg_info_buffer.appendSliceAssumeCapacity("err");
550550 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -561,7 +561,7 @@ pub const DeclState = struct {
561561 },
562562 else => {
563563 log.debug("TODO implement .debug_info for type '{}'", .{ty.fmt(self.mod)});
564 try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1));
564 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.pad1));
565565 },
566566 }
567567 }
......@@ -595,7 +595,7 @@ pub const DeclState = struct {
595595 switch (loc) {
596596 .register => |reg| {
597597 try dbg_info.ensureUnusedCapacity(4);
598 dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter));
598 dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter));
599599 // DW.AT.location, DW.FORM.exprloc
600600 var expr_len = std.io.countingWriter(std.io.null_writer);
601601 if (reg < 32) {
......@@ -614,7 +614,7 @@ pub const DeclState = struct {
614614 },
615615 .stack => |info| {
616616 try dbg_info.ensureUnusedCapacity(9);
617 dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter));
617 dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter));
618618 // DW.AT.location, DW.FORM.exprloc
619619 var expr_len = std.io.countingWriter(std.io.null_writer);
620620 if (info.fp_register < 32) {
......@@ -643,7 +643,7 @@ pub const DeclState = struct {
643643 // where each argument is encoded as
644644 // <opcode> i:uleb128
645645 dbg_info.appendSliceAssumeCapacity(&.{
646 @enumToInt(AbbrevKind.parameter),
646 @intFromEnum(AbbrevKind.parameter),
647647 DW.OP.WASM_location,
648648 DW.OP.WASM_local,
649649 });
......@@ -670,7 +670,7 @@ pub const DeclState = struct {
670670 const dbg_info = &self.dbg_info;
671671 const atom_index = self.di_atom_decls.get(owner_decl).?;
672672 const name_with_null = name.ptr[0 .. name.len + 1];
673 try dbg_info.append(@enumToInt(AbbrevKind.variable));
673 try dbg_info.append(@intFromEnum(AbbrevKind.variable));
674674 const mod = self.mod;
675675 const target = mod.getTarget();
676676 const endian = target.cpu.arch.endian();
......@@ -679,7 +679,7 @@ pub const DeclState = struct {
679679 switch (loc) {
680680 .register => |reg| {
681681 try dbg_info.ensureUnusedCapacity(4);
682 dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter));
682 dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter));
683683 // DW.AT.location, DW.FORM.exprloc
684684 var expr_len = std.io.countingWriter(std.io.null_writer);
685685 if (reg < 32) {
......@@ -699,7 +699,7 @@ pub const DeclState = struct {
699699
700700 .stack => |info| {
701701 try dbg_info.ensureUnusedCapacity(9);
702 dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter));
702 dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter));
703703 // DW.AT.location, DW.FORM.exprloc
704704 var expr_len = std.io.countingWriter(std.io.null_writer);
705705 if (info.fp_register < 32) {
......@@ -741,7 +741,7 @@ pub const DeclState = struct {
741741 const ptr_width = @intCast(u8, @divExact(target.ptrBitWidth(), 8));
742742 try dbg_info.ensureUnusedCapacity(2 + ptr_width);
743743 dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc
744 1 + ptr_width + @boolToInt(is_ptr),
744 1 + ptr_width + @intFromBool(is_ptr),
745745 DW.OP.addr, // literal address
746746 });
747747 const offset = @intCast(u32, dbg_info.items.len);
......@@ -1015,9 +1015,9 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index)
10151015 const fn_ret_type = decl.ty.fnReturnType(mod);
10161016 const fn_ret_has_bits = fn_ret_type.hasRuntimeBits(mod);
10171017 if (fn_ret_has_bits) {
1018 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram));
1018 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.subprogram));
10191019 } else {
1020 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram_retvoid));
1020 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.subprogram_retvoid));
10211021 }
10221022 // These get overwritten after generating the machine code. These values are
10231023 // "relocations" and have to be in this fixed place so that functions can be
......@@ -1617,14 +1617,14 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16171617 // These are LEB encoded but since the values are all less than 127
16181618 // we can simply append these bytes.
16191619 const abbrev_buf = [_]u8{
1620 @enumToInt(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header
1621 DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc,
1622 DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr,
1623 DW.AT.name, DW.FORM.strp, DW.AT.comp_dir,
1624 DW.FORM.strp, DW.AT.producer, DW.FORM.strp,
1625 DW.AT.language, DW.FORM.data2, 0,
1620 @intFromEnum(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header
1621 DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc,
1622 DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr,
1623 DW.AT.name, DW.FORM.strp, DW.AT.comp_dir,
1624 DW.FORM.strp, DW.AT.producer, DW.FORM.strp,
1625 DW.AT.language, DW.FORM.data2, 0,
16261626 0, // table sentinel
1627 @enumToInt(AbbrevKind.subprogram),
1627 @intFromEnum(AbbrevKind.subprogram),
16281628 DW.TAG.subprogram,
16291629 DW.CHILDREN.yes, // header
16301630 DW.AT.low_pc,
......@@ -1635,15 +1635,15 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16351635 DW.FORM.ref4,
16361636 DW.AT.name,
16371637 DW.FORM.string,
1638 0, 0, // table sentinel
1639 @enumToInt(AbbrevKind.subprogram_retvoid),
1638 0, 0, // table sentinel
1639 @intFromEnum(AbbrevKind.subprogram_retvoid),
16401640 DW.TAG.subprogram, DW.CHILDREN.yes, // header
16411641 DW.AT.low_pc, DW.FORM.addr,
16421642 DW.AT.high_pc, DW.FORM.data4,
16431643 DW.AT.name, DW.FORM.string,
16441644 0,
16451645 0, // table sentinel
1646 @enumToInt(AbbrevKind.base_type),
1646 @intFromEnum(AbbrevKind.base_type),
16471647 DW.TAG.base_type,
16481648 DW.CHILDREN.no, // header
16491649 DW.AT.encoding,
......@@ -1654,14 +1654,14 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16541654 DW.FORM.string,
16551655 0,
16561656 0, // table sentinel
1657 @enumToInt(AbbrevKind.ptr_type),
1657 @intFromEnum(AbbrevKind.ptr_type),
16581658 DW.TAG.pointer_type,
16591659 DW.CHILDREN.no, // header
16601660 DW.AT.type,
16611661 DW.FORM.ref4,
16621662 0,
16631663 0, // table sentinel
1664 @enumToInt(AbbrevKind.struct_type),
1664 @intFromEnum(AbbrevKind.struct_type),
16651665 DW.TAG.structure_type,
16661666 DW.CHILDREN.yes, // header
16671667 DW.AT.byte_size,
......@@ -1670,7 +1670,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16701670 DW.FORM.string,
16711671 0,
16721672 0, // table sentinel
1673 @enumToInt(AbbrevKind.struct_member),
1673 @intFromEnum(AbbrevKind.struct_member),
16741674 DW.TAG.member,
16751675 DW.CHILDREN.no, // header
16761676 DW.AT.name,
......@@ -1681,7 +1681,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16811681 DW.FORM.udata,
16821682 0,
16831683 0, // table sentinel
1684 @enumToInt(AbbrevKind.enum_type),
1684 @intFromEnum(AbbrevKind.enum_type),
16851685 DW.TAG.enumeration_type,
16861686 DW.CHILDREN.yes, // header
16871687 DW.AT.byte_size,
......@@ -1690,7 +1690,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16901690 DW.FORM.string,
16911691 0,
16921692 0, // table sentinel
1693 @enumToInt(AbbrevKind.enum_variant),
1693 @intFromEnum(AbbrevKind.enum_variant),
16941694 DW.TAG.enumerator,
16951695 DW.CHILDREN.no, // header
16961696 DW.AT.name,
......@@ -1699,7 +1699,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
16991699 DW.FORM.data8,
17001700 0,
17011701 0, // table sentinel
1702 @enumToInt(AbbrevKind.union_type),
1702 @intFromEnum(AbbrevKind.union_type),
17031703 DW.TAG.union_type,
17041704 DW.CHILDREN.yes, // header
17051705 DW.AT.byte_size,
......@@ -1708,32 +1708,32 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void {
17081708 DW.FORM.string,
17091709 0,
17101710 0, // table sentinel
1711 @enumToInt(AbbrevKind.pad1),
1711 @intFromEnum(AbbrevKind.pad1),
17121712 DW.TAG.unspecified_type,
17131713 DW.CHILDREN.no, // header
17141714 0,
17151715 0, // table sentinel
1716 @enumToInt(AbbrevKind.parameter),
1716 @intFromEnum(AbbrevKind.parameter),
17171717 DW.TAG.formal_parameter, DW.CHILDREN.no, // header
17181718 DW.AT.location, DW.FORM.exprloc,
17191719 DW.AT.type, DW.FORM.ref4,
17201720 DW.AT.name, DW.FORM.string,
17211721 0,
17221722 0, // table sentinel
1723 @enumToInt(AbbrevKind.variable),
1723 @intFromEnum(AbbrevKind.variable),
17241724 DW.TAG.variable, DW.CHILDREN.no, // header
17251725 DW.AT.location, DW.FORM.exprloc,
17261726 DW.AT.type, DW.FORM.ref4,
17271727 DW.AT.name, DW.FORM.string,
17281728 0,
17291729 0, // table sentinel
1730 @enumToInt(AbbrevKind.array_type),
1730 @intFromEnum(AbbrevKind.array_type),
17311731 DW.TAG.array_type, DW.CHILDREN.yes, // header
17321732 DW.AT.name, DW.FORM.string,
17331733 DW.AT.type, DW.FORM.ref4,
17341734 0,
17351735 0, // table sentinel
1736 @enumToInt(AbbrevKind.array_dim),
1736 @intFromEnum(AbbrevKind.array_dim),
17371737 DW.TAG.subrange_type, DW.CHILDREN.no, // header
17381738 DW.AT.type, DW.FORM.ref4,
17391739 DW.AT.count, DW.FORM.udata,
......@@ -1838,7 +1838,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, module: *Module, low_pc: u64, high_pc: u
18381838 const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir);
18391839 const producer_strp = try self.strtab.insert(self.allocator, link.producer_string);
18401840
1841 di_buf.appendAssumeCapacity(@enumToInt(AbbrevKind.compile_unit));
1841 di_buf.appendAssumeCapacity(@intFromEnum(AbbrevKind.compile_unit));
18421842 if (self.bin_file.tag == .macho) {
18431843 mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT.stmt_list, DW.FORM.sec_offset
18441844 mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), low_pc);
......@@ -2038,7 +2038,7 @@ fn pwriteDbgInfoNops(
20382038 const tracy = trace(@src());
20392039 defer tracy.end();
20402040
2041 const page_of_nops = [1]u8{@enumToInt(AbbrevKind.pad1)} ** 4096;
2041 const page_of_nops = [1]u8{@intFromEnum(AbbrevKind.pad1)} ** 4096;
20422042 var vecs: [32]std.os.iovec_const = undefined;
20432043 var vec_index: usize = 0;
20442044 {
......@@ -2110,9 +2110,9 @@ fn writeDbgInfoNopsToArrayList(
21102110 buffer.items.len,
21112111 offset + content.len + next_padding_size + 1,
21122112 ));
2113 @memset(buffer.items[offset - prev_padding_size .. offset], @enumToInt(AbbrevKind.pad1));
2113 @memset(buffer.items[offset - prev_padding_size .. offset], @intFromEnum(AbbrevKind.pad1));
21142114 @memcpy(buffer.items[offset..][0..content.len], content);
2115 @memset(buffer.items[offset + content.len ..][0..next_padding_size], @enumToInt(AbbrevKind.pad1));
2115 @memset(buffer.items[offset + content.len ..][0..next_padding_size], @intFromEnum(AbbrevKind.pad1));
21162116
21172117 if (trailing_zero) {
21182118 buffer.items[offset + content.len + next_padding_size] = 0;
......@@ -2653,7 +2653,7 @@ fn addDbgInfoErrorSet(
26532653 const target_endian = target.cpu.arch.endian();
26542654
26552655 // DW.AT.enumeration_type
2656 try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type));
2656 try dbg_info_buffer.append(@intFromEnum(AbbrevKind.enum_type));
26572657 // DW.AT.byte_size, DW.FORM.udata
26582658 const abi_size = Type.anyerror.abiSize(mod);
26592659 try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size);
......@@ -2664,7 +2664,7 @@ fn addDbgInfoErrorSet(
26642664 // DW.AT.enumerator
26652665 const no_error = "(no error)";
26662666 try dbg_info_buffer.ensureUnusedCapacity(no_error.len + 2 + @sizeOf(u64));
2667 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant));
2667 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant));
26682668 // DW.AT.name, DW.FORM.string
26692669 dbg_info_buffer.appendSliceAssumeCapacity(no_error);
26702670 dbg_info_buffer.appendAssumeCapacity(0);
......@@ -2677,7 +2677,7 @@ fn addDbgInfoErrorSet(
26772677 const error_name = mod.intern_pool.stringToSlice(error_name_ip);
26782678 // DW.AT.enumerator
26792679 try dbg_info_buffer.ensureUnusedCapacity(error_name.len + 2 + @sizeOf(u64));
2680 dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant));
2680 dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant));
26812681 // DW.AT.name, DW.FORM.string
26822682 dbg_info_buffer.appendSliceAssumeCapacity(error_name);
26832683 dbg_info_buffer.appendAssumeCapacity(0);
src/link/Elf.zig+5-5
......@@ -1826,7 +1826,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
18261826
18271827 for (system_libs, 0..) |link_lib, i| {
18281828 const lib_as_needed = !system_libs_values[i].needed;
1829 switch ((@as(u2, @boolToInt(lib_as_needed)) << 1) | @boolToInt(as_needed)) {
1829 switch ((@as(u2, @intFromBool(lib_as_needed)) << 1) | @intFromBool(as_needed)) {
18301830 0b00, 0b11 => {},
18311831 0b01 => {
18321832 argv.appendAssumeCapacity("--no-as-needed");
......@@ -2048,11 +2048,11 @@ fn writeElfHeader(self: *Elf) !void {
20482048 .Dynamic => elf.ET.DYN,
20492049 },
20502050 };
2051 mem.writeInt(u16, hdr_buf[index..][0..2], @enumToInt(elf_type), endian);
2051 mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian);
20522052 index += 2;
20532053
20542054 const machine = self.base.options.target.cpu.arch.toElfMachine();
2055 mem.writeInt(u16, hdr_buf[index..][0..2], @enumToInt(machine), endian);
2055 mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(machine), endian);
20562056 index += 2;
20572057
20582058 // ELF Version, again
......@@ -2557,7 +2557,7 @@ fn updateDeclCode(self: *Elf, decl_index: Module.Decl.Index, code: []const u8, s
25572557 .iov_len = code.len,
25582558 }};
25592559 var remote_vec: [1]std.os.iovec_const = .{.{
2560 .iov_base = @intToPtr([*]u8, @intCast(usize, local_sym.st_value)),
2560 .iov_base = @ptrFromInt([*]u8, @intCast(usize, local_sym.st_value)),
25612561 .iov_len = code.len,
25622562 }};
25632563 const rc = std.os.linux.process_vm_writev(pid, &code_vec, &remote_vec, 0);
......@@ -3051,7 +3051,7 @@ fn writeOffsetTableEntry(self: *Elf, index: @TypeOf(self.got_table).Index) !void
30513051 .iov_len = buf.len,
30523052 }};
30533053 var remote_vec: [1]std.os.iovec_const = .{.{
3054 .iov_base = @intToPtr([*]u8, @intCast(usize, vaddr)),
3054 .iov_base = @ptrFromInt([*]u8, @intCast(usize, vaddr)),
30553055 .iov_len = buf.len,
30563056 }};
30573057 const rc = std.os.linux.process_vm_writev(pid, &local_vec, &remote_vec, 0);
src/link/MachO/UnwindInfo.zig+4-4
......@@ -760,14 +760,14 @@ pub const UnwindEncoding = struct {
760760 pub fn isDwarf(enc: macho.compact_unwind_encoding_t, cpu_arch: std.Target.Cpu.Arch) bool {
761761 const mode = getMode(enc);
762762 return switch (cpu_arch) {
763 .aarch64 => @intToEnum(macho.UNWIND_ARM64_MODE, mode) == .DWARF,
764 .x86_64 => @intToEnum(macho.UNWIND_X86_64_MODE, mode) == .DWARF,
763 .aarch64 => @enumFromInt(macho.UNWIND_ARM64_MODE, mode) == .DWARF,
764 .x86_64 => @enumFromInt(macho.UNWIND_X86_64_MODE, mode) == .DWARF,
765765 else => unreachable,
766766 };
767767 }
768768
769769 pub fn setMode(enc: *macho.compact_unwind_encoding_t, mode: anytype) void {
770 enc.* |= @intCast(u32, @enumToInt(mode)) << 24;
770 enc.* |= @intCast(u32, @intFromEnum(mode)) << 24;
771771 }
772772
773773 pub fn hasLsda(enc: macho.compact_unwind_encoding_t) bool {
......@@ -776,7 +776,7 @@ pub const UnwindEncoding = struct {
776776 }
777777
778778 pub fn setHasLsda(enc: *macho.compact_unwind_encoding_t, has_lsda: bool) void {
779 const mask = @intCast(u32, @boolToInt(has_lsda)) << 31;
779 const mask = @intCast(u32, @intFromBool(has_lsda)) << 31;
780780 enc.* |= mask;
781781 }
782782
src/link/MachO/ZldAtom.zig+7-7
......@@ -214,7 +214,7 @@ pub fn parseRelocTarget(zld: *Zld, ctx: struct {
214214 mem.readIntLittle(u32, ctx.code[rel_offset..][0..4]);
215215 } else blk: {
216216 assert(zld.options.target.cpu.arch == .x86_64);
217 const correction: u3 = switch (@intToEnum(macho.reloc_type_x86_64, ctx.rel.r_type)) {
217 const correction: u3 = switch (@enumFromInt(macho.reloc_type_x86_64, ctx.rel.r_type)) {
218218 .X86_64_RELOC_SIGNED => 0,
219219 .X86_64_RELOC_SIGNED_1 => 1,
220220 .X86_64_RELOC_SIGNED_2 => 2,
......@@ -272,7 +272,7 @@ pub fn getRelocTargetAtomIndex(zld: *Zld, target: SymbolWithLoc, is_via_got: boo
272272
273273fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void {
274274 for (relocs) |rel| {
275 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
275 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
276276
277277 switch (rel_type) {
278278 .ARM64_RELOC_ADDEND, .ARM64_RELOC_SUBTRACTOR => continue,
......@@ -321,7 +321,7 @@ fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) cons
321321
322322fn scanAtomRelocsX86(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void {
323323 for (relocs) |rel| {
324 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
324 const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
325325
326326 switch (rel_type) {
327327 .X86_64_RELOC_SUBTRACTOR => continue,
......@@ -495,7 +495,7 @@ fn resolveRelocsArm64(
495495 var subtractor: ?SymbolWithLoc = null;
496496
497497 for (atom_relocs) |rel| {
498 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
498 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
499499
500500 switch (rel_type) {
501501 .ARM64_RELOC_ADDEND => {
......@@ -797,7 +797,7 @@ fn resolveRelocsX86(
797797 var subtractor: ?SymbolWithLoc = null;
798798
799799 for (atom_relocs) |rel| {
800 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
800 const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
801801
802802 switch (rel_type) {
803803 .X86_64_RELOC_SUBTRACTOR => {
......@@ -1004,14 +1004,14 @@ pub fn getAtomRelocs(zld: *Zld, atom_index: AtomIndex) []const macho.relocation_
10041004
10051005pub fn relocRequiresGot(zld: *Zld, rel: macho.relocation_info) bool {
10061006 switch (zld.options.target.cpu.arch) {
1007 .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) {
1007 .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) {
10081008 .ARM64_RELOC_GOT_LOAD_PAGE21,
10091009 .ARM64_RELOC_GOT_LOAD_PAGEOFF12,
10101010 .ARM64_RELOC_POINTER_TO_GOT,
10111011 => return true,
10121012 else => return false,
10131013 },
1014 .x86_64 => switch (@intToEnum(macho.reloc_type_x86_64, rel.r_type)) {
1014 .x86_64 => switch (@enumFromInt(macho.reloc_type_x86_64, rel.r_type)) {
10151015 .X86_64_RELOC_GOT,
10161016 .X86_64_RELOC_GOT_LOAD,
10171017 => return true,
src/link/MachO/dead_strip.zig+2-2
......@@ -148,7 +148,7 @@ fn markLive(zld: *Zld, atom_index: AtomIndex, alive: *AtomTable) void {
148148
149149 for (relocs) |rel| {
150150 const target = switch (cpu_arch) {
151 .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) {
151 .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) {
152152 .ARM64_RELOC_ADDEND => continue,
153153 else => Atom.parseRelocTarget(zld, .{
154154 .object_id = atom.getFile().?,
......@@ -208,7 +208,7 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable) bool {
208208
209209 for (relocs) |rel| {
210210 const target = switch (cpu_arch) {
211 .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) {
211 .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) {
212212 .ARM64_RELOC_ADDEND => continue,
213213 else => Atom.parseRelocTarget(zld, .{
214214 .object_id = atom.getFile().?,
src/link/MachO/eh_frame.zig+4-4
......@@ -291,7 +291,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
291291 for (relocs) |rel| {
292292 switch (cpu_arch) {
293293 .aarch64 => {
294 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
294 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
295295 switch (rel_type) {
296296 .ARM64_RELOC_SUBTRACTOR,
297297 .ARM64_RELOC_UNSIGNED,
......@@ -301,7 +301,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
301301 }
302302 },
303303 .x86_64 => {
304 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
304 const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
305305 switch (rel_type) {
306306 .X86_64_RELOC_GOT => {},
307307 else => unreachable,
......@@ -342,7 +342,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
342342
343343 switch (cpu_arch) {
344344 .aarch64 => {
345 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
345 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
346346 switch (rel_type) {
347347 .ARM64_RELOC_SUBTRACTOR => {
348348 // Address of the __eh_frame in the source object file
......@@ -363,7 +363,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
363363 }
364364 },
365365 .x86_64 => {
366 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
366 const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
367367 switch (rel_type) {
368368 .X86_64_RELOC_GOT => {
369369 const target_addr = try Atom.getRelocTargetAddress(zld, target, true, false);
src/link/MachO/thunks.zig+1-1
......@@ -289,7 +289,7 @@ fn scanRelocs(
289289}
290290
291291inline fn relocNeedsThunk(rel: macho.relocation_info) bool {
292 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
292 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
293293 return rel_type == .ARM64_RELOC_BRANCH26;
294294}
295295
src/link/MachO/zld.zig+4-4
......@@ -1819,12 +1819,12 @@ pub const Zld = struct {
18191819 for (relocs) |rel| {
18201820 switch (cpu_arch) {
18211821 .aarch64 => {
1822 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
1822 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
18231823 if (rel_type != .ARM64_RELOC_UNSIGNED) continue;
18241824 if (rel.r_length != 3) continue;
18251825 },
18261826 .x86_64 => {
1827 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
1827 const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
18281828 if (rel_type != .X86_64_RELOC_UNSIGNED) continue;
18291829 if (rel.r_length != 3) continue;
18301830 },
......@@ -1958,12 +1958,12 @@ pub const Zld = struct {
19581958 for (relocs) |rel| {
19591959 switch (cpu_arch) {
19601960 .aarch64 => {
1961 const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
1961 const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
19621962 if (rel_type != .ARM64_RELOC_UNSIGNED) continue;
19631963 if (rel.r_length != 3) continue;
19641964 },
19651965 .x86_64 => {
1966 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
1966 const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
19671967 if (rel_type != .X86_64_RELOC_UNSIGNED) continue;
19681968 if (rel.r_length != 3) continue;
19691969 },
src/link/Plan9.zig+1-1
......@@ -1192,7 +1192,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void {
11921192 } else {
11931193 try w.writeIntBig(u64, sym.value);
11941194 }
1195 try w.writeByte(@enumToInt(sym.type));
1195 try w.writeByte(@intFromEnum(sym.type));
11961196 try w.writeAll(sym.name);
11971197 try w.writeByte(0);
11981198}
src/link/Wasm.zig+35-35
......@@ -196,7 +196,7 @@ pub const Segment = struct {
196196 };
197197
198198 pub fn isPassive(segment: Segment) bool {
199 return segment.flags & @enumToInt(Flag.WASM_DATA_SEGMENT_IS_PASSIVE) != 0;
199 return segment.flags & @intFromEnum(Flag.WASM_DATA_SEGMENT_IS_PASSIVE) != 0;
200200 }
201201
202202 /// For a given segment, determines if it needs passive initialization
......@@ -1094,14 +1094,14 @@ fn validateFeatures(
10941094 const value = @intCast(u16, object_index) << 1 | @as(u1, 1);
10951095 switch (feature.prefix) {
10961096 .used => {
1097 used[@enumToInt(feature.tag)] = value;
1097 used[@intFromEnum(feature.tag)] = value;
10981098 },
10991099 .disallowed => {
1100 disallowed[@enumToInt(feature.tag)] = value;
1100 disallowed[@intFromEnum(feature.tag)] = value;
11011101 },
11021102 .required => {
1103 required[@enumToInt(feature.tag)] = value;
1104 used[@enumToInt(feature.tag)] = value;
1103 required[@intFromEnum(feature.tag)] = value;
1104 used[@intFromEnum(feature.tag)] = value;
11051105 },
11061106 }
11071107 }
......@@ -1120,9 +1120,9 @@ fn validateFeatures(
11201120 const is_enabled = @truncate(u1, used_set) != 0;
11211121 if (infer) {
11221122 allowed[used_index] = is_enabled;
1123 emit_features_count.* += @boolToInt(is_enabled);
1123 emit_features_count.* += @intFromBool(is_enabled);
11241124 } else if (is_enabled and !allowed[used_index]) {
1125 log.err("feature '{}' not allowed, but used by linked object", .{@intToEnum(types.Feature.Tag, used_index)});
1125 log.err("feature '{}' not allowed, but used by linked object", .{@enumFromInt(types.Feature.Tag, used_index)});
11261126 log.err(" defined in '{s}'", .{wasm.objects.items[used_set >> 1].name});
11271127 valid_feature_set = false;
11281128 }
......@@ -1133,7 +1133,7 @@ fn validateFeatures(
11331133 }
11341134
11351135 if (wasm.base.options.shared_memory) {
1136 const disallowed_feature = disallowed[@enumToInt(types.Feature.Tag.shared_mem)];
1136 const disallowed_feature = disallowed[@intFromEnum(types.Feature.Tag.shared_mem)];
11371137 if (@truncate(u1, disallowed_feature) != 0) {
11381138 log.err(
11391139 "shared-memory is disallowed by '{s}' because it wasn't compiled with 'atomics' and 'bulk-memory' features enabled",
......@@ -1143,7 +1143,7 @@ fn validateFeatures(
11431143 }
11441144
11451145 for ([_]types.Feature.Tag{ .atomics, .bulk_memory }) |feature| {
1146 if (!allowed[@enumToInt(feature)]) {
1146 if (!allowed[@intFromEnum(feature)]) {
11471147 log.err("feature '{}' is not used but is required for shared-memory", .{feature});
11481148 }
11491149 }
......@@ -1151,7 +1151,7 @@ fn validateFeatures(
11511151
11521152 if (has_tls) {
11531153 for ([_]types.Feature.Tag{ .atomics, .bulk_memory }) |feature| {
1154 if (!allowed[@enumToInt(feature)]) {
1154 if (!allowed[@intFromEnum(feature)]) {
11551155 log.err("feature '{}' is not used but is required for thread-local storage", .{feature});
11561156 }
11571157 }
......@@ -1162,7 +1162,7 @@ fn validateFeatures(
11621162 for (object.features) |feature| {
11631163 if (feature.prefix == .disallowed) continue; // already defined in 'disallowed' set.
11641164 // from here a feature is always used
1165 const disallowed_feature = disallowed[@enumToInt(feature.tag)];
1165 const disallowed_feature = disallowed[@intFromEnum(feature.tag)];
11661166 if (@truncate(u1, disallowed_feature) != 0) {
11671167 log.err("feature '{}' is disallowed, but used by linked object", .{feature.tag});
11681168 log.err(" disallowed by '{s}'", .{wasm.objects.items[disallowed_feature >> 1].name});
......@@ -1170,14 +1170,14 @@ fn validateFeatures(
11701170 valid_feature_set = false;
11711171 }
11721172
1173 object_used_features[@enumToInt(feature.tag)] = true;
1173 object_used_features[@intFromEnum(feature.tag)] = true;
11741174 }
11751175
11761176 // validate the linked object file has each required feature
11771177 for (required, 0..) |required_feature, feature_index| {
11781178 const is_required = @truncate(u1, required_feature) != 0;
11791179 if (is_required and !object_used_features[feature_index]) {
1180 log.err("feature '{}' is required but not used in linked object", .{@intToEnum(types.Feature.Tag, feature_index)});
1180 log.err("feature '{}' is required but not used in linked object", .{@enumFromInt(types.Feature.Tag, feature_index)});
11811181 log.err(" required by '{s}'", .{wasm.objects.items[required_feature >> 1].name});
11821182 log.err(" missing in '{s}'", .{object.name});
11831183 valid_feature_set = false;
......@@ -1324,7 +1324,7 @@ pub fn allocateSymbol(wasm: *Wasm) !u32 {
13241324 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);
13251325 var symbol: Symbol = .{
13261326 .name = undefined, // will be set after updateDecl
1327 .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
1327 .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
13281328 .tag = undefined, // will be set after updateDecl
13291329 .index = undefined, // will be set after updateDecl
13301330 .virtual_address = undefined, // will be set during atom allocation
......@@ -1560,7 +1560,7 @@ pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.In
15601560 atom.alignment = tv.ty.abiAlignment(mod);
15611561 wasm.symbols.items[atom.sym_index] = .{
15621562 .name = try wasm.string_table.put(wasm.base.allocator, name),
1563 .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
1563 .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
15641564 .tag = .data,
15651565 .index = undefined,
15661566 .virtual_address = undefined,
......@@ -2028,7 +2028,7 @@ fn parseAtom(wasm: *Wasm, atom_index: Atom.Index, kind: Kind) !void {
20282028 const index = @intCast(u32, wasm.segments.items.len);
20292029 var flags: u32 = 0;
20302030 if (wasm.base.options.shared_memory) {
2031 flags |= @enumToInt(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE);
2031 flags |= @intFromEnum(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE);
20322032 }
20332033 try wasm.segments.append(wasm.base.allocator, .{
20342034 .alignment = atom.alignment,
......@@ -2868,7 +2868,7 @@ pub fn getMatchingSegment(wasm: *Wasm, object_index: u16, relocatable_index: u32
28682868 result.value_ptr.* = index;
28692869 var flags: u32 = 0;
28702870 if (wasm.base.options.shared_memory) {
2871 flags |= @enumToInt(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE);
2871 flags |= @intFromEnum(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE);
28722872 }
28732873 try wasm.segments.append(wasm.base.allocator, .{
28742874 .alignment = 1,
......@@ -3073,7 +3073,7 @@ pub fn createDebugSectionForIndex(wasm: *Wasm, index: *?u32, name: []const u8) !
30733073 .tag = .section,
30743074 .name = try wasm.string_table.put(wasm.base.allocator, name),
30753075 .index = 0,
3076 .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
3076 .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
30773077 };
30783078
30793079 atom.alignment = 1; // debug sections are always 1-byte-aligned
......@@ -3544,7 +3544,7 @@ fn writeToFile(
35443544 header_offset,
35453545 .import,
35463546 @intCast(u32, binary_bytes.items.len - header_offset - header_size),
3547 @intCast(u32, wasm.imports.count() + @boolToInt(import_memory)),
3547 @intCast(u32, wasm.imports.count() + @intFromBool(import_memory)),
35483548 );
35493549 section_count += 1;
35503550 }
......@@ -3606,7 +3606,7 @@ fn writeToFile(
36063606
36073607 for (wasm.wasm_globals.items) |global| {
36083608 try binary_writer.writeByte(std.wasm.valtype(global.global_type.valtype));
3609 try binary_writer.writeByte(@boolToInt(global.global_type.mutable));
3609 try binary_writer.writeByte(@intFromBool(global.global_type.mutable));
36103610 try emitInit(binary_writer, global.init);
36113611 }
36123612
......@@ -3628,7 +3628,7 @@ fn writeToFile(
36283628 const name = wasm.string_table.get(exp.name);
36293629 try leb.writeULEB128(binary_writer, @intCast(u32, name.len));
36303630 try binary_writer.writeAll(name);
3631 try leb.writeULEB128(binary_writer, @enumToInt(exp.kind));
3631 try leb.writeULEB128(binary_writer, @intFromEnum(exp.kind));
36323632 try leb.writeULEB128(binary_writer, exp.index);
36333633 }
36343634
......@@ -3644,7 +3644,7 @@ fn writeToFile(
36443644 header_offset,
36453645 .@"export",
36463646 @intCast(u32, binary_bytes.items.len - header_offset - header_size),
3647 @intCast(u32, wasm.exports.items.len) + @boolToInt(!import_memory),
3647 @intCast(u32, wasm.exports.items.len) + @intFromBool(!import_memory),
36483648 );
36493649 section_count += 1;
36503650 }
......@@ -3682,7 +3682,7 @@ fn writeToFile(
36823682 }
36833683
36843684 // When the shared-memory option is enabled, we *must* emit the 'data count' section.
3685 const data_segments_count = wasm.data_segments.count() - @boolToInt(wasm.data_segments.contains(".bss") and import_memory);
3685 const data_segments_count = wasm.data_segments.count() - @intFromBool(wasm.data_segments.contains(".bss") and import_memory);
36863686 if (data_segments_count != 0 and wasm.base.options.shared_memory) {
36873687 const header_offset = try reserveVecSectionHeader(&binary_bytes);
36883688 try writeVecSectionHeader(
......@@ -3760,7 +3760,7 @@ fn writeToFile(
37603760 var atom_index = wasm.atoms.get(segment_index).?;
37613761
37623762 try leb.writeULEB128(binary_writer, segment.flags);
3763 if (segment.flags & @enumToInt(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) {
3763 if (segment.flags & @intFromEnum(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) {
37643764 try leb.writeULEB128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry
37653765 }
37663766 // when a segment is passive, it's initialized during runtime.
......@@ -4030,8 +4030,8 @@ fn emitFeaturesSection(binary_bytes: *std.ArrayList(u8), enabled_features: []con
40304030 try leb.writeULEB128(writer, features_count);
40314031 for (enabled_features, 0..) |enabled, feature_index| {
40324032 if (enabled) {
4033 const feature: types.Feature = .{ .prefix = .used, .tag = @intToEnum(types.Feature.Tag, feature_index) };
4034 try leb.writeULEB128(writer, @enumToInt(feature.prefix));
4033 const feature: types.Feature = .{ .prefix = .used, .tag = @enumFromInt(types.Feature.Tag, feature_index) };
4034 try leb.writeULEB128(writer, @intFromEnum(feature.prefix));
40354035 var buf: [100]u8 = undefined;
40364036 const string = try std.fmt.bufPrint(&buf, "{}", .{feature.tag});
40374037 try leb.writeULEB128(writer, @intCast(u32, string.len));
......@@ -4121,7 +4121,7 @@ fn emitNameSubsection(wasm: *Wasm, section_id: std.wasm.NameSubsection, names: a
41214121 }
41224122
41234123 // From now, write to the actual writer
4124 try leb.writeULEB128(writer, @enumToInt(section_id));
4124 try leb.writeULEB128(writer, @intFromEnum(section_id));
41254125 try leb.writeULEB128(writer, @intCast(u32, section_list.items.len));
41264126 try writer.writeAll(section_list.items);
41274127}
......@@ -4169,12 +4169,12 @@ fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void {
41694169 try leb.writeULEB128(writer, @intCast(u32, name.len));
41704170 try writer.writeAll(name);
41714171
4172 try writer.writeByte(@enumToInt(import.kind));
4172 try writer.writeByte(@intFromEnum(import.kind));
41734173 switch (import.kind) {
41744174 .function => |type_index| try leb.writeULEB128(writer, type_index),
41754175 .global => |global_type| {
41764176 try leb.writeULEB128(writer, std.wasm.valtype(global_type.valtype));
4177 try writer.writeByte(@boolToInt(global_type.mutable));
4177 try writer.writeByte(@intFromBool(global_type.mutable));
41784178 },
41794179 .table => |table| {
41804180 try leb.writeULEB128(writer, std.wasm.reftype(table.reftype));
......@@ -4609,7 +4609,7 @@ fn reserveCustomSectionHeader(bytes: *std.ArrayList(u8)) !u32 {
46094609
46104610fn writeVecSectionHeader(buffer: []u8, offset: u32, section: std.wasm.Section, size: u32, items: u32) !void {
46114611 var buf: [1 + 5 + 5]u8 = undefined;
4612 buf[0] = @enumToInt(section);
4612 buf[0] = @intFromEnum(section);
46134613 leb.writeUnsignedFixed(5, buf[1..6], size);
46144614 leb.writeUnsignedFixed(5, buf[6..], items);
46154615 buffer[offset..][0..buf.len].* = buf;
......@@ -4645,7 +4645,7 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
46454645fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void {
46464646 const writer = binary_bytes.writer();
46474647
4648 try leb.writeULEB128(writer, @enumToInt(types.SubsectionType.WASM_SYMBOL_TABLE));
4648 try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE));
46494649 const table_offset = binary_bytes.items.len;
46504650
46514651 var symbol_count: u32 = 0;
......@@ -4655,7 +4655,7 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
46554655 try symbol_table.putNoClobber(sym_loc, symbol_count);
46564656 symbol_count += 1;
46574657 log.debug("Emit symbol: {}", .{symbol});
4658 try leb.writeULEB128(writer, @enumToInt(symbol.tag));
4658 try leb.writeULEB128(writer, @intFromEnum(symbol.tag));
46594659 try leb.writeULEB128(writer, symbol.flags);
46604660
46614661 const sym_name = if (wasm.export_names.get(sym_loc)) |exp_name| wasm.string_table.get(exp_name) else sym_loc.getName(wasm);
......@@ -4693,7 +4693,7 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
46934693
46944694fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void {
46954695 const writer = binary_bytes.writer();
4696 try leb.writeULEB128(writer, @enumToInt(types.SubsectionType.WASM_SEGMENT_INFO));
4696 try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO));
46974697 const segment_offset = binary_bytes.items.len;
46984698
46994699 try leb.writeULEB128(writer, @intCast(u32, wasm.segment_info.count()));
......@@ -4754,7 +4754,7 @@ fn emitCodeRelocations(
47544754 count += 1;
47554755 const sym_loc: SymbolLoc = .{ .file = atom.file, .index = relocation.index };
47564756 const symbol_index = symbol_table.get(sym_loc).?;
4757 try leb.writeULEB128(writer, @enumToInt(relocation.relocation_type));
4757 try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type));
47584758 const offset = atom.offset + relocation.offset + size_offset;
47594759 try leb.writeULEB128(writer, offset);
47604760 try leb.writeULEB128(writer, symbol_index);
......@@ -4804,7 +4804,7 @@ fn emitDataRelocations(
48044804 .index = relocation.index,
48054805 };
48064806 const symbol_index = symbol_table.get(sym_loc).?;
4807 try leb.writeULEB128(writer, @enumToInt(relocation.relocation_type));
4807 try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type));
48084808 const offset = atom.offset + relocation.offset + size_offset;
48094809 try leb.writeULEB128(writer, offset);
48104810 try leb.writeULEB128(writer, symbol_index);
src/link/Wasm/Object.zig+8-8
......@@ -365,7 +365,7 @@ fn Parser(comptime ReaderType: type) type {
365365 const len = try readLeb(u32, parser.reader.reader());
366366 var limited_reader = std.io.limitedReader(parser.reader.reader(), len);
367367 const reader = limited_reader.reader();
368 switch (@intToEnum(std.wasm.Section, byte)) {
368 switch (@enumFromInt(std.wasm.Section, byte)) {
369369 .custom => {
370370 const name_len = try readLeb(u32, reader);
371371 const name = try gpa.alloc(u8, name_len);
......@@ -645,7 +645,7 @@ fn Parser(comptime ReaderType: type) type {
645645 /// such as access to the `import` section to find the name of a symbol.
646646 fn parseSubsection(parser: *ObjectParser, gpa: Allocator, reader: anytype) !void {
647647 const sub_type = try leb.readULEB128(u8, reader);
648 log.debug("Found subsection: {s}", .{@tagName(@intToEnum(types.SubsectionType, sub_type))});
648 log.debug("Found subsection: {s}", .{@tagName(@enumFromInt(types.SubsectionType, sub_type))});
649649 const payload_len = try leb.readULEB128(u32, reader);
650650 if (payload_len == 0) return;
651651
......@@ -655,7 +655,7 @@ fn Parser(comptime ReaderType: type) type {
655655 // every subsection contains a 'count' field
656656 const count = try leb.readULEB128(u32, limited_reader);
657657
658 switch (@intToEnum(types.SubsectionType, sub_type)) {
658 switch (@enumFromInt(types.SubsectionType, sub_type)) {
659659 .WASM_SEGMENT_INFO => {
660660 const segments = try gpa.alloc(types.Segment, count);
661661 errdefer gpa.free(segments);
......@@ -678,7 +678,7 @@ fn Parser(comptime ReaderType: type) type {
678678 // support legacy object files that specified being TLS by the name instead of the TLS flag.
679679 if (!segment.isTLS() and (std.mem.startsWith(u8, segment.name, ".tdata") or std.mem.startsWith(u8, segment.name, ".tbss"))) {
680680 // set the flag so we can simply check for the flag in the rest of the linker.
681 segment.flags |= @enumToInt(types.Segment.Flags.WASM_SEG_FLAG_TLS);
681 segment.flags |= @intFromEnum(types.Segment.Flags.WASM_SEG_FLAG_TLS);
682682 }
683683 }
684684 parser.object.segment_info = segments;
......@@ -714,7 +714,7 @@ fn Parser(comptime ReaderType: type) type {
714714 errdefer gpa.free(symbols);
715715 for (symbols) |*symbol| {
716716 symbol.* = .{
717 .kind = @intToEnum(types.ComdatSym.Type, try leb.readULEB128(u8, reader)),
717 .kind = @enumFromInt(types.ComdatSym.Type, try leb.readULEB128(u8, reader)),
718718 .index = try leb.readULEB128(u32, reader),
719719 };
720720 }
......@@ -758,7 +758,7 @@ fn Parser(comptime ReaderType: type) type {
758758 /// requires access to `Object` to find the name of a symbol when it's
759759 /// an import and flag `WASM_SYM_EXPLICIT_NAME` is not set.
760760 fn parseSymbol(parser: *ObjectParser, gpa: Allocator, reader: anytype) !Symbol {
761 const tag = @intToEnum(Symbol.Tag, try leb.readULEB128(u8, reader));
761 const tag = @enumFromInt(Symbol.Tag, try leb.readULEB128(u8, reader));
762762 const flags = try leb.readULEB128(u32, reader);
763763 var symbol: Symbol = .{
764764 .flags = flags,
......@@ -846,7 +846,7 @@ fn readLeb(comptime T: type, reader: anytype) !T {
846846/// Asserts `T` is an enum
847847fn readEnum(comptime T: type, reader: anytype) !T {
848848 switch (@typeInfo(T)) {
849 .Enum => |enum_type| return @intToEnum(T, try readLeb(enum_type.tag_type, reader)),
849 .Enum => |enum_type| return @enumFromInt(T, try readLeb(enum_type.tag_type, reader)),
850850 else => @compileError("T must be an enum. Instead was given type " ++ @typeName(T)),
851851 }
852852}
......@@ -867,7 +867,7 @@ fn readLimits(reader: anytype) !std.wasm.Limits {
867867
868868fn readInit(reader: anytype) !std.wasm.InitExpression {
869869 const opcode = try reader.readByte();
870 const init_expr: std.wasm.InitExpression = switch (@intToEnum(std.wasm.Opcode, opcode)) {
870 const init_expr: std.wasm.InitExpression = switch (@enumFromInt(std.wasm.Opcode, opcode)) {
871871 .i32_const => .{ .i32_const = try readLeb(i32, reader) },
872872 .global_get => .{ .global_get = try readLeb(u32, reader) },
873873 else => @panic("TODO: initexpression for other opcodes"),
src/link/Wasm/Symbol.zig+12-12
......@@ -91,32 +91,32 @@ pub fn requiresImport(symbol: Symbol) bool {
9191}
9292
9393pub fn isTLS(symbol: Symbol) bool {
94 return symbol.flags & @enumToInt(Flag.WASM_SYM_TLS) != 0;
94 return symbol.flags & @intFromEnum(Flag.WASM_SYM_TLS) != 0;
9595}
9696
9797pub fn hasFlag(symbol: Symbol, flag: Flag) bool {
98 return symbol.flags & @enumToInt(flag) != 0;
98 return symbol.flags & @intFromEnum(flag) != 0;
9999}
100100
101101pub fn setFlag(symbol: *Symbol, flag: Flag) void {
102 symbol.flags |= @enumToInt(flag);
102 symbol.flags |= @intFromEnum(flag);
103103}
104104
105105pub fn isUndefined(symbol: Symbol) bool {
106 return symbol.flags & @enumToInt(Flag.WASM_SYM_UNDEFINED) != 0;
106 return symbol.flags & @intFromEnum(Flag.WASM_SYM_UNDEFINED) != 0;
107107}
108108
109109pub fn setUndefined(symbol: *Symbol, is_undefined: bool) void {
110110 if (is_undefined) {
111111 symbol.setFlag(.WASM_SYM_UNDEFINED);
112112 } else {
113 symbol.flags &= ~@enumToInt(Flag.WASM_SYM_UNDEFINED);
113 symbol.flags &= ~@intFromEnum(Flag.WASM_SYM_UNDEFINED);
114114 }
115115}
116116
117117pub fn setGlobal(symbol: *Symbol, is_global: bool) void {
118118 if (is_global) {
119 symbol.flags &= ~@enumToInt(Flag.WASM_SYM_BINDING_LOCAL);
119 symbol.flags &= ~@intFromEnum(Flag.WASM_SYM_BINDING_LOCAL);
120120 } else {
121121 symbol.setFlag(.WASM_SYM_BINDING_LOCAL);
122122 }
......@@ -127,23 +127,23 @@ pub fn isDefined(symbol: Symbol) bool {
127127}
128128
129129pub fn isVisible(symbol: Symbol) bool {
130 return symbol.flags & @enumToInt(Flag.WASM_SYM_VISIBILITY_HIDDEN) == 0;
130 return symbol.flags & @intFromEnum(Flag.WASM_SYM_VISIBILITY_HIDDEN) == 0;
131131}
132132
133133pub fn isLocal(symbol: Symbol) bool {
134 return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_LOCAL) != 0;
134 return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_LOCAL) != 0;
135135}
136136
137137pub fn isGlobal(symbol: Symbol) bool {
138 return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_LOCAL) == 0;
138 return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_LOCAL) == 0;
139139}
140140
141141pub fn isHidden(symbol: Symbol) bool {
142 return symbol.flags & @enumToInt(Flag.WASM_SYM_VISIBILITY_HIDDEN) != 0;
142 return symbol.flags & @intFromEnum(Flag.WASM_SYM_VISIBILITY_HIDDEN) != 0;
143143}
144144
145145pub fn isNoStrip(symbol: Symbol) bool {
146 return symbol.flags & @enumToInt(Flag.WASM_SYM_NO_STRIP) != 0;
146 return symbol.flags & @intFromEnum(Flag.WASM_SYM_NO_STRIP) != 0;
147147}
148148
149149pub fn isExported(symbol: Symbol, is_dynamic: bool) bool {
......@@ -153,7 +153,7 @@ pub fn isExported(symbol: Symbol, is_dynamic: bool) bool {
153153}
154154
155155pub fn isWeak(symbol: Symbol) bool {
156 return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_WEAK) != 0;
156 return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_WEAK) != 0;
157157}
158158
159159/// Formats the symbol into human-readable text
src/link/Wasm/types.zig+2-2
......@@ -118,7 +118,7 @@ pub const Segment = struct {
118118 flags: u32,
119119
120120 pub fn isTLS(segment: Segment) bool {
121 return segment.flags & @enumToInt(Flags.WASM_SEG_FLAG_TLS) != 0;
121 return segment.flags & @intFromEnum(Flags.WASM_SEG_FLAG_TLS) != 0;
122122 }
123123
124124 /// Returns the name as how it will be output into the final object
......@@ -205,7 +205,7 @@ pub const Feature = struct {
205205
206206 /// From a given cpu feature, returns its linker feature
207207 pub fn fromCpuFeature(feature: std.Target.wasm.Feature) Tag {
208 return @intToEnum(Tag, @enumToInt(feature));
208 return @enumFromInt(Tag, @intFromEnum(feature));
209209 }
210210
211211 pub fn format(tag: Tag, comptime fmt: []const u8, opt: std.fmt.FormatOptions, writer: anytype) !void {
src/main.zig+8-8
......@@ -140,8 +140,8 @@ pub fn log(
140140 // Hide debug messages unless:
141141 // * logging enabled with `-Dlog`.
142142 // * the --debug-log arg for the scope has been provided
143 if (@enumToInt(level) > @enumToInt(std.options.log_level) or
144 @enumToInt(level) > @enumToInt(std.log.Level.info))
143 if (@intFromEnum(level) > @intFromEnum(std.options.log_level) or
144 @intFromEnum(level) > @intFromEnum(std.log.Level.info))
145145 {
146146 if (!build_options.enable_logging) return;
147147
......@@ -2424,8 +2424,8 @@ fn buildOutputType(
24242424 fatal("shared memory is not allowed in object files", .{});
24252425 }
24262426
2427 if (!target_info.target.cpu.features.isEnabled(@enumToInt(std.Target.wasm.Feature.atomics)) or
2428 !target_info.target.cpu.features.isEnabled(@enumToInt(std.Target.wasm.Feature.bulk_memory)))
2427 if (!target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.atomics)) or
2428 !target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.bulk_memory)))
24292429 {
24302430 fatal("'atomics' and 'bulk-memory' features must be enabled to use shared memory", .{});
24312431 }
......@@ -2640,7 +2640,7 @@ fn buildOutputType(
26402640
26412641 if (output_mode == .Obj and (object_format == .coff or object_format == .macho)) {
26422642 const total_obj_count = c_source_files.items.len +
2643 @boolToInt(root_src_file != null) +
2643 @intFromBool(root_src_file != null) +
26442644 link_objects.items.len;
26452645 if (total_obj_count > 1) {
26462646 fatal("{s} does not support linking multiple objects into one", .{@tagName(object_format)});
......@@ -3466,7 +3466,7 @@ fn serve(
34663466 }
34673467 },
34683468 else => {
3469 fatal("unrecognized message from client: 0x{x}", .{@enumToInt(hdr.tag)});
3469 fatal("unrecognized message from client: 0x{x}", .{@intFromEnum(hdr.tag)});
34703470 },
34713471 }
34723472 }
......@@ -4706,7 +4706,7 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
47064706 defer gpa.free(formatted);
47074707
47084708 if (check_flag) {
4709 const code: u8 = @boolToInt(mem.eql(u8, formatted, source_code));
4709 const code: u8 = @intFromBool(mem.eql(u8, formatted, source_code));
47104710 process.exit(code);
47114711 }
47124712
......@@ -5080,7 +5080,7 @@ pub fn lldMain(
50805080 unreachable;
50815081 }
50825082 };
5083 return @boolToInt(!ok);
5083 return @intFromBool(!ok);
50845084}
50855085
50865086const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true, .single_quotes = true });
src/objcopy.zig+2-2
......@@ -544,7 +544,7 @@ const HexWriter = struct {
544544 const parts = addressParts(self.address);
545545 sum +%= parts[0];
546546 sum +%= parts[1];
547 sum +%= @enumToInt(self.payload);
547 sum +%= @intFromEnum(self.payload);
548548 for (payload_bytes) |byte| {
549549 sum +%= byte;
550550 }
......@@ -562,7 +562,7 @@ const HexWriter = struct {
562562 const line = try std.fmt.bufPrint(&outbuf, ":{0X:0>2}{1X:0>4}{2X:0>2}{3s}{4X:0>2}" ++ linesep, .{
563563 @intCast(u8, payload_bytes.len),
564564 self.address,
565 @enumToInt(self.payload),
565 @intFromEnum(self.payload),
566566 std.fmt.fmtSliceHexUpper(payload_bytes),
567567 self.checksum(),
568568 });
src/print_air.zig+6-6
......@@ -183,8 +183,8 @@ const Writer = struct {
183183 .is_non_err,
184184 .is_err_ptr,
185185 .is_non_err_ptr,
186 .ptrtoint,
187 .bool_to_int,
186 .int_from_ptr,
187 .int_from_bool,
188188 .ret,
189189 .ret_load,
190190 .is_named_enum_value,
......@@ -254,10 +254,10 @@ const Writer = struct {
254254 .struct_field_ptr_index_2,
255255 .struct_field_ptr_index_3,
256256 .array_to_slice,
257 .int_to_float,
257 .float_from_int,
258258 .splat,
259 .float_to_int,
260 .float_to_int_optimized,
259 .int_from_float,
260 .int_from_float_optimized,
261261 .get_union_tag,
262262 .clz,
263263 .ctz,
......@@ -956,7 +956,7 @@ const Writer = struct {
956956 operand: Air.Inst.Ref,
957957 dies: bool,
958958 ) @TypeOf(s).Error!void {
959 const i = @enumToInt(operand);
959 const i = @intFromEnum(operand);
960960
961961 if (i < InternPool.static_len) {
962962 return s.print("@{}", .{operand});
src/print_zir.zig+45-45
......@@ -36,7 +36,7 @@ pub fn renderAsTextToFile(
3636 try stream.print("%{d} ", .{main_struct_inst});
3737 try writer.writeInstToStream(stream, main_struct_inst);
3838 try stream.writeAll("\n");
39 const imports_index = scope_file.zir.extra[@enumToInt(Zir.ExtraIndex.imports)];
39 const imports_index = scope_file.zir.extra[@intFromEnum(Zir.ExtraIndex.imports)];
4040 if (imports_index != 0) {
4141 try stream.writeAll("Imports:\n");
4242
......@@ -187,12 +187,12 @@ const Writer = struct {
187187 .size_of,
188188 .bit_size_of,
189189 .typeof_log2_int_type,
190 .ptr_to_int,
190 .int_from_ptr,
191191 .compile_error,
192192 .set_eval_branch_quota,
193 .enum_to_int,
193 .int_from_enum,
194194 .align_of,
195 .bool_to_int,
195 .int_from_bool,
196196 .embed_file,
197197 .error_name,
198198 .panic,
......@@ -321,10 +321,10 @@ const Writer = struct {
321321 .merge_error_sets,
322322 .bit_and,
323323 .bit_or,
324 .float_to_int,
325 .int_to_float,
326 .int_to_ptr,
327 .int_to_enum,
324 .int_from_float,
325 .float_from_int,
326 .ptr_from_int,
327 .enum_from_int,
328328 .float_cast,
329329 .int_cast,
330330 .ptr_cast,
......@@ -502,8 +502,8 @@ const Writer = struct {
502502 .set_align_stack,
503503 .set_cold,
504504 .wasm_memory_size,
505 .error_to_int,
506 .int_to_error,
505 .int_from_error,
506 .error_from_int,
507507 .reify,
508508 .c_va_copy,
509509 .c_va_end,
......@@ -559,7 +559,7 @@ const Writer = struct {
559559 fn writeElemTypeIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
560560 const inst_data = self.code.instructions.items(.data)[inst].bin;
561561 try self.writeInstRef(stream, inst_data.lhs);
562 try stream.print(", {d})", .{@enumToInt(inst_data.rhs)});
562 try stream.print(", {d})", .{@intFromEnum(inst_data.rhs)});
563563 }
564564
565565 fn writeUnNode(
......@@ -632,25 +632,25 @@ const Writer = struct {
632632 var extra_index = extra.end;
633633 if (inst_data.flags.has_sentinel) {
634634 try stream.writeAll(", ");
635 try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]));
635 try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]));
636636 extra_index += 1;
637637 }
638638 if (inst_data.flags.has_align) {
639639 try stream.writeAll(", align(");
640 try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]));
640 try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]));
641641 extra_index += 1;
642642 if (inst_data.flags.has_bit_range) {
643 const bit_start = extra_index + @boolToInt(inst_data.flags.has_addrspace);
643 const bit_start = extra_index + @intFromBool(inst_data.flags.has_addrspace);
644644 try stream.writeAll(":");
645 try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[bit_start]));
645 try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[bit_start]));
646646 try stream.writeAll(":");
647 try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[bit_start + 1]));
647 try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[bit_start + 1]));
648648 }
649649 try stream.writeAll(")");
650650 }
651651 if (inst_data.flags.has_addrspace) {
652652 try stream.writeAll(", addrspace(");
653 try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]));
653 try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]));
654654 try stream.writeAll(")");
655655 }
656656 try stream.writeAll(") ");
......@@ -1084,7 +1084,7 @@ const Writer = struct {
10841084
10851085 try self.writeFlag(stream, "volatile, ", is_volatile);
10861086 if (tmpl_is_expr) {
1087 try self.writeInstRef(stream, @intToEnum(Zir.Inst.Ref, extra.data.asm_source));
1087 try self.writeInstRef(stream, @enumFromInt(Zir.Inst.Ref, extra.data.asm_source));
10881088 try stream.writeAll(", ");
10891089 } else {
10901090 const asm_source = self.code.nullTerminatedString(extra.data.asm_source);
......@@ -1179,7 +1179,7 @@ const Writer = struct {
11791179 if (extra.data.flags.ensure_result_used) {
11801180 try stream.writeAll("nodiscard ");
11811181 }
1182 try stream.print(".{s}, ", .{@tagName(@intToEnum(std.builtin.CallModifier, extra.data.flags.packed_modifier))});
1182 try stream.print(".{s}, ", .{@tagName(@enumFromInt(std.builtin.CallModifier, extra.data.flags.packed_modifier))});
11831183 switch (kind) {
11841184 .direct => try self.writeInstRef(stream, extra.data.callee),
11851185 .field => {
......@@ -1287,7 +1287,7 @@ const Writer = struct {
12871287 extra_index += 1;
12881288 try stream.writeAll("Packed(");
12891289 if (backing_int_body_len == 0) {
1290 const backing_int_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1290 const backing_int_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
12911291 extra_index += 1;
12921292 try self.writeInstRef(stream, backing_int_ref);
12931293 } else {
......@@ -1369,7 +1369,7 @@ const Writer = struct {
13691369 if (has_type_body) {
13701370 fields[field_i].type_len = self.code.extra[extra_index];
13711371 } else {
1372 fields[field_i].type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1372 fields[field_i].type = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
13731373 }
13741374 extra_index += 1;
13751375
......@@ -1454,7 +1454,7 @@ const Writer = struct {
14541454 } else null;
14551455
14561456 const tag_type_ref = if (small.has_tag_type) blk: {
1457 const tag_type_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1457 const tag_type_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
14581458 extra_index += 1;
14591459 break :blk tag_type_ref;
14601460 } else .none;
......@@ -1552,14 +1552,14 @@ const Writer = struct {
15521552 try stream.print("{}", .{std.zig.fmtId(field_name)});
15531553
15541554 if (has_type) {
1555 const field_type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1555 const field_type = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
15561556 extra_index += 1;
15571557
15581558 try stream.writeAll(": ");
15591559 try self.writeInstRef(stream, field_type);
15601560 }
15611561 if (has_align) {
1562 const align_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1562 const align_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
15631563 extra_index += 1;
15641564
15651565 try stream.writeAll(" align(");
......@@ -1567,7 +1567,7 @@ const Writer = struct {
15671567 try stream.writeAll(")");
15681568 }
15691569 if (has_value) {
1570 const default_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1570 const default_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
15711571 extra_index += 1;
15721572
15731573 try stream.writeAll(" = ");
......@@ -1618,17 +1618,17 @@ const Writer = struct {
16181618 extra_index += 1;
16191619
16201620 const align_inst: Zir.Inst.Ref = if (!has_align) .none else inst: {
1621 const inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1621 const inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
16221622 extra_index += 1;
16231623 break :inst inst;
16241624 };
16251625 const section_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: {
1626 const inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1626 const inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
16271627 extra_index += 1;
16281628 break :inst inst;
16291629 };
16301630 const addrspace_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: {
1631 const inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1631 const inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
16321632 extra_index += 1;
16331633 break :inst inst;
16341634 };
......@@ -1712,7 +1712,7 @@ const Writer = struct {
17121712 } else null;
17131713
17141714 const tag_type_ref = if (small.has_tag_type) blk: {
1715 const tag_type_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1715 const tag_type_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
17161716 extra_index += 1;
17171717 break :blk tag_type_ref;
17181718 } else .none;
......@@ -1797,7 +1797,7 @@ const Writer = struct {
17971797 try stream.print("{}", .{std.zig.fmtId(field_name)});
17981798
17991799 if (has_tag_value) {
1800 const tag_value_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1800 const tag_value_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
18011801 extra_index += 1;
18021802
18031803 try stream.writeAll(" = ");
......@@ -1940,7 +1940,7 @@ const Writer = struct {
19401940 const scalar_cases_len = extra.data.bits.scalar_cases_len;
19411941 var scalar_i: usize = 0;
19421942 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
1943 const item_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1943 const item_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
19441944 extra_index += 1;
19451945 const info = @bitCast(Zir.Inst.SwitchBlock.ProngInfo, self.code.extra[extra_index]);
19461946 extra_index += 1;
......@@ -1988,9 +1988,9 @@ const Writer = struct {
19881988
19891989 var range_i: usize = 0;
19901990 while (range_i < ranges_len) : (range_i += 1) {
1991 const item_first = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1991 const item_first = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
19921992 extra_index += 1;
1993 const item_last = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1993 const item_last = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
19941994 extra_index += 1;
19951995
19961996 if (range_i != 0 or items.len != 0) {
......@@ -2091,7 +2091,7 @@ const Writer = struct {
20912091 ret_ty_ref = .void_type;
20922092 },
20932093 1 => {
2094 ret_ty_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2094 ret_ty_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
20952095 extra_index += 1;
20962096 },
20972097 else => {
......@@ -2162,7 +2162,7 @@ const Writer = struct {
21622162 align_body = self.code.extra[extra_index..][0..body_len];
21632163 extra_index += align_body.len;
21642164 } else if (extra.data.bits.has_align_ref) {
2165 align_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2165 align_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
21662166 extra_index += 1;
21672167 }
21682168 if (extra.data.bits.has_addrspace_body) {
......@@ -2171,7 +2171,7 @@ const Writer = struct {
21712171 addrspace_body = self.code.extra[extra_index..][0..body_len];
21722172 extra_index += addrspace_body.len;
21732173 } else if (extra.data.bits.has_addrspace_ref) {
2174 addrspace_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2174 addrspace_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
21752175 extra_index += 1;
21762176 }
21772177 if (extra.data.bits.has_section_body) {
......@@ -2180,7 +2180,7 @@ const Writer = struct {
21802180 section_body = self.code.extra[extra_index..][0..body_len];
21812181 extra_index += section_body.len;
21822182 } else if (extra.data.bits.has_section_ref) {
2183 section_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2183 section_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
21842184 extra_index += 1;
21852185 }
21862186 if (extra.data.bits.has_cc_body) {
......@@ -2189,7 +2189,7 @@ const Writer = struct {
21892189 cc_body = self.code.extra[extra_index..][0..body_len];
21902190 extra_index += cc_body.len;
21912191 } else if (extra.data.bits.has_cc_ref) {
2192 cc_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2192 cc_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
21932193 extra_index += 1;
21942194 }
21952195 if (extra.data.bits.has_ret_ty_body) {
......@@ -2198,7 +2198,7 @@ const Writer = struct {
21982198 ret_ty_body = self.code.extra[extra_index..][0..body_len];
21992199 extra_index += ret_ty_body.len;
22002200 } else if (extra.data.bits.has_ret_ty_ref) {
2201 ret_ty_ref = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2201 ret_ty_ref = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
22022202 extra_index += 1;
22032203 }
22042204
......@@ -2251,12 +2251,12 @@ const Writer = struct {
22512251 try stream.print(", lib_name=\"{}\"", .{std.zig.fmtEscapes(lib_name)});
22522252 }
22532253 const align_inst: Zir.Inst.Ref = if (!small.has_align) .none else blk: {
2254 const align_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2254 const align_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
22552255 extra_index += 1;
22562256 break :blk align_inst;
22572257 };
22582258 const init_inst: Zir.Inst.Ref = if (!small.has_init) .none else blk: {
2259 const init_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2259 const init_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
22602260 extra_index += 1;
22612261 break :blk init_inst;
22622262 };
......@@ -2274,12 +2274,12 @@ const Writer = struct {
22742274
22752275 var extra_index: usize = extra.end;
22762276 const type_inst: Zir.Inst.Ref = if (!small.has_type) .none else blk: {
2277 const type_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2277 const type_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
22782278 extra_index += 1;
22792279 break :blk type_inst;
22802280 };
22812281 const align_inst: Zir.Inst.Ref = if (!small.has_align) .none else blk: {
2282 const align_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
2282 const align_inst = @enumFromInt(Zir.Inst.Ref, self.code.extra[extra_index]);
22832283 extra_index += 1;
22842284 break :blk align_inst;
22852285 };
......@@ -2480,8 +2480,8 @@ const Writer = struct {
24802480 }
24812481
24822482 fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void {
2483 const i = @enumToInt(ref);
2484 if (i < InternPool.static_len) return stream.print("@{}", .{@intToEnum(InternPool.Index, i)});
2483 const i = @intFromEnum(ref);
2484 if (i < InternPool.static_len) return stream.print("@{}", .{@enumFromInt(InternPool.Index, i)});
24852485 return self.writeInstIndex(stream, i - InternPool.static_len);
24862486 }
24872487
src/register_manager.zig+6-6
......@@ -366,7 +366,7 @@ const MockRegister1 = enum(u2) {
366366 r3,
367367
368368 pub fn id(reg: MockRegister1) u2 {
369 return @enumToInt(reg);
369 return @intFromEnum(reg);
370370 }
371371
372372 const allocatable_registers = [_]MockRegister1{ .r2, .r3 };
......@@ -394,7 +394,7 @@ const MockRegister2 = enum(u2) {
394394 r3,
395395
396396 pub fn id(reg: MockRegister2) u2 {
397 return @enumToInt(reg);
397 return @intFromEnum(reg);
398398 }
399399
400400 const allocatable_registers = [_]MockRegister2{ .r0, .r1, .r2, .r3 };
......@@ -426,14 +426,14 @@ const MockRegister3 = enum(u3) {
426426 x3,
427427
428428 pub fn id(reg: MockRegister3) u3 {
429 return switch (@enumToInt(reg)) {
430 0...3 => @as(u3, @truncate(u2, @enumToInt(reg))),
431 4...7 => @enumToInt(reg),
429 return switch (@intFromEnum(reg)) {
430 0...3 => @as(u3, @truncate(u2, @intFromEnum(reg))),
431 4...7 => @intFromEnum(reg),
432432 };
433433 }
434434
435435 pub fn enc(reg: MockRegister3) u2 {
436 return @truncate(u2, @enumToInt(reg));
436 return @truncate(u2, @intFromEnum(reg));
437437 }
438438
439439 const gp_regs = [_]MockRegister3{ .r0, .r1, .r2, .r3 };
src/translate_c.zig+108-108
......@@ -110,7 +110,7 @@ const Scope = struct {
110110 if (self.base.parent.?.id == .do_loop) {
111111 // We reserve 1 extra statement if the parent is a do_loop. This is in case of
112112 // do while, we want to put `if (cond) break;` at the end.
113 const alloc_len = self.statements.items.len + @boolToInt(self.base.parent.?.id == .do_loop);
113 const alloc_len = self.statements.items.len + @intFromBool(self.base.parent.?.id == .do_loop);
114114 var stmts = try c.arena.alloc(Node, alloc_len);
115115 stmts.len = self.statements.items.len;
116116 @memcpy(stmts[0..self.statements.items.len], self.statements.items);
......@@ -507,14 +507,14 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void {
507507 const enum_decl = enum_ty.getDecl();
508508 // check if this decl is unnamed
509509 if (@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin()[0] != 0) return;
510 break @ptrToInt(enum_decl.getCanonicalDecl());
510 break @intFromPtr(enum_decl.getCanonicalDecl());
511511 },
512512 .Record => {
513513 const record_ty = @ptrCast(*const clang.RecordType, child_ty);
514514 const record_decl = record_ty.getDecl();
515515 // check if this decl is unnamed
516516 if (@ptrCast(*const clang.NamedDecl, record_decl).getName_bytes_begin()[0] != 0) return;
517 break @ptrToInt(record_decl.getCanonicalDecl());
517 break @intFromPtr(record_decl.getCanonicalDecl());
518518 },
519519 .Elaborated => {
520520 const elaborated_ty = @ptrCast(*const clang.ElaboratedType, child_ty);
......@@ -543,7 +543,7 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void {
543543 }
544544 result.value_ptr.* = decl_name;
545545 // Put this typedef in the decl_table to avoid redefinitions.
546 try c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), decl_name);
546 try c.decl_table.putNoClobber(c.gpa, @intFromPtr(typedef_decl.getCanonicalDecl()), decl_name);
547547 try c.typedefs.put(c.gpa, decl_name, {});
548548 }
549549 }
......@@ -845,7 +845,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co
845845 error.OutOfMemory => |e| return e,
846846 };
847847 if (!qualTypeIsBoolean(qual_type) and isBoolRes(init_node.?)) {
848 init_node = try Tag.bool_to_int.create(c.arena, init_node.?);
848 init_node = try Tag.int_from_bool.create(c.arena, init_node.?);
849849 } else if (init_node.?.tag() == .string_literal and qualTypeIsCharStar(qual_type)) {
850850 init_node = try stringLiteralToCharStar(c, init_node.?);
851851 }
......@@ -913,7 +913,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{
913913});
914914
915915fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void {
916 if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |_|
916 if (c.decl_table.get(@intFromPtr(typedef_decl.getCanonicalDecl()))) |_|
917917 return; // Avoid processing this decl twice
918918 const toplevel = scope.id == .root;
919919 const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined;
......@@ -922,10 +922,10 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa
922922 try c.typedefs.put(c.gpa, name, {});
923923
924924 if (builtin_typedef_map.get(name)) |builtin| {
925 return c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), builtin);
925 return c.decl_table.putNoClobber(c.gpa, @intFromPtr(typedef_decl.getCanonicalDecl()), builtin);
926926 }
927927 if (!toplevel) name = try bs.makeMangledName(c, name);
928 try c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), name);
928 try c.decl_table.putNoClobber(c.gpa, @intFromPtr(typedef_decl.getCanonicalDecl()), name);
929929
930930 const child_qt = typedef_decl.getUnderlyingType();
931931 const typedef_loc = typedef_decl.getLocation();
......@@ -938,7 +938,7 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa
938938
939939 const payload = try c.arena.create(ast.Payload.SimpleVarDecl);
940940 payload.* = .{
941 .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(toplevel)] },
941 .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@intFromBool(toplevel)] },
942942 .data = .{
943943 .name = name,
944944 .init = init_node,
......@@ -1063,7 +1063,7 @@ fn hasFlexibleArrayField(c: *Context, record_def: *const clang.RecordDecl) bool
10631063}
10641064
10651065fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void {
1066 if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |_|
1066 if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |_|
10671067 return; // Avoid processing this decl twice
10681068 const record_loc = record_decl.getLocation();
10691069 const toplevel = scope.id == .root;
......@@ -1079,13 +1079,13 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
10791079 } else if (record_decl.isStruct()) {
10801080 container_kind_name = "struct";
10811081 } else {
1082 try c.decl_table.putNoClobber(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), bare_name);
1082 try c.decl_table.putNoClobber(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), bare_name);
10831083 return failDecl(c, record_loc, bare_name, "record {s} is not a struct or union", .{bare_name});
10841084 }
10851085
10861086 var is_unnamed = false;
10871087 var name = bare_name;
1088 if (c.unnamed_typedefs.get(@ptrToInt(record_decl.getCanonicalDecl()))) |typedef_name| {
1088 if (c.unnamed_typedefs.get(@intFromPtr(record_decl.getCanonicalDecl()))) |typedef_name| {
10891089 bare_name = typedef_name;
10901090 name = typedef_name;
10911091 } else {
......@@ -1098,12 +1098,12 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
10981098 name = try std.fmt.allocPrint(c.arena, "{s}_{s}", .{ container_kind_name, bare_name });
10991099 }
11001100 if (!toplevel) name = try bs.makeMangledName(c, name);
1101 try c.decl_table.putNoClobber(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), name);
1101 try c.decl_table.putNoClobber(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), name);
11021102
11031103 const is_pub = toplevel and !is_unnamed;
11041104 const init_node = blk: {
11051105 const record_def = record_decl.getDefinition() orelse {
1106 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
1106 try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {});
11071107 break :blk Tag.opaque_literal.init();
11081108 };
11091109
......@@ -1126,7 +1126,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
11261126 const field_qt = field_decl.getType();
11271127
11281128 if (field_decl.isBitField()) {
1129 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
1129 try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {});
11301130 try warn(c, scope, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name});
11311131 break :blk Tag.opaque_literal.init();
11321132 }
......@@ -1142,7 +1142,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
11421142 if (isFlexibleArrayFieldDecl(c, field_decl)) {
11431143 const flexible_array_fn = buildFlexibleArrayFn(c, scope, layout, field_name, field_decl) catch |err| switch (err) {
11441144 error.UnsupportedType => {
1145 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
1145 try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {});
11461146 try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of flexible array field {s}", .{ container_kind_name, field_name });
11471147 break :blk Tag.opaque_literal.init();
11481148 },
......@@ -1153,7 +1153,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
11531153 }
11541154 const field_type = transQualType(c, scope, field_qt, field_loc) catch |err| switch (err) {
11551155 error.UnsupportedType => {
1156 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
1156 try c.opaque_demotes.put(c.gpa, @intFromPtr(record_decl.getCanonicalDecl()), {});
11571157 try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, field_name });
11581158 break :blk Tag.opaque_literal.init();
11591159 },
......@@ -1166,7 +1166,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
11661166 ClangAlignment.forField(c, field_decl, record_def).zigAlignment();
11671167
11681168 if (is_anon) {
1169 try c.decl_table.putNoClobber(c.gpa, @ptrToInt(field_decl.getCanonicalDecl()), field_name);
1169 try c.decl_table.putNoClobber(c.gpa, @intFromPtr(field_decl.getCanonicalDecl()), field_name);
11701170 }
11711171
11721172 try fields.append(.{
......@@ -1178,7 +1178,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
11781178
11791179 const record_payload = try c.arena.create(ast.Payload.Record);
11801180 record_payload.* = .{
1181 .base = .{ .tag = ([2]Tag{ .@"struct", .@"union" })[@boolToInt(is_union)] },
1181 .base = .{ .tag = ([2]Tag{ .@"struct", .@"union" })[@intFromBool(is_union)] },
11821182 .data = .{
11831183 .layout = .@"extern",
11841184 .fields = try c.arena.dupe(ast.Payload.Record.Field, fields.items),
......@@ -1191,7 +1191,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
11911191
11921192 const payload = try c.arena.create(ast.Payload.SimpleVarDecl);
11931193 payload.* = .{
1194 .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(is_pub)] },
1194 .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@intFromBool(is_pub)] },
11951195 .data = .{
11961196 .name = name,
11971197 .init = init_node,
......@@ -1211,7 +1211,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
12111211}
12121212
12131213fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void {
1214 if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |_|
1214 if (c.decl_table.get(@intFromPtr(enum_decl.getCanonicalDecl()))) |_|
12151215 return; // Avoid processing this decl twice
12161216 const enum_loc = enum_decl.getLocation();
12171217 const toplevel = scope.id == .root;
......@@ -1220,7 +1220,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E
12201220 var is_unnamed = false;
12211221 var bare_name: []const u8 = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin());
12221222 var name = bare_name;
1223 if (c.unnamed_typedefs.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |typedef_name| {
1223 if (c.unnamed_typedefs.get(@intFromPtr(enum_decl.getCanonicalDecl()))) |typedef_name| {
12241224 bare_name = typedef_name;
12251225 name = typedef_name;
12261226 } else {
......@@ -1231,7 +1231,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E
12311231 name = try std.fmt.allocPrint(c.arena, "enum_{s}", .{bare_name});
12321232 }
12331233 if (!toplevel) name = try bs.makeMangledName(c, name);
1234 try c.decl_table.putNoClobber(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), name);
1234 try c.decl_table.putNoClobber(c.gpa, @intFromPtr(enum_decl.getCanonicalDecl()), name);
12351235
12361236 const enum_type_node = if (enum_decl.getDefinition()) |enum_def| blk: {
12371237 var it = enum_def.enumerator_begin();
......@@ -1280,14 +1280,14 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E
12801280 else
12811281 try Tag.type.create(c.arena, "c_int");
12821282 } else blk: {
1283 try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {});
1283 try c.opaque_demotes.put(c.gpa, @intFromPtr(enum_decl.getCanonicalDecl()), {});
12841284 break :blk Tag.opaque_literal.init();
12851285 };
12861286
12871287 const is_pub = toplevel and !is_unnamed;
12881288 const payload = try c.arena.create(ast.Payload.SimpleVarDecl);
12891289 payload.* = .{
1290 .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@boolToInt(is_pub)] },
1290 .base = .{ .tag = ([2]Tag{ .var_simple, .pub_var_simple })[@intFromBool(is_pub)] },
12911291 .data = .{
12921292 .init = enum_type_node,
12931293 .name = name,
......@@ -1536,7 +1536,7 @@ fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransEr
15361536 if (component.getKind() == .Field) {
15371537 const field_decl = component.getField();
15381538 if (field_decl.getParent()) |record_decl| {
1539 if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |type_name| {
1539 if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |type_name| {
15401540 const type_node = try Tag.type.create(c.arena, type_name);
15411541
15421542 var raw_field_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin());
......@@ -1753,22 +1753,22 @@ fn transBinaryOperator(
17531753 const rhs_uncasted = try transExpr(c, scope, stmt.getRHS(), .used);
17541754
17551755 const lhs = if (isBoolRes(lhs_uncasted))
1756 try Tag.bool_to_int.create(c.arena, lhs_uncasted)
1756 try Tag.int_from_bool.create(c.arena, lhs_uncasted)
17571757 else if (isPointerDiffExpr)
1758 try Tag.ptr_to_int.create(c.arena, lhs_uncasted)
1758 try Tag.int_from_ptr.create(c.arena, lhs_uncasted)
17591759 else
17601760 lhs_uncasted;
17611761
17621762 const rhs = if (isBoolRes(rhs_uncasted))
1763 try Tag.bool_to_int.create(c.arena, rhs_uncasted)
1763 try Tag.int_from_bool.create(c.arena, rhs_uncasted)
17641764 else if (isPointerDiffExpr)
1765 try Tag.ptr_to_int.create(c.arena, rhs_uncasted)
1765 try Tag.int_from_ptr.create(c.arena, rhs_uncasted)
17661766 else
17671767 rhs_uncasted;
17681768
17691769 const infixOpNode = try transCreateNodeInfixOp(c, op_id, lhs, rhs, result_used);
17701770 if (isPointerDiffExpr) {
1771 // @divExact(@bitCast(<platform-ptrdiff_t>, @ptrToInt(lhs) -% @ptrToInt(rhs)), @sizeOf(<lhs target type>))
1771 // @divExact(@bitCast(<platform-ptrdiff_t>, @intFromPtr(lhs) -% @intFromPtr(rhs)), @sizeOf(<lhs target type>))
17721772 const ptrdiff_type = try transQualTypeIntWidthOf(c, qt, true);
17731773
17741774 // C standard requires that pointer subtraction operands are of the same type,
......@@ -1944,7 +1944,7 @@ fn transDeclStmtOne(
19441944 else
19451945 Tag.undefined_literal.init();
19461946 if (!qualTypeIsBoolean(qual_type) and isBoolRes(init_node)) {
1947 init_node = try Tag.bool_to_int.create(c.arena, init_node);
1947 init_node = try Tag.int_from_bool.create(c.arena, init_node);
19481948 } else if (init_node.tag() == .string_literal and qualTypeIsCharStar(qual_type)) {
19491949 const dst_type_node = try transQualType(c, scope, qual_type, loc);
19501950 init_node = try removeCVQualifiers(c, dst_type_node, init_node);
......@@ -2074,11 +2074,11 @@ fn transImplicitCastExpr(
20742074 return Tag.null_literal.init();
20752075 },
20762076 .PointerToBoolean => {
2077 // @ptrToInt(val) != 0
2077 // @intFromPtr(val) != 0
20782078 const ptr_node = try transExpr(c, scope, sub_expr, .used);
2079 const ptr_to_int = try Tag.ptr_to_int.create(c.arena, ptr_node);
2079 const int_from_ptr = try Tag.int_from_ptr.create(c.arena, ptr_node);
20802080
2081 const ne = try Tag.not_equal.create(c.arena, .{ .lhs = ptr_to_int, .rhs = Tag.zero_literal.init() });
2081 const ne = try Tag.not_equal.create(c.arena, .{ .lhs = int_from_ptr, .rhs = Tag.zero_literal.init() });
20822082 return maybeSuppressResult(c, result_used, ne);
20832083 },
20842084 .IntegralToBoolean, .FloatingToBoolean => {
......@@ -2138,7 +2138,7 @@ fn transBoolExpr(
21382138 return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "invalid integer literal", .{});
21392139 }
21402140 const is_zero = signum == 0;
2141 return Node{ .tag_if_small_enough = @enumToInt(([2]Tag{ .true_literal, .false_literal })[@boolToInt(is_zero)]) };
2141 return Node{ .tag_if_small_enough = @intFromEnum(([2]Tag{ .true_literal, .false_literal })[@intFromBool(is_zero)]) };
21422142 }
21432143
21442144 var res = try transExpr(c, scope, expr, used);
......@@ -2334,7 +2334,7 @@ fn transReturnStmt(
23342334 var rhs = try transExprCoercing(c, scope, val_expr, .used);
23352335 const return_qt = scope.findBlockReturnType();
23362336 if (isBoolRes(rhs) and !qualTypeIsBoolean(return_qt)) {
2337 rhs = try Tag.bool_to_int.create(c.arena, rhs);
2337 rhs = try Tag.int_from_bool.create(c.arena, rhs);
23382338 }
23392339 return Tag.@"return".create(c.arena, rhs);
23402340}
......@@ -2493,7 +2493,7 @@ fn transCCast(
24932493 var src_int_expr = expr;
24942494
24952495 if (isBoolRes(src_int_expr)) {
2496 src_int_expr = try Tag.bool_to_int.create(c.arena, src_int_expr);
2496 src_int_expr = try Tag.int_from_bool.create(c.arena, src_int_expr);
24972497 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = src_int_expr });
24982498 }
24992499
......@@ -2521,34 +2521,34 @@ fn transCCast(
25212521 return Tag.bit_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
25222522 }
25232523 if (cIsInteger(dst_type) and qualTypeIsPtr(src_type)) {
2524 // @intCast(dest_type, @ptrToInt(val))
2525 const ptr_to_int = try Tag.ptr_to_int.create(c.arena, expr);
2526 return Tag.int_cast.create(c.arena, .{ .lhs = dst_node, .rhs = ptr_to_int });
2524 // @intCast(dest_type, @intFromPtr(val))
2525 const int_from_ptr = try Tag.int_from_ptr.create(c.arena, expr);
2526 return Tag.int_cast.create(c.arena, .{ .lhs = dst_node, .rhs = int_from_ptr });
25272527 }
25282528 if (cIsInteger(src_type) and qualTypeIsPtr(dst_type)) {
2529 // @intToPtr(dest_type, val)
2530 return Tag.int_to_ptr.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
2529 // @ptrFromInt(dest_type, val)
2530 return Tag.ptr_from_int.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
25312531 }
25322532 if (cIsFloating(src_type) and cIsFloating(dst_type)) {
25332533 // @floatCast(dest_type, val)
25342534 return Tag.float_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
25352535 }
25362536 if (cIsFloating(src_type) and !cIsFloating(dst_type)) {
2537 // @floatToInt(dest_type, val)
2538 return Tag.float_to_int.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
2537 // @intFromFloat(dest_type, val)
2538 return Tag.int_from_float.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
25392539 }
25402540 if (!cIsFloating(src_type) and cIsFloating(dst_type)) {
25412541 var rhs = expr;
2542 if (qualTypeIsBoolean(src_type)) rhs = try Tag.bool_to_int.create(c.arena, expr);
2543 // @intToFloat(dest_type, val)
2544 return Tag.int_to_float.create(c.arena, .{ .lhs = dst_node, .rhs = rhs });
2542 if (qualTypeIsBoolean(src_type)) rhs = try Tag.int_from_bool.create(c.arena, expr);
2543 // @floatFromInt(dest_type, val)
2544 return Tag.float_from_int.create(c.arena, .{ .lhs = dst_node, .rhs = rhs });
25452545 }
25462546 if (qualTypeIsBoolean(src_type) and !qualTypeIsBoolean(dst_type)) {
2547 // @boolToInt returns either a comptime_int or a u1
2547 // @intFromBool returns a u1
25482548 // TODO: if dst_type is 1 bit & signed (bitfield) we need @bitCast
25492549 // instead of @as
2550 const bool_to_int = try Tag.bool_to_int.create(c.arena, expr);
2551 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = bool_to_int });
2550 const int_from_bool = try Tag.int_from_bool.create(c.arena, expr);
2551 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = int_from_bool });
25522552 }
25532553 // @as(dest_type, val)
25542554 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
......@@ -2599,7 +2599,7 @@ fn literalFitsInType(c: *Context, expr: *const clang.Expr, qt: clang.QualType) b
25992599 var width = qualTypeIntBitWidth(c, qt) catch 8;
26002600 if (width == 0) width = 8; // Byte is the smallest type.
26012601 const is_signed = cIsSignedInteger(qt);
2602 const width_max_int = (@as(u64, 1) << math.lossyCast(u6, width - @boolToInt(is_signed))) - 1;
2602 const width_max_int = (@as(u64, 1) << math.lossyCast(u6, width - @intFromBool(is_signed))) - 1;
26032603
26042604 switch (@ptrCast(*const clang.Stmt, expr).getStmtClass()) {
26052605 .CharacterLiteralClass => {
......@@ -2664,7 +2664,7 @@ fn transInitListExprRecord(
26642664 // .field_name = expr
26652665 var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin());
26662666 if (field_decl.isAnonymousStructOrUnion()) {
2667 const name = c.decl_table.get(@ptrToInt(field_decl.getCanonicalDecl())).?;
2667 const name = c.decl_table.get(@intFromPtr(field_decl.getCanonicalDecl())).?;
26682668 raw_name = try c.arena.dupe(u8, name);
26692669 }
26702670
......@@ -3442,7 +3442,7 @@ fn transMemberExpr(c: *Context, scope: *Scope, stmt: *const clang.MemberExpr, re
34423442 if (decl_kind == .Field) {
34433443 const field_decl = @ptrCast(*const clang.FieldDecl, member_decl);
34443444 if (field_decl.isAnonymousStructOrUnion()) {
3445 const name = c.decl_table.get(@ptrToInt(field_decl.getCanonicalDecl())).?;
3445 const name = c.decl_table.get(@intFromPtr(field_decl.getCanonicalDecl())).?;
34463446 break :blk try c.arena.dupe(u8, name);
34473447 }
34483448 }
......@@ -3642,7 +3642,7 @@ fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result
36423642 if (i < param_count) {
36433643 const param_qt = fn_proto.getParamType(@intCast(c_uint, i));
36443644 if (isBoolRes(arg) and cIsNativeInt(param_qt)) {
3645 arg = try Tag.bool_to_int.create(c.arena, arg);
3645 arg = try Tag.int_from_bool.create(c.arena, arg);
36463646 } else if (arg.tag() == .string_literal and qualTypeIsCharStar(param_qt)) {
36473647 const loc = @ptrCast(*const clang.Stmt, stmt).getBeginLoc();
36483648 const dst_type_node = try transQualType(c, scope, param_qt, loc);
......@@ -3774,7 +3774,7 @@ fn transUnaryOperator(c: *Context, scope: *Scope, stmt: *const clang.UnaryOperat
37743774 const sub_expr_node = try transExpr(c, scope, op_expr, .used);
37753775 const to_negate = if (isBoolRes(sub_expr_node)) blk: {
37763776 const ty_node = try Tag.type.create(c.arena, "c_int");
3777 const int_node = try Tag.bool_to_int.create(c.arena, sub_expr_node);
3777 const int_node = try Tag.int_from_bool.create(c.arena, sub_expr_node);
37783778 break :blk try Tag.as.create(c.arena, .{ .lhs = ty_node, .rhs = int_node });
37793779 } else sub_expr_node;
37803780 return Tag.negate.create(c.arena, to_negate);
......@@ -4026,10 +4026,10 @@ fn transCreateCompoundAssign(
40264026 return block_scope.complete(c);
40274027}
40284028
4029// Casting away const or volatile requires us to use @intToPtr
4029// Casting away const or volatile requires us to use @ptrFromInt
40304030fn removeCVQualifiers(c: *Context, dst_type_node: Node, expr: Node) Error!Node {
4031 const ptr_to_int = try Tag.ptr_to_int.create(c.arena, expr);
4032 return Tag.int_to_ptr.create(c.arena, .{ .lhs = dst_type_node, .rhs = ptr_to_int });
4031 const int_from_ptr = try Tag.int_from_ptr.create(c.arena, expr);
4032 return Tag.ptr_from_int.create(c.arena, .{ .lhs = dst_type_node, .rhs = int_from_ptr });
40334033}
40344034
40354035fn transCPtrCast(
......@@ -4132,12 +4132,12 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang
41324132 const cond_node = try finishBoolExpr(c, &cond_scope.base, cond_expr.getBeginLoc(), ty, cond_ident, .used);
41334133 var then_body = cond_ident;
41344134 if (!res_is_bool and isBoolRes(init_node)) {
4135 then_body = try Tag.bool_to_int.create(c.arena, then_body);
4135 then_body = try Tag.int_from_bool.create(c.arena, then_body);
41364136 }
41374137
41384138 var else_body = try transExpr(c, &block_scope.base, false_expr, .used);
41394139 if (!res_is_bool and isBoolRes(else_body)) {
4140 else_body = try Tag.bool_to_int.create(c.arena, else_body);
4140 else_body = try Tag.int_from_bool.create(c.arena, else_body);
41414141 }
41424142 const if_node = try Tag.@"if".create(c.arena, .{
41434143 .cond = cond_node,
......@@ -4173,12 +4173,12 @@ fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.Condi
41734173
41744174 var then_body = try transExpr(c, scope, true_expr, used);
41754175 if (!res_is_bool and isBoolRes(then_body)) {
4176 then_body = try Tag.bool_to_int.create(c.arena, then_body);
4176 then_body = try Tag.int_from_bool.create(c.arena, then_body);
41774177 }
41784178
41794179 var else_body = try transExpr(c, scope, false_expr, used);
41804180 if (!res_is_bool and isBoolRes(else_body)) {
4181 else_body = try Tag.bool_to_int.create(c.arena, else_body);
4181 else_body = try Tag.int_from_bool.create(c.arena, else_body);
41824182 }
41834183
41844184 const if_node = try Tag.@"if".create(c.arena, .{
......@@ -4556,7 +4556,7 @@ fn transCreateNodeAssign(
45564556 const lhs_node = try transExpr(c, scope, lhs, .used);
45574557 var rhs_node = try transExprCoercing(c, scope, rhs, .used);
45584558 if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) {
4559 rhs_node = try Tag.bool_to_int.create(c.arena, rhs_node);
4559 rhs_node = try Tag.int_from_bool.create(c.arena, rhs_node);
45604560 }
45614561 return transCreateNodeInfixOp(c, .assign, lhs_node, rhs_node, .used);
45624562 }
......@@ -4574,7 +4574,7 @@ fn transCreateNodeAssign(
45744574 const tmp = try block_scope.reserveMangledName(c, "tmp");
45754575 var rhs_node = try transExpr(c, &block_scope.base, rhs, .used);
45764576 if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) {
4577 rhs_node = try Tag.bool_to_int.create(c.arena, rhs_node);
4577 rhs_node = try Tag.int_from_bool.create(c.arena, rhs_node);
45784578 }
45794579
45804580 const tmp_decl = try Tag.var_simple.create(c.arena, .{ .name = tmp, .init = rhs_node });
......@@ -4835,7 +4835,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan
48354835 if (builtin_typedef_map.get(decl_name)) |builtin| return Tag.type.create(c.arena, builtin);
48364836 }
48374837 try transTypeDef(c, trans_scope, typedef_decl);
4838 const name = c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl())).?;
4838 const name = c.decl_table.get(@intFromPtr(typedef_decl.getCanonicalDecl())).?;
48394839 return Tag.identifier.create(c.arena, name);
48404840 },
48414841 .Record => {
......@@ -4848,7 +4848,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan
48484848 if (c.global_names.get(decl_name)) |_| trans_scope = &c.global_scope.base;
48494849 }
48504850 try transRecordDecl(c, trans_scope, record_decl);
4851 const name = c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl())).?;
4851 const name = c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl())).?;
48524852 return Tag.identifier.create(c.arena, name);
48534853 },
48544854 .Enum => {
......@@ -4861,7 +4861,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan
48614861 if (c.global_names.get(decl_name)) |_| trans_scope = &c.global_scope.base;
48624862 }
48634863 try transEnumDecl(c, trans_scope, enum_decl);
4864 const name = c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl())).?;
4864 const name = c.decl_table.get(@intFromPtr(enum_decl.getCanonicalDecl())).?;
48654865 return Tag.identifier.create(c.arena, name);
48664866 },
48674867 .Elaborated => {
......@@ -4928,7 +4928,7 @@ fn qualTypeWasDemotedToOpaque(c: *Context, qt: clang.QualType) bool {
49284928 const record_ty = @ptrCast(*const clang.RecordType, ty);
49294929
49304930 const record_decl = record_ty.getDecl();
4931 const canonical = @ptrToInt(record_decl.getCanonicalDecl());
4931 const canonical = @intFromPtr(record_decl.getCanonicalDecl());
49324932 if (c.opaque_demotes.contains(canonical)) return true;
49334933
49344934 // check all childern for opaque types.
......@@ -4944,7 +4944,7 @@ fn qualTypeWasDemotedToOpaque(c: *Context, qt: clang.QualType) bool {
49444944 const enum_ty = @ptrCast(*const clang.EnumType, ty);
49454945
49464946 const enum_decl = enum_ty.getDecl();
4947 const canonical = @ptrToInt(enum_decl.getCanonicalDecl());
4947 const canonical = @intFromPtr(enum_decl.getCanonicalDecl());
49484948 return c.opaque_demotes.contains(canonical);
49494949 },
49504950 .Elaborated => {
......@@ -5533,7 +5533,7 @@ fn getMacroText(unit: *const clang.ASTUnit, c: *const Context, macro: *const cla
55335533
55345534 const begin_c = c.source_manager.getCharacterData(begin_loc);
55355535 const end_c = c.source_manager.getCharacterData(end_loc);
5536 const slice_len = @ptrToInt(end_c) - @ptrToInt(begin_c);
5536 const slice_len = @intFromPtr(end_c) - @intFromPtr(begin_c);
55375537 return begin_c[0..slice_len];
55385538}
55395539
......@@ -6087,12 +6087,12 @@ fn parseCPrimaryExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
60876087 return node;
60886088}
60896089
6090fn macroBoolToInt(c: *Context, node: Node) !Node {
6090fn macroIntFromBool(c: *Context, node: Node) !Node {
60916091 if (!isBoolRes(node)) {
60926092 return node;
60936093 }
60946094
6095 return Tag.bool_to_int.create(c.arena, node);
6095 return Tag.int_from_bool.create(c.arena, node);
60966096}
60976097
60986098fn macroIntToBool(c: *Context, node: Node) !Node {
......@@ -6141,8 +6141,8 @@ fn parseCAndExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61416141fn parseCBitOrExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61426142 var node = try parseCBitXorExpr(c, m, scope);
61436143 while (m.next().? == .Pipe) {
6144 const lhs = try macroBoolToInt(c, node);
6145 const rhs = try macroBoolToInt(c, try parseCBitXorExpr(c, m, scope));
6144 const lhs = try macroIntFromBool(c, node);
6145 const rhs = try macroIntFromBool(c, try parseCBitXorExpr(c, m, scope));
61466146 node = try Tag.bit_or.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
61476147 }
61486148 m.i -= 1;
......@@ -6152,8 +6152,8 @@ fn parseCBitOrExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61526152fn parseCBitXorExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61536153 var node = try parseCBitAndExpr(c, m, scope);
61546154 while (m.next().? == .Caret) {
6155 const lhs = try macroBoolToInt(c, node);
6156 const rhs = try macroBoolToInt(c, try parseCBitAndExpr(c, m, scope));
6155 const lhs = try macroIntFromBool(c, node);
6156 const rhs = try macroIntFromBool(c, try parseCBitAndExpr(c, m, scope));
61576157 node = try Tag.bit_xor.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
61586158 }
61596159 m.i -= 1;
......@@ -6163,8 +6163,8 @@ fn parseCBitXorExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61636163fn parseCBitAndExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61646164 var node = try parseCEqExpr(c, m, scope);
61656165 while (m.next().? == .Ampersand) {
6166 const lhs = try macroBoolToInt(c, node);
6167 const rhs = try macroBoolToInt(c, try parseCEqExpr(c, m, scope));
6166 const lhs = try macroIntFromBool(c, node);
6167 const rhs = try macroIntFromBool(c, try parseCEqExpr(c, m, scope));
61686168 node = try Tag.bit_and.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
61696169 }
61706170 m.i -= 1;
......@@ -6177,14 +6177,14 @@ fn parseCEqExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61776177 switch (m.peek().?) {
61786178 .BangEqual => {
61796179 _ = m.next();
6180 const lhs = try macroBoolToInt(c, node);
6181 const rhs = try macroBoolToInt(c, try parseCRelExpr(c, m, scope));
6180 const lhs = try macroIntFromBool(c, node);
6181 const rhs = try macroIntFromBool(c, try parseCRelExpr(c, m, scope));
61826182 node = try Tag.not_equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
61836183 },
61846184 .EqualEqual => {
61856185 _ = m.next();
6186 const lhs = try macroBoolToInt(c, node);
6187 const rhs = try macroBoolToInt(c, try parseCRelExpr(c, m, scope));
6186 const lhs = try macroIntFromBool(c, node);
6187 const rhs = try macroIntFromBool(c, try parseCRelExpr(c, m, scope));
61886188 node = try Tag.equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
61896189 },
61906190 else => return node,
......@@ -6198,26 +6198,26 @@ fn parseCRelExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
61986198 switch (m.peek().?) {
61996199 .AngleBracketRight => {
62006200 _ = m.next();
6201 const lhs = try macroBoolToInt(c, node);
6202 const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope));
6201 const lhs = try macroIntFromBool(c, node);
6202 const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope));
62036203 node = try Tag.greater_than.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62046204 },
62056205 .AngleBracketRightEqual => {
62066206 _ = m.next();
6207 const lhs = try macroBoolToInt(c, node);
6208 const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope));
6207 const lhs = try macroIntFromBool(c, node);
6208 const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope));
62096209 node = try Tag.greater_than_equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62106210 },
62116211 .AngleBracketLeft => {
62126212 _ = m.next();
6213 const lhs = try macroBoolToInt(c, node);
6214 const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope));
6213 const lhs = try macroIntFromBool(c, node);
6214 const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope));
62156215 node = try Tag.less_than.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62166216 },
62176217 .AngleBracketLeftEqual => {
62186218 _ = m.next();
6219 const lhs = try macroBoolToInt(c, node);
6220 const rhs = try macroBoolToInt(c, try parseCShiftExpr(c, m, scope));
6219 const lhs = try macroIntFromBool(c, node);
6220 const rhs = try macroIntFromBool(c, try parseCShiftExpr(c, m, scope));
62216221 node = try Tag.less_than_equal.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62226222 },
62236223 else => return node,
......@@ -6231,14 +6231,14 @@ fn parseCShiftExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
62316231 switch (m.peek().?) {
62326232 .AngleBracketAngleBracketLeft => {
62336233 _ = m.next();
6234 const lhs = try macroBoolToInt(c, node);
6235 const rhs = try macroBoolToInt(c, try parseCAddSubExpr(c, m, scope));
6234 const lhs = try macroIntFromBool(c, node);
6235 const rhs = try macroIntFromBool(c, try parseCAddSubExpr(c, m, scope));
62366236 node = try Tag.shl.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62376237 },
62386238 .AngleBracketAngleBracketRight => {
62396239 _ = m.next();
6240 const lhs = try macroBoolToInt(c, node);
6241 const rhs = try macroBoolToInt(c, try parseCAddSubExpr(c, m, scope));
6240 const lhs = try macroIntFromBool(c, node);
6241 const rhs = try macroIntFromBool(c, try parseCAddSubExpr(c, m, scope));
62426242 node = try Tag.shr.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62436243 },
62446244 else => return node,
......@@ -6252,14 +6252,14 @@ fn parseCAddSubExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
62526252 switch (m.peek().?) {
62536253 .Plus => {
62546254 _ = m.next();
6255 const lhs = try macroBoolToInt(c, node);
6256 const rhs = try macroBoolToInt(c, try parseCMulExpr(c, m, scope));
6255 const lhs = try macroIntFromBool(c, node);
6256 const rhs = try macroIntFromBool(c, try parseCMulExpr(c, m, scope));
62576257 node = try Tag.add.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62586258 },
62596259 .Minus => {
62606260 _ = m.next();
6261 const lhs = try macroBoolToInt(c, node);
6262 const rhs = try macroBoolToInt(c, try parseCMulExpr(c, m, scope));
6261 const lhs = try macroIntFromBool(c, node);
6262 const rhs = try macroIntFromBool(c, try parseCMulExpr(c, m, scope));
62636263 node = try Tag.sub.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62646264 },
62656265 else => return node,
......@@ -6272,18 +6272,18 @@ fn parseCMulExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
62726272 while (true) {
62736273 switch (m.next().?) {
62746274 .Asterisk => {
6275 const lhs = try macroBoolToInt(c, node);
6276 const rhs = try macroBoolToInt(c, try parseCCastExpr(c, m, scope));
6275 const lhs = try macroIntFromBool(c, node);
6276 const rhs = try macroIntFromBool(c, try parseCCastExpr(c, m, scope));
62776277 node = try Tag.mul.create(c.arena, .{ .lhs = lhs, .rhs = rhs });
62786278 },
62796279 .Slash => {
6280 const lhs = try macroBoolToInt(c, node);
6281 const rhs = try macroBoolToInt(c, try parseCCastExpr(c, m, scope));
6280 const lhs = try macroIntFromBool(c, node);
6281 const rhs = try macroIntFromBool(c, try parseCCastExpr(c, m, scope));
62826282 node = try Tag.macro_arithmetic.create(c.arena, .{ .op = .div, .lhs = lhs, .rhs = rhs });
62836283 },
62846284 .Percent => {
6285 const lhs = try macroBoolToInt(c, node);
6286 const rhs = try macroBoolToInt(c, try parseCCastExpr(c, m, scope));
6285 const lhs = try macroIntFromBool(c, node);
6286 const rhs = try macroIntFromBool(c, try parseCCastExpr(c, m, scope));
62876287 node = try Tag.macro_arithmetic.create(c.arena, .{ .op = .rem, .lhs = lhs, .rhs = rhs });
62886288 },
62896289 else => {
......@@ -6512,7 +6512,7 @@ fn parseCPostfixExpr(c: *Context, m: *MacroCtx, scope: *Scope, type_name: ?Node)
65126512 node = try Tag.field_access.create(c.arena, .{ .lhs = deref, .field_name = m.slice() });
65136513 },
65146514 .LBracket => {
6515 const index_val = try macroBoolToInt(c, try parseCExpr(c, m, scope));
6515 const index_val = try macroIntFromBool(c, try parseCExpr(c, m, scope));
65166516 const index = try Tag.int_cast.create(c.arena, .{
65176517 .lhs = try Tag.type.create(c.arena, "usize"),
65186518 .rhs = index_val,
......@@ -6610,12 +6610,12 @@ fn parseCUnaryExpr(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
66106610 return Tag.not.create(c.arena, operand);
66116611 },
66126612 .Minus => {
6613 const operand = try macroBoolToInt(c, try parseCCastExpr(c, m, scope));
6613 const operand = try macroIntFromBool(c, try parseCCastExpr(c, m, scope));
66146614 return Tag.negate.create(c.arena, operand);
66156615 },
66166616 .Plus => return try parseCCastExpr(c, m, scope),
66176617 .Tilde => {
6618 const operand = try macroBoolToInt(c, try parseCCastExpr(c, m, scope));
6618 const operand = try macroIntFromBool(c, try parseCCastExpr(c, m, scope));
66196619 return Tag.bit_not.create(c.arena, operand);
66206620 },
66216621 .Asterisk => {
src/translate_c/ast.zig+40-40
......@@ -128,8 +128,8 @@ pub const Node = extern union {
128128 signed_remainder,
129129 /// @divTrunc(lhs, rhs)
130130 div_trunc,
131 /// @boolToInt(operand)
132 bool_to_int,
131 /// @intFromBool(operand)
132 int_from_bool,
133133 /// @as(lhs, rhs)
134134 as,
135135 /// @truncate(lhs, rhs)
......@@ -138,14 +138,14 @@ pub const Node = extern union {
138138 bit_cast,
139139 /// @floatCast(lhs, rhs)
140140 float_cast,
141 /// @floatToInt(lhs, rhs)
142 float_to_int,
143 /// @intToFloat(lhs, rhs)
144 int_to_float,
145 /// @intToPtr(lhs, rhs)
146 int_to_ptr,
147 /// @ptrToInt(operand)
148 ptr_to_int,
141 /// @intFromFloat(lhs, rhs)
142 int_from_float,
143 /// @floatFromInt(lhs, rhs)
144 float_from_int,
145 /// @ptrFromInt(lhs, rhs)
146 ptr_from_int,
147 /// @intFromPtr(operand)
148 int_from_ptr,
149149 /// @alignCast(lhs, rhs)
150150 align_cast,
151151 /// @ptrCast(lhs, rhs)
......@@ -228,7 +228,7 @@ pub const Node = extern union {
228228 array_filler,
229229
230230 pub const last_no_payload_tag = Tag.@"break";
231 pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
231 pub const no_payload_count = @intFromEnum(last_no_payload_tag) + 1;
232232
233233 pub fn Type(comptime t: Tag) type {
234234 return switch (t) {
......@@ -263,7 +263,7 @@ pub const Node = extern union {
263263 .address_of,
264264 .unwrap,
265265 .deref,
266 .ptr_to_int,
266 .int_from_ptr,
267267 .empty_array,
268268 .while_true,
269269 .if_not_break,
......@@ -271,7 +271,7 @@ pub const Node = extern union {
271271 .block_single,
272272 .helpers_sizeof,
273273 .std_meta_alignment,
274 .bool_to_int,
274 .int_from_bool,
275275 .sizeof,
276276 .alignof,
277277 .typeof,
......@@ -319,9 +319,9 @@ pub const Node = extern union {
319319 .truncate,
320320 .bit_cast,
321321 .float_cast,
322 .float_to_int,
323 .int_to_float,
324 .int_to_ptr,
322 .int_from_float,
323 .float_from_int,
324 .ptr_from_int,
325325 .array_cat,
326326 .ellipsis3,
327327 .assign,
......@@ -381,8 +381,8 @@ pub const Node = extern union {
381381 }
382382
383383 pub fn init(comptime t: Tag) Node {
384 comptime std.debug.assert(@enumToInt(t) < Tag.no_payload_count);
385 return .{ .tag_if_small_enough = @enumToInt(t) };
384 comptime std.debug.assert(@intFromEnum(t) < Tag.no_payload_count);
385 return .{ .tag_if_small_enough = @intFromEnum(t) };
386386 }
387387
388388 pub fn create(comptime t: Tag, ally: Allocator, data: Data(t)) error{OutOfMemory}!Node {
......@@ -401,7 +401,7 @@ pub const Node = extern union {
401401
402402 pub fn tag(self: Node) Tag {
403403 if (self.tag_if_small_enough < Tag.no_payload_count) {
404 return @intToEnum(Tag, @intCast(std.meta.Tag(Tag), self.tag_if_small_enough));
404 return @enumFromInt(Tag, @intCast(std.meta.Tag(Tag), self.tag_if_small_enough));
405405 } else {
406406 return self.ptr_otherwise.tag;
407407 }
......@@ -418,7 +418,7 @@ pub const Node = extern union {
418418 }
419419
420420 pub fn initPayload(payload: *Payload) Node {
421 std.debug.assert(@enumToInt(payload.tag) >= Tag.no_payload_count);
421 std.debug.assert(@intFromEnum(payload.tag) >= Tag.no_payload_count);
422422 return .{ .ptr_otherwise = payload };
423423 }
424424
......@@ -1355,9 +1355,9 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
13551355 const payload = node.castTag(.div_trunc).?.data;
13561356 return renderBuiltinCall(c, "@divTrunc", &.{ payload.lhs, payload.rhs });
13571357 },
1358 .bool_to_int => {
1359 const payload = node.castTag(.bool_to_int).?.data;
1360 return renderBuiltinCall(c, "@boolToInt", &.{payload});
1358 .int_from_bool => {
1359 const payload = node.castTag(.int_from_bool).?.data;
1360 return renderBuiltinCall(c, "@intFromBool", &.{payload});
13611361 },
13621362 .as => {
13631363 const payload = node.castTag(.as).?.data;
......@@ -1375,21 +1375,21 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
13751375 const payload = node.castTag(.float_cast).?.data;
13761376 return renderBuiltinCall(c, "@floatCast", &.{ payload.lhs, payload.rhs });
13771377 },
1378 .float_to_int => {
1379 const payload = node.castTag(.float_to_int).?.data;
1380 return renderBuiltinCall(c, "@floatToInt", &.{ payload.lhs, payload.rhs });
1378 .int_from_float => {
1379 const payload = node.castTag(.int_from_float).?.data;
1380 return renderBuiltinCall(c, "@intFromFloat", &.{ payload.lhs, payload.rhs });
13811381 },
1382 .int_to_float => {
1383 const payload = node.castTag(.int_to_float).?.data;
1384 return renderBuiltinCall(c, "@intToFloat", &.{ payload.lhs, payload.rhs });
1382 .float_from_int => {
1383 const payload = node.castTag(.float_from_int).?.data;
1384 return renderBuiltinCall(c, "@floatFromInt", &.{ payload.lhs, payload.rhs });
13851385 },
1386 .int_to_ptr => {
1387 const payload = node.castTag(.int_to_ptr).?.data;
1388 return renderBuiltinCall(c, "@intToPtr", &.{ payload.lhs, payload.rhs });
1386 .ptr_from_int => {
1387 const payload = node.castTag(.ptr_from_int).?.data;
1388 return renderBuiltinCall(c, "@ptrFromInt", &.{ payload.lhs, payload.rhs });
13891389 },
1390 .ptr_to_int => {
1391 const payload = node.castTag(.ptr_to_int).?.data;
1392 return renderBuiltinCall(c, "@ptrToInt", &.{payload});
1390 .int_from_ptr => {
1391 const payload = node.castTag(.int_from_ptr).?.data;
1392 return renderBuiltinCall(c, "@intFromPtr", &.{payload});
13931393 },
13941394 .align_cast => {
13951395 const payload = node.castTag(.align_cast).?.data;
......@@ -2326,13 +2326,13 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
23262326 .truncate,
23272327 .bit_cast,
23282328 .float_cast,
2329 .float_to_int,
2330 .int_to_float,
2331 .int_to_ptr,
2329 .int_from_float,
2330 .float_from_int,
2331 .ptr_from_int,
23322332 .std_mem_zeroes,
23332333 .std_math_Log2Int,
23342334 .log2_int_type,
2335 .ptr_to_int,
2335 .int_from_ptr,
23362336 .sizeof,
23372337 .alignof,
23382338 .typeof,
......@@ -2371,7 +2371,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
23712371 .call,
23722372 .array_type,
23732373 .null_sentinel_array_type,
2374 .bool_to_int,
2374 .int_from_bool,
23752375 .div_exact,
23762376 .offset_of,
23772377 .shuffle,
src/type.zig+8-8
......@@ -130,7 +130,7 @@ pub const Type = struct {
130130 // The InternPool data structure hashes based on Key to make interned objects
131131 // unique. An Index can be treated simply as u32 value for the
132132 // purpose of Type/Value hashing and equality.
133 return std.hash.uint32(@enumToInt(ty.toIntern()));
133 return std.hash.uint32(@intFromEnum(ty.toIntern()));
134134 }
135135
136136 pub fn format(ty: Type, comptime unused_fmt_string: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
......@@ -227,7 +227,7 @@ pub const Type = struct {
227227 if (info.vector_index == .runtime) {
228228 try writer.writeAll(":?");
229229 } else if (info.vector_index != .none) {
230 try writer.print(":{d}", .{@enumToInt(info.vector_index)});
230 try writer.print(":{d}", .{@intFromEnum(info.vector_index)});
231231 }
232232 try writer.writeAll(") ");
233233 }
......@@ -1227,7 +1227,7 @@ pub const Type = struct {
12271227 if (have_tag) {
12281228 return abiAlignmentAdvanced(union_obj.tag_ty, mod, strat);
12291229 } else {
1230 return AbiAlignmentAdvanced{ .scalar = @boolToInt(union_obj.layout == .Extern) };
1230 return AbiAlignmentAdvanced{ .scalar = @intFromBool(union_obj.layout == .Extern) };
12311231 }
12321232 }
12331233
......@@ -1307,7 +1307,7 @@ pub const Type = struct {
13071307 .anyframe_type => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
13081308
13091309 .array_type => |array_type| {
1310 const len = array_type.len + @boolToInt(array_type.sentinel != .none);
1310 const len = array_type.len + @intFromBool(array_type.sentinel != .none);
13111311 switch (try array_type.child.toType().abiSizeAdvanced(mod, strat)) {
13121312 .scalar => |elem_size| return .{ .scalar = len * elem_size },
13131313 .val => switch (strat) {
......@@ -1630,7 +1630,7 @@ pub const Type = struct {
16301630 .anyframe_type => return target.ptrBitWidth(),
16311631
16321632 .array_type => |array_type| {
1633 const len = array_type.len + @boolToInt(array_type.sentinel != .none);
1633 const len = array_type.len + @intFromBool(array_type.sentinel != .none);
16341634 if (len == 0) return 0;
16351635 const elem_ty = array_type.child.toType();
16361636 const elem_size = @max(elem_ty.abiAlignment(mod), elem_ty.abiSize(mod));
......@@ -2182,7 +2182,7 @@ pub const Type = struct {
21822182 }
21832183
21842184 pub fn arrayLenIncludingSentinel(ty: Type, mod: *const Module) u64 {
2185 return ty.arrayLen(mod) + @boolToInt(ty.sentinel(mod) != null);
2185 return ty.arrayLen(mod) + @intFromBool(ty.sentinel(mod) != null);
21862186 }
21872187
21882188 pub fn vectorLen(ty: Type, mod: *const Module) u32 {
......@@ -2477,7 +2477,7 @@ pub const Type = struct {
24772477
24782478 inline .array_type, .vector_type => |seq_type, seq_tag| {
24792479 const has_sentinel = seq_tag == .array_type and seq_type.sentinel != .none;
2480 if (seq_type.len + @boolToInt(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
2480 if (seq_type.len + @intFromBool(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
24812481 .ty = ty.toIntern(),
24822482 .storage = .{ .elems = &.{} },
24832483 } })).toValue();
......@@ -3540,7 +3540,7 @@ pub const Type = struct {
35403540 if (max == 0) return 0;
35413541 const base = std.math.log2(max);
35423542 const upper = (@as(u64, 1) << @intCast(u6, base)) - 1;
3543 return @intCast(u16, base + @boolToInt(upper < max));
3543 return @intCast(u16, base + @intFromBool(upper < max));
35443544 }
35453545
35463546 /// This is only used for comptime asserts. Bump this number when you make a change
src/value.zig+30-30
......@@ -112,7 +112,7 @@ pub const Value = struct {
112112 return self.castTag(T.base_tag);
113113 }
114114 inline for (@typeInfo(Tag).Enum.fields) |field| {
115 const t = @intToEnum(Tag, field.value);
115 const t = @enumFromInt(Tag, field.value);
116116 if (self.legacy.ptr_otherwise.tag == t) {
117117 if (T == t.Type()) {
118118 return @fieldParentPtr(T, "base", self.legacy.ptr_otherwise);
......@@ -503,7 +503,7 @@ pub const Value = struct {
503503 return self.toIntern().toType();
504504 }
505505
506 pub fn enumToInt(val: Value, ty: Type, mod: *Module) Allocator.Error!Value {
506 pub fn intFromEnum(val: Value, ty: Type, mod: *Module) Allocator.Error!Value {
507507 const ip = &mod.intern_pool;
508508 return switch (ip.indexToKey(ip.typeOf(val.toIntern()))) {
509509 // Assume it is already an integer and return it directly.
......@@ -703,7 +703,7 @@ pub const Value = struct {
703703 switch (ty.zigTypeTag(mod)) {
704704 .Void => {},
705705 .Bool => {
706 buffer[0] = @boolToInt(val.toBool());
706 buffer[0] = @intFromBool(val.toBool());
707707 },
708708 .Int, .Enum => {
709709 const int_info = ty.intInfo(mod);
......@@ -836,7 +836,7 @@ pub const Value = struct {
836836 const bits = ty.intInfo(mod).bits;
837837 if (bits == 0) return;
838838
839 switch (mod.intern_pool.indexToKey((try val.enumToInt(ty, mod)).toIntern()).int.storage) {
839 switch (mod.intern_pool.indexToKey((try val.intFromEnum(ty, mod)).toIntern()).int.storage) {
840840 inline .u64, .i64 => |int| std.mem.writeVarPackedInt(buffer, bit_offset, bits, int, endian),
841841 .big_int => |bigint| bigint.writePackedTwosComplement(buffer, bit_offset, bits, endian),
842842 else => unreachable,
......@@ -1170,10 +1170,10 @@ pub const Value = struct {
11701170 if (T == f80) {
11711171 @panic("TODO we can't lower this properly on non-x86 llvm backend yet");
11721172 }
1173 return @intToFloat(T, x);
1173 return @floatFromInt(T, x);
11741174 },
1175 .lazy_align => |ty| @intToFloat(T, ty.toType().abiAlignment(mod)),
1176 .lazy_size => |ty| @intToFloat(T, ty.toType().abiSize(mod)),
1175 .lazy_align => |ty| @floatFromInt(T, ty.toType().abiAlignment(mod)),
1176 .lazy_size => |ty| @floatFromInt(T, ty.toType().abiSize(mod)),
11771177 },
11781178 .float => |float| switch (float.storage) {
11791179 inline else => |x| @floatCast(T, x),
......@@ -1191,7 +1191,7 @@ pub const Value = struct {
11911191 var i: usize = limbs.len;
11921192 while (i != 0) {
11931193 i -= 1;
1194 const limb: f128 = @intToFloat(f128, limbs[i]);
1194 const limb: f128 = @floatFromInt(f128, limbs[i]);
11951195 result = @mulAdd(f128, base, result, limb);
11961196 }
11971197 if (positive) {
......@@ -1593,8 +1593,8 @@ pub const Value = struct {
15931593 return a_type.eql(b_type, mod);
15941594 },
15951595 .Enum => {
1596 const a_val = try a.enumToInt(ty, mod);
1597 const b_val = try b.enumToInt(ty, mod);
1596 const a_val = try a.intFromEnum(ty, mod);
1597 const b_val = try b.intFromEnum(ty, mod);
15981598 const int_ty = ty.intTagType(mod);
15991599 return eqlAdvanced(a_val, int_ty, b_val, int_ty, mod, opt_sema);
16001600 },
......@@ -2124,30 +2124,30 @@ pub const Value = struct {
21242124 };
21252125 }
21262126
2127 pub fn intToFloat(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module) !Value {
2128 return intToFloatAdvanced(val, arena, int_ty, float_ty, mod, null) catch |err| switch (err) {
2127 pub fn floatFromInt(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module) !Value {
2128 return floatFromIntAdvanced(val, arena, int_ty, float_ty, mod, null) catch |err| switch (err) {
21292129 error.OutOfMemory => return error.OutOfMemory,
21302130 else => unreachable,
21312131 };
21322132 }
21332133
2134 pub fn intToFloatAdvanced(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value {
2134 pub fn floatFromIntAdvanced(val: Value, arena: Allocator, int_ty: Type, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value {
21352135 if (int_ty.zigTypeTag(mod) == .Vector) {
21362136 const result_data = try arena.alloc(InternPool.Index, int_ty.vectorLen(mod));
21372137 const scalar_ty = float_ty.scalarType(mod);
21382138 for (result_data, 0..) |*scalar, i| {
21392139 const elem_val = try val.elemValue(mod, i);
2140 scalar.* = try (try intToFloatScalar(elem_val, scalar_ty, mod, opt_sema)).intern(scalar_ty, mod);
2140 scalar.* = try (try floatFromIntScalar(elem_val, scalar_ty, mod, opt_sema)).intern(scalar_ty, mod);
21412141 }
21422142 return (try mod.intern(.{ .aggregate = .{
21432143 .ty = float_ty.toIntern(),
21442144 .storage = .{ .elems = result_data },
21452145 } })).toValue();
21462146 }
2147 return intToFloatScalar(val, float_ty, mod, opt_sema);
2147 return floatFromIntScalar(val, float_ty, mod, opt_sema);
21482148 }
21492149
2150 pub fn intToFloatScalar(val: Value, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value {
2150 pub fn floatFromIntScalar(val: Value, float_ty: Type, mod: *Module, opt_sema: ?*Sema) !Value {
21512151 return switch (mod.intern_pool.indexToKey(val.toIntern())) {
21522152 .undef => (try mod.intern(.{ .undef = float_ty.toIntern() })).toValue(),
21532153 .int => |int| switch (int.storage) {
......@@ -2155,30 +2155,30 @@ pub const Value = struct {
21552155 const float = bigIntToFloat(big_int.limbs, big_int.positive);
21562156 return mod.floatValue(float_ty, float);
21572157 },
2158 inline .u64, .i64 => |x| intToFloatInner(x, float_ty, mod),
2158 inline .u64, .i64 => |x| floatFromIntInner(x, float_ty, mod),
21592159 .lazy_align => |ty| if (opt_sema) |sema| {
2160 return intToFloatInner((try ty.toType().abiAlignmentAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod);
2160 return floatFromIntInner((try ty.toType().abiAlignmentAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod);
21612161 } else {
2162 return intToFloatInner(ty.toType().abiAlignment(mod), float_ty, mod);
2162 return floatFromIntInner(ty.toType().abiAlignment(mod), float_ty, mod);
21632163 },
21642164 .lazy_size => |ty| if (opt_sema) |sema| {
2165 return intToFloatInner((try ty.toType().abiSizeAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod);
2165 return floatFromIntInner((try ty.toType().abiSizeAdvanced(mod, .{ .sema = sema })).scalar, float_ty, mod);
21662166 } else {
2167 return intToFloatInner(ty.toType().abiSize(mod), float_ty, mod);
2167 return floatFromIntInner(ty.toType().abiSize(mod), float_ty, mod);
21682168 },
21692169 },
21702170 else => unreachable,
21712171 };
21722172 }
21732173
2174 fn intToFloatInner(x: anytype, dest_ty: Type, mod: *Module) !Value {
2174 fn floatFromIntInner(x: anytype, dest_ty: Type, mod: *Module) !Value {
21752175 const target = mod.getTarget();
21762176 const storage: InternPool.Key.Float.Storage = switch (dest_ty.floatBits(target)) {
2177 16 => .{ .f16 = @intToFloat(f16, x) },
2178 32 => .{ .f32 = @intToFloat(f32, x) },
2179 64 => .{ .f64 = @intToFloat(f64, x) },
2180 80 => .{ .f80 = @intToFloat(f80, x) },
2181 128 => .{ .f128 = @intToFloat(f128, x) },
2177 16 => .{ .f16 = @floatFromInt(f16, x) },
2178 32 => .{ .f32 = @floatFromInt(f32, x) },
2179 64 => .{ .f64 = @floatFromInt(f64, x) },
2180 80 => .{ .f80 = @floatFromInt(f80, x) },
2181 128 => .{ .f128 = @floatFromInt(f128, x) },
21822182 else => unreachable,
21832183 };
21842184 return (try mod.intern(.{ .float = .{
......@@ -2193,7 +2193,7 @@ pub const Value = struct {
21932193 }
21942194
21952195 const w_value = @fabs(scalar);
2196 return @divFloor(@floatToInt(std.math.big.Limb, std.math.log2(w_value)), @typeInfo(std.math.big.Limb).Int.bits) + 1;
2196 return @divFloor(@intFromFloat(std.math.big.Limb, std.math.log2(w_value)), @typeInfo(std.math.big.Limb).Int.bits) + 1;
21972197 }
21982198
21992199 pub const OverflowArithmeticResult = struct {
......@@ -2364,7 +2364,7 @@ pub const Value = struct {
23642364 }
23652365
23662366 return OverflowArithmeticResult{
2367 .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)),
2367 .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)),
23682368 .wrapped_result = try mod.intValue_big(ty, result_bigint.toConst()),
23692369 };
23702370 }
......@@ -3177,7 +3177,7 @@ pub const Value = struct {
31773177 result_bigint.truncate(result_bigint.toConst(), info.signedness, info.bits);
31783178 }
31793179 return OverflowArithmeticResult{
3180 .overflow_bit = try mod.intValue(Type.u1, @boolToInt(overflowed)),
3180 .overflow_bit = try mod.intValue(Type.u1, @intFromBool(overflowed)),
31813181 .wrapped_result = try mod.intValue_big(ty, result_bigint.toConst()),
31823182 };
31833183 }
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
test/behavior.zig+1-1
......@@ -174,7 +174,7 @@ test {
174174 _ = @import("behavior/inline_switch.zig");
175175 _ = @import("behavior/int128.zig");
176176 _ = @import("behavior/int_comparison_elision.zig");
177 _ = @import("behavior/inttoptr.zig");
177 _ = @import("behavior/ptrfromint.zig");
178178 _ = @import("behavior/ir_block_deps.zig");
179179 _ = @import("behavior/lower_strlit_to_vector.zig");
180180 _ = @import("behavior/math.zig");
test/behavior/align.zig+7-7
......@@ -24,7 +24,7 @@ test "slicing array of length 1 can not assume runtime index is always zero" {
2424 const slice = @as(*align(4) [1]u8, &foo)[runtime_index..];
2525 try expect(@TypeOf(slice) == []u8);
2626 try expect(slice.len == 0);
27 try expect(@truncate(u2, @ptrToInt(slice.ptr) - 1) == 0);
27 try expect(@truncate(u2, @intFromPtr(slice.ptr) - 1) == 0);
2828}
2929
3030test "default alignment allows unspecified in type syntax" {
......@@ -299,11 +299,11 @@ test "page aligned array on stack" {
299299 var number1: u8 align(16) = 42;
300300 var number2: u8 align(16) = 43;
301301
302 try expect(@ptrToInt(&array[0]) & 0xFFF == 0);
302 try expect(@intFromPtr(&array[0]) & 0xFFF == 0);
303303 try expect(array[3] == 4);
304304
305 try expect(@truncate(u4, @ptrToInt(&number1)) == 0);
306 try expect(@truncate(u4, @ptrToInt(&number2)) == 0);
305 try expect(@truncate(u4, @intFromPtr(&number1)) == 0);
306 try expect(@truncate(u4, @intFromPtr(&number2)) == 0);
307307 try expect(number1 == 42);
308308 try expect(number2 == 43);
309309}
......@@ -518,7 +518,7 @@ test "struct field explicit alignment" {
518518 node.massive_byte = 100;
519519 try expect(node.massive_byte == 100);
520520 try comptime expect(@TypeOf(&node.massive_byte) == *align(64) u8);
521 try expect(@ptrToInt(&node.massive_byte) % 64 == 0);
521 try expect(@intFromPtr(&node.massive_byte) % 64 == 0);
522522}
523523
524524test "align(@alignOf(T)) T does not force resolution of T" {
......@@ -561,7 +561,7 @@ test "align(N) on functions" {
561561 if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest;
562562 if (native_arch == .thumb) return error.SkipZigTest;
563563
564 try expect((@ptrToInt(&overaligned_fn) & (0x1000 - 1)) == 0);
564 try expect((@intFromPtr(&overaligned_fn) & (0x1000 - 1)) == 0);
565565}
566566fn overaligned_fn() align(0x1000) i32 {
567567 return 42;
......@@ -578,7 +578,7 @@ test "comptime alloc alignment" {
578578 _ = bytes1;
579579
580580 comptime var bytes2 align(256) = [_]u8{0};
581 var bytes2_addr = @ptrToInt(&bytes2);
581 var bytes2_addr = @intFromPtr(&bytes2);
582582 try expect(bytes2_addr & 0xff == 0);
583583}
584584
test/behavior/array.zig+2-2
......@@ -176,8 +176,8 @@ test "array with sentinels" {
176176 var arr: [3:0x55]u8 = undefined;
177177 // Make sure the sentinel pointer is pointing after the last element.
178178 if (!is_ct) {
179 const sentinel_ptr = @ptrToInt(&arr[3]);
180 const last_elem_ptr = @ptrToInt(&arr[2]);
179 const sentinel_ptr = @intFromPtr(&arr[3]);
180 const last_elem_ptr = @intFromPtr(&arr[2]);
181181 try expect((sentinel_ptr - last_elem_ptr) == 1);
182182 }
183183 // Make sure the sentinel is writeable.
test/behavior/async_fn.zig+3-3
......@@ -829,7 +829,7 @@ test "alignment of local variables in async functions" {
829829 var y: u8 = 123;
830830 _ = y;
831831 var x: u8 align(128) = 1;
832 try expect(@ptrToInt(&x) % 128 == 0);
832 try expect(@intFromPtr(&x) % 128 == 0);
833833 }
834834 };
835835 try S.doTheTest();
......@@ -1184,7 +1184,7 @@ test "using @TypeOf on a generic function call" {
11841184 global_frame = @frame();
11851185 }
11861186 const F = @TypeOf(async amain(x - 1));
1187 const frame = @intToPtr(*F, @ptrToInt(&buf));
1187 const frame = @ptrFromInt(*F, @intFromPtr(&buf));
11881188 return await @asyncCall(frame, {}, amain, .{x - 1});
11891189 }
11901190 };
......@@ -1212,7 +1212,7 @@ test "recursive call of await @asyncCall with struct return type" {
12121212 global_frame = @frame();
12131213 }
12141214 const F = @TypeOf(async amain(x - 1));
1215 const frame = @intToPtr(*F, @ptrToInt(&buf));
1215 const frame = @ptrFromInt(*F, @intFromPtr(&buf));
12161216 return await @asyncCall(frame, {}, amain, .{x - 1});
12171217 }
12181218
test/behavior/bool.zig+14-14
......@@ -13,22 +13,22 @@ test "cast bool to int" {
1313
1414 const t = true;
1515 const f = false;
16 try expectEqual(@as(u32, 1), @boolToInt(t));
17 try expectEqual(@as(u32, 0), @boolToInt(f));
18 try expectEqual(-1, @bitCast(i1, @boolToInt(t)));
19 try expectEqual(0, @bitCast(i1, @boolToInt(f)));
20 try expectEqual(u1, @TypeOf(@boolToInt(t)));
21 try expectEqual(u1, @TypeOf(@boolToInt(f)));
22 try nonConstCastBoolToInt(t, f);
16 try expectEqual(@as(u32, 1), @intFromBool(t));
17 try expectEqual(@as(u32, 0), @intFromBool(f));
18 try expectEqual(-1, @bitCast(i1, @intFromBool(t)));
19 try expectEqual(0, @bitCast(i1, @intFromBool(f)));
20 try expectEqual(u1, @TypeOf(@intFromBool(t)));
21 try expectEqual(u1, @TypeOf(@intFromBool(f)));
22 try nonConstCastIntFromBool(t, f);
2323}
2424
25fn nonConstCastBoolToInt(t: bool, f: bool) !void {
26 try expectEqual(@as(u32, 1), @boolToInt(t));
27 try expectEqual(@as(u32, 0), @boolToInt(f));
28 try expectEqual(@as(i1, -1), @bitCast(i1, @boolToInt(t)));
29 try expectEqual(@as(i1, 0), @bitCast(i1, @boolToInt(f)));
30 try expectEqual(u1, @TypeOf(@boolToInt(t)));
31 try expectEqual(u1, @TypeOf(@boolToInt(f)));
25fn nonConstCastIntFromBool(t: bool, f: bool) !void {
26 try expectEqual(@as(u32, 1), @intFromBool(t));
27 try expectEqual(@as(u32, 0), @intFromBool(f));
28 try expectEqual(@as(i1, -1), @bitCast(i1, @intFromBool(t)));
29 try expectEqual(@as(i1, 0), @bitCast(i1, @intFromBool(f)));
30 try expectEqual(u1, @TypeOf(@intFromBool(t)));
31 try expectEqual(u1, @TypeOf(@intFromBool(f)));
3232}
3333
3434test "bool cmp" {
test/behavior/bugs/10138.zig+1-1
......@@ -17,7 +17,7 @@ fn open() usize {
1717}
1818
1919fn write(fd: usize, a: [*]const u8, len: usize) usize {
20 return syscall4(.WRITE, fd, @ptrToInt(a), len);
20 return syscall4(.WRITE, fd, @intFromPtr(a), len);
2121}
2222
2323fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize {
test/behavior/bugs/12142.zig+1-1
......@@ -15,7 +15,7 @@ const Letter = enum(u8) {
1515};
1616
1717fn letter(e: Letter) u8 {
18 return @enumToInt(e);
18 return @intFromEnum(e);
1919}
2020
2121test {
test/behavior/bugs/12450.zig+1-1
......@@ -18,6 +18,6 @@ test {
1818
1919 var f1: *align(16) Foo = @alignCast(16, @ptrCast(*align(1) Foo, &buffer[0]));
2020 try expect(@typeInfo(@TypeOf(f1)).Pointer.alignment == 16);
21 try expect(@ptrToInt(f1) == @ptrToInt(&f1.a));
21 try expect(@intFromPtr(f1) == @intFromPtr(&f1.a));
2222 try expect(@typeInfo(@TypeOf(&f1.a)).Pointer.alignment == 16);
2323}
test/behavior/bugs/12680_other_file.zig+1-1
......@@ -1,6 +1,6 @@
11// export this function twice
22pub export fn testFunc() callconv(.C) usize {
3 return @ptrToInt(&testFunc);
3 return @intFromPtr(&testFunc);
44}
55
66comptime {
test/behavior/bugs/12723.zig+2-2
......@@ -3,6 +3,6 @@ const expect = @import("std").testing.expect;
33test "Non-exhaustive enum backed by comptime_int" {
44 const E = enum(comptime_int) { a, b, c, _ };
55 comptime var e: E = .a;
6 e = @intToEnum(E, 378089457309184723749);
7 try expect(@enumToInt(e) == 378089457309184723749);
6 e = @enumFromInt(E, 378089457309184723749);
7 try expect(@intFromEnum(e) == 378089457309184723749);
88}
test/behavior/bugs/1741.zig+1-1
......@@ -8,5 +8,5 @@ test "fixed" {
88 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
99
1010 const x: f32 align(128) = 12.34;
11 try std.testing.expect(@ptrToInt(&x) % 128 == 0);
11 try std.testing.expect(@intFromPtr(&x) % 128 == 0);
1212}
test/behavior/bugs/9584.zig+1-1
......@@ -35,7 +35,7 @@ pub fn a(
3535 _ = flag_a;
3636 // With this bug present, `flag_b` would actually contain the value 17.
3737 // Note: this bug only presents itself on debug mode.
38 const flag_b_byte: u8 = @boolToInt(flag_b);
38 const flag_b_byte: u8 = @intFromBool(flag_b);
3939 try std.testing.expect(flag_b_byte == 1);
4040}
4141
test/behavior/builtin_functions_returning_void_or_noreturn.zig+2-2
......@@ -17,8 +17,8 @@ test {
1717 try testing.expectEqual(void, @TypeOf(@breakpoint()));
1818 try testing.expectEqual({}, @export(x, .{ .name = "x" }));
1919 try testing.expectEqual({}, @fence(.Acquire));
20 try testing.expectEqual({}, @memcpy(@intToPtr([*]u8, 1)[0..0], @intToPtr([*]u8, 1)[0..0]));
21 try testing.expectEqual({}, @memset(@intToPtr([*]u8, 1)[0..0], undefined));
20 try testing.expectEqual({}, @memcpy(@ptrFromInt([*]u8, 1)[0..0], @ptrFromInt([*]u8, 1)[0..0]));
21 try testing.expectEqual({}, @memset(@ptrFromInt([*]u8, 1)[0..0], undefined));
2222 try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));
2323 try testing.expectEqual({}, @prefetch(&val, .{}));
2424 try testing.expectEqual({}, @setAlignStack(16));
test/behavior/call.zig+2-2
......@@ -364,11 +364,11 @@ test "Enum constructed by @Type passed as generic argument" {
364364 alive: bool,
365365 });
366366 fn foo(comptime a: E, b: u32) !void {
367 try expect(@enumToInt(a) == b);
367 try expect(@intFromEnum(a) == b);
368368 }
369369 };
370370 inline for (@typeInfo(S.E).Enum.fields, 0..) |_, i| {
371 try S.foo(@intToEnum(S.E, i), i);
371 try S.foo(@enumFromInt(S.E, i), i);
372372 }
373373}
374374
test/behavior/cast.zig+50-50
......@@ -10,14 +10,14 @@ const native_endian = builtin.target.cpu.arch.endian();
1010
1111test "int to ptr cast" {
1212 const x = @as(usize, 13);
13 const y = @intToPtr(*u8, x);
14 const z = @ptrToInt(y);
13 const y = @ptrFromInt(*u8, x);
14 const z = @intFromPtr(y);
1515 try expect(z == 13);
1616}
1717
1818test "integer literal to pointer cast" {
19 const vga_mem = @intToPtr(*u16, 0xB8000);
20 try expect(@ptrToInt(vga_mem) == 0xB8000);
19 const vga_mem = @ptrFromInt(*u16, 0xB8000);
20 try expect(@intFromPtr(vga_mem) == 0xB8000);
2121}
2222
2323test "peer type resolution: ?T and T" {
......@@ -66,37 +66,37 @@ test "implicit cast comptime_int to comptime_float" {
6666 try expect(2 == 2.0);
6767}
6868
69test "comptime_int @intToFloat" {
69test "comptime_int @floatFromInt" {
7070 {
71 const result = @intToFloat(f16, 1234);
71 const result = @floatFromInt(f16, 1234);
7272 try expect(@TypeOf(result) == f16);
7373 try expect(result == 1234.0);
7474 }
7575 {
76 const result = @intToFloat(f32, 1234);
76 const result = @floatFromInt(f32, 1234);
7777 try expect(@TypeOf(result) == f32);
7878 try expect(result == 1234.0);
7979 }
8080 {
81 const result = @intToFloat(f64, 1234);
81 const result = @floatFromInt(f64, 1234);
8282 try expect(@TypeOf(result) == f64);
8383 try expect(result == 1234.0);
8484 }
8585
8686 {
87 const result = @intToFloat(f128, 1234);
87 const result = @floatFromInt(f128, 1234);
8888 try expect(@TypeOf(result) == f128);
8989 try expect(result == 1234.0);
9090 }
9191 // big comptime_int (> 64 bits) to f128 conversion
9292 {
93 const result = @intToFloat(f128, 0x1_0000_0000_0000_0000);
93 const result = @floatFromInt(f128, 0x1_0000_0000_0000_0000);
9494 try expect(@TypeOf(result) == f128);
9595 try expect(result == 0x1_0000_0000_0000_0000.0);
9696 }
9797}
9898
99test "@intToFloat" {
99test "@floatFromInt" {
100100 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
101101 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
102102 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
......@@ -107,8 +107,8 @@ test "@intToFloat" {
107107 }
108108
109109 fn testIntToFloat(k: i32) !void {
110 const f = @intToFloat(f32, k);
111 const i = @floatToInt(i32, f);
110 const f = @floatFromInt(f32, k);
111 const i = @intFromFloat(i32, f);
112112 try expect(i == k);
113113 }
114114 };
......@@ -116,7 +116,7 @@ test "@intToFloat" {
116116 try comptime S.doTheTest();
117117}
118118
119test "@intToFloat(f80)" {
119test "@floatFromInt(f80)" {
120120 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
121121 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
122122 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
......@@ -131,8 +131,8 @@ test "@intToFloat(f80)" {
131131
132132 fn testIntToFloat(comptime Int: type, k: Int) !void {
133133 @setRuntimeSafety(false); // TODO
134 const f = @intToFloat(f80, k);
135 const i = @floatToInt(Int, f);
134 const f = @floatFromInt(f80, k);
135 const i = @intFromFloat(Int, f);
136136 try expect(i == k);
137137 }
138138 };
......@@ -152,28 +152,28 @@ test "@intToFloat(f80)" {
152152 try comptime S.doTheTest(i256);
153153}
154154
155test "@floatToInt" {
155test "@intFromFloat" {
156156 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
157157 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
158158 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
159159 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
160160
161 try testFloatToInts();
162 try comptime testFloatToInts();
161 try testIntFromFloats();
162 try comptime testIntFromFloats();
163163}
164164
165fn testFloatToInts() !void {
165fn testIntFromFloats() !void {
166166 const x = @as(i32, 1e4);
167167 try expect(x == 10000);
168 const y = @floatToInt(i32, @as(f32, 1e4));
168 const y = @intFromFloat(i32, @as(f32, 1e4));
169169 try expect(y == 10000);
170 try expectFloatToInt(f32, 255.1, u8, 255);
171 try expectFloatToInt(f32, 127.2, i8, 127);
172 try expectFloatToInt(f32, -128.2, i8, -128);
170 try expectIntFromFloat(f32, 255.1, u8, 255);
171 try expectIntFromFloat(f32, 127.2, i8, 127);
172 try expectIntFromFloat(f32, -128.2, i8, -128);
173173}
174174
175fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void {
176 try expect(@floatToInt(I, f) == i);
175fn expectIntFromFloat(comptime F: type, f: F, comptime I: type, i: I) !void {
176 try expect(@intFromFloat(I, f) == i);
177177}
178178
179179test "implicitly cast indirect pointer to maybe-indirect pointer" {
......@@ -280,9 +280,9 @@ test "*usize to *void" {
280280 v.* = {};
281281}
282282
283test "@intToEnum passed a comptime_int to an enum with one item" {
283test "@enumFromInt passed a comptime_int to an enum with one item" {
284284 const E = enum { A };
285 const x = @intToEnum(E, 0);
285 const x = @enumFromInt(E, 0);
286286 try expect(x == E.A);
287287}
288288
......@@ -420,8 +420,8 @@ test "explicit cast from integer to error type" {
420420 try comptime testCastIntToErr(error.ItBroke);
421421}
422422fn testCastIntToErr(err: anyerror) !void {
423 const x = @errorToInt(err);
424 const y = @intToError(x);
423 const x = @intFromError(err);
424 const y = @errorFromInt(x);
425425 try expect(error.ItBroke == y);
426426}
427427
......@@ -1093,15 +1093,15 @@ test "peer type resolve array pointer and unknown pointer" {
10931093test "comptime float casts" {
10941094 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
10951095
1096 const a = @intToFloat(comptime_float, 1);
1096 const a = @floatFromInt(comptime_float, 1);
10971097 try expect(a == 1);
10981098 try expect(@TypeOf(a) == comptime_float);
1099 const b = @floatToInt(comptime_int, 2);
1099 const b = @intFromFloat(comptime_int, 2);
11001100 try expect(b == 2);
11011101 try expect(@TypeOf(b) == comptime_int);
11021102
1103 try expectFloatToInt(comptime_int, 1234, i16, 1234);
1104 try expectFloatToInt(comptime_float, 12.3, comptime_int, 12);
1103 try expectIntFromFloat(comptime_int, 1234, i16, 1234);
1104 try expectIntFromFloat(comptime_float, 12.3, comptime_int, 12);
11051105}
11061106
11071107test "pointer reinterpret const float to int" {
......@@ -1146,11 +1146,11 @@ test "compile time int to ptr of function" {
11461146
11471147// On some architectures function pointers must be aligned.
11481148const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);
1149pub const FUNCTION_CONSTANT = @intToPtr(PFN_void, hardcoded_fn_addr);
1149pub const FUNCTION_CONSTANT = @ptrFromInt(PFN_void, hardcoded_fn_addr);
11501150pub const PFN_void = *const fn (*anyopaque) callconv(.C) void;
11511151
11521152fn foobar(func: PFN_void) !void {
1153 try std.testing.expect(@ptrToInt(func) == hardcoded_fn_addr);
1153 try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);
11541154}
11551155
11561156test "implicit ptr to *anyopaque" {
......@@ -1285,11 +1285,11 @@ test "implicit cast *[0]T to E![]const u8" {
12851285var global_array: [4]u8 = undefined;
12861286test "cast from array reference to fn: comptime fn ptr" {
12871287 const f = @ptrCast(*align(1) const fn () callconv(.C) void, &global_array);
1288 try expect(@ptrToInt(f) == @ptrToInt(&global_array));
1288 try expect(@intFromPtr(f) == @intFromPtr(&global_array));
12891289}
12901290test "cast from array reference to fn: runtime fn ptr" {
12911291 var f = @ptrCast(*align(1) const fn () callconv(.C) void, &global_array);
1292 try expect(@ptrToInt(f) == @ptrToInt(&global_array));
1292 try expect(@intFromPtr(f) == @intFromPtr(&global_array));
12931293}
12941294
12951295test "*const [N]null u8 to ?[]const u8" {
......@@ -1500,19 +1500,19 @@ test "coerce between pointers of compatible differently-named floats" {
15001500}
15011501
15021502test "peer type resolution of const and non-const pointer to array" {
1503 const a = @intToPtr(*[1024]u8, 42);
1504 const b = @intToPtr(*const [1024]u8, 42);
1503 const a = @ptrFromInt(*[1024]u8, 42);
1504 const b = @ptrFromInt(*const [1024]u8, 42);
15051505 try std.testing.expect(@TypeOf(a, b) == *const [1024]u8);
15061506 try std.testing.expect(a == b);
15071507}
15081508
1509test "floatToInt to zero-bit int" {
1509test "intFromFloat to zero-bit int" {
15101510 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
15111511 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
15121512 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
15131513
15141514 const a: f32 = 0.0;
1515 try comptime std.testing.expect(@floatToInt(u0, a) == 0);
1515 try comptime std.testing.expect(@intFromFloat(u0, a) == 0);
15161516}
15171517
15181518test "peer type resolution of function pointer and function body" {
......@@ -1560,9 +1560,9 @@ test "optional pointer coerced to optional allowzero pointer" {
15601560
15611561 var p: ?*u32 = undefined;
15621562 var q: ?*allowzero u32 = undefined;
1563 p = @intToPtr(*u32, 4);
1563 p = @ptrFromInt(*u32, 4);
15641564 q = p;
1565 try expect(@ptrToInt(q.?) == 4);
1565 try expect(@intFromPtr(q.?) == 4);
15661566}
15671567
15681568test "single item pointer to pointer to array to slice" {
......@@ -1623,8 +1623,8 @@ test "peer type resolution: const sentinel slice and mutable non-sentinel slice"
16231623
16241624 const S = struct {
16251625 fn doTheTest(comptime T: type, comptime s: T) !void {
1626 var a: [:s]const T = @intToPtr(*const [2:s]T, 0x1000);
1627 var b: []T = @intToPtr(*[3]T, 0x2000);
1626 var a: [:s]const T = @ptrFromInt(*const [2:s]T, 0x1000);
1627 var b: []T = @ptrFromInt(*[3]T, 0x2000);
16281628 comptime assert(@TypeOf(a, b) == []const T);
16291629 comptime assert(@TypeOf(b, a) == []const T);
16301630
......@@ -1634,8 +1634,8 @@ test "peer type resolution: const sentinel slice and mutable non-sentinel slice"
16341634
16351635 const R = @TypeOf(r1);
16361636
1637 try expectEqual(@as(R, @intToPtr(*const [2:s]T, 0x1000)), r1);
1638 try expectEqual(@as(R, @intToPtr(*const [3]T, 0x2000)), r2);
1637 try expectEqual(@as(R, @ptrFromInt(*const [2:s]T, 0x1000)), r1);
1638 try expectEqual(@as(R, @ptrFromInt(*const [3]T, 0x2000)), r2);
16391639 }
16401640 };
16411641
......@@ -1815,7 +1815,7 @@ test "peer type resolution: three-way resolution combines error set and optional
18151815
18161816 const E = error{Foo};
18171817 var a: E = error.Foo;
1818 var b: *const [5:0]u8 = @intToPtr(*const [5:0]u8, 0x1000);
1818 var b: *const [5:0]u8 = @ptrFromInt(*const [5:0]u8, 0x1000);
18191819 var c: ?[*:0]u8 = null;
18201820 comptime assert(@TypeOf(a, b, c) == E!?[*:0]const u8);
18211821 comptime assert(@TypeOf(a, c, b) == E!?[*:0]const u8);
......@@ -1844,7 +1844,7 @@ test "peer type resolution: three-way resolution combines error set and optional
18441844 const T = @TypeOf(r1);
18451845
18461846 try expectEqual(@as(T, error.Foo), r1);
1847 try expectEqual(@as(T, @intToPtr([*:0]u8, 0x1000)), r2);
1847 try expectEqual(@as(T, @ptrFromInt([*:0]u8, 0x1000)), r2);
18481848 try expectEqual(@as(T, null), r3);
18491849}
18501850
test/behavior/comptime_memory.zig+20-20
......@@ -192,9 +192,9 @@ test "basic pointer preservation" {
192192 }
193193
194194 comptime {
195 const lazy_address = @ptrToInt(&imports.global_u32);
196 try testing.expectEqual(@ptrToInt(&imports.global_u32), lazy_address);
197 try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, lazy_address));
195 const lazy_address = @intFromPtr(&imports.global_u32);
196 try testing.expectEqual(@intFromPtr(&imports.global_u32), lazy_address);
197 try testing.expectEqual(&imports.global_u32, @ptrFromInt(*u32, lazy_address));
198198 }
199199}
200200
......@@ -251,7 +251,7 @@ test "shuffle chunks of linker value" {
251251 return error.SkipZigTest;
252252 }
253253
254 const lazy_address = @ptrToInt(&imports.global_u32);
254 const lazy_address = @intFromPtr(&imports.global_u32);
255255 const shuffled1_rt = shuffle(lazy_address, Bits, ShuffledBits);
256256 const unshuffled1_rt = shuffle(shuffled1_rt, ShuffledBits, Bits);
257257 try testing.expectEqual(lazy_address, unshuffled1_rt);
......@@ -271,8 +271,8 @@ test "dance on linker values" {
271271
272272 comptime {
273273 var arr: [2]usize = undefined;
274 arr[0] = @ptrToInt(&imports.global_u32);
275 arr[1] = @ptrToInt(&imports.global_u32);
274 arr[0] = @intFromPtr(&imports.global_u32);
275 arr[1] = @intFromPtr(&imports.global_u32);
276276
277277 const weird_ptr = @ptrCast([*]Bits, @ptrCast([*]u8, &arr) + @sizeOf(usize) - 3);
278278 try doTypePunBitsTest(&weird_ptr[0]);
......@@ -290,7 +290,7 @@ test "dance on linker values" {
290290 rebuilt_bytes[i] = arr_bytes[1][i];
291291 }
292292
293 try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, @bitCast(usize, rebuilt_bytes)));
293 try testing.expectEqual(&imports.global_u32, @ptrFromInt(*u32, @bitCast(usize, rebuilt_bytes)));
294294 }
295295}
296296
......@@ -309,14 +309,14 @@ test "offset array ptr by element size" {
309309 .{ .x = bigToNativeEndian(u32, 0x03070b0f) },
310310 };
311311
312 const address = @ptrToInt(&arr);
313 try testing.expectEqual(@ptrToInt(&arr[0]), address);
314 try testing.expectEqual(@ptrToInt(&arr[0]) + 10, address + 10);
315 try testing.expectEqual(@ptrToInt(&arr[1]), address + @sizeOf(VirtualStruct));
316 try testing.expectEqual(@ptrToInt(&arr[2]), address + 2 * @sizeOf(VirtualStruct));
317 try testing.expectEqual(@ptrToInt(&arr[3]), address + @sizeOf(VirtualStruct) * 3);
312 const address = @intFromPtr(&arr);
313 try testing.expectEqual(@intFromPtr(&arr[0]), address);
314 try testing.expectEqual(@intFromPtr(&arr[0]) + 10, address + 10);
315 try testing.expectEqual(@intFromPtr(&arr[1]), address + @sizeOf(VirtualStruct));
316 try testing.expectEqual(@intFromPtr(&arr[2]), address + 2 * @sizeOf(VirtualStruct));
317 try testing.expectEqual(@intFromPtr(&arr[3]), address + @sizeOf(VirtualStruct) * 3);
318318
319 const secondElement = @intToPtr(*VirtualStruct, @ptrToInt(&arr[0]) + 2 * @sizeOf(VirtualStruct));
319 const secondElement = @ptrFromInt(*VirtualStruct, @intFromPtr(&arr[0]) + 2 * @sizeOf(VirtualStruct));
320320 try testing.expectEqual(bigToNativeEndian(u32, 0x02060a0e), secondElement.x);
321321 }
322322}
......@@ -331,18 +331,18 @@ test "offset instance by field size" {
331331 const VirtualStruct = struct { x: u32, y: u32, z: u32, w: u32 };
332332 var inst = VirtualStruct{ .x = 0, .y = 1, .z = 2, .w = 3 };
333333
334 var ptr = @ptrToInt(&inst);
334 var ptr = @intFromPtr(&inst);
335335 ptr -= 4;
336336 ptr += @offsetOf(VirtualStruct, "x");
337 try testing.expectEqual(@as(u32, 0), @intToPtr([*]u32, ptr)[1]);
337 try testing.expectEqual(@as(u32, 0), @ptrFromInt([*]u32, ptr)[1]);
338338 ptr -= @offsetOf(VirtualStruct, "x");
339339 ptr += @offsetOf(VirtualStruct, "y");
340 try testing.expectEqual(@as(u32, 1), @intToPtr([*]u32, ptr)[1]);
340 try testing.expectEqual(@as(u32, 1), @ptrFromInt([*]u32, ptr)[1]);
341341 ptr = ptr - @offsetOf(VirtualStruct, "y") + @offsetOf(VirtualStruct, "z");
342 try testing.expectEqual(@as(u32, 2), @intToPtr([*]u32, ptr)[1]);
343 ptr = @ptrToInt(&inst.z) - 4 - @offsetOf(VirtualStruct, "z");
342 try testing.expectEqual(@as(u32, 2), @ptrFromInt([*]u32, ptr)[1]);
343 ptr = @intFromPtr(&inst.z) - 4 - @offsetOf(VirtualStruct, "z");
344344 ptr += @offsetOf(VirtualStruct, "w");
345 try testing.expectEqual(@as(u32, 3), @intToPtr(*u32, ptr + 4).*);
345 try testing.expectEqual(@as(u32, 3), @ptrFromInt(*u32, ptr + 4).*);
346346 }
347347}
348348
test/behavior/enum.zig+30-30
......@@ -8,7 +8,7 @@ const Tag = std.meta.Tag;
88const Number = enum { Zero, One, Two, Three, Four };
99
1010fn shouldEqual(n: Number, expected: u3) !void {
11 try expect(@enumToInt(n) == expected);
11 try expect(@intFromEnum(n) == expected);
1212}
1313
1414test "enum to int" {
......@@ -20,7 +20,7 @@ test "enum to int" {
2020}
2121
2222fn testIntToEnumEval(x: i32) !void {
23 try expect(@intToEnum(IntToEnumNumber, x) == IntToEnumNumber.Three);
23 try expect(@enumFromInt(IntToEnumNumber, x) == IntToEnumNumber.Three);
2424}
2525const IntToEnumNumber = enum { Zero, One, Two, Three, Four };
2626
......@@ -597,7 +597,7 @@ const MultipleChoice = enum(u32) {
597597};
598598
599599fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void {
600 try expect(@enumToInt(x) == 60);
600 try expect(@intFromEnum(x) == 60);
601601 try expect(1234 == switch (x) {
602602 MultipleChoice.A => 1,
603603 MultipleChoice.B => 2,
......@@ -629,7 +629,7 @@ test "non-exhaustive enum" {
629629 .b => true,
630630 _ => false,
631631 });
632 e = @intToEnum(E, 12);
632 e = @enumFromInt(E, 12);
633633 try expect(switch (e) {
634634 .a => false,
635635 .b => false,
......@@ -648,10 +648,10 @@ test "non-exhaustive enum" {
648648 });
649649
650650 try expect(@typeInfo(E).Enum.fields.len == 2);
651 e = @intToEnum(E, 12);
652 try expect(@enumToInt(e) == 12);
653 e = @intToEnum(E, y);
654 try expect(@enumToInt(e) == 52);
651 e = @enumFromInt(E, 12);
652 try expect(@intFromEnum(e) == 12);
653 e = @enumFromInt(E, y);
654 try expect(@intFromEnum(e) == 52);
655655 try expect(@typeInfo(E).Enum.is_exhaustive == false);
656656 }
657657 };
......@@ -666,11 +666,11 @@ test "empty non-exhaustive enum" {
666666 const E = enum(u8) { _ };
667667
668668 fn doTheTest(y: u8) !void {
669 var e = @intToEnum(E, y);
669 var e = @enumFromInt(E, y);
670670 try expect(switch (e) {
671671 _ => true,
672672 });
673 try expect(@enumToInt(e) == y);
673 try expect(@intFromEnum(e) == y);
674674
675675 try expect(@typeInfo(E).Enum.fields.len == 0);
676676 try expect(@typeInfo(E).Enum.is_exhaustive == false);
......@@ -693,7 +693,7 @@ test "single field non-exhaustive enum" {
693693 .a => true,
694694 _ => false,
695695 });
696 e = @intToEnum(E, 12);
696 e = @enumFromInt(E, 12);
697697 try expect(switch (e) {
698698 .a => false,
699699 _ => true,
......@@ -709,7 +709,7 @@ test "single field non-exhaustive enum" {
709709 else => false,
710710 });
711711
712 try expect(@enumToInt(@intToEnum(E, y)) == y);
712 try expect(@intFromEnum(@enumFromInt(E, y)) == y);
713713 try expect(@typeInfo(E).Enum.fields.len == 1);
714714 try expect(@typeInfo(E).Enum.is_exhaustive == false);
715715 }
......@@ -725,7 +725,7 @@ const EnumWithTagValues = enum(u4) {
725725 D = 1 << 3,
726726};
727727test "enum with tag values don't require parens" {
728 try expect(@enumToInt(EnumWithTagValues.C) == 0b0100);
728 try expect(@intFromEnum(EnumWithTagValues.C) == 0b0100);
729729}
730730
731731const MultipleChoice2 = enum(u32) {
......@@ -741,8 +741,8 @@ const MultipleChoice2 = enum(u32) {
741741};
742742
743743test "cast integer literal to enum" {
744 try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);
745 try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B);
744 try expect(@enumFromInt(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);
745 try expect(@enumFromInt(MultipleChoice2, 40) == MultipleChoice2.B);
746746}
747747
748748test "enum with specified and unspecified tag values" {
......@@ -754,7 +754,7 @@ test "enum with specified and unspecified tag values" {
754754}
755755
756756fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void {
757 try expect(@enumToInt(x) == 1000);
757 try expect(@intFromEnum(x) == 1000);
758758 try expect(1234 == switch (x) {
759759 MultipleChoice2.A => 1,
760760 MultipleChoice2.B => 2,
......@@ -790,7 +790,7 @@ test "casting enum to its tag type" {
790790}
791791
792792fn testCastEnumTag(value: Small2) !void {
793 try expect(@enumToInt(value) == 1);
793 try expect(@intFromEnum(value) == 1);
794794}
795795
796796test "enum with 1 field but explicit tag type should still have the tag type" {
......@@ -807,27 +807,27 @@ test "signed integer as enum tag" {
807807 A2 = 1,
808808 };
809809
810 try expect(@enumToInt(SignedEnum.A0) == -1);
811 try expect(@enumToInt(SignedEnum.A1) == 0);
812 try expect(@enumToInt(SignedEnum.A2) == 1);
810 try expect(@intFromEnum(SignedEnum.A0) == -1);
811 try expect(@intFromEnum(SignedEnum.A1) == 0);
812 try expect(@intFromEnum(SignedEnum.A2) == 1);
813813}
814814
815815test "enum with one member and custom tag type" {
816816 const E = enum(u2) {
817817 One,
818818 };
819 try expect(@enumToInt(E.One) == 0);
819 try expect(@intFromEnum(E.One) == 0);
820820 const E2 = enum(u2) {
821821 One = 2,
822822 };
823 try expect(@enumToInt(E2.One) == 2);
823 try expect(@intFromEnum(E2.One) == 2);
824824}
825825
826test "enum with one member and u1 tag type @enumToInt" {
826test "enum with one member and u1 tag type @intFromEnum" {
827827 const Enum = enum(u1) {
828828 Test,
829829 };
830 try expect(@enumToInt(Enum.Test) == 0);
830 try expect(@intFromEnum(Enum.Test) == 0);
831831}
832832
833833test "enum with comptime_int tag type" {
......@@ -901,9 +901,9 @@ test "enum value allocation" {
901901 A2,
902902 };
903903
904 try expect(@enumToInt(LargeEnum.A0) == 0x80000000);
905 try expect(@enumToInt(LargeEnum.A1) == 0x80000001);
906 try expect(@enumToInt(LargeEnum.A2) == 0x80000002);
904 try expect(@intFromEnum(LargeEnum.A0) == 0x80000000);
905 try expect(@intFromEnum(LargeEnum.A1) == 0x80000001);
906 try expect(@intFromEnum(LargeEnum.A2) == 0x80000002);
907907}
908908
909909test "enum literal casting to tagged union" {
......@@ -1183,7 +1183,7 @@ test "Non-exhaustive enum with nonstandard int size behaves correctly" {
11831183test "runtime int to enum with one possible value" {
11841184 const E = enum { one };
11851185 var runtime: usize = 0;
1186 if (@intToEnum(E, runtime) != .one) {
1186 if (@enumFromInt(E, runtime) != .one) {
11871187 @compileError("test failed");
11881188 }
11891189}
......@@ -1194,6 +1194,6 @@ test "enum tag from a local variable" {
11941194 return enum(Inner) { _ };
11951195 }
11961196 };
1197 const i = @intToEnum(S.Int(u32), 0);
1198 try std.testing.expect(@enumToInt(i) == 0);
1197 const i = @enumFromInt(S.Int(u32), 0);
1198 try std.testing.expect(@intFromEnum(i) == 0);
11991199}
test/behavior/error.zig+5-5
......@@ -16,8 +16,8 @@ fn expectError(expected_err: anyerror, observed_err_union: anytype) !void {
1616}
1717
1818test "error values" {
19 const a = @errorToInt(error.err1);
20 const b = @errorToInt(error.err2);
19 const a = @intFromError(error.err1);
20 const b = @intFromError(error.err2);
2121 try expect(a != b);
2222}
2323
......@@ -259,14 +259,14 @@ fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void {
259259}
260260
261261test "comptime err to int of error set with only 1 possible value" {
262 testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A));
263 comptime testErrToIntWithOnePossibleValue(error.A, @errorToInt(error.A));
262 testErrToIntWithOnePossibleValue(error.A, @intFromError(error.A));
263 comptime testErrToIntWithOnePossibleValue(error.A, @intFromError(error.A));
264264}
265265fn testErrToIntWithOnePossibleValue(
266266 x: error{A},
267267 comptime value: u32,
268268) void {
269 if (@errorToInt(x) != value) {
269 if (@intFromError(x) != value) {
270270 @compileError("bad");
271271 }
272272}
test/behavior/eval.zig+1-1
......@@ -1372,7 +1372,7 @@ test "lazy value is resolved as slice operand" {
13721372
13731373 const ptr1 = a[0..@sizeOf(A)];
13741374 const ptr2 = @ptrCast([*]u8, &a)[0..@sizeOf(A)];
1375 try expect(@ptrToInt(ptr1) == @ptrToInt(ptr2));
1375 try expect(@intFromPtr(ptr1) == @intFromPtr(ptr2));
13761376 try expect(ptr1.len == ptr2.len);
13771377}
13781378
test/behavior/export.zig+1-1
......@@ -7,7 +7,7 @@ const builtin = @import("builtin");
77
88// can't really run this test but we can make sure it has no compile error
99// and generates code
10const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000];
10const vram = @ptrFromInt([*]volatile u8, 0x20000000)[0..0x8000];
1111export fn writeToVRam() void {
1212 vram[0] = 'X';
1313}
test/behavior/export_self_referential_type_info.zig+1-1
......@@ -1 +1 @@
1export const self_referential_type_info: c_int = @boolToInt(@typeInfo(@This()).Struct.is_tuple);
1export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).Struct.is_tuple);
test/behavior/floatop.zig+2-2
......@@ -89,12 +89,12 @@ fn testDifferentSizedFloatComparisons() !void {
8989// }
9090//}
9191
92test "negative f128 floatToInt at compile-time" {
92test "negative f128 intFromFloat at compile-time" {
9393 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
9494 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
9595
9696 const a: f128 = -2;
97 var b = @floatToInt(i64, a);
97 var b = @intFromFloat(i64, a);
9898 try expect(@as(i64, -2) == b);
9999}
100100
test/behavior/fn_in_struct_in_comptime.zig+2-2
......@@ -5,7 +5,7 @@ fn get_foo() fn (*u8) usize {
55 comptime {
66 return struct {
77 fn func(ptr: *u8) usize {
8 var u = @ptrToInt(ptr);
8 var u = @intFromPtr(ptr);
99 return u;
1010 }
1111 }.func;
......@@ -14,5 +14,5 @@ fn get_foo() fn (*u8) usize {
1414
1515test "define a function in an anonymous struct in comptime" {
1616 const foo = get_foo();
17 try expect(foo(@intToPtr(*u8, 12345)) == 12345);
17 try expect(foo(@ptrFromInt(*u8, 12345)) == 12345);
1818}
test/behavior/generics.zig+3-3
......@@ -267,7 +267,7 @@ test "generic function instantiation turns into comptime call" {
267267 .Enum => std.builtin.Type.EnumField,
268268 else => void,
269269 } {
270 return @typeInfo(T).Enum.fields[@enumToInt(field)];
270 return @typeInfo(T).Enum.fields[@intFromEnum(field)];
271271 }
272272
273273 pub fn FieldEnum(comptime T: type) type {
......@@ -425,10 +425,10 @@ test "null sentinel pointer passed as generic argument" {
425425
426426 const S = struct {
427427 fn doTheTest(a: anytype) !void {
428 try std.testing.expect(@ptrToInt(a) == 8);
428 try std.testing.expect(@intFromPtr(a) == 8);
429429 }
430430 };
431 try S.doTheTest((@intToPtr([*:null]const [*c]const u8, 8)));
431 try S.doTheTest((@ptrFromInt([*:null]const [*c]const u8, 8)));
432432}
433433
434434test "generic function passed as comptime argument" {
test/behavior/inline_switch.zig+1-1
......@@ -103,7 +103,7 @@ test "inline else enum" {
103103 var a: E2 = .a;
104104 switch (a) {
105105 .a, .b => {},
106 inline else => |val| comptime if (@enumToInt(val) < 4) @compileError("bad"),
106 inline else => |val| comptime if (@intFromEnum(val) < 4) @compileError("bad"),
107107 }
108108}
109109
test/behavior/inttoptr.zig deleted-48
......@@ -1,48 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const expectEqual = std.testing.expectEqual;
4
5test "casting integer address to function pointer" {
6 addressToFunction();
7 comptime addressToFunction();
8}
9
10fn addressToFunction() void {
11 var addr: usize = 0xdeadbee0;
12 _ = @intToPtr(*const fn () void, addr);
13}
14
15test "mutate through ptr initialized with constant intToPtr value" {
16 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
17 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
18 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
19
20 forceCompilerAnalyzeBranchHardCodedPtrDereference(false);
21}
22
23fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void {
24 const hardCodedP = @intToPtr(*volatile u8, 0xdeadbeef);
25 if (x) {
26 hardCodedP.* = hardCodedP.* | 10;
27 } else {
28 return;
29 }
30}
31
32test "@intToPtr creates null pointer" {
33 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
34 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
35 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
36
37 const ptr = @intToPtr(?*u32, 0);
38 try expectEqual(@as(?*u32, null), ptr);
39}
40
41test "@intToPtr creates allowzero zero pointer" {
42 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
43 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
44 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
45
46 const ptr = @intToPtr(*allowzero u32, 0);
47 try expectEqual(@as(usize, 0), @ptrToInt(ptr));
48}
test/behavior/packed-struct.zig+2-2
......@@ -375,7 +375,7 @@ test "load pointer from packed struct" {
375375 }
376376}
377377
378test "@ptrToInt on a packed struct field" {
378test "@intFromPtr on a packed struct field" {
379379 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
380380 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
381381 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
......@@ -394,7 +394,7 @@ test "@ptrToInt on a packed struct field" {
394394 .z = 0,
395395 };
396396 };
397 try expect(@ptrToInt(&S.p0.z) - @ptrToInt(&S.p0.x) == 2);
397 try expect(@intFromPtr(&S.p0.z) - @intFromPtr(&S.p0.x) == 2);
398398}
399399
400400test "optional pointer in packed struct" {
test/behavior/pointers.zig+16-16
......@@ -184,8 +184,8 @@ test "implicit cast error unions with non-optional to optional pointer" {
184184}
185185
186186test "compare equality of optional and non-optional pointer" {
187 const a = @intToPtr(*const usize, 0x12345678);
188 const b = @intToPtr(?*usize, 0x12345678);
187 const a = @ptrFromInt(*const usize, 0x12345678);
188 const b = @ptrFromInt(?*usize, 0x12345678);
189189 try expect(a == b);
190190 try expect(b == a);
191191}
......@@ -197,14 +197,14 @@ test "allowzero pointer and slice" {
197197 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
198198 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
199199
200 var ptr = @intToPtr([*]allowzero i32, 0);
200 var ptr = @ptrFromInt([*]allowzero i32, 0);
201201 var opt_ptr: ?[*]allowzero i32 = ptr;
202202 try expect(opt_ptr != null);
203 try expect(@ptrToInt(ptr) == 0);
203 try expect(@intFromPtr(ptr) == 0);
204204 var runtime_zero: usize = 0;
205205 var slice = ptr[runtime_zero..10];
206206 try comptime expect(@TypeOf(slice) == []allowzero i32);
207 try expect(@ptrToInt(&slice[5]) == 20);
207 try expect(@intFromPtr(&slice[5]) == 20);
208208
209209 try comptime expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);
210210 try comptime expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);
......@@ -367,10 +367,10 @@ test "pointer sentinel with +inf" {
367367}
368368
369369test "pointer to array at fixed address" {
370 const array = @intToPtr(*volatile [2]u32, 0x10);
370 const array = @ptrFromInt(*volatile [2]u32, 0x10);
371371 // Silly check just to reference `array`
372 try expect(@ptrToInt(&array[0]) == 0x10);
373 try expect(@ptrToInt(&array[1]) == 0x14);
372 try expect(@intFromPtr(&array[0]) == 0x10);
373 try expect(@intFromPtr(&array[1]) == 0x14);
374374}
375375
376376test "pointer arithmetic affects the alignment" {
......@@ -404,16 +404,16 @@ test "pointer arithmetic affects the alignment" {
404404 }
405405}
406406
407test "@ptrToInt on null optional at comptime" {
407test "@intFromPtr on null optional at comptime" {
408408 {
409 const pointer = @intToPtr(?*u8, 0x000);
410 const x = @ptrToInt(pointer);
409 const pointer = @ptrFromInt(?*u8, 0x000);
410 const x = @intFromPtr(pointer);
411411 _ = x;
412 try comptime expect(0 == @ptrToInt(pointer));
412 try comptime expect(0 == @intFromPtr(pointer));
413413 }
414414 {
415 const pointer = @intToPtr(?*u8, 0xf00);
416 try comptime expect(0xf00 == @ptrToInt(pointer));
415 const pointer = @ptrFromInt(?*u8, 0xf00);
416 try comptime expect(0xf00 == @intFromPtr(pointer));
417417 }
418418}
419419
......@@ -516,7 +516,7 @@ test "ptrCast comptime known slice to C pointer" {
516516 try std.testing.expectEqualStrings(s, std.mem.sliceTo(p, 0));
517517}
518518
519test "ptrToInt on a generic function" {
519test "intFromPtr on a generic function" {
520520 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
521521 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
522522 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
......@@ -527,7 +527,7 @@ test "ptrToInt on a generic function" {
527527 return i;
528528 }
529529 fn doTheTest(a: anytype) !void {
530 try expect(@ptrToInt(a) != 0);
530 try expect(@intFromPtr(a) != 0);
531531 }
532532 };
533533 try S.doTheTest(&S.generic);
test/behavior/ptrfromint.zig created+48
......@@ -0,0 +1,48 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const expectEqual = std.testing.expectEqual;
4
5test "casting integer address to function pointer" {
6 addressToFunction();
7 comptime addressToFunction();
8}
9
10fn addressToFunction() void {
11 var addr: usize = 0xdeadbee0;
12 _ = @ptrFromInt(*const fn () void, addr);
13}
14
15test "mutate through ptr initialized with constant ptrFromInt value" {
16 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
17 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
18 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
19
20 forceCompilerAnalyzeBranchHardCodedPtrDereference(false);
21}
22
23fn forceCompilerAnalyzeBranchHardCodedPtrDereference(x: bool) void {
24 const hardCodedP = @ptrFromInt(*volatile u8, 0xdeadbeef);
25 if (x) {
26 hardCodedP.* = hardCodedP.* | 10;
27 } else {
28 return;
29 }
30}
31
32test "@ptrFromInt creates null pointer" {
33 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
34 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
35 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
36
37 const ptr = @ptrFromInt(?*u32, 0);
38 try expectEqual(@as(?*u32, null), ptr);
39}
40
41test "@ptrFromInt creates allowzero zero pointer" {
42 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
43 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
44 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
45
46 const ptr = @ptrFromInt(*allowzero u32, 0);
47 try expectEqual(@as(usize, 0), @intFromPtr(ptr));
48}
test/behavior/sizeof_and_typeof.zig+11-11
......@@ -92,15 +92,15 @@ test "@offsetOf" {
9292
9393 // // Normal struct fields can be moved/padded
9494 var a: A = undefined;
95 try expect(@ptrToInt(&a.a) - @ptrToInt(&a) == @offsetOf(A, "a"));
96 try expect(@ptrToInt(&a.b) - @ptrToInt(&a) == @offsetOf(A, "b"));
97 try expect(@ptrToInt(&a.c) - @ptrToInt(&a) == @offsetOf(A, "c"));
98 try expect(@ptrToInt(&a.d) - @ptrToInt(&a) == @offsetOf(A, "d"));
99 try expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @offsetOf(A, "e"));
100 try expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @offsetOf(A, "f"));
101 try expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @offsetOf(A, "g"));
102 try expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @offsetOf(A, "h"));
103 try expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @offsetOf(A, "i"));
95 try expect(@intFromPtr(&a.a) - @intFromPtr(&a) == @offsetOf(A, "a"));
96 try expect(@intFromPtr(&a.b) - @intFromPtr(&a) == @offsetOf(A, "b"));
97 try expect(@intFromPtr(&a.c) - @intFromPtr(&a) == @offsetOf(A, "c"));
98 try expect(@intFromPtr(&a.d) - @intFromPtr(&a) == @offsetOf(A, "d"));
99 try expect(@intFromPtr(&a.e) - @intFromPtr(&a) == @offsetOf(A, "e"));
100 try expect(@intFromPtr(&a.f) - @intFromPtr(&a) == @offsetOf(A, "f"));
101 try expect(@intFromPtr(&a.g) - @intFromPtr(&a) == @offsetOf(A, "g"));
102 try expect(@intFromPtr(&a.h) - @intFromPtr(&a) == @offsetOf(A, "h"));
103 try expect(@intFromPtr(&a.i) - @intFromPtr(&a) == @offsetOf(A, "i"));
104104}
105105
106106test "@bitOffsetOf" {
......@@ -231,7 +231,7 @@ test "@sizeOf comparison against zero" {
231231
232232test "hardcoded address in typeof expression" {
233233 const S = struct {
234 fn func() @TypeOf(@intToPtr(*[]u8, 0x10).*[0]) {
234 fn func() @TypeOf(@ptrFromInt(*[]u8, 0x10).*[0]) {
235235 return 0;
236236 }
237237 };
......@@ -252,7 +252,7 @@ test "array access of generic param in typeof expression" {
252252test "lazy size cast to float" {
253253 {
254254 const S = struct { a: u8 };
255 try expect(@intToFloat(f32, @sizeOf(S)) == 1.0);
255 try expect(@floatFromInt(f32, @sizeOf(S)) == 1.0);
256256 }
257257 {
258258 const S = struct { a: u8 };
test/behavior/slice.zig+7-7
......@@ -138,10 +138,10 @@ fn memFree(comptime T: type, memory: []T) void {
138138test "slice of hardcoded address to pointer" {
139139 const S = struct {
140140 fn doTheTest() !void {
141 const pointer = @intToPtr([*]u8, 0x04)[0..2];
141 const pointer = @ptrFromInt([*]u8, 0x04)[0..2];
142142 try comptime expect(@TypeOf(pointer) == *[2]u8);
143143 const slice: []const u8 = pointer;
144 try expect(@ptrToInt(slice.ptr) == 4);
144 try expect(@intFromPtr(slice.ptr) == 4);
145145 try expect(slice.len == 2);
146146 }
147147 };
......@@ -197,13 +197,13 @@ test "slicing pointer by length" {
197197 }
198198}
199199
200const x = @intToPtr([*]i32, 0x1000)[0..0x500];
200const x = @ptrFromInt([*]i32, 0x1000)[0..0x500];
201201const y = x[0x100..];
202202test "compile time slice of pointer to hard coded address" {
203 try expect(@ptrToInt(x) == 0x1000);
203 try expect(@intFromPtr(x) == 0x1000);
204204 try expect(x.len == 0x500);
205205
206 try expect(@ptrToInt(y) == 0x1400);
206 try expect(@intFromPtr(y) == 0x1400);
207207 try expect(y.len == 0x400);
208208}
209209
......@@ -838,13 +838,13 @@ test "empty slice ptr is non null" {
838838 const empty_slice: []u8 = &[_]u8{};
839839 const p: [*]u8 = empty_slice.ptr + 0;
840840 const t = @ptrCast([*]i8, p);
841 try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr));
841 try expect(@intFromPtr(t) == @intFromPtr(empty_slice.ptr));
842842 }
843843 {
844844 const empty_slice: []u8 = &.{};
845845 const p: [*]u8 = empty_slice.ptr + 0;
846846 const t = @ptrCast([*]i8, p);
847 try expect(@ptrToInt(t) == @ptrToInt(empty_slice.ptr));
847 try expect(@intFromPtr(t) == @intFromPtr(empty_slice.ptr));
848848 }
849849}
850850
test/behavior/struct.zig+1-1
......@@ -838,7 +838,7 @@ test "non-packed struct with u128 entry in union" {
838838
839839 var sx: S = undefined;
840840 var s = &sx;
841 try expect(@ptrToInt(&s.f2) - @ptrToInt(&s.f1) == @offsetOf(S, "f2"));
841 try expect(@intFromPtr(&s.f2) - @intFromPtr(&s.f1) == @offsetOf(S, "f2"));
842842 var v2 = U{ .Num = 123 };
843843 s.f2 = v2;
844844 try expect(s.f2.Num == 123);
test/behavior/switch.zig+5-5
......@@ -590,9 +590,9 @@ test "switch on pointer type" {
590590 field: u32,
591591 };
592592
593 const P1 = @intToPtr(*X, 0x400);
594 const P2 = @intToPtr(*X, 0x800);
595 const P3 = @intToPtr(*X, 0xC00);
593 const P1 = @ptrFromInt(*X, 0x400);
594 const P2 = @ptrFromInt(*X, 0x800);
595 const P3 = @ptrFromInt(*X, 0xC00);
596596
597597 fn doTheTest(arg: *X) i32 {
598598 switch (arg) {
......@@ -682,9 +682,9 @@ test "enum value without tag name used as switch item" {
682682 b = 2,
683683 _,
684684 };
685 var e: E = @intToEnum(E, 0);
685 var e: E = @enumFromInt(E, 0);
686686 switch (e) {
687 @intToEnum(E, 0) => {},
687 @enumFromInt(E, 0) => {},
688688 .a => return error.TestFailed,
689689 .b => return error.TestFailed,
690690 _ => return error.TestFailed,
test/behavior/translate_c_macros.zig+1-1
......@@ -60,7 +60,7 @@ test "cast negative integer to pointer" {
6060 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
6161 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
6262
63 try expectEqual(@intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED);
63 try expectEqual(@ptrFromInt(?*anyopaque, @bitCast(usize, @as(isize, -1))), h.MAP_FAILED);
6464}
6565
6666test "casting to union with a macro" {
test/behavior/type.zig+5-5
......@@ -363,8 +363,8 @@ test "Type.Enum" {
363363 },
364364 });
365365 try testing.expectEqual(true, @typeInfo(Foo).Enum.is_exhaustive);
366 try testing.expectEqual(@as(u8, 1), @enumToInt(Foo.a));
367 try testing.expectEqual(@as(u8, 5), @enumToInt(Foo.b));
366 try testing.expectEqual(@as(u8, 1), @intFromEnum(Foo.a));
367 try testing.expectEqual(@as(u8, 5), @intFromEnum(Foo.b));
368368 const Bar = @Type(.{
369369 .Enum = .{
370370 .tag_type = u32,
......@@ -377,9 +377,9 @@ test "Type.Enum" {
377377 },
378378 });
379379 try testing.expectEqual(false, @typeInfo(Bar).Enum.is_exhaustive);
380 try testing.expectEqual(@as(u32, 1), @enumToInt(Bar.a));
381 try testing.expectEqual(@as(u32, 5), @enumToInt(Bar.b));
382 try testing.expectEqual(@as(u32, 6), @enumToInt(@intToEnum(Bar, 6)));
380 try testing.expectEqual(@as(u32, 1), @intFromEnum(Bar.a));
381 try testing.expectEqual(@as(u32, 5), @intFromEnum(Bar.b));
382 try testing.expectEqual(@as(u32, 6), @intFromEnum(@enumFromInt(Bar, 6)));
383383}
384384
385385test "Type.Union" {
test/behavior/union.zig+9-9
......@@ -364,7 +364,7 @@ test "simple union(enum(u32))" {
364364
365365 var x = MultipleChoice.C;
366366 try expect(x == MultipleChoice.C);
367 try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60);
367 try expect(@intFromEnum(@as(Tag(MultipleChoice), x)) == 60);
368368}
369369
370370const PackedPtrOrInt = packed union {
......@@ -655,7 +655,7 @@ const MultipleChoice2 = union(enum(u32)) {
655655};
656656
657657fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void {
658 try expect(@enumToInt(@as(Tag(MultipleChoice2), x)) == 60);
658 try expect(@intFromEnum(@as(Tag(MultipleChoice2), x)) == 60);
659659 try expect(1123 == switch (x) {
660660 MultipleChoice2.A => 1,
661661 MultipleChoice2.B => 2,
......@@ -721,11 +721,11 @@ test "union with only 1 field casted to its enum type which has enum value speci
721721 try comptime expect(Tag(ExprTag) == comptime_int);
722722 comptime var t = @as(ExprTag, e);
723723 try expect(t == Expr.Literal);
724 try expect(@enumToInt(t) == 33);
725 try comptime expect(@enumToInt(t) == 33);
724 try expect(@intFromEnum(t) == 33);
725 try comptime expect(@intFromEnum(t) == 33);
726726}
727727
728test "@enumToInt works on unions" {
728test "@intFromEnum works on unions" {
729729 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
730730 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
731731 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
......@@ -739,9 +739,9 @@ test "@enumToInt works on unions" {
739739 const a = Bar{ .A = true };
740740 var b = Bar{ .B = undefined };
741741 var c = Bar.C;
742 try expect(@enumToInt(a) == 0);
743 try expect(@enumToInt(b) == 1);
744 try expect(@enumToInt(c) == 2);
742 try expect(@intFromEnum(a) == 0);
743 try expect(@intFromEnum(b) == 1);
744 try expect(@intFromEnum(c) == 2);
745745}
746746
747747test "comptime union field value equality" {
......@@ -1396,7 +1396,7 @@ test "@unionInit uses tag value instead of field index" {
13961396 var a = &u.b;
13971397 try expect(a.* == i);
13981398 }
1399 try expect(@enumToInt(u) == 255);
1399 try expect(@intFromEnum(u) == 255);
14001400}
14011401
14021402test "union field ptr - zero sized payload" {
test/behavior/vector.zig+1-1
......@@ -1173,7 +1173,7 @@ test "byte vector initialized in inline function" {
11731173 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
11741174
11751175 if (comptime builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .x86_64 and
1176 builtin.cpu.features.isEnabled(@enumToInt(std.Target.x86.Feature.avx512f)))
1176 builtin.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.avx512f)))
11771177 {
11781178 // TODO https://github.com/ziglang/zig/issues/13279
11791179 return error.SkipZigTest;
test/c_abi/main.zig+5-5
......@@ -143,11 +143,11 @@ export fn zig_longdouble(x: c_longdouble) void {
143143extern fn c_ptr(*anyopaque) void;
144144
145145test "C ABI pointer" {
146 c_ptr(@intToPtr(*anyopaque, 0xdeadbeef));
146 c_ptr(@ptrFromInt(*anyopaque, 0xdeadbeef));
147147}
148148
149149export fn zig_ptr(x: *anyopaque) void {
150 expect(@ptrToInt(x) == 0xdeadbeef) catch @panic("test failure: zig_ptr");
150 expect(@intFromPtr(x) == 0xdeadbeef) catch @panic("test failure: zig_ptr");
151151}
152152
153153extern fn c_bool(bool) void;
......@@ -1058,14 +1058,14 @@ test "C function that takes byval struct called via function pointer" {
10581058
10591059 var fn_ptr = &c_func_ptr_byval;
10601060 fn_ptr(
1061 @intToPtr(*anyopaque, 1),
1062 @intToPtr(*anyopaque, 2),
1061 @ptrFromInt(*anyopaque, 1),
1062 @ptrFromInt(*anyopaque, 2),
10631063 ByVal{
10641064 .origin = .{ .x = 9, .y = 10, .z = 11 },
10651065 .size = .{ .width = 12, .height = 13, .depth = 14 },
10661066 },
10671067 @as(c_ulong, 3),
1068 @intToPtr(*anyopaque, 4),
1068 @ptrFromInt(*anyopaque, 4),
10691069 @as(c_ulong, 5),
10701070 );
10711071}
test/cases/assert_function.18.zig+1-1
......@@ -7,7 +7,7 @@ pub fn main() void {
77}
88
99fn print() void {
10 _ = write(1, @ptrToInt("hello\n"), 6);
10 _ = write(1, @intFromPtr("hello\n"), 6);
1111}
1212
1313// run
test/cases/assert_function.7.zig+1-1
......@@ -7,7 +7,7 @@ pub fn main() void {
77}
88
99fn print() void {
10 _ = write(1, @ptrToInt("hello\n"), 6);
10 _ = write(1, @intFromPtr("hello\n"), 6);
1111}
1212
1313pub fn assert(ok: bool) void {
test/cases/assert_function.8.zig+1-1
......@@ -7,7 +7,7 @@ pub fn main() void {
77}
88
99fn print() void {
10 _ = write(1, @ptrToInt("hello\n"), 6);
10 _ = write(1, @intFromPtr("hello\n"), 6);
1111}
1212
1313pub fn assert(ok: bool) void {
test/cases/compile_errors/add_overflow_in_function_evaluation.zig+3-1
......@@ -3,7 +3,9 @@ fn add(a: u16, b: u16) u16 {
33 return a + b;
44}
55
6export fn entry() usize { return @sizeOf(@TypeOf(y)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(y));
8}
79
810// error
911// backend=stage2
test/cases/compile_errors/addition_with_non_numbers.zig+5-3
......@@ -1,12 +1,14 @@
11const Foo = struct {
22 field: i32,
33};
4const x = Foo {.field = 1} + Foo {.field = 2};
4const x = Foo{ .field = 1 } + Foo{ .field = 2 };
55
6export fn entry() usize { return @sizeOf(@TypeOf(x)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(x));
8}
79
810// error
911// backend=llvm
1012// target=native
1113//
12// :4:28: error: invalid operands to binary expression: 'Struct' and 'Struct'
14// :4:29: error: invalid operands to binary expression: 'Struct' and 'Struct'
test/cases/compile_errors/address_of_number_literal.zig+8-4
......@@ -1,12 +1,16 @@
11const x = 3;
22const y = &x;
3fn foo() *const i32 { return y; }
4export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
3fn foo() *const i32 {
4 return y;
5}
6export fn entry() usize {
7 return @sizeOf(@TypeOf(&foo));
8}
59
610// error
711// backend=stage2
812// target=native
913//
10// :3:30: error: expected type '*const i32', found '*const comptime_int'
11// :3:30: note: pointer type child 'comptime_int' cannot cast into pointer type child 'i32'
14// :4:12: error: expected type '*const i32', found '*const comptime_int'
15// :4:12: note: pointer type child 'comptime_int' cannot cast into pointer type child 'i32'
1216// :3:10: note: function return type declared here
test/cases/compile_errors/alignment_of_enum_field_specified.zig+4-1
......@@ -1,7 +1,10 @@
1// zig fmt: off
12const Number = enum {
23 a,
34 b align(i32),
45};
6// zig fmt: on
7
58export fn entry1() void {
69 var x: Number = undefined;
710 _ = x;
......@@ -11,4 +14,4 @@ export fn entry1() void {
1114// backend=stage2
1215// target=native
1316//
14// :3:13: error: enum fields cannot be aligned
17// :4:13: error: enum fields cannot be aligned
test/cases/compile_errors/array_concatenation_with_wrong_type.zig+3-1
......@@ -2,7 +2,9 @@ const src = "aoeu";
22const derp: usize = 1234;
33const a = derp ++ "foo";
44
5export fn entry() usize { return @sizeOf(@TypeOf(a)); }
5export fn entry() usize {
6 return @sizeOf(@TypeOf(a));
7}
68
79// error
810// backend=stage2
test/cases/compile_errors/array_mult_with_number_type.zig+1-1
......@@ -7,4 +7,4 @@ export fn entry(base: f32, exponent: f32) f32 {
77// target=native
88//
99// :2:12: error: expected indexable; found 'f32'
10// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation
\ No newline at end of file
10// :2:17: note: this operator multiplies arrays; use std.math.pow for exponentiation
test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig+1-1
......@@ -2,7 +2,7 @@ export fn entry() void {
22 var a = &b;
33 _ = a;
44}
5fn b() callconv(.Inline) void { }
5inline fn b() void {}
66
77// error
88// backend=stage2
test/cases/compile_errors/assign_null_to_non-optional_pointer.zig+3-1
......@@ -1,6 +1,8 @@
11const a: *u8 = null;
22
3export fn entry() usize { return @sizeOf(@TypeOf(a)); }
3export fn entry() usize {
4 return @sizeOf(@TypeOf(a));
5}
46
57// error
68// backend=stage2
test/cases/compile_errors/assign_through_constant_pointer.zig+3-3
......@@ -1,10 +1,10 @@
11export fn f() void {
2 var cstr = "Hat";
3 cstr[0] = 'W';
2 var cstr = "Hat";
3 cstr[0] = 'W';
44}
55
66// error
77// backend=stage2
88// target=native
99//
10// :3:7: error: cannot assign to constant
10// :3:9: error: cannot assign to constant
test/cases/compile_errors/assign_through_constant_slice.zig+3-3
......@@ -1,10 +1,10 @@
11export fn f() void {
2 var cstr: []const u8 = "Hat";
3 cstr[0] = 'W';
2 var cstr: []const u8 = "Hat";
3 cstr[0] = 'W';
44}
55
66// error
77// backend=stage2
88// target=native
99//
10// :3:7: error: cannot assign to constant
10// :3:9: error: cannot assign to constant
test/cases/compile_errors/assign_to_constant_field.zig+4-2
......@@ -2,7 +2,9 @@ const Foo = struct {
22 field: i32,
33};
44export fn derp() void {
5 const f = Foo {.field = 1234,};
5 const f = Foo{
6 .field = 1234,
7 };
68 f.field = 0;
79}
810
......@@ -10,4 +12,4 @@ export fn derp() void {
1012// backend=stage2
1113// target=native
1214//
13// :6:6: error: cannot assign to constant
15// :8:6: error: cannot assign to constant
test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig+1-1
......@@ -3,7 +3,7 @@ export fn entry() void {
33 var bytes: [100]u8 align(16) = undefined;
44 _ = @asyncCall(&bytes, {}, ptr, .{});
55}
6fn afunc() void { }
6fn afunc() void {}
77
88// error
99// backend=stage1
test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig+1-1
......@@ -21,4 +21,4 @@ fn func() void {}
2121//
2222// :3:28: error: expected type 'anyframe->i32', found 'anyframe'
2323// :8:28: error: expected type 'anyframe->i32', found 'i32'
24// tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)'
\ No newline at end of file
24// tmp.zig:13:29: error: expected type 'anyframe->i32', found '*@Frame(func)'
test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig+1-1
......@@ -3,7 +3,7 @@ export fn entry() void {
33 _ = async ptr();
44}
55
6fn afunc() callconv(.Async) void { }
6fn afunc() callconv(.Async) void {}
77
88// error
99// backend=stage1
test/cases/compile_errors/bad_alignCast_at_comptime.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 const ptr = @intToPtr(*align(1) i32, 0x1);
2 const ptr = @ptrFromInt(*align(1) i32, 0x1);
33 const aligned = @alignCast(4, ptr);
44 _ = aligned;
55}
test/cases/compile_errors/bad_import.zig+3-1
......@@ -1,4 +1,6 @@
1const bogus = @import("bogus-does-not-exist.zig",);
1const bogus = @import(
2 "bogus-does-not-exist.zig",
3);
24
35// error
46// backend=stage2
test/cases/compile_errors/binary_not_on_number_literal.zig+3-1
......@@ -2,7 +2,9 @@ const TINY_QUANTUM_SHIFT = 4;
22const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT;
33var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1);
44
5export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); }
5export fn entry() usize {
6 return @sizeOf(@TypeOf(block_aligned_stuff));
7}
68
79// error
810// backend=stage2
test/cases/compile_errors/bitCast_to_enum_type.zig+1-1
......@@ -9,4 +9,4 @@ export fn entry() void {
99// target=native
1010//
1111// :3:24: error: cannot @bitCast to 'tmp.entry.E'
12// :3:24: note: use @intToEnum to cast from 'u32'
12// :3:24: note: use @enumFromInt to cast from 'u32'
test/cases/compile_errors/bogus_compile_var.zig+3-1
......@@ -1,5 +1,7 @@
11const x = @import("builtin").bogus;
2export fn entry() usize { return @sizeOf(@TypeOf(x)); }
2export fn entry() usize {
3 return @sizeOf(@TypeOf(x));
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/bogus_method_call_on_slice.zig+5-3
......@@ -2,7 +2,9 @@ var self = "aoeu";
22fn f(m: []const u8) void {
33 m.copy(u8, self[0..], m);
44}
5export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
5export fn entry() usize {
6 return @sizeOf(@TypeOf(&f));
7}
68pub export fn entry1() void {
79 .{}.bar();
810}
......@@ -14,6 +16,6 @@ pub export fn entry2() void {
1416// backend=stage2
1517// target=native
1618//
17// :7:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
18// :10:18: error: no field or member function named 'bar' in 'struct{comptime foo: comptime_int = 1}'
19// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
20// :12:18: error: no field or member function named 'bar' in 'struct{comptime foo: comptime_int = 1}'
1921// :3:6: error: no field or member function named 'copy' in '[]const u8'
test/cases/compile_errors/branch_on_undefined_value.zig+3-1
......@@ -1,6 +1,8 @@
11const x = if (undefined) true else false;
22
3export fn entry() usize { return @sizeOf(@TypeOf(x)); }
3export fn entry() usize {
4 return @sizeOf(@TypeOf(x));
5}
46
57// error
68// backend=stage2
test/cases/compile_errors/calling_function_with_naked_calling_convention.zig+1-1
......@@ -1,7 +1,7 @@
11export fn entry() void {
22 foo();
33}
4fn foo() callconv(.Naked) void { }
4fn foo() callconv(.Naked) void {}
55
66// error
77// backend=llvm
test/cases/compile_errors/calling_var_args_extern_function_passing_array_instead_of_pointer.zig+5-3
......@@ -1,5 +1,7 @@
11export fn entry() void {
2 foo("hello".*,);
2 foo(
3 "hello".*,
4 );
35}
46pub extern fn foo(format: *const u8, ...) void;
57
......@@ -7,5 +9,5 @@ pub extern fn foo(format: *const u8, ...) void;
79// backend=stage2
810// target=native
911//
10// :2:16: error: expected type '*const u8', found '[5:0]u8'
11// :4:27: note: parameter type declared here
12// :3:16: error: expected type '*const u8', found '[5:0]u8'
13// :6:27: note: parameter type declared here
test/cases/compile_errors/cast_unreachable.zig+3-1
......@@ -1,7 +1,9 @@
11fn f() i32 {
22 return @as(i32, return 1);
33}
4export fn entry() void { _ = f(); }
4export fn entry() void {
5 _ = f();
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/casting_bit_offset_pointer_to_regular_pointer.zig+3-1
......@@ -12,7 +12,9 @@ fn bar(x: *const u3) u3 {
1212 return x.*;
1313}
1414
15export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
15export fn entry() usize {
16 return @sizeOf(@TypeOf(&foo));
17}
1618
1719// error
1820// backend=stage2
test/cases/compile_errors/colliding_invalid_top_level_functions.zig+3-1
......@@ -1,6 +1,8 @@
11fn func() bogus {}
22fn func() bogus {}
3export fn entry() usize { return @sizeOf(@TypeOf(func)); }
3export fn entry() usize {
4 return @sizeOf(@TypeOf(func));
5}
46
57// error
68// backend=stage2
test/cases/compile_errors/compileError_shows_traceback_of_references_that_caused_it.zig+3-1
......@@ -1,4 +1,6 @@
1const foo = @compileError("aoeu",);
1const foo = @compileError(
2 "aoeu",
3);
24
35const bar = baz + foo;
46const baz = 1;
test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig+5-3
......@@ -4,15 +4,17 @@ export fn entry() void {
44}
55fn inner(comptime n: usize) void {
66 comptime var i = 0;
7 inline while (i < n) : (i += 1) { @compileLog("!@#$"); }
7 inline while (i < n) : (i += 1) {
8 @compileLog("!@#$");
9 }
810}
911
1012// error
1113// backend=llvm
1214// target=native
1315//
14// :7:39: error: found compile log statement
15// :7:39: note: also here
16// :8:9: error: found compile log statement
17// :8:9: note: also here
1618//
1719// Compile Log Output:
1820// @as(*const [4:0]u8, "!@#$")
test/cases/compile_errors/compile_time_division_by_zero.zig+3-1
......@@ -3,7 +3,9 @@ fn foo(x: u32) u32 {
33 return 1 / x;
44}
55
6export fn entry() usize { return @sizeOf(@TypeOf(y)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(y));
8}
79
810// error
911// backend=llvm
test/cases/compile_errors/comptime_call_of_function_pointer.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 const fn_ptr = @intToPtr(*align(1) fn () void, 0xffd2);
2 const fn_ptr = @ptrFromInt(*align(1) fn () void, 0xffd2);
33 comptime fn_ptr();
44}
55
test/cases/compile_errors/comptime_if_inside_runtime_for.zig+7-7
......@@ -1,14 +1,14 @@
11export fn entry() void {
2 var x: u32 = 0;
3 for(0..1, 1..2) |_, _| {
4 var y = x + if(x == 0) 1 else 0;
5 _ = y;
6 }
2 var x: u32 = 0;
3 for (0..1, 1..2) |_, _| {
4 var y = x + if (x == 0) 1 else 0;
5 _ = y;
6 }
77}
88
99// error
1010// backend=stage2
1111// target=native
1212//
13// :4:15: error: value with comptime-only type 'comptime_int' depends on runtime control flow
14// :3:6: note: runtime control flow here
13// :4:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
14// :3:10: note: runtime control flow here
test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig+3-1
......@@ -1,7 +1,9 @@
11const ContextAllocator = MemoryPool(usize);
22
33pub fn MemoryPool(comptime T: type) type {
4 const free_list_t = @compileError("aoeu",);
4 const free_list_t = @compileError(
5 "aoeu",
6 );
57 _ = T;
68
79 return struct {
test/cases/compile_errors/container_init_with_non-type.zig+3-1
......@@ -1,7 +1,9 @@
11const zero: i32 = 0;
22const a = zero{1};
33
4export fn entry() usize { return @sizeOf(@TypeOf(a)); }
4export fn entry() usize {
5 return @sizeOf(@TypeOf(a));
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/control_flow_uses_comptime_var_at_runtime.zig+1-1
......@@ -5,7 +5,7 @@ export fn foo() void {
55 }
66}
77
8fn bar() void { }
8fn bar() void {}
99export fn baz() void {
1010 comptime var idx: u32 = 0;
1111 while (idx < 1) {
test/cases/compile_errors/dereference_an_array.zig+3-1
......@@ -5,7 +5,9 @@ pub fn pass(in: []u8) []u8 {
55 return out.*[0..1];
66}
77
8export fn entry() usize { return @sizeOf(@TypeOf(&pass)); }
8export fn entry() usize {
9 return @sizeOf(@TypeOf(&pass));
10}
911
1012// error
1113// backend=stage2
test/cases/compile_errors/direct_struct_loop.zig+7-3
......@@ -1,9 +1,13 @@
1const A = struct { a : A, };
2export fn entry() usize { return @sizeOf(A); }
1const A = struct {
2 a: A,
3};
4export fn entry() usize {
5 return @sizeOf(A);
6}
37
48// error
59// backend=stage2
610// target=native
711//
812// :1:11: error: struct 'tmp.A' depends on itself
9// :1:20: note: while checking this field
13// :2:5: note: while checking this field
test/cases/compile_errors/disallow_coercion_from_non-null-terminated_pointer_to_null-terminated_pointer.zig+1-1
......@@ -1,6 +1,6 @@
11extern fn puts(s: [*:0]const u8) c_int;
22pub export fn entry() void {
3 const no_zero_array = [_]u8{'h', 'e', 'l', 'l', 'o'};
3 const no_zero_array = [_]u8{ 'h', 'e', 'l', 'l', 'o' };
44 const no_zero_ptr: [*]const u8 = &no_zero_array;
55 _ = puts(no_zero_ptr);
66}
test/cases/compile_errors/division_by_zero.zig+12-4
......@@ -3,10 +3,18 @@ const lit_float_x = 1.0 / 0.0;
33const int_x = @as(u32, 1) / @as(u32, 0);
44const float_x = @as(f32, 1.0) / @as(f32, 0.0);
55
6export fn entry1() usize { return @sizeOf(@TypeOf(lit_int_x)); }
7export fn entry2() usize { return @sizeOf(@TypeOf(lit_float_x)); }
8export fn entry3() usize { return @sizeOf(@TypeOf(int_x)); }
9export fn entry4() usize { return @sizeOf(@TypeOf(float_x)); } // no error on purpose
6export fn entry1() usize {
7 return @sizeOf(@TypeOf(lit_int_x));
8}
9export fn entry2() usize {
10 return @sizeOf(@TypeOf(lit_float_x));
11}
12export fn entry3() usize {
13 return @sizeOf(@TypeOf(int_x));
14}
15export fn entry4() usize {
16 return @sizeOf(@TypeOf(float_x));
17} // no error on purpose
1018
1119// error
1220// backend=stage2
test/cases/compile_errors/duplicate-unused_labels.zig+19-13
......@@ -1,31 +1,37 @@
11comptime {
2 blk: { blk: while (false) {} }
2 blk: {
3 blk: while (false) {}
4 }
35}
46comptime {
5 blk: while (false) { blk: for (@as([0]void, undefined)) |_| {} }
7 blk: while (false) {
8 blk: for (@as([0]void, undefined)) |_| {}
9 }
610}
711comptime {
8 blk: for (@as([0]void, undefined)) |_| { blk: {} }
12 blk: for (@as([0]void, undefined)) |_| {
13 blk: {}
14 }
915}
1016comptime {
1117 blk: {}
1218}
1319comptime {
14 blk: while(false) {}
20 blk: while (false) {}
1521}
1622comptime {
17 blk: for(@as([0]void, undefined)) |_| {}
23 blk: for (@as([0]void, undefined)) |_| {}
1824}
1925
2026// error
2127// target=native
2228//
23// :2:12: error: redefinition of label 'blk'
29// :3:9: error: redefinition of label 'blk'
2430// :2:5: note: previous definition here
25// :5:26: error: redefinition of label 'blk'
26// :5:5: note: previous definition here
27// :8:46: error: redefinition of label 'blk'
28// :8:5: note: previous definition here
29// :11:5: error: unused block label
30// :14:5: error: unused while loop label
31// :17:5: error: unused for loop label
31// :8:9: error: redefinition of label 'blk'
32// :7:5: note: previous definition here
33// :13:9: error: redefinition of label 'blk'
34// :12:5: note: previous definition here
35// :17:5: error: unused block label
36// :20:5: error: unused while loop label
37// :23:5: error: unused for loop label
test/cases/compile_errors/duplicate_error_value_in_error_set.zig+1-1
......@@ -1,4 +1,4 @@
1const Foo = error {
1const Foo = error{
22 Bar,
33 Bar,
44};
test/cases/compile_errors/duplicate_field_in_struct_value_expression.zig+4-4
......@@ -1,10 +1,10 @@
11const A = struct {
2 x : i32,
3 y : i32,
4 z : i32,
2 x: i32,
3 y: i32,
4 z: i32,
55};
66export fn f() void {
7 const a = A {
7 const a = A{
88 .z = 1,
99 .y = 2,
1010 .x = 3,
test/cases/compile_errors/embedFile_with_bogus_file.zig+4-2
......@@ -1,6 +1,8 @@
1const resource = @embedFile("bogus.txt",);
1const resource = @embedFile("bogus.txt");
22
3export fn entry() usize { return @sizeOf(@TypeOf(resource)); }
3export fn entry() usize {
4 return @sizeOf(@TypeOf(resource));
5}
46
57// error
68// backend=stage2
test/cases/compile_errors/empty_switch_on_an_integer.zig+1-1
......@@ -1,6 +1,6 @@
11export fn entry() void {
22 var x: u32 = 0;
3 switch(x) {}
3 switch (x) {}
44}
55
66// error
test/cases/compile_errors/enumFromInt_on_non-exhaustive_enums_checks_int_in_range.zig created+11
......@@ -0,0 +1,11 @@
1pub export fn entry() void {
2 const E = enum(u3) { a, b, c, _ };
3 @compileLog(@enumFromInt(E, 100));
4}
5
6// error
7// target=native
8// backend=stage2
9//
10// :3:17: error: int value '100' out of range of non-exhaustive enum 'tmp.entry.E'
11// :2:15: note: enum declared here
test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig+1-1
......@@ -3,7 +3,7 @@ const Foo = enum(u32) {
33 B = 11,
44};
55export fn entry() void {
6 var x = @intToEnum(Foo, 0);
6 var x = @enumFromInt(Foo, 0);
77 _ = x;
88}
99
test/cases/compile_errors/enum_with_declarations_unavailable_for_reify_type.zig+4-1
......@@ -1,5 +1,8 @@
11export fn entry() void {
2 _ = @Type(@typeInfo(enum { foo, const bar = 1; }));
2 _ = @Type(@typeInfo(enum {
3 foo,
4 const bar = 1;
5 }));
36}
47
58// error
test/cases/compile_errors/error_not_handled_in_switch.zig+3-3
......@@ -5,9 +5,9 @@ export fn entry() void {
55}
66fn foo(x: i32) !void {
77 switch (x) {
8 0 ... 10 => return error.Foo,
9 11 ... 20 => return error.Bar,
10 21 ... 30 => return error.Baz,
8 0...10 => return error.Foo,
9 11...20 => return error.Bar,
10 21...30 => return error.Baz,
1111 else => {},
1212 }
1313}
test/cases/compile_errors/error_note_for_function_parameter_incompatibility.zig+9-5
......@@ -1,5 +1,9 @@
1fn do_the_thing(func: *const fn (arg: i32) void) void { _ = func; }
2fn bar(arg: bool) void { _ = arg; }
1fn do_the_thing(func: *const fn (arg: i32) void) void {
2 _ = func;
3}
4fn bar(arg: bool) void {
5 _ = arg;
6}
37export fn entry() void {
48 do_the_thing(bar);
59}
......@@ -8,6 +12,6 @@ export fn entry() void {
812// backend=stage2
913// target=native
1014//
11// :4:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void'
12// :4:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void'
13// :4:18: note: parameter 0 'bool' cannot cast into 'i32'
15// :8:18: error: expected type '*const fn(i32) void', found '*const fn(bool) void'
16// :8:18: note: pointer type child 'fn(bool) void' cannot cast into pointer type child 'fn(i32) void'
17// :8:18: note: parameter 0 'bool' cannot cast into 'i32'
test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig+2-2
......@@ -7,7 +7,7 @@ const Small = enum(u2) {
77
88export fn entry() void {
99 var y = @as(f32, 3);
10 var x = @intToEnum(Small, y);
10 var x = @enumFromInt(Small, y);
1111 _ = x;
1212}
1313
......@@ -15,4 +15,4 @@ export fn entry() void {
1515// backend=stage2
1616// target=native
1717//
18// :10:31: error: expected integer type, found 'f32'
18// :10:33: error: expected integer type, found 'f32'
test/cases/compile_errors/export_function_with_comptime_parameter.zig+1-1
......@@ -1,4 +1,4 @@
1export fn foo(comptime x: anytype, y: i32) i32{
1export fn foo(comptime x: anytype, y: i32) i32 {
22 return x + y;
33}
44
test/cases/compile_errors/export_with_empty_name_string.zig+1-1
......@@ -1,4 +1,4 @@
1pub export fn entry() void { }
1pub export fn entry() void {}
22comptime {
33 @export(entry, .{ .name = "" });
44}
test/cases/compile_errors/extern_function_pointer_mismatch.zig+15-7
......@@ -1,13 +1,21 @@
1const fns = [_](fn(i32)i32) { a, b, c };
2pub fn a(x: i32) i32 {return x + 0;}
3pub fn b(x: i32) i32 {return x + 1;}
4export fn c(x: i32) i32 {return x + 2;}
1const fns = [_](fn (i32) i32){ a, b, c };
2pub fn a(x: i32) i32 {
3 return x + 0;
4}
5pub fn b(x: i32) i32 {
6 return x + 1;
7}
8export fn c(x: i32) i32 {
9 return x + 2;
10}
511
6export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
12export fn entry() usize {
13 return @sizeOf(@TypeOf(fns));
14}
715
816// error
917// backend=stage2
1018// target=native
1119//
12// :1:37: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'
13// :1:37: note: calling convention 'C' cannot cast into calling convention 'Unspecified'
20// :1:38: error: expected type 'fn(i32) i32', found 'fn(i32) callconv(.C) i32'
21// :1:38: note: calling convention 'C' cannot cast into calling convention 'Unspecified'
test/cases/compile_errors/extern_function_with_comptime_parameter.zig+9-3
......@@ -4,9 +4,15 @@ fn f() i32 {
44}
55pub extern fn entry1(b: u32, comptime a: [2]u8, c: i32) void;
66pub extern fn entry2(b: u32, noalias a: anytype, i43) void;
7comptime { _ = &f; }
8comptime { _ = &entry1; }
9comptime { _ = &entry2; }
7comptime {
8 _ = &f;
9}
10comptime {
11 _ = &entry1;
12}
13comptime {
14 _ = &entry2;
15}
1016
1117// error
1218// backend=stage2
test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig+6-4
......@@ -1,3 +1,4 @@
1// zig fmt: off
12pub const E = enum {
23@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",
34@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",
......@@ -27,6 +28,7 @@ pub const E = enum {
2728@"245",@"246",@"247",@"248",@"249",@"250",@"251",@"252",@"253",
2829@"254",@"255", @"256"
2930};
31// zig fmt: on
3032pub const S = extern struct {
3133 e: E,
3234};
......@@ -39,7 +41,7 @@ export fn entry() void {
3941// backend=stage2
4042// target=native
4143//
42// :31:8: error: extern structs cannot contain fields of type 'tmp.E'
43// :31:8: note: enum tag type 'u9' is not extern compatible
44// :31:8: note: only integers with power of two bits are extern compatible
45// :1:15: note: enum declared here
44// :33:8: error: extern structs cannot contain fields of type 'tmp.E'
45// :33:8: note: enum tag type 'u9' is not extern compatible
46// :33:8: note: only integers with power of two bits are extern compatible
47// :2:15: note: enum declared here
test/cases/compile_errors/extern_union_field_missing_type.zig+1-1
......@@ -2,7 +2,7 @@ const Letter = extern union {
22 A,
33};
44export fn entry() void {
5 var a = Letter { .A = {} };
5 var a = Letter{ .A = {} };
66 _ = a;
77}
88
test/cases/compile_errors/extern_union_given_enum_tag_type.zig+1-1
......@@ -9,7 +9,7 @@ const Payload = extern union(Letter) {
99 C: bool,
1010};
1111export fn entry() void {
12 var a = Payload { .A = 1234 };
12 var a = Payload{ .A = 1234 };
1313 _ = a;
1414}
1515
test/cases/compile_errors/fieldParentPtr-comptime_field_ptr_not_based_on_struct.zig+6-3
......@@ -2,10 +2,13 @@ const Foo = struct {
22 a: i32,
33 b: i32,
44};
5const foo = Foo { .a = 1, .b = 2, };
5const foo = Foo{
6 .a = 1,
7 .b = 2,
8};
69
710comptime {
8 const field_ptr = @intToPtr(*i32, 0x1234);
11 const field_ptr = @ptrFromInt(*i32, 0x1234);
912 const another_foo_ptr = @fieldParentPtr(Foo, "b", field_ptr);
1013 _ = another_foo_ptr;
1114}
......@@ -14,4 +17,4 @@ comptime {
1417// backend=stage2
1518// target=native
1619//
17// :9:55: error: pointer value not based on parent struct
20// :12:55: error: pointer value not based on parent struct
test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig+5-2
......@@ -2,7 +2,10 @@ const Foo = struct {
22 a: i32,
33 b: i32,
44};
5const foo = Foo { .a = 1, .b = 2, };
5const foo = Foo{
6 .a = 1,
7 .b = 2,
8};
69
710comptime {
811 const another_foo_ptr = @fieldParentPtr(Foo, "b", &foo.a);
......@@ -13,5 +16,5 @@ comptime {
1316// backend=stage2
1417// target=native
1518//
16// :8:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
19// :11:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
1720// :1:13: note: struct declared here
test/cases/compile_errors/floatToInt_comptime_safety.zig deleted-17
......@@ -1,17 +0,0 @@
1comptime {
2 _ = @floatToInt(i8, @as(f32, -129.1));
3}
4comptime {
5 _ = @floatToInt(u8, @as(f32, -1.1));
6}
7comptime {
8 _ = @floatToInt(u8, @as(f32, 256.1));
9}
10
11// error
12// backend=stage2
13// target=native
14//
15// :2:25: error: float value '-129.10000610351562' cannot be stored in integer type 'i8'
16// :5:25: error: float value '-1.100000023841858' cannot be stored in integer type 'u8'
17// :8:25: error: float value '256.1000061035156' cannot be stored in integer type 'u8'
test/cases/compile_errors/for.zig+14-10
......@@ -1,13 +1,15 @@
11export fn a() void {
22 for (0..10, 10..21) |i, j| {
3 _ = i; _ = j;
3 _ = i;
4 _ = j;
45 }
56}
67export fn b() void {
78 const s1 = "hello";
89 const s2 = true;
910 for (s1, s2) |i, j| {
10 _ = i; _ = j;
11 _ = i;
12 _ = j;
1113 }
1214}
1315export fn c() void {
......@@ -20,7 +22,9 @@ export fn d() void {
2022 const x: [*]const u8 = "hello";
2123 const y: [*]const u8 = "world";
2224 for (x, 0.., y) |x1, x2, x3| {
23 _ = x1; _ = x2; _ = x3;
25 _ = x1;
26 _ = x2;
27 _ = x3;
2428 }
2529}
2630
......@@ -31,10 +35,10 @@ export fn d() void {
3135// :2:5: error: non-matching for loop lengths
3236// :2:11: note: length 10 here
3337// :2:19: note: length 11 here
34// :9:14: error: type 'bool' is not indexable and not a range
35// :9:14: note: for loop operand must be a range, array, slice, tuple, or vector
36// :15:16: error: pointer capture of non pointer type '[10]u8'
37// :15:10: note: consider using '&' here
38// :22:5: error: unbounded for loop
39// :22:10: note: type '[*]const u8' has no upper bound
40// :22:18: note: type '[*]const u8' has no upper bound
38// :10:14: error: type 'bool' is not indexable and not a range
39// :10:14: note: for loop operand must be a range, array, slice, tuple, or vector
40// :17:16: error: pointer capture of non pointer type '[10]u8'
41// :17:10: note: consider using '&' here
42// :24:5: error: unbounded for loop
43// :24:10: note: type '[*]const u8' has no upper bound
44// :24:18: note: type '[*]const u8' has no upper bound
test/cases/compile_errors/for_extra_capture.zig+6-3
......@@ -1,12 +1,15 @@
1// zig fmt: off
12export fn b() void {
23 for (0..10) |i, j| {
3 _ = i; _ = j;
4 _ = i;
5 _ = j;
46 }
57}
8// zig fmt: on
69
710// error
811// backend=stage2
912// target=native
1013//
11// :2:21: error: extra capture in for loop
12// :2:21: note: run 'zig fmt' to upgrade your code automatically
14// :3:21: error: extra capture in for loop
15// :3:21: note: run 'zig fmt' to upgrade your code automatically
test/cases/compile_errors/function_alignment_non_power_of_2.zig+3-1
......@@ -1,5 +1,7 @@
11extern fn foo() align(3) void;
2export fn entry() void { return foo(); }
2export fn entry() void {
3 return foo();
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/function_call_assigned_to_incorrect_type.zig+1-1
......@@ -3,7 +3,7 @@ export fn entry() void {
33 arr = concat();
44}
55fn concat() [16]f32 {
6 return [1]f32{0}**16;
6 return [1]f32{0} ** 16;
77}
88
99// error
test/cases/compile_errors/function_parameter_is_opaque.zig+7-3
......@@ -9,12 +9,16 @@ export fn entry2() void {
99 _ = someFuncPtr;
1010}
1111
12fn foo(p: FooType) void {_ = p;}
12fn foo(p: FooType) void {
13 _ = p;
14}
1315export fn entry3() void {
1416 _ = foo;
1517}
1618
17fn bar(p: @TypeOf(null)) void {_ = p;}
19fn bar(p: @TypeOf(null)) void {
20 _ = p;
21}
1822export fn entry4() void {
1923 _ = bar;
2024}
......@@ -28,4 +32,4 @@ export fn entry4() void {
2832// :8:28: error: parameter of type '@TypeOf(null)' not allowed
2933// :12:8: error: parameter of opaque type 'tmp.FooType' not allowed
3034// :1:17: note: opaque declared here
31// :17:8: error: parameter of type '@TypeOf(null)' not allowed
35// :19:8: error: parameter of type '@TypeOf(null)' not allowed
test/cases/compile_errors/function_with_non-extern_non-packed_enum_parameter.zig+3-1
......@@ -1,5 +1,7 @@
11const Foo = enum { A, B, C };
2export fn entry(foo: Foo) void { _ = foo; }
2export fn entry(foo: Foo) void {
3 _ = foo;
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/function_with_non-extern_non-packed_struct_parameter.zig+3-1
......@@ -3,7 +3,9 @@ const Foo = struct {
33 B: f32,
44 C: bool,
55};
6export fn entry(foo: Foo) void { _ = foo; }
6export fn entry(foo: Foo) void {
7 _ = foo;
8}
79
810// error
911// backend=stage2
test/cases/compile_errors/function_with_non-extern_non-packed_union_parameter.zig+3-1
......@@ -3,7 +3,9 @@ const Foo = union {
33 B: f32,
44 C: bool,
55};
6export fn entry(foo: Foo) void { _ = foo; }
6export fn entry(foo: Foo) void {
7 _ = foo;
8}
79
810// error
911// backend=stage2
test/cases/compile_errors/generic_function_call_assigned_to_incorrect_type.zig+1-1
......@@ -2,7 +2,7 @@ pub export fn entry() void {
22 var res: []i32 = undefined;
33 res = myAlloc(i32);
44}
5fn myAlloc(comptime arg: type) anyerror!arg{
5fn myAlloc(comptime arg: type) anyerror!arg {
66 unreachable;
77}
88
test/cases/compile_errors/generic_function_instance_with_non-constant_expression.zig+8-4
......@@ -1,13 +1,17 @@
1fn foo(comptime x: i32, y: i32) i32 { return x + y; }
1fn foo(comptime x: i32, y: i32) i32 {
2 return x + y;
3}
24fn test1(a: i32, b: i32) i32 {
35 return foo(a, b);
46}
57
6export fn entry() usize { return @sizeOf(@TypeOf(&test1)); }
8export fn entry() usize {
9 return @sizeOf(@TypeOf(&test1));
10}
711
812// error
913// backend=stage2
1014// target=native
1115//
12// :3:16: error: unable to resolve comptime value
13// :3:16: note: parameter is comptime
16// :5:16: error: unable to resolve comptime value
17// :5:16: note: parameter is comptime
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig-1
......@@ -6,7 +6,6 @@ pub export fn entry() void {
66}
77fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {}
88
9
109// error
1110// backend=llvm
1211// target=native
test/cases/compile_errors/global_variable_alignment_non_power_of_2.zig+3-1
......@@ -1,5 +1,7 @@
11const some_data: [100]u8 align(3) = undefined;
2export fn entry() usize { return @sizeOf(@TypeOf(some_data)); }
2export fn entry() usize {
3 return @sizeOf(@TypeOf(some_data));
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/global_variable_initializer_must_be_constant_expression.zig+3-1
......@@ -1,6 +1,8 @@
11extern fn foo() i32;
22const x = foo();
3export fn entry() i32 { return x; }
3export fn entry() i32 {
4 return x;
5}
46
57// error
68// backend=stage2
test/cases/compile_errors/ignored_assert-err-ok_return_value.zig+3-1
......@@ -1,7 +1,9 @@
11export fn foo() void {
22 bar() catch unreachable;
33}
4fn bar() anyerror!i32 { return 0; }
4fn bar() anyerror!i32 {
5 return 0;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/ignored_comptime_statement_value.zig+6-4
......@@ -1,11 +1,13 @@
11export fn foo() void {
2 comptime {1;}
2 comptime {
3 1;
4 }
35}
46
57// error
68// backend=stage2
79// target=native
810//
9// :2:15: error: value of type 'comptime_int' ignored
10// :2:15: note: all non-void values must be used
11// :2:15: note: this error can be suppressed by assigning the value to '_'
11// :3:9: error: value of type 'comptime_int' ignored
12// :3:9: note: all non-void values must be used
13// :3:9: note: this error can be suppressed by assigning the value to '_'
test/cases/compile_errors/ignored_deferred_function_call.zig+3-1
......@@ -1,7 +1,9 @@
11export fn foo() void {
22 defer bar();
33}
4fn bar() anyerror!i32 { return 0; }
4fn bar() anyerror!i32 {
5 return 0;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/ignored_deferred_statement_value.zig+6-4
......@@ -1,11 +1,13 @@
11export fn foo() void {
2 defer {1;}
2 defer {
3 1;
4 }
35}
46
57// error
68// backend=stage2
79// target=native
810//
9// :2:12: error: value of type 'comptime_int' ignored
10// :2:12: note: all non-void values must be used
11// :2:12: note: this error can be suppressed by assigning the value to '_'
11// :3:9: error: value of type 'comptime_int' ignored
12// :3:9: note: all non-void values must be used
13// :3:9: note: this error can be suppressed by assigning the value to '_'
test/cases/compile_errors/ignored_return_value.zig+3-1
......@@ -1,7 +1,9 @@
11export fn foo() void {
22 bar();
33}
4fn bar() i32 { return 0; }
4fn bar() i32 {
5 return 0;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/illegal_comparison_of_types.zig+6-2
......@@ -9,8 +9,12 @@ fn bad_eql_2(a: *const EnumWithData, b: *const EnumWithData) bool {
99 return a.* == b.*;
1010}
1111
12export fn entry1() usize { return @sizeOf(@TypeOf(&bad_eql_1)); }
13export fn entry2() usize { return @sizeOf(@TypeOf(&bad_eql_2)); }
12export fn entry1() usize {
13 return @sizeOf(@TypeOf(&bad_eql_1));
14}
15export fn entry2() usize {
16 return @sizeOf(@TypeOf(&bad_eql_2));
17}
1418
1519// error
1620// backend=stage2
test/cases/compile_errors/implicit_cast_from_array_to_mutable_slice.zig+4-2
......@@ -1,5 +1,7 @@
11var global_array: [10]i32 = undefined;
2fn foo(param: []i32) void {_ = param;}
2fn foo(param: []i32) void {
3 _ = param;
4}
35export fn entry() void {
46 foo(global_array);
57}
......@@ -8,4 +10,4 @@ export fn entry() void {
810// backend=llvm
911// target=native
1012//
11// :4:9: error: array literal requires address-of operator (&) to coerce to slice type '[]i32'
13// :6:9: error: array literal requires address-of operator (&) to coerce to slice type '[]i32'
test/cases/compile_errors/implicitly_increasing_pointer_alignment.zig+1-1
......@@ -4,7 +4,7 @@ const Foo = packed struct {
44};
55
66export fn entry() void {
7 var foo = Foo { .a = 1, .b = 10 };
7 var foo = Foo{ .a = 1, .b = 10 };
88 bar(&foo.b);
99}
1010
test/cases/compile_errors/implicitly_increasing_slice_alignment.zig+1-1
......@@ -4,7 +4,7 @@ const Foo = packed struct {
44};
55
66export fn entry() void {
7 var foo = Foo { .a = 1, .b = 10 };
7 var foo = Foo{ .a = 1, .b = 10 };
88 foo.b += 1;
99 bar(@as(*[1]u32, &foo.b)[0..]);
1010}
test/cases/compile_errors/import_outside_package_path.zig+1-1
......@@ -1,4 +1,4 @@
1comptime{
1comptime {
22 _ = @import("../a.zig");
33}
44
test/cases/compile_errors/incorrect_return_type.zig+19-19
......@@ -1,24 +1,24 @@
1 pub export fn entry() void{
2 _ = foo();
3 }
4 const A = struct {
5 a: u32,
6 };
7 fn foo() A {
8 return bar();
9 }
10 const B = struct {
11 a: u32,
12 };
13 fn bar() B {
14 unreachable;
15 }
1pub export fn entry() void {
2 _ = foo();
3}
4const A = struct {
5 a: u32,
6};
7fn foo() A {
8 return bar();
9}
10const B = struct {
11 a: u32,
12};
13fn bar() B {
14 unreachable;
15}
1616
1717// error
1818// backend=stage2
1919// target=native
2020//
21// :8:16: error: expected type 'tmp.A', found 'tmp.B'
22// :10:12: note: struct declared here
23// :4:12: note: struct declared here
24// :7:11: note: function return type declared here
21// :8:15: error: expected type 'tmp.A', found 'tmp.B'
22// :10:11: note: struct declared here
23// :4:11: note: struct declared here
24// :7:10: note: function return type declared here
test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() u32 {
2 var bytes: [4]u8 = [_]u8{0x01, 0x02, 0x03, 0x04};
2 var bytes: [4]u8 = [_]u8{ 0x01, 0x02, 0x03, 0x04 };
33 const ptr = @ptrCast(*u32, &bytes[0]);
44 return ptr.*;
55}
test/cases/compile_errors/indirect_struct_loop.zig+15-7
......@@ -1,13 +1,21 @@
1const A = struct { b : B, };
2const B = struct { c : C, };
3const C = struct { a : A, };
4export fn entry() usize { return @sizeOf(A); }
1const A = struct {
2 b: B,
3};
4const B = struct {
5 c: C,
6};
7const C = struct {
8 a: A,
9};
10export fn entry() usize {
11 return @sizeOf(A);
12}
513
614// error
715// backend=stage2
816// target=native
917//
1018// :1:11: error: struct 'tmp.A' depends on itself
11// :3:20: note: while checking this field
12// :2:20: note: while checking this field
13// :1:20: note: while checking this field
19// :8:5: note: while checking this field
20// :5:5: note: while checking this field
21// :2:5: note: while checking this field
test/cases/compile_errors/inferred_array_size_invalid_here.zig+1-1
......@@ -4,7 +4,7 @@ export fn entry() void {
44}
55export fn entry2() void {
66 const S = struct { a: *const [_]u8 };
7 var a = .{ S{} };
7 var a = .{S{}};
88 _ = a;
99}
1010
test/cases/compile_errors/inferring_error_set_of_function_pointer.zig+2-2
......@@ -1,9 +1,9 @@
11comptime {
2 const z: ?fn()!void = null;
2 const z: ?fn () !void = null;
33}
44
55// error
66// backend=stage2
77// target=native
88//
9// :2:19: error: function prototype may not have inferred error set
9// :2:21: error: function prototype may not have inferred error set
test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig+6-6
......@@ -1,17 +1,17 @@
11export fn foo() void {
22 var a: f32 = 2;
3 _ = @floatToInt(comptime_int, a);
3 _ = @intFromFloat(comptime_int, a);
44}
55export fn bar() void {
66 var a: u32 = 2;
7 _ = @intToFloat(comptime_float, a);
7 _ = @floatFromInt(comptime_float, a);
88}
99
1010// error
1111// backend=stage2
1212// target=native
1313//
14// :3:35: error: unable to resolve comptime value
15// :3:35: note: value being casted to 'comptime_int' must be comptime-known
16// :7:37: error: unable to resolve comptime value
17// :7:37: note: value being casted to 'comptime_float' must be comptime-known
14// :3:37: error: unable to resolve comptime value
15// :3:37: note: value being casted to 'comptime_int' must be comptime-known
16// :7:39: error: unable to resolve comptime value
17// :7:39: note: value being casted to 'comptime_float' must be comptime-known
test/cases/compile_errors/intFromFloat_comptime_safety.zig created+17
......@@ -0,0 +1,17 @@
1comptime {
2 _ = @intFromFloat(i8, @as(f32, -129.1));
3}
4comptime {
5 _ = @intFromFloat(u8, @as(f32, -1.1));
6}
7comptime {
8 _ = @intFromFloat(u8, @as(f32, 256.1));
9}
10
11// error
12// backend=stage2
13// target=native
14//
15// :2:27: error: float value '-129.10000610351562' cannot be stored in integer type 'i8'
16// :5:27: error: float value '-1.100000023841858' cannot be stored in integer type 'u8'
17// :8:27: error: float value '256.1000061035156' cannot be stored in integer type 'u8'
test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig created+10
......@@ -0,0 +1,10 @@
1export fn entry() void {
2 var b = @ptrFromInt(*i32, 0);
3 _ = b;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:31: error: pointer type '*i32' does not allow address zero
test/cases/compile_errors/intToEnum_on_non-exhaustive_enums_checks_int_in_range.zig deleted-11
......@@ -1,11 +0,0 @@
1pub export fn entry() void {
2 const E = enum(u3) { a, b, c, _ };
3 @compileLog(@intToEnum(E, 100));
4}
5
6// error
7// target=native
8// backend=stage2
9//
10// :3:17: error: int value '100' out of range of non-exhaustive enum 'tmp.entry.E'
11// :2:15: note: enum declared here
test/cases/compile_errors/intToPtr_with_misaligned_address.zig deleted-10
......@@ -1,10 +0,0 @@
1pub export fn entry() void {
2 var y = @intToPtr([*]align(4) u8, 5);
3 _ = y;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:39: error: pointer type '[*]align(4) u8' requires aligned address
test/cases/compile_errors/int_to_err_global_invalid_number.zig+2-2
......@@ -4,7 +4,7 @@ const Set1 = error{
44};
55comptime {
66 var x: u16 = 3;
7 var y = @intToError(x);
7 var y = @errorFromInt(x);
88 _ = y;
99}
1010
......@@ -12,4 +12,4 @@ comptime {
1212// backend=stage2
1313// target=native
1414//
15// :7:25: error: integer value '3' represents no error
15// :7:27: error: integer value '3' represents no error
test/cases/compile_errors/int_to_err_non_global_invalid_number.zig+2-2
......@@ -7,8 +7,8 @@ const Set2 = error{
77 C,
88};
99comptime {
10 var x = @errorToInt(Set1.B);
11 var y = @errSetCast(Set2, @intToError(x));
10 var x = @intFromError(Set1.B);
11 var y = @errSetCast(Set2, @errorFromInt(x));
1212 _ = y;
1313}
1414
test/cases/compile_errors/integer_overflow_error.zig+5-3
......@@ -1,8 +1,10 @@
1const x : u8 = 300;
2export fn entry() usize { return @sizeOf(@TypeOf(x)); }
1const x: u8 = 300;
2export fn entry() usize {
3 return @sizeOf(@TypeOf(x));
4}
35
46// error
57// backend=stage2
68// target=native
79//
8// :1:16: error: type 'u8' cannot represent integer value '300'
10// :1:15: error: type 'u8' cannot represent integer value '300'
test/cases/compile_errors/integer_underflow_error.zig+2-2
......@@ -1,9 +1,9 @@
11export fn entry() void {
2 _ = @intToPtr(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1);
2 _ = @ptrFromInt(*anyopaque, ~@as(usize, @import("std").math.maxInt(usize)) - 1);
33}
44
55// error
66// backend=stage2
77// target=native
88//
9// :2:78: error: overflow of integer type 'usize' with value '-1'
9// :2:80: error: overflow of integer type 'usize' with value '-1'
test/cases/compile_errors/inttoptr_non_ptr_type.zig deleted-15
......@@ -1,15 +0,0 @@
1pub export fn entry() void {
2 _ = @intToPtr(i32, 10);
3}
4
5pub export fn entry2() void {
6 _ = @intToPtr([]u8, 20);
7}
8
9// error
10// backend=stage2
11// target=native
12//
13// :2:19: error: expected pointer type, found 'i32'
14// :6:19: error: integer cannot be converted to slice type '[]u8'
15// :6:19: note: slice length cannot be inferred from address
test/cases/compile_errors/invalid_builtin_fn.zig+3-2
......@@ -1,6 +1,7 @@
1fn f() @bogus(foo) {
1fn f() @bogus(foo) {}
2export fn entry() void {
3 _ = f();
24}
3export fn entry() void { _ = f(); }
45
56// error
67// backend=stage2
test/cases/compile_errors/invalid_capture_type.zig+6-4
......@@ -1,5 +1,7 @@
11export fn f1() void {
2 if (true) |x| { _ = x; }
2 if (true) |x| {
3 _ = x;
4 }
35}
46export fn f2() void {
57 if (@as(usize, 5)) |_| {}
......@@ -19,6 +21,6 @@ export fn f5() void {
1921// target=native
2022//
2123// :2:9: error: expected optional type, found 'bool'
22// :5:9: error: expected optional type, found 'usize'
23// :8:9: error: expected error union type, found 'usize'
24// :14:9: error: expected error union type, found 'error{Foo}'
24// :7:9: error: expected optional type, found 'usize'
25// :10:9: error: expected error union type, found 'usize'
26// :16:9: error: expected error union type, found 'error{Foo}'
test/cases/compile_errors/invalid_comparison_for_function_pointers.zig+3-1
......@@ -1,7 +1,9 @@
11fn foo() void {}
22const invalid = foo > foo;
33
4export fn entry() usize { return @sizeOf(@TypeOf(invalid)); }
4export fn entry() usize {
5 return @sizeOf(@TypeOf(invalid));
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/invalid_field_access_in_comptime.zig+5-2
......@@ -1,7 +1,10 @@
1comptime { var x = doesnt_exist.whatever; _ = x; }
1comptime {
2 var x = doesnt_exist.whatever;
3 _ = x;
4}
25
36// error
47// backend=stage2
58// target=native
69//
7// :1:20: error: use of undeclared identifier 'doesnt_exist'
10// :2:13: error: use of undeclared identifier 'doesnt_exist'
test/cases/compile_errors/invalid_field_in_struct_value_expression.zig+4-5
......@@ -1,10 +1,10 @@
11const A = struct {
2 x : i32,
3 y : i32,
4 z : i32,
2 x: i32,
3 y: i32,
4 z: i32,
55};
66export fn f() void {
7 const a = A {
7 const a = A{
88 .z = 4,
99 .y = 2,
1010 .foo = 42,
......@@ -21,7 +21,6 @@ pub export fn entry() void {
2121 dump(.{ .field_1 = 123, .field_3 = 456 });
2222}
2323
24
2524// error
2625// backend=stage2
2726// target=native
test/cases/compile_errors/invalid_float_casts.zig+4-4
......@@ -4,11 +4,11 @@ export fn foo() void {
44}
55export fn bar() void {
66 var a: f32 = 2;
7 _ = @floatToInt(f32, a);
7 _ = @intFromFloat(f32, a);
88}
99export fn baz() void {
1010 var a: f32 = 2;
11 _ = @intToFloat(f32, a);
11 _ = @floatFromInt(f32, a);
1212}
1313export fn qux() void {
1414 var a: u32 = 2;
......@@ -20,6 +20,6 @@ export fn qux() void {
2020// target=native
2121//
2222// :3:36: error: unable to cast runtime value to 'comptime_float'
23// :7:21: error: expected integer type, found 'f32'
24// :11:26: error: expected integer type, found 'f32'
23// :7:23: error: expected integer type, found 'f32'
24// :11:28: error: expected integer type, found 'f32'
2525// :15:25: error: expected float type, found 'u32'
test/cases/compile_errors/invalid_int_casts.zig+4-4
......@@ -4,11 +4,11 @@ export fn foo() void {
44}
55export fn bar() void {
66 var a: u32 = 2;
7 _ = @intToFloat(u32, a);
7 _ = @floatFromInt(u32, a);
88}
99export fn baz() void {
1010 var a: u32 = 2;
11 _ = @floatToInt(u32, a);
11 _ = @intFromFloat(u32, a);
1212}
1313export fn qux() void {
1414 var a: f32 = 2;
......@@ -20,6 +20,6 @@ export fn qux() void {
2020// target=native
2121//
2222// :3:32: error: unable to cast runtime value to 'comptime_int'
23// :7:21: error: expected float type, found 'u32'
24// :11:26: error: expected float type, found 'u32'
23// :7:23: error: expected float type, found 'u32'
24// :11:28: error: expected float type, found 'u32'
2525// :15:23: error: expected integer or vector, found 'f32'
test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig+3-3
......@@ -8,12 +8,12 @@ const U = union(E) {
88 b,
99};
1010export fn foo() void {
11 var e = @intToEnum(E, 15);
11 var e = @enumFromInt(E, 15);
1212 var u: U = e;
1313 _ = u;
1414}
1515export fn bar() void {
16 const e = @intToEnum(E, 15);
16 const e = @enumFromInt(E, 15);
1717 var u: U = e;
1818 _ = u;
1919}
......@@ -24,5 +24,5 @@ export fn bar() void {
2424//
2525// :12:16: error: runtime coercion to union 'tmp.U' from non-exhaustive enum
2626// :1:11: note: enum declared here
27// :17:16: error: union 'tmp.U' has no tag with value '@intToEnum(tmp.E, 15)'
27// :17:16: error: union 'tmp.U' has no tag with value '@enumFromInt(tmp.E, 15)'
2828// :6:11: note: union declared here
test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig+3-1
......@@ -1,7 +1,9 @@
11const stroo = extern struct {
22 moo: ?[*c]u8,
33};
4export fn testf(fluff: *stroo) void { _ = fluff; }
4export fn testf(fluff: *stroo) void {
5 _ = fluff;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/invalid_pointer_with_reify_type.zig+1-1
......@@ -8,7 +8,7 @@ export fn entry() void {
88 .child = u8,
99 .is_allowzero = false,
1010 .sentinel = &@as(u8, 0),
11 }});
11 } });
1212}
1313
1414// error
test/cases/compile_errors/invalid_shift_amount_error.zig+4-2
......@@ -1,8 +1,10 @@
1const x : u8 = 2;
1const x: u8 = 2;
22fn f() u16 {
33 return x << 8;
44}
5export fn entry() u16 { return f(); }
5export fn entry() u16 {
6 return f();
7}
68
79// error
810// backend=stage2
test/cases/compile_errors/invalid_type.zig+3-1
......@@ -1,5 +1,7 @@
11fn a() bogus {}
2export fn entry() void { _ = a(); }
2export fn entry() void {
3 _ = a();
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/invalid_type_in_builtin_extern.zig+1-1
......@@ -1,4 +1,4 @@
1const x = @extern(*comptime_int, .{.name="foo"});
1const x = @extern(*comptime_int, .{ .name = "foo" });
22pub export fn entry() void {
33 _ = x;
44}
test/cases/compile_errors/invalid_variadic_function.zig+6-2
......@@ -1,8 +1,12 @@
11fn foo(...) void {}
22fn bar(a: anytype, ...) callconv(a) void {}
33
4comptime { _ = foo; }
5comptime { _ = bar; }
4comptime {
5 _ = foo;
6}
7comptime {
8 _ = bar;
9}
610
711// error
812// backend=stage2
test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig+4-4
......@@ -1,10 +1,10 @@
11export fn foo1() void {
2 var bytes = [_]u8{1, 2};
2 var bytes = [_]u8{ 1, 2 };
33 const word: u16 = @bitCast(u16, bytes[0..]);
44 _ = word;
55}
66export fn foo2() void {
7 var bytes: []const u8 = &[_]u8{1, 2};
7 var bytes: []const u8 = &[_]u8{ 1, 2 };
88 const word: u16 = @bitCast(u16, bytes);
99 _ = word;
1010}
......@@ -14,6 +14,6 @@ export fn foo2() void {
1414// target=native
1515//
1616// :3:42: error: cannot @bitCast from '*[2]u8'
17// :3:42: note: use @ptrToInt to cast to 'u16'
17// :3:42: note: use @intFromPtr to cast to 'u16'
1818// :8:37: error: cannot @bitCast from '[]const u8'
19// :8:37: note: use @ptrToInt to cast to 'u16'
19// :8:37: note: use @intFromPtr to cast to 'u16'
test/cases/compile_errors/local_variable_redeclaration.zig+1-1
......@@ -1,5 +1,5 @@
11export fn f() void {
2 const a : i32 = 0;
2 const a: i32 = 0;
33 var a = 0;
44}
55
test/cases/compile_errors/local_variable_redeclares_parameter.zig+4-2
......@@ -1,7 +1,9 @@
1fn f(a : i32) void {
1fn f(a: i32) void {
22 const a = 0;
33}
4export fn entry() void { f(1); }
4export fn entry() void {
5 f(1);
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/local_variable_shadowing_global.zig+1-1
......@@ -2,7 +2,7 @@ const Foo = struct {};
22const Bar = struct {};
33
44export fn entry() void {
5 var Bar : i32 = undefined;
5 var Bar: i32 = undefined;
66 _ = Bar;
77}
88
test/cases/compile_errors/main_function_with_bogus_args_type.zig+3-1
......@@ -1,4 +1,6 @@
1pub fn main(args: [][]bogus) !void {_ = args;}
1pub fn main(args: [][]bogus) !void {
2 _ = args;
3}
24
35// error
46// backend=stage2
test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig+1-1
......@@ -2,7 +2,7 @@ const Geo3DTex2D = struct { vertices: [][2]f32 };
22pub fn getGeo3DTex2D() Geo3DTex2D {
33 return Geo3DTex2D{
44 .vertices = [_][2]f32{
5 [_]f32{ -0.5, -0.5},
5 [_]f32{ -0.5, -0.5 },
66 },
77 };
88}
test/cases/compile_errors/missing_else_clause.zig+13-9
......@@ -1,9 +1,13 @@
11fn f(b: bool) void {
2 const x : i32 = if (b) h: { break :h 1; };
2 const x: i32 = if (b) h: {
3 break :h 1;
4 };
35 _ = x;
46}
57fn g(b: bool) void {
6 const y = if (b) h: { break :h @as(i32, 1); };
8 const y = if (b) h: {
9 break :h @as(i32, 1);
10 };
711 _ = y;
812}
913fn h() void {
......@@ -30,10 +34,10 @@ export fn entry() void {
3034// backend=stage2
3135// target=native
3236//
33// :2:21: error: incompatible types: 'i32' and 'void'
34// :2:31: note: type 'i32' here
35// :6:15: error: incompatible types: 'i32' and 'void'
36// :6:25: note: type 'i32' here
37// :12:16: error: expected type 'tmp.h.T', found 'void'
38// :11:15: note: struct declared here
39// :18:9: error: incompatible types: 'void' and 'tmp.k.T'
37// :2:20: error: incompatible types: 'i32' and 'void'
38// :2:30: note: type 'i32' here
39// :8:15: error: incompatible types: 'i32' and 'void'
40// :8:25: note: type 'i32' here
41// :16:16: error: expected type 'tmp.h.T', found 'void'
42// :15:15: note: struct declared here
43// :22:9: error: incompatible types: 'void' and 'tmp.k.T'
test/cases/compile_errors/missing_field_in_struct_value_expression.zig+5-5
......@@ -1,12 +1,12 @@
11const A = struct {
2 x : i32,
3 y : i32,
4 z : i32,
2 x: i32,
3 y: i32,
4 z: i32,
55};
66export fn f() void {
77 // we want the error on the '{' not the 'A' because
88 // the A could be a complicated expression
9 const a = A {
9 const a = A{
1010 .z = 4,
1111 .y = 2,
1212 };
......@@ -17,5 +17,5 @@ export fn f() void {
1717// backend=stage2
1818// target=native
1919//
20// :9:17: error: missing struct field: x
20// :9:16: error: missing struct field: x
2121// :1:11: note: struct 'tmp.A' declared here
test/cases/compile_errors/missing_main_fn_in_executable.zig-2
......@@ -1,5 +1,3 @@
1
2
31// error
42// backend=llvm
53// target=x86_64-linux
test/cases/compile_errors/missing_param_name.zig+3-1
......@@ -1,5 +1,7 @@
11fn f(i32) void {}
2export fn entry() usize { return @sizeOf(@TypeOf(f)); }
2export fn entry() usize {
3 return @sizeOf(@TypeOf(f));
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig+4-2
......@@ -24,11 +24,13 @@ pub const JsonNode = struct {
2424fn foo() void {
2525 var jll: JasonList = undefined;
2626 jll.init(1234);
27 var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} };
27 var jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} };
2828 _ = jd;
2929}
3030
31export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
31export fn entry() usize {
32 return @sizeOf(@TypeOf(foo));
33}
3234
3335// error
3436// backend=stage2
test/cases/compile_errors/mul_overflow_in_function_evaluation.zig+3-2
......@@ -3,7 +3,9 @@ fn mul(a: u16, b: u16) u16 {
33 return a * b;
44}
55
6export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(&y));
8}
79
810// error
911// backend=stage2
......@@ -11,4 +13,3 @@ export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
1113//
1214// :3:14: error: overflow of integer type 'u16' with value '1800000'
1315// :1:14: note: called from here
14
test/cases/compile_errors/multiple_function_definitions.zig+3-1
......@@ -1,6 +1,8 @@
11fn a() void {}
22fn a() void {}
3export fn entry() void { a(); }
3export fn entry() void {
4 a();
5}
46
57// error
68// backend=stage2
test/cases/compile_errors/negation_overflow_in_function_evaluation.zig+3-1
......@@ -3,7 +3,9 @@ fn neg(x: i8) i8 {
33 return -x;
44}
55
6export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(&y));
8}
79
810// error
911// backend=stage2
test/cases/compile_errors/nested_vectors.zig-1
......@@ -10,4 +10,3 @@ export fn entry() void {
1010// target=native
1111//
1212// :3:16: error: expected integer, float, bool, or pointer for the vector element type; found '@Vector(4, u8)'
13
test/cases/compile_errors/noalias_on_non_pointer_param.zig+14-6
......@@ -1,11 +1,19 @@
1fn f(noalias x: i32) void { _ = x; }
2export fn entry() void { f(1234); }
1fn f(noalias x: i32) void {
2 _ = x;
3}
4export fn entry() void {
5 f(1234);
6}
37
4fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {}
5comptime { _ = &generic; }
8fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void {}
9comptime {
10 _ = &generic;
11}
612
7fn slice(noalias _: []u8) void {}
8comptime { _ = &slice; }
13fn slice(noalias _: []u8) void {}
14comptime {
15 _ = &slice;
16}
917
1018// error
1119// backend=stage2
test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig+1-2
......@@ -5,8 +5,7 @@ export fn entry() void {
55 _ = llamas2;
66}
77
8fn makeLlamas(count: usize) [count]u8 {
9}
8fn makeLlamas(count: usize) [count]u8 {}
109
1110// error
1211// target=native
test/cases/compile_errors/non-const_expression_function_call_with_struct_return_value_outside_function.zig+4-2
......@@ -4,11 +4,13 @@ const Foo = struct {
44const a = get_it();
55fn get_it() Foo {
66 global_side_effect = true;
7 return Foo {.x = 13};
7 return Foo{ .x = 13 };
88}
99var global_side_effect = false;
1010
11export fn entry() usize { return @sizeOf(@TypeOf(a)); }
11export fn entry() usize {
12 return @sizeOf(@TypeOf(a));
13}
1214
1315// error
1416// backend=stage2
test/cases/compile_errors/non-const_expression_in_struct_literal_outside_function.zig+4-2
......@@ -1,10 +1,12 @@
11const Foo = struct {
22 x: i32,
33};
4const a = Foo {.x = get_it()};
4const a = Foo{ .x = get_it() };
55extern fn get_it() i32;
66
7export fn entry() usize { return @sizeOf(@TypeOf(a)); }
7export fn entry() usize {
8 return @sizeOf(@TypeOf(a));
9}
810
911// error
1012// backend=stage2
test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig+25-25
......@@ -1,30 +1,30 @@
11export fn entry1() void {
2 var m2 = &2;
3 _ = m2;
2 var m2 = &2;
3 _ = m2;
44}
55export fn entry2() void {
6 var a = undefined;
7 _ = a;
6 var a = undefined;
7 _ = a;
88}
99export fn entry3() void {
10 var b = 1;
11 _ = b;
10 var b = 1;
11 _ = b;
1212}
1313export fn entry4() void {
14 var c = 1.0;
15 _ = c;
14 var c = 1.0;
15 _ = c;
1616}
1717export fn entry5() void {
18 var d = null;
19 _ = d;
18 var d = null;
19 _ = d;
2020}
2121export fn entry6(opaque_: *Opaque) void {
22 var e = opaque_.*;
23 _ = e;
22 var e = opaque_.*;
23 _ = e;
2424}
2525export fn entry7() void {
26 var f = i32;
27 _ = f;
26 var f = i32;
27 _ = f;
2828}
2929const Opaque = opaque {};
3030
......@@ -32,14 +32,14 @@ const Opaque = opaque {};
3232// backend=stage2
3333// target=native
3434//
35// :2:8: error: variable of type '*const comptime_int' must be const or comptime
36// :6:8: error: variable of type '@TypeOf(undefined)' must be const or comptime
37// :10:8: error: variable of type 'comptime_int' must be const or comptime
38// :10:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
39// :14:8: error: variable of type 'comptime_float' must be const or comptime
40// :14:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
41// :18:8: error: variable of type '@TypeOf(null)' must be const or comptime
42// :22:19: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known
43// :22:19: note: opaque type 'tmp.Opaque' has undefined size
44// :26:8: error: variable of type 'type' must be const or comptime
45// :26:8: note: types are not available at runtime
35// :2:9: error: variable of type '*const comptime_int' must be const or comptime
36// :6:9: error: variable of type '@TypeOf(undefined)' must be const or comptime
37// :10:9: error: variable of type 'comptime_int' must be const or comptime
38// :10:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
39// :14:9: error: variable of type 'comptime_float' must be const or comptime
40// :14:9: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
41// :18:9: error: variable of type '@TypeOf(null)' must be const or comptime
42// :22:20: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known
43// :22:20: note: opaque type 'tmp.Opaque' has undefined size
44// :26:9: error: variable of type 'type' must be const or comptime
45// :26:9: note: types are not available at runtime
test/cases/compile_errors/non-exhaustive_enum_marker_assigned_a_value.zig+4-1
......@@ -8,7 +8,10 @@ const B = enum {
88 b,
99 _,
1010};
11comptime { _ = A; _ = B; }
11comptime {
12 _ = A;
13 _ = B;
14}
1215
1316// error
1417// backend=stage2
test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig+3-1
......@@ -4,7 +4,9 @@ const Foo = struct {
44};
55export fn entry() void {
66 const xx: [2]Foo = .{ .{ .name = "", .T = u8 }, .{ .name = "", .T = u8 } };
7 for (xx) |f| { _ = f;}
7 for (xx) |f| {
8 _ = f;
9 }
810}
911
1012// error
test/cases/compile_errors/non_constant_expression_in_array_size.zig+8-4
......@@ -2,14 +2,18 @@ const Foo = struct {
22 y: [get()]u8,
33};
44var global_var: usize = 1;
5fn get() usize { return global_var; }
5fn get() usize {
6 return global_var;
7}
68
7export fn entry() usize { return @offsetOf(Foo, "y"); }
9export fn entry() usize {
10 return @offsetOf(Foo, "y");
11}
812
913// error
1014// backend=stage2
1115// target=native
1216//
13// :5:18: error: unable to resolve comptime value
14// :5:18: note: value being returned at comptime must be comptime-known
17// :6:5: error: unable to resolve comptime value
18// :6:5: note: value being returned at comptime must be comptime-known
1519// :2:12: note: called from here
test/cases/compile_errors/non_float_passed_to_floatToInt.zig deleted-10
......@@ -1,10 +0,0 @@
1export fn entry() void {
2 const x = @floatToInt(i32, @as(i32, 54));
3 _ = x;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:32: error: expected float type, found 'i32'
test/cases/compile_errors/non_float_passed_to_intFromFloat.zig created+10
......@@ -0,0 +1,10 @@
1export fn entry() void {
2 const x = @intFromFloat(i32, @as(i32, 54));
3 _ = x;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:34: error: expected float type, found 'i32'
test/cases/compile_errors/non_int_passed_to_floatFromInt.zig created+10
......@@ -0,0 +1,10 @@
1export fn entry() void {
2 const x = @floatFromInt(f32, 1.1);
3 _ = x;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:34: error: expected integer type, found 'comptime_float'
test/cases/compile_errors/non_int_passed_to_intToFloat.zig deleted-10
......@@ -1,10 +0,0 @@
1export fn entry() void {
2 const x = @intToFloat(f32, 1.1);
3 _ = x;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:32: error: expected integer type, found 'comptime_float'
test/cases/compile_errors/non_pointer_given_to_intFromPtr.zig created+9
......@@ -0,0 +1,9 @@
1export fn entry(x: i32) usize {
2 return @intFromPtr(x);
3}
4
5// error
6// backend=stage2
7// target=native
8//
9// :2:24: error: expected pointer, found 'i32'
test/cases/compile_errors/non_pointer_given_to_ptrToInt.zig deleted-9
......@@ -1,9 +0,0 @@
1export fn entry(x: i32) usize {
2 return @ptrToInt(x);
3}
4
5// error
6// backend=stage2
7// target=native
8//
9// :2:22: error: expected pointer, found 'i32'
test/cases/compile_errors/offsetOf-bad_field_name.zig+5-2
......@@ -2,12 +2,15 @@ const Foo = struct {
22 derp: i32,
33};
44export fn foo() usize {
5 return @offsetOf(Foo, "a",);
5 return @offsetOf(
6 Foo,
7 "a",
8 );
69}
710
811// error
912// backend=stage2
1013// target=native
1114//
12// :5:27: error: no field named 'a' in struct 'tmp.Foo'
15// :7:9: error: no field named 'a' in struct 'tmp.Foo'
1316// :1:13: note: struct declared here
test/cases/compile_errors/offsetOf-non_struct.zig+1-1
......@@ -1,6 +1,6 @@
11const Foo = i32;
22export fn foo() usize {
3 return @offsetOf(Foo, "a",);
3 return @offsetOf(Foo, "a");
44}
55
66// error
test/cases/compile_errors/old_fn_ptr_in_extern_context.zig+1-1
......@@ -5,7 +5,7 @@ comptime {
55 _ = @sizeOf(S) == 1;
66}
77comptime {
8 _ = [*c][4]fn() callconv(.C) void;
8 _ = [*c][4]fn () callconv(.C) void;
99}
1010
1111// error
test/cases/compile_errors/out_of_int_range_comptime_float_passed_to_intFromFloat.zig created+10
......@@ -0,0 +1,10 @@
1export fn entry() void {
2 const x = @intFromFloat(i8, 200);
3 _ = x;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:33: error: float value '200' cannot be stored in integer type 'i8'
test/cases/compile_errors/out_of_range_comptime_int_passed_to_floatToInt.zig deleted-10
......@@ -1,10 +0,0 @@
1export fn entry() void {
2 const x = @floatToInt(i8, 200);
3 _ = x;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:31: error: float value '200' cannot be stored in integer type 'i8'
test/cases/compile_errors/overflow_in_enum_value_allocation.zig+2-2
......@@ -3,8 +3,8 @@ const Moo = enum(u8) {
33 Over,
44};
55pub export fn entry() void {
6 var y = Moo.Last;
7 _ = y;
6 var y = Moo.Last;
7 _ = y;
88}
99
1010// error
test/cases/compile_errors/packed_union_given_enum_tag_type.zig+1-1
......@@ -9,7 +9,7 @@ const Payload = packed union(Letter) {
99 C: bool,
1010};
1111export fn entry() void {
12 var a = Payload { .A = 1234 };
12 var a = Payload{ .A = 1234 };
1313 _ = a;
1414}
1515
test/cases/compile_errors/packed_union_with_automatic_layout_field.zig+1-1
......@@ -7,7 +7,7 @@ const Payload = packed union {
77 B: bool,
88};
99export fn entry() void {
10 var a = Payload { .B = true };
10 var a = Payload{ .B = true };
1111 _ = a;
1212}
1313
test/cases/compile_errors/panic_called_at_compile_time.zig+3-1
......@@ -1,6 +1,8 @@
11export fn entry() void {
22 comptime {
3 @panic("aoeu",);
3 @panic(
4 "aoeu",
5 );
46 }
57}
68
test/cases/compile_errors/parameter_redeclaration.zig+4-3
......@@ -1,10 +1,11 @@
1fn f(a : i32, a : i32) void {
1fn f(a: i32, a: i32) void {}
2export fn entry() void {
3 f(1, 2);
24}
3export fn entry() void { f(1, 2); }
45
56// error
67// backend=stage2
78// target=native
89//
9// :1:15: error: redeclaration of function parameter 'a'
10// :1:14: error: redeclaration of function parameter 'a'
1011// :1:6: note: previous declaration here
test/cases/compile_errors/pass_const_ptr_to_mutable_ptr_fn.zig+6-3
......@@ -1,14 +1,17 @@
11fn foo() bool {
2 const a = @as([]const u8, "a",);
2 const a = @as([]const u8, "a");
33 const b = &a;
44 return ptrEql(b, b);
55}
66fn ptrEql(a: *[]const u8, b: *[]const u8) bool {
7 _ = a; _ = b;
7 _ = a;
8 _ = b;
89 return true;
910}
1011
11export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
12export fn entry() usize {
13 return @sizeOf(@TypeOf(&foo));
14}
1215
1316// error
1417// backend=stage2
test/cases/compile_errors/passing_an_under-aligned_function_pointer.zig+3-1
......@@ -4,7 +4,9 @@ export fn entry() void {
44fn testImplicitlyDecreaseFnAlign(ptr: *const fn () align(8) i32, answer: i32) void {
55 if (ptr() != answer) unreachable;
66}
7fn alignedSmall() align(4) i32 { return 1234; }
7fn alignedSmall() align(4) i32 {
8 return 1234;
9}
810
911// error
1012// backend=stage2
test/cases/compile_errors/pointer_to_noreturn.zig+3-1
......@@ -1,5 +1,7 @@
11fn a() *noreturn {}
2export fn entry() void { _ = a(); }
2export fn entry() void {
3 _ = a();
4}
35
46// error
57// backend=stage2
test/cases/compile_errors/ptrFromInt_non_ptr_type.zig created+15
......@@ -0,0 +1,15 @@
1pub export fn entry() void {
2 _ = @ptrFromInt(i32, 10);
3}
4
5pub export fn entry2() void {
6 _ = @ptrFromInt([]u8, 20);
7}
8
9// error
10// backend=stage2
11// target=native
12//
13// :2:21: error: expected pointer type, found 'i32'
14// :6:21: error: integer cannot be converted to slice type '[]u8'
15// :6:21: note: slice length cannot be inferred from address
test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig created+10
......@@ -0,0 +1,10 @@
1pub export fn entry() void {
2 var y = @ptrFromInt([*]align(4) u8, 5);
3 _ = y;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:41: error: pointer type '[*]align(4) u8' requires aligned address
test/cases/compile_errors/ptrToInt_0_to_non_optional_pointer.zig deleted-10
......@@ -1,10 +0,0 @@
1export fn entry() void {
2 var b = @intToPtr(*i32, 0);
3 _ = b;
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :2:29: error: pointer type '*i32' does not allow address zero
test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig+4-4
......@@ -1,13 +1,13 @@
11export fn entry() void {
22 foo(452) catch |err| switch (err) {
3 error.Foo ... error.Bar => {},
3 error.Foo...error.Bar => {},
44 else => {},
55 };
66}
77fn foo(x: i32) !void {
88 switch (x) {
9 0 ... 10 => return error.Foo,
10 11 ... 20 => return error.Bar,
9 0...10 => return error.Foo,
10 11...20 => return error.Bar,
1111 else => {},
1212 }
1313}
......@@ -17,4 +17,4 @@ fn foo(x: i32) !void {
1717// target=native
1818//
1919// :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).Fn.return_type.?).ErrorUnion.error_set'
20// :3:19: note: range here
20// :3:18: note: range here
test/cases/compile_errors/reassign_to_array_parameter.zig+2-2
......@@ -1,8 +1,8 @@
11fn reassign(a: [3]f32) void {
2 a = [3]f32{4, 5, 6};
2 a = [3]f32{ 4, 5, 6 };
33}
44export fn entry() void {
5 reassign(.{1, 2, 3});
5 reassign(.{ 1, 2, 3 });
66}
77
88// error
test/cases/compile_errors/reassign_to_struct_parameter.zig+2-2
......@@ -2,10 +2,10 @@ const S = struct {
22 x: u32,
33};
44fn reassign(s: S) void {
5 s = S{.x = 2};
5 s = S{ .x = 2 };
66}
77export fn entry() void {
8 reassign(S{.x = 3});
8 reassign(S{ .x = 3 });
99}
1010
1111// error
test/cases/compile_errors/redefinition_of_enums.zig+2-2
......@@ -1,5 +1,5 @@
1const A = enum {x};
2const A = enum {x};
1const A = enum { x };
2const A = enum { x };
33
44// error
55// backend=stage2
test/cases/compile_errors/redefinition_of_global_variables.zig+2-2
......@@ -1,5 +1,5 @@
1var a : i32 = 1;
2var a : i32 = 2;
1var a: i32 = 1;
2var a: i32 = 2;
33
44// error
55// backend=stage2
test/cases/compile_errors/redefinition_of_struct.zig+2-2
......@@ -1,5 +1,5 @@
1const A = struct { x : i32, };
2const A = struct { y : i32, };
1const A = struct { x: i32 };
2const A = struct { y: i32 };
33
44// error
55// backend=stage2
test/cases/compile_errors/reference_to_const_data.zig+3-3
......@@ -1,5 +1,5 @@
11export fn foo() void {
2 var ptr = &[_]u8{0,0,0,0};
2 var ptr = &[_]u8{ 0, 0, 0, 0 };
33 ptr[1] = 2;
44}
55export fn bar() void {
......@@ -11,11 +11,11 @@ export fn baz() void {
1111 ptr.* = false;
1212}
1313export fn qux() void {
14 const S = struct{
14 const S = struct {
1515 x: usize,
1616 y: usize,
1717 };
18 var ptr = &S{.x=1,.y=2};
18 var ptr = &S{ .x = 1, .y = 2 };
1919 ptr.x = 2;
2020}
2121export fn quux() void {
test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig+3-1
......@@ -8,7 +8,9 @@ const Foo = @Type(.{
88 .params = &.{},
99 },
1010});
11comptime { _ = Foo; }
11comptime {
12 _ = Foo;
13}
1214
1315// error
1416// backend=stage2
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+3-1
......@@ -8,7 +8,9 @@ const Foo = @Type(.{
88 .params = &.{},
99 },
1010});
11comptime { _ = Foo; }
11comptime {
12 _ = Foo;
13}
1214
1315// error
1416// backend=stage2
test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig+3-1
......@@ -8,7 +8,9 @@ const Foo = @Type(.{
88 .params = &.{},
99 },
1010});
11comptime { _ = Foo; }
11comptime {
12 _ = Foo;
13}
1214
1315// error
1416// backend=stage2
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig+1-1
......@@ -7,7 +7,7 @@ const Tag = @Type(.{
77 },
88});
99export fn entry() void {
10 _ = @intToEnum(Tag, 0);
10 _ = @enumFromInt(Tag, 0);
1111}
1212
1313// error
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig+1-1
......@@ -7,7 +7,7 @@ const Tag = @Type(.{
77 },
88});
99export fn entry() void {
10 _ = @intToEnum(Tag, 0);
10 _ = @enumFromInt(Tag, 0);
1111}
1212
1313// error
test/cases/compile_errors/reify_type_union_payload_is_undefined.zig+3-1
......@@ -1,7 +1,9 @@
11const Foo = @Type(.{
22 .Struct = undefined,
33});
4comptime { _ = Foo; }
4comptime {
5 _ = Foo;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/return_from_defer_expression.zig+4-2
......@@ -6,13 +6,15 @@ pub fn testTrickyDefer() !void {
66 const a = maybeInt() orelse return;
77}
88
9fn canFail() anyerror!void { }
9fn canFail() anyerror!void {}
1010
1111pub fn maybeInt() ?i32 {
1212 return 0;
1313}
1414
15export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); }
15export fn entry() usize {
16 return @sizeOf(@TypeOf(testTrickyDefer));
17}
1618
1719// error
1820// backend=stage2
test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig+3-3
......@@ -4,7 +4,7 @@ const Foo = struct {
44};
55export fn f() void {
66 var x: u8 = 0;
7 const foo = Foo { .Bar = x, .Baz = u8 };
7 const foo = Foo{ .Bar = x, .Baz = u8 };
88 _ = foo;
99}
1010
......@@ -12,5 +12,5 @@ export fn f() void {
1212// backend=stage2
1313// target=native
1414//
15// :7:30: error: unable to resolve comptime value
16// :7:30: note: initializer of comptime only struct must be comptime-known
15// :7:29: error: unable to resolve comptime value
16// :7:29: note: initializer of comptime only struct must be comptime-known
test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig+3-3
......@@ -4,7 +4,7 @@ const Foo = union {
44};
55export fn f() void {
66 var x: u8 = 0;
7 const foo = Foo { .Bar = x };
7 const foo = Foo{ .Bar = x };
88 _ = foo;
99}
1010
......@@ -12,5 +12,5 @@ export fn f() void {
1212// backend=stage2
1313// target=native
1414//
15// :7:30: error: unable to resolve comptime value
16// :7:30: note: initializer of comptime only union must be comptime-known
15// :7:29: error: unable to resolve comptime value
16// :7:29: note: initializer of comptime only union must be comptime-known
test/cases/compile_errors/runtime_to_comptime_num.zig+3-3
......@@ -2,16 +2,16 @@ pub export fn entry() void {
22 var a: u32 = 0;
33 _ = @as(comptime_int, a);
44}
5pub export fn entry2() void{
5pub export fn entry2() void {
66 var a: u32 = 0;
77 _ = @as(comptime_float, a);
88}
9pub export fn entry3() void{
9pub export fn entry3() void {
1010 comptime var aa: comptime_float = 0.0;
1111 var a: f32 = 4;
1212 aa = a;
1313}
14pub export fn entry4() void{
14pub export fn entry4() void {
1515 comptime var aa: comptime_int = 0.0;
1616 var a: f32 = 4;
1717 aa = a;
test/cases/compile_errors/saturating_shl_assign_does_not_allow_negative_rhs_at_comptime.zig+4-4
......@@ -1,12 +1,12 @@
11export fn a() void {
22 comptime {
3 var x = @as(i32, 1);
4 x <<|= @as(i32, -2);
5 }
3 var x = @as(i32, 1);
4 x <<|= @as(i32, -2);
5 }
66}
77
88// error
99// backend=stage2
1010// target=native
1111//
12// :4:14: error: shift by negative amount '-2'
12// :4:16: error: shift by negative amount '-2'
test/cases/compile_errors/self_referential_struct_requires_comptime.zig-1
......@@ -7,7 +7,6 @@ pub export fn entry() void {
77 _ = s;
88}
99
10
1110// error
1211// backend=stage2
1312// target=native
test/cases/compile_errors/setAlignStack_in_inline_function.zig+1-2
......@@ -1,7 +1,7 @@
11export fn entry() void {
22 foo();
33}
4fn foo() callconv(.Inline) void {
4inline fn foo() void {
55 @setAlignStack(16);
66}
77
......@@ -12,7 +12,6 @@ fn bar() void {
1212 @setAlignStack(16);
1313}
1414
15
1615// error
1716// backend=stage2
1817// target=native
test/cases/compile_errors/slice_passed_as_array_init_type_with_elems.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 const x = []u8{1, 2};
2 const x = []u8{ 1, 2 };
33 _ = x;
44}
55
test/cases/compile_errors/slice_sentinel_mismatch-2.zig+3-1
......@@ -2,7 +2,9 @@ fn foo() [:0]u8 {
22 var x: []u8 = undefined;
33 return x;
44}
5comptime { _ = &foo; }
5comptime {
6 _ = &foo;
7}
68
79// error
810// backend=stage2
test/cases/compile_errors/slice_used_as_extern_fn_param.zig+1-1
......@@ -1,4 +1,4 @@
1extern fn Text(str: []const u8, num: i32) callconv(.C) void;
1extern fn Text(str: []const u8, num: i32) callconv(.C) void;
22export fn entry() void {
33 _ = Text;
44}
test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig+1-1
......@@ -1,4 +1,4 @@
1const Small = enum (u2) {
1const Small = enum(u2) {
22 One,
33 Two,
44 Three,
test/cases/compile_errors/specify_non-integer_enum_tag_type.zig+2-2
......@@ -1,4 +1,4 @@
1const Small = enum (f32) {
1const Small = enum(f32) {
22 One,
33 Two,
44 Three,
......@@ -13,4 +13,4 @@ export fn entry() void {
1313// backend=stage2
1414// target=native
1515//
16// :1:21: error: expected integer tag type, found 'f32'
16// :1:20: error: expected integer tag type, found 'f32'
test/cases/compile_errors/src_fields_runtime.zig+4-1
......@@ -4,7 +4,10 @@ pub export fn entry1() void {
44 comptime var b: []const u8 = s.fn_name;
55 comptime var c: u32 = s.column;
66 comptime var d: u32 = s.line;
7 _ = a; _ = b; _ = c; _ = d;
7 _ = a;
8 _ = b;
9 _ = c;
10 _ = d;
811}
912
1013// error
test/cases/compile_errors/stage1/obj/generic_function_where_return_type_is_self-referenced.zig+2-4
......@@ -1,10 +1,8 @@
11fn Foo(comptime T: type) Foo(T) {
2 return struct{ x: T };
2 return struct { x: T };
33}
44export fn entry() void {
5 const t = Foo(u32) {
6 .x = 1
7 };
5 const t = Foo(u32){ .x = 1 };
86 _ = t;
97}
108
test/cases/compile_errors/stage1/obj/unsupported_modifier_at_start_of_asm_output_constraint.zig+5-1
......@@ -1,6 +1,10 @@
11export fn foo() void {
22 var bar: u32 = 3;
3 asm volatile ("" : [baz]"+r"(bar) : : "");
3 asm volatile (""
4 : [baz] "+r" (bar),
5 :
6 : ""
7 );
48}
59
610// error
test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15});
2 @import("std").debug.print("{d} {d} {d} {d} {d}", .{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 });
33}
44
55// error
test/cases/compile_errors/struct_type_mismatch_in_arg.zig+4-4
......@@ -1,18 +1,18 @@
11const Foo = struct { i: i32 };
22const Bar = struct { j: i32 };
33
4pub fn helper(_: Foo, _: Bar) void { }
4pub fn helper(_: Foo, _: Bar) void {}
55
66comptime {
7 helper(Bar { .j = 10 }, Bar { .j = 10 });
8 helper(Bar { .i = 10 }, Bar { .j = 10 });
7 helper(Bar{ .j = 10 }, Bar{ .j = 10 });
8 helper(Bar{ .i = 10 }, Bar{ .j = 10 });
99}
1010
1111// error
1212// backend=stage2
1313// target=native
1414//
15// :7:16: error: expected type 'tmp.Foo', found 'tmp.Bar'
15// :7:15: error: expected type 'tmp.Foo', found 'tmp.Bar'
1616// :2:13: note: struct declared here
1717// :1:13: note: struct declared here
1818// :4:18: note: parameter type declared here
test/cases/compile_errors/struct_type_returned_from_non-generic_function.zig+1-1
......@@ -1,5 +1,5 @@
11pub export fn entry(param: usize) usize {
2 return struct{ param };
2 return struct { param };
33}
44
55// error
test/cases/compile_errors/struct_with_declarations_unavailable_for_reify_type.zig+3-1
......@@ -1,5 +1,7 @@
11export fn entry() void {
2 _ = @Type(@typeInfo(struct { const foo = 1; }));
2 _ = @Type(@typeInfo(struct {
3 const foo = 1;
4 }));
35}
46
57// error
test/cases/compile_errors/struct_with_invalid_field.zig+5-5
......@@ -1,10 +1,10 @@
1const std = @import("std",);
1const std = @import(
2 "std",
3);
24const Allocator = std.mem.Allocator;
35const ArrayList = std.ArrayList;
46
5const HeaderWeight = enum {
6 H1, H2, H3, H4, H5, H6,
7};
7const HeaderWeight = enum { H1, H2, H3, H4, H5, H6 };
88
99const MdText = ArrayList(u8);
1010
......@@ -16,7 +16,7 @@ const MdNode = union(enum) {
1616};
1717
1818export fn entry() void {
19 const a = MdNode.Header {
19 const a = MdNode.Header{
2020 .text = MdText.init(std.testing.allocator),
2121 .weight = HeaderWeight.H1,
2222 };
test/cases/compile_errors/sub_overflow_in_function_evaluation.zig+3-1
......@@ -3,7 +3,9 @@ fn sub(a: u16, b: u16) u16 {
33 return a - b;
44}
55
6export fn entry() usize { return @sizeOf(@TypeOf(&y)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(&y));
8}
79
810// error
911// backend=stage2
test/cases/compile_errors/suspend_inside_suspend_block.zig+1-2
......@@ -3,8 +3,7 @@ export fn entry() void {
33}
44fn foo() void {
55 suspend {
6 suspend {
7 }
6 suspend {}
87 }
98}
109
test/cases/compile_errors/switch_expression-duplicate_enumeration_prong.zig+3-1
......@@ -14,7 +14,9 @@ fn f(n: Number) i32 {
1414 }
1515}
1616
17export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
17export fn entry() usize {
18 return @sizeOf(@TypeOf(&f));
19}
1820
1921// error
2022// backend=stage2
test/cases/compile_errors/switch_expression-duplicate_enumeration_prong_when_else_present.zig+3-1
......@@ -15,7 +15,9 @@ fn f(n: Number) i32 {
1515 }
1616}
1717
18export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
18export fn entry() usize {
19 return @sizeOf(@TypeOf(&f));
20}
1921
2022// error
2123// backend=stage2
test/cases/compile_errors/switch_expression-duplicate_or_overlapping_integer_value.zig+9-7
......@@ -1,16 +1,18 @@
11fn foo(x: u8) u8 {
22 return switch (x) {
3 0 ... 100 => @as(u8, 0),
4 101 ... 200 => 1,
5 201, 203 ... 207 => 2,
6 206 ... 255 => 3,
3 0...100 => @as(u8, 0),
4 101...200 => 1,
5 201, 203...207 => 2,
6 206...255 => 3,
77 };
88}
9export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
9export fn entry() usize {
10 return @sizeOf(@TypeOf(&foo));
11}
1012
1113// error
1214// backend=stage2
1315// target=native
1416//
15// :6:13: error: duplicate switch value
16// :5:18: note: previous value here
17// :6:12: error: duplicate switch value
18// :5:17: note: previous value here
test/cases/compile_errors/switch_expression-duplicate_type.zig+3-1
......@@ -7,7 +7,9 @@ fn foo(comptime T: type, x: T) u8 {
77 else => 3,
88 };
99}
10export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); }
10export fn entry() usize {
11 return @sizeOf(@TypeOf(foo(u32, 0)));
12}
1113
1214// error
1315// backend=stage2
test/cases/compile_errors/switch_expression-duplicate_type_struct_alias.zig+3-1
......@@ -11,7 +11,9 @@ fn foo(comptime T: type, x: T) u8 {
1111 else => 3,
1212 };
1313}
14export fn entry() usize { return @sizeOf(@TypeOf(foo(u32, 0))); }
14export fn entry() usize {
15 return @sizeOf(@TypeOf(foo(u32, 0)));
16}
1517
1618// error
1719// backend=stage2
test/cases/compile_errors/switch_expression-missing_enumeration_prong.zig+3-1
......@@ -12,7 +12,9 @@ fn f(n: Number) i32 {
1212 }
1313}
1414
15export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
15export fn entry() usize {
16 return @sizeOf(@TypeOf(&f));
17}
1618
1719// error
1820// backend=stage2
test/cases/compile_errors/switch_expression-non_exhaustive_integer_prongs.zig+3-1
......@@ -3,7 +3,9 @@ fn foo(x: u8) void {
33 0 => {},
44 }
55}
6export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
6export fn entry() usize {
7 return @sizeOf(@TypeOf(&foo));
8}
79
810// error
911// backend=stage2
test/cases/compile_errors/switch_expression-switch_on_pointer_type_with_no_else.zig+3-1
......@@ -4,7 +4,9 @@ fn foo(x: *u8) void {
44 }
55}
66var y: u8 = 100;
7export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
7export fn entry() usize {
8 return @sizeOf(@TypeOf(&foo));
9}
810
911// error
1012// backend=stage2
test/cases/compile_errors/switch_expression-unreachable_else_prong_bool.zig+3-1
......@@ -5,7 +5,9 @@ fn foo(x: bool) void {
55 else => {},
66 }
77}
8export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
8export fn entry() usize {
9 return @sizeOf(@TypeOf(&foo));
10}
911
1012// error
1113// backend=stage2
test/cases/compile_errors/switch_expression-unreachable_else_prong_enum.zig+4-2
......@@ -1,4 +1,4 @@
1const TestEnum = enum{ T1, T2 };
1const TestEnum = enum { T1, T2 };
22
33fn err(x: u8) TestEnum {
44 switch (x) {
......@@ -15,7 +15,9 @@ fn foo(x: u8) void {
1515 }
1616}
1717
18export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
18export fn entry() usize {
19 return @sizeOf(@TypeOf(&foo));
20}
1921
2022// error
2123// backend=llvm
test/cases/compile_errors/switch_expression-unreachable_else_prong_range_i8.zig+3-1
......@@ -8,7 +8,9 @@ fn foo(x: i8) void {
88 else => {},
99 }
1010}
11export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
11export fn entry() usize {
12 return @sizeOf(@TypeOf(&foo));
13}
1214
1315// error
1416// backend=stage2
test/cases/compile_errors/switch_expression-unreachable_else_prong_range_u8.zig+3-1
......@@ -8,7 +8,9 @@ fn foo(x: u8) void {
88 else => {},
99 }
1010}
11export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
11export fn entry() usize {
12 return @sizeOf(@TypeOf(&foo));
13}
1214
1315// error
1416// backend=stage2
test/cases/compile_errors/switch_expression-unreachable_else_prong_u1.zig+3-1
......@@ -5,7 +5,9 @@ fn foo(x: u1) void {
55 else => {},
66 }
77}
8export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
8export fn entry() usize {
9 return @sizeOf(@TypeOf(&foo));
10}
911
1012// error
1113// backend=stage2
test/cases/compile_errors/switch_expression-unreachable_else_prong_u2.zig+3-1
......@@ -7,7 +7,9 @@ fn foo(x: u2) void {
77 else => {},
88 }
99}
10export fn entry() usize { return @sizeOf(@TypeOf(&foo)); }
10export fn entry() usize {
11 return @sizeOf(@TypeOf(&foo));
12}
1113
1214// error
1315// backend=stage2
test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig+1-1
......@@ -1,4 +1,4 @@
1const E = enum{
1const E = enum {
22 a,
33 b,
44};
test/cases/compile_errors/switching_with_non-exhaustive_enums.zig+1-1
......@@ -22,7 +22,7 @@ pub export fn entry2() void {
2222 }
2323}
2424pub export fn entry3() void {
25 var u = U{.a = 2};
25 var u = U{ .a = 2 };
2626 switch (u) { // error: `_` prong not allowed when switching on tagged union
2727 .a => {},
2828 .b => {},
test/cases/compile_errors/tagName_on_invalid_value_of_non-exhaustive_enum.zig+2-2
......@@ -1,6 +1,6 @@
11test "enum" {
22 const E = enum(u8) { A, B, _ };
3 _ = @tagName(@intToEnum(E, 5));
3 _ = @tagName(@enumFromInt(E, 5));
44}
55
66// error
......@@ -8,5 +8,5 @@ test "enum" {
88// target=native
99// is_test=1
1010//
11// :3:9: error: no field with value '@intToEnum(tmp.test.enum.E, 5)' in enum 'test.enum.E'
11// :3:9: error: no field with value '@enumFromInt(tmp.test.enum.E, 5)' in enum 'test.enum.E'
1212// :2:15: note: declared here
test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig+1-1
......@@ -3,7 +3,7 @@ const FloatInt = extern union {
33 Int: i32,
44};
55export fn entry() void {
6 var fi = FloatInt{.Float = 123.45};
6 var fi = FloatInt{ .Float = 123.45 };
77 var tagName = @tagName(fi);
88 _ = tagName;
99}
test/cases/compile_errors/top_level_decl_dependency_loop.zig+2-2
......@@ -1,5 +1,5 @@
1const a : @TypeOf(b) = 0;
2const b : @TypeOf(a) = 0;
1const a: @TypeOf(b) = 0;
2const b: @TypeOf(a) = 0;
33export fn entry() void {
44 const c = a + b;
55 _ = c;
test/cases/compile_errors/try_in_function_with_non_error_return_type.zig+1-1
......@@ -1,7 +1,7 @@
11export fn f() void {
22 try something();
33}
4fn something() anyerror!void { }
4fn something() anyerror!void {}
55
66// error
77// backend=stage2
test/cases/compile_errors/tuple_init_edge_cases.zig+27-15
......@@ -1,44 +1,56 @@
11pub export fn entry1() void {
22 const T = @TypeOf(.{ 123, 3 });
3 var b = T{ .@"1" = 3 }; _ = b;
4 var c = T{ 123, 3 }; _ = c;
5 var d = T{}; _ = d;
3 var b = T{ .@"1" = 3 };
4 _ = b;
5 var c = T{ 123, 3 };
6 _ = c;
7 var d = T{};
8 _ = d;
69}
710pub export fn entry2() void {
811 var a: u32 = 2;
912 const T = @TypeOf(.{ 123, a });
10 var b = T{ .@"1" = 3 }; _ = b;
11 var c = T{ 123, 3 }; _ = c;
12 var d = T{}; _ = d;
13 var b = T{ .@"1" = 3 };
14 _ = b;
15 var c = T{ 123, 3 };
16 _ = c;
17 var d = T{};
18 _ = d;
1319}
1420pub export fn entry3() void {
1521 var a: u32 = 2;
1622 const T = @TypeOf(.{ 123, a });
17 var b = T{ .@"0" = 123 }; _ = b;
23 var b = T{ .@"0" = 123 };
24 _ = b;
1825}
1926comptime {
2027 var a: u32 = 2;
2128 const T = @TypeOf(.{ 123, a });
22 var b = T{ .@"0" = 123 }; _ = b;
23 var c = T{ 123, 2 }; _ = c;
24 var d = T{}; _ = d;
29 var b = T{ .@"0" = 123 };
30 _ = b;
31 var c = T{ 123, 2 };
32 _ = c;
33 var d = T{};
34 _ = d;
2535}
2636pub export fn entry4() void {
2737 var a: u32 = 2;
2838 const T = @TypeOf(.{ 123, a });
29 var b = T{ 123, 4, 5 }; _ = b;
39 var b = T{ 123, 4, 5 };
40 _ = b;
3041}
3142pub export fn entry5() void {
3243 var a: u32 = 2;
3344 const T = @TypeOf(.{ 123, a });
34 var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 }; _ = b;
45 var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 };
46 _ = b;
3547}
3648
3749// error
3850// backend=stage2
3951// target=native
4052//
41// :12:14: error: missing tuple field with index 1
4253// :17:14: error: missing tuple field with index 1
43// :29:14: error: expected at most 2 tuple fields; found 3
44// :34:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
54// :23:14: error: missing tuple field with index 1
55// :39:14: error: expected at most 2 tuple fields; found 3
56// :45:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
test/cases/compile_errors/type_checking_function_pointers.zig+6-4
......@@ -1,7 +1,9 @@
11fn a(b: *const fn (*const u8) void) void {
22 _ = b;
33}
4fn c(d: u8) void {_ = d;}
4fn c(d: u8) void {
5 _ = d;
6}
57export fn entry() void {
68 a(c);
79}
......@@ -10,6 +12,6 @@ export fn entry() void {
1012// backend=stage2
1113// target=native
1214//
13// :6:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void'
14// :6:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void'
15// :6:7: note: parameter 0 'u8' cannot cast into '*const u8'
15// :8:7: error: expected type '*const fn(*const u8) void', found '*const fn(u8) void'
16// :8:7: note: pointer type child 'fn(u8) void' cannot cast into pointer type child 'fn(*const u8) void'
17// :8:7: note: parameter 0 'u8' cannot cast into '*const u8'
test/cases/compile_errors/undeclared_identifier.zig+2-4
......@@ -1,11 +1,9 @@
11export fn a() void {
2 return
3 b +
4 c;
2 return b + c;
53}
64
75// error
86// backend=stage2
97// target=native
108//
11// :3:5: error: use of undeclared identifier 'b'
9// :2:12: error: use of undeclared identifier 'b'
test/cases/compile_errors/union_auto-enum_value_already_taken.zig+1-1
......@@ -6,7 +6,7 @@ const MultipleChoice = union(enum(u32)) {
66 E = 60,
77};
88export fn entry() void {
9 var x = MultipleChoice { .C = {} };
9 var x = MultipleChoice{ .C = {} };
1010 _ = x;
1111}
1212
test/cases/compile_errors/union_enum_field_does_not_match_enum.zig+1-1
......@@ -10,7 +10,7 @@ const Payload = union(Letter) {
1010 D: bool,
1111};
1212export fn entry() void {
13 var a = Payload {.A = 1234};
13 var a = Payload{ .A = 1234 };
1414 _ = a;
1515}
1616
test/cases/compile_errors/unreachable_parameter.zig+6-2
......@@ -1,5 +1,9 @@
1fn f(a: noreturn) void { _ = a; }
2export fn entry() void { f(); }
1fn f(a: noreturn) void {
2 _ = a;
3}
4export fn entry() void {
5 f();
6}
37
48// error
59// backend=stage2
test/cases/compile_errors/unreachable_with_return.zig+7-3
......@@ -1,9 +1,13 @@
1fn a() noreturn {return;}
2export fn entry() void { a(); }
1fn a() noreturn {
2 return;
3}
4export fn entry() void {
5 a();
6}
37
48// error
59// backend=stage2
610// target=native
711//
8// :1:18: error: function declared 'noreturn' returns
12// :2:5: error: function declared 'noreturn' returns
913// :1:8: note: 'noreturn' declared here
test/cases/compile_errors/while_expected_bool_got_error_union.zig+3-1
......@@ -1,7 +1,9 @@
11export fn foo() void {
22 while (bar()) {}
33}
4fn bar() anyerror!i32 { return 1; }
4fn bar() anyerror!i32 {
5 return 1;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/while_expected_bool_got_optional.zig+3-1
......@@ -1,7 +1,9 @@
11export fn foo() void {
22 while (bar()) {}
33}
4fn bar() ?i32 { return 1; }
4fn bar() ?i32 {
5 return 1;
6}
57
68// error
79// backend=stage2
test/cases/compile_errors/while_expected_error_union_got_bool.zig+8-2
......@@ -1,7 +1,13 @@
11export fn foo() void {
2 while (bar()) |x| {_ = x;} else |err| {_ = err;}
2 while (bar()) |x| {
3 _ = x;
4 } else |err| {
5 _ = err;
6 }
7}
8fn bar() bool {
9 return true;
310}
4fn bar() bool { return true; }
511
612// error
713// backend=stage2
test/cases/compile_errors/while_expected_error_union_got_optional.zig+8-2
......@@ -1,7 +1,13 @@
11export fn foo() void {
2 while (bar()) |x| {_ = x;} else |err| {_ = err;}
2 while (bar()) |x| {
3 _ = x;
4 } else |err| {
5 _ = err;
6 }
7}
8fn bar() ?i32 {
9 return 1;
310}
4fn bar() ?i32 { return 1; }
511
612// error
713// backend=stage2
test/cases/compile_errors/while_expected_optional_got_bool.zig+6-2
......@@ -1,7 +1,11 @@
11export fn foo() void {
2 while (bar()) |x| {_ = x;}
2 while (bar()) |x| {
3 _ = x;
4 }
5}
6fn bar() bool {
7 return true;
38}
4fn bar() bool { return true; }
59
610// error
711// backend=stage2
test/cases/compile_errors/while_expected_optional_got_error_union.zig+6-2
......@@ -1,7 +1,11 @@
11export fn foo() void {
2 while (bar()) |x| {_ = x;}
2 while (bar()) |x| {
3 _ = x;
4 }
5}
6fn bar() anyerror!i32 {
7 return 1;
38}
4fn bar() anyerror!i32 { return 1; }
59
610// error
711// backend=stage2
test/cases/compile_errors/write_to_const_global_variable.zig+4-2
......@@ -1,8 +1,10 @@
1const x : i32 = 99;
1const x: i32 = 99;
22fn f() void {
33 x = 1;
44}
5export fn entry() void { f(); }
5export fn entry() void {
6 f();
7}
68
79// error
810// backend=stage2
test/cases/compile_errors/wrong_function_type.zig+13-5
......@@ -1,8 +1,16 @@
1const fns = [_]fn() void { a, b, c };
2fn a() i32 {return 0;}
3fn b() i32 {return 1;}
4fn c() i32 {return 2;}
5export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
1const fns = [_]fn () void{ a, b, c };
2fn a() i32 {
3 return 0;
4}
5fn b() i32 {
6 return 1;
7}
8fn c() i32 {
9 return 2;
10}
11export fn entry() usize {
12 return @sizeOf(@TypeOf(fns));
13}
614
715// error
816// backend=stage2
test/cases/compile_errors/wrong_number_of_arguments.zig+5-1
......@@ -1,7 +1,11 @@
11export fn a() void {
22 c(1);
33}
4fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; }
4fn c(d: i32, e: i32, f: i32) void {
5 _ = d;
6 _ = e;
7 _ = f;
8}
59
610// error
711// backend=stage2
test/cases/compile_errors/wrong_number_of_arguments_for_method_fn_call.zig+8-4
......@@ -1,15 +1,19 @@
11const Foo = struct {
2 fn method(self: *const Foo, a: i32) void {_ = self; _ = a;}
2 fn method(self: *const Foo, a: i32) void {
3 _ = self;
4 _ = a;
5 }
36};
47fn f(foo: *const Foo) void {
5
68 foo.method(1, 2);
79}
8export fn entry() usize { return @sizeOf(@TypeOf(&f)); }
10export fn entry() usize {
11 return @sizeOf(@TypeOf(&f));
12}
913
1014// error
1115// backend=stage2
1216// target=native
1317//
14// :6:8: error: member function expected 1 argument(s), found 2
18// :8:8: error: member function expected 1 argument(s), found 2
1519// :2:5: note: function declared here
test/cases/compile_errors/wrong_size_to_an_array_literal.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 const array = [2]u8{1, 2, 3};
2 const array = [2]u8{ 1, 2, 3 };
33 _ = array;
44}
55
test/cases/compile_errors/wrong_types_given_to_export.zig+3-3
......@@ -1,11 +1,11 @@
1fn entry() callconv(.C) void { }
1fn entry() callconv(.C) void {}
22comptime {
3 @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) });
3 @export(entry, .{ .name = "entry", .linkage = @as(u32, 1234) });
44}
55
66// error
77// backend=stage2
88// target=native
99//
10// :3:50: error: expected type 'builtin.GlobalLinkage', found 'u32'
10// :3:51: error: expected type 'builtin.GlobalLinkage', found 'u32'
1111// :?:?: note: enum declared here
test/cases/comptime_var.2.zig+1-1
......@@ -8,7 +8,7 @@ pub fn main() void {
88}
99
1010fn print(len: usize) void {
11 _ = write(1, @ptrToInt("Hello, World!\n"), len);
11 _ = write(1, @intFromPtr("Hello, World!\n"), len);
1212}
1313
1414// run
test/cases/comptime_var.6.zig+1-1
......@@ -7,7 +7,7 @@ pub fn main() void {
77 }
88}
99fn print(len: usize) void {
10 _ = write(1, @ptrToInt("Hello"), len);
10 _ = write(1, @intFromPtr("Hello"), len);
1111}
1212
1313// run
test/cases/conditional_branches.0.zig+1-1
......@@ -12,7 +12,7 @@ fn foo(x: u64) void {
1212
1313fn print() void {
1414 const str = "Hello, World!\n";
15 _ = write(1, @ptrToInt(str.ptr), ptr.len);
15 _ = write(1, @intFromPtr(str.ptr), ptr.len);
1616}
1717
1818// run
test/cases/conditional_branches.1.zig+1-1
......@@ -15,7 +15,7 @@ fn foo(x: bool) void {
1515
1616fn print() void {
1717 const str = "Hello, World!\n";
18 _ = write(1, @ptrToInt(str.ptr), ptr.len);
18 _ = write(1, @intFromPtr(str.ptr), ptr.len);
1919}
2020
2121// run
test/cases/decl_value_arena.zig+9-9
......@@ -1,20 +1,20 @@
11pub const Protocols: struct {
2 list: *const fn(*Connection) void = undefined,
3 handShake: type = struct {
4 const stepStart: u8 = 0;
5 },
2 list: *const fn (*Connection) void = undefined,
3 handShake: type = struct {
4 const stepStart: u8 = 0;
5 },
66} = .{};
77
88pub const Connection = struct {
9 streamBuffer: [0]u8 = undefined,
10 __lastReceivedPackets: [0]u8 = undefined,
9 streamBuffer: [0]u8 = undefined,
10 __lastReceivedPackets: [0]u8 = undefined,
1111
12 handShakeState: u8 = Protocols.handShake.stepStart,
12 handShakeState: u8 = Protocols.handShake.stepStart,
1313};
1414
1515pub fn main() void {
16 var conn: Connection = undefined;
17 _ = conn;
16 var conn: Connection = undefined;
17 _ = conn;
1818}
1919
2020// run
test/cases/enum_values.0.zig+2-2
......@@ -7,8 +7,8 @@ pub fn main() void {
77 number1;
88 number2;
99 }
10 const number3 = @intToEnum(Number, 2);
11 if (@enumToInt(number3) != 2) {
10 const number3 = @enumFromInt(Number, 2);
11 if (@intFromEnum(number3) != 2) {
1212 unreachable;
1313 }
1414 return;
test/cases/enum_values.1.zig+4-4
......@@ -3,12 +3,12 @@ const Number = enum { One, Two, Three };
33pub fn main() void {
44 var number1 = Number.One;
55 var number2: Number = .Two;
6 const number3 = @intToEnum(Number, 2);
6 const number3 = @enumFromInt(Number, 2);
77 assert(number1 != number2);
88 assert(number2 != number3);
9 assert(@enumToInt(number1) == 0);
10 assert(@enumToInt(number2) == 1);
11 assert(@enumToInt(number3) == 2);
9 assert(@intFromEnum(number1) == 0);
10 assert(@intFromEnum(number2) == 1);
11 assert(@intFromEnum(number3) == 2);
1212 var x: Number = .Two;
1313 assert(number2 == x);
1414
test/cases/error_in_nested_declaration.zig+1-1
......@@ -5,7 +5,7 @@ const S = struct {
55 pub fn str(_: @This(), extra: []u32) []i32 {
66 return @bitCast([]i32, extra);
77 }
8 },
8 },
99};
1010
1111pub export fn entry() void {
test/cases/hello_world_with_updates.2.zig+1-1
......@@ -8,7 +8,7 @@ pub export fn main() noreturn {
88}
99
1010fn print() void {
11 const msg = @ptrToInt("Hello, World!\n");
11 const msg = @intFromPtr("Hello, World!\n");
1212 const len = 14;
1313 _ = write(1, msg, len);
1414}
test/cases/hello_world_with_updates.3.zig+1-1
......@@ -5,7 +5,7 @@ pub fn main() void {
55}
66
77fn print() void {
8 const msg = @ptrToInt("Hello, World!\n");
8 const msg = @intFromPtr("Hello, World!\n");
99 const len = 14;
1010 _ = write(1, msg, len);
1111}
test/cases/hello_world_with_updates.4.zig+1-1
......@@ -8,7 +8,7 @@ pub fn main() void {
88}
99
1010fn print() void {
11 const msg = @ptrToInt("Hello, World!\n");
11 const msg = @intFromPtr("Hello, World!\n");
1212 const len = 14;
1313 _ = write(1, msg, len);
1414}
test/cases/hello_world_with_updates.5.zig+1-1
......@@ -5,7 +5,7 @@ pub fn main() void {
55}
66
77fn print() void {
8 const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
8 const msg = @intFromPtr("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
99 const len = 104;
1010 _ = write(1, msg, len);
1111}
test/cases/hello_world_with_updates.6.zig+1-1
......@@ -8,7 +8,7 @@ pub fn main() void {
88}
99
1010fn print() void {
11 const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
11 const msg = @intFromPtr("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
1212 const len = 104;
1313 _ = write(1, msg, len);
1414}
test/cases/int_to_ptr.0.zig+1-1
......@@ -1,5 +1,5 @@
11pub fn main() void {
2 _ = @intToPtr(*u8, 0);
2 _ = @ptrFromInt(*u8, 0);
33}
44
55// error
test/cases/int_to_ptr.1.zig+1-1
......@@ -1,5 +1,5 @@
11pub fn main() void {
2 _ = @intToPtr(*u32, 2);
2 _ = @ptrFromInt(*u32, 2);
33}
44
55// error
test/cases/llvm/f_segment_address_space_reading_and_writing.zig+4-4
......@@ -20,7 +20,7 @@ fn getFs() c_ulong {
2020 :
2121 : [number] "{rax}" (158),
2222 [code] "{rdi}" (0x1003),
23 [ptr] "{rsi}" (@ptrToInt(&result)),
23 [ptr] "{rsi}" (@intFromPtr(&result)),
2424 : "rcx", "r11", "memory"
2525 );
2626 return result;
......@@ -31,10 +31,10 @@ var test_value: u64 = 12345;
3131pub fn main() void {
3232 const orig_fs = getFs();
3333
34 setFs(@ptrToInt(&test_value));
35 assert(getFs() == @ptrToInt(&test_value));
34 setFs(@intFromPtr(&test_value));
35 assert(getFs() == @intFromPtr(&test_value));
3636
37 var test_ptr = @intToPtr(*allowzero addrspace(.fs) u64, 0);
37 var test_ptr = @ptrFromInt(*allowzero addrspace(.fs) u64, 0);
3838 assert(test_ptr.* == 12345);
3939 test_ptr.* = 98765;
4040 assert(test_value == 98765);
test/cases/safety/@alignCast misaligned.zig +1-1
......@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010
1111pub fn main() !void {
12 var array align(4) = [_]u32{0x11111111, 0x11111111};
12 var array align(4) = [_]u32{ 0x11111111, 0x11111111 };
1313 const bytes = std.mem.sliceAsBytes(array[0..]);
1414 if (foo(bytes) != 0x11111111) return error.Wrong;
1515 return error.TestFailed;
test/cases/safety/@enumFromInt - no matching tag value.zig created+26
......@@ -0,0 +1,26 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid enum value")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10const Foo = enum {
11 A,
12 B,
13 C,
14};
15pub fn main() !void {
16 baz(bar(3));
17 return error.TestFailed;
18}
19fn bar(a: u2) Foo {
20 return @enumFromInt(Foo, a);
21}
22fn baz(_: Foo) void {}
23
24// run
25// backend=llvm
26// target=native
test/cases/safety/@errSetCast error not present in destination.zig +2-2
......@@ -7,8 +7,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
77 }
88 std.process.exit(1);
99}
10const Set1 = error{A, B};
11const Set2 = error{A, C};
10const Set1 = error{ A, B };
11const Set2 = error{ A, C };
1212pub fn main() !void {
1313 foo(Set1.B) catch {};
1414 return error.TestFailed;
test/cases/safety/@floatToInt cannot fit - negative out of range.zig deleted-20
......@@ -1,20 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 baz(bar(-129.1));
12 return error.TestFailed;
13}
14fn bar(a: f32) i8 {
15 return @floatToInt(i8, a);
16}
17fn baz(_: i8) void { }
18// run
19// backend=llvm
20// target=native
test/cases/safety/@floatToInt cannot fit - negative to unsigned.zig deleted-20
......@@ -1,20 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 baz(bar(-1.1));
12 return error.TestFailed;
13}
14fn bar(a: f32) u8 {
15 return @floatToInt(u8, a);
16}
17fn baz(_: u8) void { }
18// run
19// backend=llvm
20// target=native
test/cases/safety/@floatToInt cannot fit - positive out of range.zig deleted-20
......@@ -1,20 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 baz(bar(256.2));
12 return error.TestFailed;
13}
14fn bar(a: f32) u8 {
15 return @floatToInt(u8, a);
16}
17fn baz(_: u8) void { }
18// run
19// backend=llvm
20// target=native
test/cases/safety/@intFromFloat cannot fit - negative out of range.zig created+20
......@@ -0,0 +1,20 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 baz(bar(-129.1));
12 return error.TestFailed;
13}
14fn bar(a: f32) i8 {
15 return @intFromFloat(i8, a);
16}
17fn baz(_: i8) void {}
18// run
19// backend=llvm
20// target=native
test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig created+20
......@@ -0,0 +1,20 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 baz(bar(-1.1));
12 return error.TestFailed;
13}
14fn bar(a: f32) u8 {
15 return @intFromFloat(u8, a);
16}
17fn baz(_: u8) void {}
18// run
19// backend=llvm
20// target=native
test/cases/safety/@intFromFloat cannot fit - positive out of range.zig created+20
......@@ -0,0 +1,20 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 baz(bar(256.2));
12 return error.TestFailed;
13}
14fn bar(a: f32) u8 {
15 return @intFromFloat(u8, a);
16}
17fn baz(_: u8) void {}
18// run
19// backend=llvm
20// target=native
test/cases/safety/@intToEnum - no matching tag value.zig deleted-26
......@@ -1,26 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "invalid enum value")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10const Foo = enum {
11 A,
12 B,
13 C,
14};
15pub fn main() !void {
16 baz(bar(3));
17 return error.TestFailed;
18}
19fn bar(a: u2) Foo {
20 return @intToEnum(Foo, a);
21}
22fn baz(_: Foo) void {}
23
24// run
25// backend=llvm
26// target=native
test/cases/safety/@intToPtr address zero to non-optional byte-aligned pointer.zig deleted-18
......@@ -1,18 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 var zero: usize = 0;
12 var b = @intToPtr(*u8, zero);
13 _ = b;
14 return error.TestFailed;
15}
16// run
17// backend=llvm
18// target=native
test/cases/safety/@intToPtr address zero to non-optional pointer.zig deleted-18
......@@ -1,18 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 var zero: usize = 0;
12 var b = @intToPtr(*i32, zero);
13 _ = b;
14 return error.TestFailed;
15}
16// run
17// backend=llvm
18// target=native
test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig created+18
......@@ -0,0 +1,18 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 var zero: usize = 0;
12 var b = @ptrFromInt(*u8, zero);
13 _ = b;
14 return error.TestFailed;
15}
16// run
17// backend=llvm
18// target=native
test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig created+18
......@@ -0,0 +1,18 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "cast causes pointer to be null")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 var zero: usize = 0;
12 var b = @ptrFromInt(*i32, zero);
13 _ = b;
14 return error.TestFailed;
15}
16// run
17// backend=llvm
18// target=native
test/cases/safety/@ptrFromInt with misaligned address.zig created+18
......@@ -0,0 +1,18 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "incorrect alignment")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 var x: usize = 5;
12 var y = @ptrFromInt([*]align(4) u8, x);
13 _ = y;
14 return error.TestFailed;
15}
16// run
17// backend=llvm
18// target=native
test/cases/safety/bad union field access.zig +1-1
......@@ -14,7 +14,7 @@ const Foo = union {
1414};
1515
1616pub fn main() !void {
17 var f = Foo { .int = 42 };
17 var f = Foo{ .int = 42 };
1818 bar(&f);
1919 return error.TestFailed;
2020}
test/cases/safety/cast []u8 to bigger slice of wrong size.zig +1-1
......@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010
1111pub fn main() !void {
12 const x = widenSlice(&[_]u8{1, 2, 3, 4, 5});
12 const x = widenSlice(&[_]u8{ 1, 2, 3, 4, 5 });
1313 if (x.len == 0) return error.Whatever;
1414 return error.TestFailed;
1515}
test/cases/safety/cast integer to global error and no code matches.zig +1-1
......@@ -12,7 +12,7 @@ pub fn main() !void {
1212 return error.TestFailed;
1313}
1414fn bar(x: u16) anyerror {
15 return @intToError(x);
15 return @errorFromInt(x);
1616}
1717// run
1818// backend=llvm
test/cases/safety/error return trace across suspend points.zig +1-2
......@@ -1,6 +1,5 @@
11const std = @import("std");
22
3
43pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
54 _ = message;
65 _ = stack_trace;
......@@ -36,4 +35,4 @@ fn printTrace(p: anyframe->anyerror!void) void {
3635}
3736// run
3837// backend=stage1
39// target=native
\ No newline at end of file
38// target=native
test/cases/safety/exact division failure - vectors.zig +2-2
......@@ -9,8 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010
1111pub fn main() !void {
12 var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};
13 var b: @Vector(4, i32) = [4]i32{111, 222, 333, 441};
12 var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
13 var b: @Vector(4, i32) = [4]i32{ 111, 222, 333, 441 };
1414 const x = divExact(a, b);
1515 _ = x;
1616 return error.TestFailed;
test/cases/safety/for_len_mismatch_three.zig-1
......@@ -21,4 +21,3 @@ pub fn main() !void {
2121// run
2222// backend=llvm
2323// target=native
24
test/cases/safety/intToPtr with misaligned address.zig deleted-18
......@@ -1,18 +0,0 @@
1const std = @import("std");
2
3pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
4 _ = stack_trace;
5 if (std.mem.eql(u8, message, "incorrect alignment")) {
6 std.process.exit(0);
7 }
8 std.process.exit(1);
9}
10pub fn main() !void {
11 var x: usize = 5;
12 var y = @intToPtr([*]align(4) u8, x);
13 _ = y;
14 return error.TestFailed;
15}
16// run
17// backend=llvm
18// target=native
test/cases/safety/integer division by zero - vectors.zig +2-2
......@@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
88 std.process.exit(1);
99}
1010pub fn main() !void {
11 var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};
12 var b: @Vector(4, i32) = [4]i32{111, 0, 333, 444};
11 var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
12 var b: @Vector(4, i32) = [4]i32{ 111, 0, 333, 444 };
1313 const x = div0(a, b);
1414 _ = x;
1515 return error.TestFailed;
test/cases/safety/pointer casting to null function pointer.zig +1-1
......@@ -13,7 +13,7 @@ fn getNullPtr() ?*const anyopaque {
1313}
1414pub fn main() !void {
1515 const null_ptr: ?*const anyopaque = getNullPtr();
16 const required_ptr: *align(1) const fn() void = @ptrCast(*align(1) const fn() void, null_ptr);
16 const required_ptr: *align(1) const fn () void = @ptrCast(*align(1) const fn () void, null_ptr);
1717 _ = required_ptr;
1818 return error.TestFailed;
1919}
test/cases/safety/slice sentinel mismatch - optional pointers.zig +1-1
......@@ -9,7 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010
1111pub fn main() !void {
12 var buf: [4]?*i32 = .{ @intToPtr(*i32, 4), @intToPtr(*i32, 8), @intToPtr(*i32, 12), @intToPtr(*i32, 16) };
12 var buf: [4]?*i32 = .{ @ptrFromInt(*i32, 4), @ptrFromInt(*i32, 8), @ptrFromInt(*i32, 12), @ptrFromInt(*i32, 16) };
1313 const slice = buf[0..3 :null];
1414 _ = slice;
1515 return error.TestFailed;
test/cases/safety/zero casted to error.zig +1-1
......@@ -12,7 +12,7 @@ pub fn main() !void {
1212 return error.TestFailed;
1313}
1414fn bar(x: u16) anyerror {
15 return @intToError(x);
15 return @errorFromInt(x);
1616}
1717// run
1818// backend=llvm
test/cases/unused_labels.3.zig+3-1
......@@ -1,5 +1,7 @@
11comptime {
2 blk: {blk: {}}
2 blk: {
3 blk: {}
4 }
35}
46
57// error
test/cases/variable_shadowing.3.zig+1-2
......@@ -1,7 +1,6 @@
11pub fn main() void {
22 var i = 0;
3 for ("n", 0..) |_, i| {
4 }
3 for ("n", 0..) |_, i| {}
54}
65
76// error
test/cases/variable_shadowing.4.zig+1-2
......@@ -1,7 +1,6 @@
11pub fn main() void {
22 var i = 0;
3 for ("n") |i| {
4 }
3 for ("n") |i| {}
54}
65
76// error
test/cases/variable_shadowing.5.zig+1-2
......@@ -1,7 +1,6 @@
11pub fn main() void {
22 var i = 0;
3 while ("n") |i| {
4 }
3 while ("n") |i| {}
54}
65
76// error
test/cases/variable_shadowing.6.zig+1-3
......@@ -2,9 +2,7 @@ pub fn main() void {
22 var i = 0;
33 while ("n") |bruh| {
44 _ = bruh;
5 } else |i| {
6
7 }
5 } else |i| {}
86}
97
108// error
test/cases/x86_64-linux/inline_assembly.2.zig+1-1
......@@ -2,7 +2,7 @@ pub fn main() void {
22 var bruh: u32 = 1;
33 asm (""
44 :
5 : [bruh] "{rax}" (4)
5 : [bruh] "{rax}" (4),
66 : "memory"
77 );
88}
test/cases/x86_64-linux/inline_assembly.3.zig+1-1
......@@ -2,7 +2,7 @@ pub fn main() void {}
22comptime {
33 asm (""
44 :
5 : [bruh] "{rax}" (4)
5 : [bruh] "{rax}" (4),
66 : "memory"
77 );
88}
test/cbe.zig+15-15
......@@ -71,22 +71,22 @@ pub fn addCases(ctx: *Cases) !void {
7171 }
7272
7373 {
74 var case = ctx.exeFromCompiledC("intToError", .{});
74 var case = ctx.exeFromCompiledC("errorFromInt", .{});
7575
7676 case.addCompareOutput(
7777 \\pub export fn main() c_int {
7878 \\ // comptime checks
7979 \\ const a = error.A;
8080 \\ const b = error.B;
81 \\ const c = @intToError(2);
82 \\ const d = @intToError(1);
81 \\ const c = @errorFromInt(2);
82 \\ const d = @errorFromInt(1);
8383 \\ if (!(c == b)) unreachable;
8484 \\ if (!(a == d)) unreachable;
8585 \\ // runtime checks
8686 \\ var x = error.A;
8787 \\ var y = error.B;
88 \\ var z = @intToError(2);
89 \\ var f = @intToError(1);
88 \\ var z = @errorFromInt(2);
89 \\ var f = @errorFromInt(1);
9090 \\ if (!(y == z)) unreachable;
9191 \\ if (!(x == f)) unreachable;
9292 \\ return 0;
......@@ -94,13 +94,13 @@ pub fn addCases(ctx: *Cases) !void {
9494 , "");
9595 case.addError(
9696 \\pub export fn main() c_int {
97 \\ _ = @intToError(0);
97 \\ _ = @errorFromInt(0);
9898 \\ return 0;
9999 \\}
100100 , &.{":2:21: error: integer value '0' represents no error"});
101101 case.addError(
102102 \\pub export fn main() c_int {
103 \\ _ = @intToError(3);
103 \\ _ = @errorFromInt(3);
104104 \\ return 0;
105105 \\}
106106 , &.{":2:21: error: integer value '3' represents no error"});
......@@ -635,19 +635,19 @@ pub fn addCases(ctx: *Cases) !void {
635635 ":6:12: note: consider 'union(enum)' here to make it a tagged union",
636636 });
637637
638 // @enumToInt, @intToEnum, enum literal coercion, field access syntax, comparison, switch
638 // @intFromEnum, @enumFromInt, enum literal coercion, field access syntax, comparison, switch
639639 case.addCompareOutput(
640640 \\const Number = enum { One, Two, Three };
641641 \\
642642 \\pub export fn main() c_int {
643643 \\ var number1 = Number.One;
644644 \\ var number2: Number = .Two;
645 \\ const number3 = @intToEnum(Number, 2);
645 \\ const number3 = @enumFromInt(Number, 2);
646646 \\ if (number1 == number2) return 1;
647647 \\ if (number2 == number3) return 1;
648 \\ if (@enumToInt(number1) != 0) return 1;
649 \\ if (@enumToInt(number2) != 1) return 1;
650 \\ if (@enumToInt(number3) != 2) return 1;
648 \\ if (@intFromEnum(number1) != 0) return 1;
649 \\ if (@intFromEnum(number2) != 1) return 1;
650 \\ if (@intFromEnum(number3) != 2) return 1;
651651 \\ var x: Number = .Two;
652652 \\ if (number2 != x) return 1;
653653 \\ switch (x) {
......@@ -728,7 +728,7 @@ pub fn addCases(ctx: *Cases) !void {
728728 case.addError(
729729 \\pub export fn main() c_int {
730730 \\ const a = true;
731 \\ _ = @enumToInt(a);
731 \\ _ = @intFromEnum(a);
732732 \\}
733733 , &.{
734734 ":3:20: error: expected enum or tagged union, found 'bool'",
......@@ -737,7 +737,7 @@ pub fn addCases(ctx: *Cases) !void {
737737 case.addError(
738738 \\pub export fn main() c_int {
739739 \\ const a = 1;
740 \\ _ = @intToEnum(bool, a);
740 \\ _ = @enumFromInt(bool, a);
741741 \\}
742742 , &.{
743743 ":3:20: error: expected enum, found 'bool'",
......@@ -746,7 +746,7 @@ pub fn addCases(ctx: *Cases) !void {
746746 case.addError(
747747 \\const E = enum { a, b, c };
748748 \\pub export fn main() c_int {
749 \\ _ = @intToEnum(E, 3);
749 \\ _ = @enumFromInt(E, 3);
750750 \\}
751751 , &.{
752752 ":3:9: error: enum 'tmp.E' has no tag with value '3'",
test/compare_output.zig+2-2
......@@ -229,8 +229,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
229229 \\ }
230230 \\ const small: f32 = 3.25;
231231 \\ const x: f64 = small;
232 \\ const y = @floatToInt(i32, x);
233 \\ const z = @intToFloat(f64, y);
232 \\ const y = @intFromFloat(i32, x);
233 \\ const z = @floatFromInt(f64, y);
234234 \\ _ = c.printf("%.2f\n%d\n%.2f\n%.2f\n", x, y, z, @as(f64, -0.4));
235235 \\ return 0;
236236 \\}
test/gen_h.zig+1-1
......@@ -137,7 +137,7 @@ pub fn addCases(cases: *tests.GenHContext) void {
137137 \\};
138138 \\
139139 \\export fn a(s: *E) u8 {
140 \\ return @enumToInt(s.*);
140 \\ return @intFromEnum(s.*);
141141 \\}
142142 , &[_][]const u8{
143143 \\enum E;
test/link/common_symbols_alignment/main.zig+2-2
......@@ -4,6 +4,6 @@ extern var foo: i32;
44extern var bar: i32;
55
66test {
7 try std.testing.expect(@ptrToInt(&foo) % 4 == 0);
8 try std.testing.expect(@ptrToInt(&bar) % 4096 == 0);
7 try std.testing.expect(@intFromPtr(&foo) % 4 == 0);
8 try std.testing.expect(@intFromPtr(&bar) % 4096 == 0);
99}
test/standalone/pie/main.zig+1-1
......@@ -5,7 +5,7 @@ threadlocal var foo: u8 = 42;
55
66test "Check ELF header" {
77 // PIE executables are marked as ET_DYN, regular exes as ET_EXEC.
8 const header = @intToPtr(*elf.Ehdr, std.process.getBaseAddress());
8 const header = @ptrFromInt(*elf.Ehdr, std.process.getBaseAddress());
99 try std.testing.expectEqual(elf.ET.DYN, header.e_type);
1010}
1111
test/translate_c.zig+46-46
......@@ -300,7 +300,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
300300 , &[_][]const u8{
301301 \\pub const FOO = (foo + @as(c_int, 2)).*;
302302 ,
303 \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9));
303 \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @intFromBool(@as(c_int, 8) == @as(c_int, 9));
304304 ,
305305 \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) {
306306 \\ return (@import("std").zig.c_translation.cast([*c]u8, p).* | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16));
......@@ -439,8 +439,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
439439 \\#define FOO(x) ((x >= 0) + (x >= 0))
440440 \\#define BAR 1 && 2 > 4
441441 , &[_][]const u8{
442 \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) {
443 \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0));
442 \\pub inline fn FOO(x: anytype) @TypeOf(@intFromBool(x >= @as(c_int, 0)) + @intFromBool(x >= @as(c_int, 0))) {
443 \\ return @intFromBool(x >= @as(c_int, 0)) + @intFromBool(x >= @as(c_int, 0));
444444 \\}
445445 ,
446446 \\pub const BAR = (@as(c_int, 1) != 0) and (@as(c_int, 2) > @as(c_int, 4));
......@@ -905,7 +905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
905905 \\pub extern fn foo() void;
906906 \\pub export fn bar() void {
907907 \\ var func_ptr: ?*anyopaque = @ptrCast(?*anyopaque, &foo);
908 \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @intToPtr(?*const fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr)));
908 \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @ptrFromInt(?*const fn () callconv(.C) void, @intCast(c_ulong, @intFromPtr(func_ptr)));
909909 \\ _ = @TypeOf(typed_func_ptr);
910910 \\}
911911 });
......@@ -1719,10 +1719,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
17191719 \\ var a: c_int = undefined;
17201720 \\ var b: f32 = undefined;
17211721 \\ var c: ?*anyopaque = undefined;
1722 \\ return @boolToInt(!(a == @as(c_int, 0)));
1723 \\ return @boolToInt(!(a != 0));
1724 \\ return @boolToInt(!(b != 0));
1725 \\ return @boolToInt(!(c != null));
1722 \\ return @intFromBool(!(a == @as(c_int, 0)));
1723 \\ return @intFromBool(!(a != 0));
1724 \\ return @intFromBool(!(b != 0));
1725 \\ return @intFromBool(!(c != null));
17261726 \\}
17271727 });
17281728
......@@ -2238,7 +2238,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
22382238 , &[_][]const u8{
22392239 \\pub export var a: f32 = @floatCast(f32, 3.1415);
22402240 \\pub export var b: f64 = 3.1415;
2241 \\pub export var c: c_int = @floatToInt(c_int, 3.1415);
2241 \\pub export var c: c_int = @intFromFloat(c_int, 3.1415);
22422242 \\pub export var d: f64 = 3;
22432243 });
22442244
......@@ -2417,13 +2417,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
24172417 });
24182418
24192419 cases.add("c style cast",
2420 \\int float_to_int(float a) {
2420 \\int int_from_float(float a) {
24212421 \\ return (int)a;
24222422 \\}
24232423 , &[_][]const u8{
2424 \\pub export fn float_to_int(arg_a: f32) c_int {
2424 \\pub export fn int_from_float(arg_a: f32) c_int {
24252425 \\ var a = arg_a;
2426 \\ return @floatToInt(c_int, a);
2426 \\ return @intFromFloat(c_int, a);
24272427 \\}
24282428 });
24292429
......@@ -2534,18 +2534,18 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25342534 \\ var b = arg_b;
25352535 \\ var c = arg_c;
25362536 \\ var d: enum_Foo = @bitCast(c_uint, FooA);
2537 \\ var e: c_int = @boolToInt((a != 0) and (b != 0));
2538 \\ var f: c_int = @boolToInt((b != 0) and (c != null));
2539 \\ var g: c_int = @boolToInt((a != 0) and (c != null));
2540 \\ var h: c_int = @boolToInt((a != 0) or (b != 0));
2541 \\ var i: c_int = @boolToInt((b != 0) or (c != null));
2542 \\ var j: c_int = @boolToInt((a != 0) or (c != null));
2543 \\ var k: c_int = @boolToInt((a != 0) or (@bitCast(c_int, d) != 0));
2544 \\ var l: c_int = @boolToInt((@bitCast(c_int, d) != 0) and (b != 0));
2545 \\ var m: c_int = @boolToInt((c != null) or (d != 0));
2537 \\ var e: c_int = @intFromBool((a != 0) and (b != 0));
2538 \\ var f: c_int = @intFromBool((b != 0) and (c != null));
2539 \\ var g: c_int = @intFromBool((a != 0) and (c != null));
2540 \\ var h: c_int = @intFromBool((a != 0) or (b != 0));
2541 \\ var i: c_int = @intFromBool((b != 0) or (c != null));
2542 \\ var j: c_int = @intFromBool((a != 0) or (c != null));
2543 \\ var k: c_int = @intFromBool((a != 0) or (@bitCast(c_int, d) != 0));
2544 \\ var l: c_int = @intFromBool((@bitCast(c_int, d) != 0) and (b != 0));
2545 \\ var m: c_int = @intFromBool((c != null) or (d != 0));
25462546 \\ var td: SomeTypedef = 44;
2547 \\ var o: c_int = @boolToInt((td != 0) or (b != 0));
2548 \\ var p: c_int = @boolToInt((c != null) and (td != 0));
2547 \\ var o: c_int = @intFromBool((td != 0) or (b != 0));
2548 \\ var p: c_int = @intFromBool((c != null) and (td != 0));
25492549 \\ return (((((((((e + f) + g) + h) + i) + j) + k) + l) + m) + o) + p;
25502550 \\}
25512551 ,
......@@ -2605,13 +2605,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26052605 \\pub export fn test_comparisons(arg_a: c_int, arg_b: c_int) c_int {
26062606 \\ var a = arg_a;
26072607 \\ var b = arg_b;
2608 \\ var c: c_int = @boolToInt(a < b);
2609 \\ var d: c_int = @boolToInt(a > b);
2610 \\ var e: c_int = @boolToInt(a <= b);
2611 \\ var f: c_int = @boolToInt(a >= b);
2612 \\ var g: c_int = @boolToInt(c < d);
2613 \\ var h: c_int = @boolToInt(e < f);
2614 \\ var i: c_int = @boolToInt(g < h);
2608 \\ var c: c_int = @intFromBool(a < b);
2609 \\ var d: c_int = @intFromBool(a > b);
2610 \\ var e: c_int = @intFromBool(a <= b);
2611 \\ var f: c_int = @intFromBool(a >= b);
2612 \\ var g: c_int = @intFromBool(c < d);
2613 \\ var h: c_int = @intFromBool(e < f);
2614 \\ var i: c_int = @intFromBool(g < h);
26152615 \\ return i;
26162616 \\}
26172617 });
......@@ -3258,11 +3258,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
32583258 \\pub extern fn fn_bool(x: bool) void;
32593259 \\pub extern fn fn_ptr(x: ?*anyopaque) void;
32603260 \\pub export fn call() void {
3261 \\ fn_int(@floatToInt(c_int, 3.0));
3262 \\ fn_int(@floatToInt(c_int, 3.0));
3261 \\ fn_int(@intFromFloat(c_int, 3.0));
3262 \\ fn_int(@intFromFloat(c_int, 3.0));
32633263 \\ fn_int(@as(c_int, 1094861636));
3264 \\ fn_f32(@intToFloat(f32, @as(c_int, 3)));
3265 \\ fn_f64(@intToFloat(f64, @as(c_int, 3)));
3264 \\ fn_f32(@floatFromInt(f32, @as(c_int, 3)));
3265 \\ fn_f64(@floatFromInt(f64, @as(c_int, 3)));
32663266 \\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, '3'))));
32673267 \\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, '\x01'))));
32683268 \\ fn_char(@bitCast(u8, @truncate(i8, @as(c_int, 0))));
......@@ -3270,9 +3270,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
32703270 \\ fn_f64(3.0);
32713271 \\ fn_bool(@as(c_int, 123) != 0);
32723272 \\ fn_bool(@as(c_int, 0) != 0);
3273 \\ fn_bool(@ptrToInt(&fn_int) != 0);
3274 \\ fn_int(@intCast(c_int, @ptrToInt(&fn_int)));
3275 \\ fn_ptr(@intToPtr(?*anyopaque, @as(c_int, 42)));
3273 \\ fn_bool(@intFromPtr(&fn_int) != 0);
3274 \\ fn_int(@intCast(c_int, @intFromPtr(&fn_int)));
3275 \\ fn_ptr(@ptrFromInt(?*anyopaque, @as(c_int, 42)));
32763276 \\}
32773277 });
32783278
......@@ -3473,11 +3473,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34733473 \\}
34743474 \\pub export fn bar(arg_a: [*c]const c_int) void {
34753475 \\ var a = arg_a;
3476 \\ foo(@intToPtr([*c]c_int, @ptrToInt(a)));
3476 \\ foo(@ptrFromInt([*c]c_int, @intFromPtr(a)));
34773477 \\}
34783478 \\pub export fn baz(arg_a: [*c]volatile c_int) void {
34793479 \\ var a = arg_a;
3480 \\ foo(@intToPtr([*c]c_int, @ptrToInt(a)));
3480 \\ foo(@ptrFromInt([*c]c_int, @intFromPtr(a)));
34813481 \\}
34823482 });
34833483
......@@ -3491,10 +3491,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
34913491 , &[_][]const u8{
34923492 \\pub export fn foo(arg_x: bool) bool {
34933493 \\ var x = arg_x;
3494 \\ var a: bool = @as(c_int, @boolToInt(x)) != @as(c_int, 1);
3495 \\ var b: bool = @as(c_int, @boolToInt(a)) != @as(c_int, 0);
3496 \\ var c: bool = @ptrToInt(&foo) != 0;
3497 \\ return foo(@as(c_int, @boolToInt(c)) != @as(c_int, @boolToInt(b)));
3494 \\ var a: bool = @as(c_int, @intFromBool(x)) != @as(c_int, 1);
3495 \\ var b: bool = @as(c_int, @intFromBool(a)) != @as(c_int, 0);
3496 \\ var c: bool = @intFromPtr(&foo) != 0;
3497 \\ return foo(@as(c_int, @intFromBool(c)) != @as(c_int, @intFromBool(b)));
34983498 \\}
34993499 });
35003500
......@@ -3910,7 +3910,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
39103910 \\pub export fn foo() void {
39113911 \\ var a: c_int = undefined;
39123912 \\ if ((blk: {
3913 \\ const tmp = @boolToInt(@as(c_int, 1) > @as(c_int, 0));
3913 \\ const tmp = @intFromBool(@as(c_int, 1) > @as(c_int, 0));
39143914 \\ a = tmp;
39153915 \\ break :blk tmp;
39163916 \\ }) != 0) {}
......@@ -3928,7 +3928,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
39283928 \\pub export fn foo() void {
39293929 \\ var a: S = undefined;
39303930 \\ var b: S = undefined;
3931 \\ var c: c_longlong = @divExact(@bitCast(c_longlong, @ptrToInt(a) -% @ptrToInt(b)), @sizeOf(u8));
3931 \\ var c: c_longlong = @divExact(@bitCast(c_longlong, @intFromPtr(a) -% @intFromPtr(b)), @sizeOf(u8));
39323932 \\ _ = @TypeOf(c);
39333933 \\}
39343934 });
......@@ -3943,7 +3943,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
39433943 \\pub export fn foo() void {
39443944 \\ var a: S = undefined;
39453945 \\ var b: S = undefined;
3946 \\ var c: c_long = @divExact(@bitCast(c_long, @ptrToInt(a) -% @ptrToInt(b)), @sizeOf(u8));
3946 \\ var c: c_long = @divExact(@bitCast(c_long, @intFromPtr(a) -% @intFromPtr(b)), @sizeOf(u8));
39473947 \\ _ = @TypeOf(c);
39483948 \\}
39493949 });
tools/gen_outline_atomics.zig+4-4
......@@ -31,7 +31,7 @@ pub fn main() !void {
3131 \\/// It is intentionally not exported in order to make the machine code that
3232 \\/// uses it a statically predicted direct branch rather than using the PLT,
3333 \\/// which ARM is concerned would have too much overhead.
34 \\var __aarch64_have_lse_atomics: u8 = @boolToInt(always_has_lse);
34 \\var __aarch64_have_lse_atomics: u8 = @intFromBool(always_has_lse);
3535 \\
3636 \\
3737 );
......@@ -144,11 +144,11 @@ const N = enum(u8) {
144144 }
145145
146146 fn register(n: N) []const u8 {
147 return if (@enumToInt(n) < 8) "w" else "x";
147 return if (@intFromEnum(n) < 8) "w" else "x";
148148 }
149149
150150 fn toBytes(n: N) u8 {
151 return @enumToInt(n);
151 return @intFromEnum(n);
152152 }
153153
154154 fn toBits(n: N) u8 {
......@@ -212,7 +212,7 @@ fn generateCas(arena: Allocator, n: N, order: Ordering) ![]const u8 {
212212
213213 const reg = n.register();
214214
215 if (@enumToInt(n) < 16) {
215 if (@intFromEnum(n) < 16) {
216216 const cas = try std.fmt.allocPrint(arena, ".inst 0x08a07c41 + {s} + {s}", .{ s_def.b, o_def.m });
217217 const ldxr = try std.fmt.allocPrint(arena, "ld{s}xr{s}", .{ o_def.a, s_def.s });
218218 const stxr = try std.fmt.allocPrint(arena, "st{s}xr{s}", .{ o_def.l, s_def.s });
tools/gen_stubs.zig+1-1
......@@ -444,7 +444,7 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
444444 const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0));
445445 const ty = @truncate(u4, sym.st_info);
446446 const binding = @truncate(u4, sym.st_info >> 4);
447 const visib = @intToEnum(elf.STV, @truncate(u2, sym.st_other));
447 const visib = @enumFromInt(elf.STV, @truncate(u2, sym.st_other));
448448 const size = s(sym.st_size);
449449
450450 if (parse.blacklist.contains(name)) continue;
tools/process_headers.zig+5-5
......@@ -32,7 +32,7 @@ const MultiArch = union(enum) {
3232 specific: Arch,
3333
3434 fn eql(a: MultiArch, b: MultiArch) bool {
35 if (@enumToInt(a) != @enumToInt(b))
35 if (@intFromEnum(a) != @intFromEnum(b))
3636 return false;
3737 if (a != .specific)
3838 return true;
......@@ -45,7 +45,7 @@ const MultiAbi = union(enum) {
4545 specific: Abi,
4646
4747 fn eql(a: MultiAbi, b: MultiAbi) bool {
48 if (@enumToInt(a) != @enumToInt(b))
48 if (@intFromEnum(a) != @intFromEnum(b))
4949 return false;
5050 if (std.meta.Tag(MultiAbi)(a) != .specific)
5151 return true;
......@@ -262,9 +262,9 @@ const DestTarget = struct {
262262 const HashContext = struct {
263263 pub fn hash(self: @This(), a: DestTarget) u32 {
264264 _ = self;
265 return @enumToInt(a.arch) +%
266 (@enumToInt(a.os) *% @as(u32, 4202347608)) +%
267 (@enumToInt(a.abi) *% @as(u32, 4082223418));
265 return @intFromEnum(a.arch) +%
266 (@intFromEnum(a.os) *% @as(u32, 4202347608)) +%
267 (@intFromEnum(a.abi) *% @as(u32, 4082223418));
268268 }
269269
270270 pub fn eql(self: @This(), a: DestTarget, b: DestTarget, b_index: usize) bool {
tools/update-linux-headers.zig+1-1
......@@ -37,7 +37,7 @@ const MultiArch = union(enum) {
3737 specific: Arch,
3838
3939 fn eql(a: MultiArch, b: MultiArch) bool {
40 if (@enumToInt(a) != @enumToInt(b))
40 if (@intFromEnum(a) != @intFromEnum(b))
4141 return false;
4242 if (a != .specific)
4343 return true;
tools/update_clang_options.zig+1-1
......@@ -591,7 +591,7 @@ pub fn main() anyerror!void {
591591
592592 for (all_features, 0..) |feat, i| {
593593 const llvm_name = feat.llvm_name orelse continue;
594 const zig_feat = @intToEnum(Feature, i);
594 const zig_feat = @enumFromInt(Feature, i);
595595 const zig_name = @tagName(zig_feat);
596596 try llvm_to_zig_cpu_features.put(llvm_name, zig_name);
597597 }
tools/update_cpu_features.zig+2-2
......@@ -1247,7 +1247,7 @@ fn processOneTarget(job: Job) anyerror!void {
12471247 for (all_features.items) |feature| {
12481248 if (feature.llvm_name) |llvm_name| {
12491249 try w.print(
1250 \\ result[@enumToInt(Feature.{})] = .{{
1250 \\ result[@intFromEnum(Feature.{})] = .{{
12511251 \\ .llvm_name = "{}",
12521252 \\ .description = "{}",
12531253 \\ .dependencies = featureSet(&[_]Feature{{
......@@ -1260,7 +1260,7 @@ fn processOneTarget(job: Job) anyerror!void {
12601260 );
12611261 } else {
12621262 try w.print(
1263 \\ result[@enumToInt(Feature.{})] = .{{
1263 \\ result[@intFromEnum(Feature.{})] = .{{
12641264 \\ .llvm_name = null,
12651265 \\ .description = "{}",
12661266 \\ .dependencies = featureSet(&[_]Feature{{
tools/update_spirv_features.zig+3-3
......@@ -137,7 +137,7 @@ pub fn main() !void {
137137
138138 for (versions, 0..) |ver, i| {
139139 try w.print(
140 \\ result[@enumToInt(Feature.v{0}_{1})] = .{{
140 \\ result[@intFromEnum(Feature.v{0}_{1})] = .{{
141141 \\ .llvm_name = null,
142142 \\ .description = "SPIR-V version {0}.{1}",
143143 \\
......@@ -163,7 +163,7 @@ pub fn main() !void {
163163 // TODO: Extension dependencies.
164164 for (extensions) |ext| {
165165 try w.print(
166 \\ result[@enumToInt(Feature.{s})] = .{{
166 \\ result[@intFromEnum(Feature.{s})] = .{{
167167 \\ .llvm_name = null,
168168 \\ .description = "SPIR-V extension {s}",
169169 \\ .dependencies = featureSet(&[_]Feature{{}}),
......@@ -178,7 +178,7 @@ pub fn main() !void {
178178 // TODO: Capability extension dependencies.
179179 for (capabilities) |cap| {
180180 try w.print(
181 \\ result[@enumToInt(Feature.{s})] = .{{
181 \\ result[@intFromEnum(Feature.{s})] = .{{
182182 \\ .llvm_name = null,
183183 \\ .description = "Enable SPIR-V capability {s}",
184184 \\ .dependencies = featureSet(&[_]Feature{{