authorgravatar for bratishkaerik@getgoogleoff.meEric Joldasov <bratishkaerik@getgoogleoff.me> 2023-06-14 20:27:03+06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-19 12:34:24-07:00
loga6c8ee5231230947c928bbe1c6a39eb6e1bb9c5b
tree02631a8f2b2b131116cba7e933ccb66f4da11cf9
parente6e8cacab904f10d6e5a773867826570783d0bf4

compiler: rename "@XToY" to "@YFromX", zig fmt: rewrite them

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>

22 files changed, 339 insertions(+), 319 deletions(-)

lib/std/zig/render.zig+20
...@@ -1396,6 +1396,26 @@ fn renderBuiltinCall(...@@ -1396,6 +1396,26 @@ fn renderBuiltinCall(
1396 try ais.writer().writeAll("@max");1396 try ais.writer().writeAll("@max");
1397 } else if (mem.eql(u8, slice, "@minimum")) {1397 } else if (mem.eql(u8, slice, "@minimum")) {
1398 try ais.writer().writeAll("@min");1398 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");
1399 } else {1419 } else {
1400 try renderToken(ais, tree, builtin_token, .none); // @name1420 try renderToken(ais, tree, builtin_token, .none); // @name
1401 }1421 }
src/Air.zig+16-16
...@@ -478,11 +478,11 @@ pub const Inst = struct {...@@ -478,11 +478,11 @@ pub const Inst = struct {
478 /// Converts a pointer to its address. Result type is always `usize`.478 /// Converts a pointer to its address. Result type is always `usize`.
479 /// Pointer type size may be any, including slice.479 /// Pointer type size may be any, including slice.
480 /// Uses the `un_op` field.480 /// Uses the `un_op` field.
481 ptrtoint,481 int_from_ptr,
482 /// Given a boolean, returns 0 or 1.482 /// Given a boolean, returns 0 or 1.
483 /// Result type is always `u1`.483 /// Result type is always `u1`.
484 /// Uses the `un_op` field.484 /// Uses the `un_op` field.
485 bool_to_int,485 int_from_bool,
486 /// Return a value from a function.486 /// Return a value from a function.
487 /// Result type is always noreturn; no instructions in a block follow this one.487 /// Result type is always noreturn; no instructions in a block follow this one.
488 /// Uses the `un_op` field.488 /// Uses the `un_op` field.
...@@ -629,12 +629,12 @@ pub const Inst = struct {...@@ -629,12 +629,12 @@ pub const Inst = struct {
629 array_to_slice,629 array_to_slice,
630 /// Given a float operand, return the integer with the closest mathematical meaning.630 /// Given a float operand, return the integer with the closest mathematical meaning.
631 /// Uses the `ty_op` field.631 /// Uses the `ty_op` field.
632 float_to_int,632 int_from_float,
633 /// Same as `float_to_int` with optimized float mode.633 /// Same as `int_from_float` with optimized float mode.
634 float_to_int_optimized,634 int_from_float_optimized,
635 /// Given an integer operand, return the float with the closest mathematical meaning.635 /// Given an integer operand, return the float with the closest mathematical meaning.
636 /// Uses the `ty_op` field.636 /// Uses the `ty_op` field.
637 int_to_float,637 float_from_int,
638638
639 /// Transforms a vector into a scalar value by performing a sequential639 /// Transforms a vector into a scalar value by performing a sequential
640 /// horizontal reduction of its elements using the specified operator.640 /// horizontal reduction of its elements using the specified operator.
...@@ -1337,9 +1337,9 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {...@@ -1337,9 +1337,9 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
1337 .struct_field_ptr_index_2,1337 .struct_field_ptr_index_2,
1338 .struct_field_ptr_index_3,1338 .struct_field_ptr_index_3,
1339 .array_to_slice,1339 .array_to_slice,
1340 .float_to_int,1340 .int_from_float,
1341 .float_to_int_optimized,1341 .int_from_float_optimized,
1342 .int_to_float,1342 .float_from_int,
1343 .splat,1343 .splat,
1344 .get_union_tag,1344 .get_union_tag,
1345 .clz,1345 .clz,
...@@ -1387,7 +1387,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {...@@ -1387,7 +1387,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
1387 .c_va_end,1387 .c_va_end,
1388 => return Type.void,1388 => return Type.void,
13891389
1390 .ptrtoint,1390 .int_from_ptr,
1391 .slice_len,1391 .slice_len,
1392 .ret_addr,1392 .ret_addr,
1393 .frame_addr,1393 .frame_addr,
...@@ -1397,7 +1397,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {...@@ -1397,7 +1397,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
1397 .wasm_memory_grow => return Type.i32,1397 .wasm_memory_grow => return Type.i32,
1398 .wasm_memory_size => return Type.u32,1398 .wasm_memory_size => return Type.u32,
13991399
1400 .bool_to_int => return Type.u1,1400 .int_from_bool => return Type.u1,
14011401
1402 .tag_name, .error_name => return Type.slice_const_u8_sentinel_0,1402 .tag_name, .error_name => return Type.slice_const_u8_sentinel_0,
14031403
...@@ -1687,8 +1687,8 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -1687,8 +1687,8 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1687 .is_non_err_ptr,1687 .is_non_err_ptr,
1688 .bool_and,1688 .bool_and,
1689 .bool_or,1689 .bool_or,
1690 .ptrtoint,1690 .int_from_ptr,
1691 .bool_to_int,1691 .int_from_bool,
1692 .fptrunc,1692 .fptrunc,
1693 .fpext,1693 .fpext,
1694 .intcast,1694 .intcast,
...@@ -1718,9 +1718,9 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -1718,9 +1718,9 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1718 .slice_elem_ptr,1718 .slice_elem_ptr,
1719 .ptr_elem_ptr,1719 .ptr_elem_ptr,
1720 .array_to_slice,1720 .array_to_slice,
1721 .float_to_int,1721 .int_from_float,
1722 .float_to_int_optimized,1722 .int_from_float_optimized,
1723 .int_to_float,1723 .float_from_int,
1724 .reduce,1724 .reduce,
1725 .reduce_optimized,1725 .reduce_optimized,
1726 .splat,1726 .splat,
src/AstGen.zig+19-19
...@@ -2626,15 +2626,15 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As...@@ -2626,15 +2626,15 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
2626 .error_set_decl,2626 .error_set_decl,
2627 .error_set_decl_anon,2627 .error_set_decl_anon,
2628 .error_set_decl_func,2628 .error_set_decl_func,
2629 .int_to_enum,2629 .enum_from_int,
2630 .enum_to_int,2630 .int_from_enum,
2631 .type_info,2631 .type_info,
2632 .size_of,2632 .size_of,
2633 .bit_size_of,2633 .bit_size_of,
2634 .typeof_log2_int_type,2634 .typeof_log2_int_type,
2635 .ptr_to_int,2635 .int_from_ptr,
2636 .align_of,2636 .align_of,
2637 .bool_to_int,2637 .int_from_bool,
2638 .embed_file,2638 .embed_file,
2639 .error_name,2639 .error_name,
2640 .sqrt,2640 .sqrt,
...@@ -2655,9 +2655,9 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As...@@ -2655,9 +2655,9 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
2655 .type_name,2655 .type_name,
2656 .frame_type,2656 .frame_type,
2657 .frame_size,2657 .frame_size,
2658 .float_to_int,2658 .int_from_float,
2659 .int_to_float,2659 .float_from_int,
2660 .int_to_ptr,2660 .ptr_from_int,
2661 .float_cast,2661 .float_cast,
2662 .int_cast,2662 .int_cast,
2663 .ptr_cast,2663 .ptr_cast,
...@@ -8281,11 +8281,11 @@ fn builtinCall(...@@ -8281,11 +8281,11 @@ fn builtinCall(
8281 .bit_size_of => return simpleUnOpType(gz, scope, ri, node, params[0], .bit_size_of),8281 .bit_size_of => return simpleUnOpType(gz, scope, ri, node, params[0], .bit_size_of),
8282 .align_of => return simpleUnOpType(gz, scope, ri, node, params[0], .align_of),8282 .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),
8285 .compile_error => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .slice_const_u8_type } }, params[0], .compile_error),8285 .compile_error => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .slice_const_u8_type } }, params[0], .compile_error),
8286 .set_eval_branch_quota => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0], .set_eval_branch_quota),8286 .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),8287 .int_from_enum => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .int_from_enum),
8288 .bool_to_int => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .bool_to_int),8288 .int_from_bool => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .int_from_bool),
8289 .embed_file => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .slice_const_u8_type } }, params[0], .embed_file),8289 .embed_file => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .slice_const_u8_type } }, params[0], .embed_file),
8290 .error_name => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .anyerror_type } }, params[0], .error_name),8290 .error_name => return simpleUnOp(gz, scope, ri, node, .{ .rl = .{ .ty = .anyerror_type } }, params[0], .error_name),
8291 .set_runtime_safety => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .set_runtime_safety),8291 .set_runtime_safety => return simpleUnOp(gz, scope, ri, node, bool_ri, params[0], .set_runtime_safety),
...@@ -8308,10 +8308,10 @@ fn builtinCall(...@@ -8308,10 +8308,10 @@ fn builtinCall(
8308 .Frame => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .frame_type),8308 .Frame => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .frame_type),
8309 .frame_size => return simpleUnOp(gz, scope, ri, node, .{ .rl = .none }, params[0], .frame_size),8309 .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),8311 .int_from_float => return typeCast(gz, scope, ri, node, params[0], params[1], .int_from_float),
8312 .int_to_float => return typeCast(gz, scope, ri, node, params[0], params[1], .int_to_float),8312 .float_from_int => return typeCast(gz, scope, ri, node, params[0], params[1], .float_from_int),
8313 .int_to_ptr => return typeCast(gz, scope, ri, node, params[0], params[1], .int_to_ptr),8313 .ptr_from_int => return typeCast(gz, scope, ri, node, params[0], params[1], .ptr_from_int),
8314 .int_to_enum => return typeCast(gz, scope, ri, node, params[0], params[1], .int_to_enum),8314 .enum_from_int => return typeCast(gz, scope, ri, node, params[0], params[1], .enum_from_int),
8315 .float_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .float_cast),8315 .float_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .float_cast),
8316 .int_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .int_cast),8316 .int_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .int_cast),
8317 .ptr_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .ptr_cast),8317 .ptr_cast => return typeCast(gz, scope, ri, node, params[0], params[1], .ptr_cast),
...@@ -8352,17 +8352,17 @@ fn builtinCall(...@@ -8352,17 +8352,17 @@ fn builtinCall(
8352 _ = try gz.addNode(.trap, node);8352 _ = try gz.addNode(.trap, node);
8353 return rvalue(gz, ri, .unreachable_value, node);8353 return rvalue(gz, ri, .unreachable_value, node);
8354 },8354 },
8355 .error_to_int => {8355 .int_from_error => {
8356 const operand = try expr(gz, scope, .{ .rl = .none }, params[0]);8356 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{
8358 .node = gz.nodeIndexToRelative(node),8358 .node = gz.nodeIndexToRelative(node),
8359 .operand = operand,8359 .operand = operand,
8360 });8360 });
8361 return rvalue(gz, ri, result, node);8361 return rvalue(gz, ri, result, node);
8362 },8362 },
8363 .int_to_error => {8363 .error_from_int => {
8364 const operand = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .u16_type } }, params[0]);8364 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{
8366 .node = gz.nodeIndexToRelative(node),8366 .node = gz.nodeIndexToRelative(node),
8367 .operand = operand,8367 .operand = operand,
8368 });8368 });
...@@ -8769,7 +8769,7 @@ fn simpleUnOp(...@@ -8769,7 +8769,7 @@ fn simpleUnOp(
8769 else8769 else
8770 try expr(gz, scope, operand_ri, operand_node);8770 try expr(gz, scope, operand_ri, operand_node);
8771 switch (tag) {8771 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),
8773 else => {},8773 else => {},
8774 }8774 }
8775 const result = try gz.addUnNode(tag, operand, node);8775 const result = try gz.addUnNode(tag, operand, node);
src/Autodoc.zig+9-9
...@@ -1473,7 +1473,7 @@ fn walkInstruction(...@@ -1473,7 +1473,7 @@ fn walkInstruction(
14731473
1474 // builtin functions1474 // builtin functions
1475 .align_of,1475 .align_of,
1476 .bool_to_int,1476 .int_from_bool,
1477 .embed_file,1477 .embed_file,
1478 .error_name,1478 .error_name,
1479 .panic,1479 .panic,
...@@ -1496,7 +1496,7 @@ fn walkInstruction(...@@ -1496,7 +1496,7 @@ fn walkInstruction(
1496 .type_name,1496 .type_name,
1497 .frame_type,1497 .frame_type,
1498 .frame_size,1498 .frame_size,
1499 .ptr_to_int,1499 .int_from_ptr,
1500 .bit_not,1500 .bit_not,
1501 // @check1501 // @check
1502 .clz,1502 .clz,
...@@ -1521,10 +1521,10 @@ fn walkInstruction(...@@ -1521,10 +1521,10 @@ fn walkInstruction(
1521 };1521 };
1522 },1522 },
15231523
1524 .float_to_int,1524 .int_from_float,
1525 .int_to_float,1525 .float_from_int,
1526 .int_to_ptr,1526 .ptr_from_int,
1527 .int_to_enum,1527 .enum_from_int,
1528 .float_cast,1528 .float_cast,
1529 .int_cast,1529 .int_cast,
1530 .ptr_cast,1530 .ptr_cast,
...@@ -1936,7 +1936,7 @@ fn walkInstruction(...@@ -1936,7 +1936,7 @@ fn walkInstruction(
1936 .expr = .{ .bitSizeOf = operand_index },1936 .expr = .{ .bitSizeOf = operand_index },
1937 };1937 };
1938 },1938 },
1939 .enum_to_int => {1939 .int_from_enum => {
1940 // not working correctly with `align()`1940 // not working correctly with `align()`
1941 const un_node = data[inst_index].un_node;1941 const un_node = data[inst_index].un_node;
1942 const operand = try self.walkRef(1942 const operand = try self.walkRef(
...@@ -3021,8 +3021,8 @@ fn walkInstruction(...@@ -3021,8 +3021,8 @@ fn walkInstruction(
3021 },3021 },
3022 };3022 };
3023 },3023 },
3024 .error_to_int,3024 .int_from_error,
3025 .int_to_error,3025 .error_from_int,
3026 .reify,3026 .reify,
3027 .const_cast,3027 .const_cast,
3028 .volatile_cast,3028 .volatile_cast,
src/BuiltinFn.zig+27-27
...@@ -12,7 +12,7 @@ pub const Tag = enum {...@@ -12,7 +12,7 @@ pub const Tag = enum {
12 atomic_store,12 atomic_store,
13 bit_cast,13 bit_cast,
14 bit_offset_of,14 bit_offset_of,
15 bool_to_int,15 int_from_bool,
16 bit_size_of,16 bit_size_of,
17 breakpoint,17 breakpoint,
18 mul_add,18 mul_add,
...@@ -39,10 +39,10 @@ pub const Tag = enum {...@@ -39,10 +39,10 @@ pub const Tag = enum {
39 div_floor,39 div_floor,
40 div_trunc,40 div_trunc,
41 embed_file,41 embed_file,
42 enum_to_int,42 int_from_enum,
43 error_name,43 error_name,
44 error_return_trace,44 error_return_trace,
45 error_to_int,45 int_from_error,
46 err_set_cast,46 err_set_cast,
47 @"export",47 @"export",
48 @"extern",48 @"extern",
...@@ -50,7 +50,7 @@ pub const Tag = enum {...@@ -50,7 +50,7 @@ pub const Tag = enum {
50 field,50 field,
51 field_parent_ptr,51 field_parent_ptr,
52 float_cast,52 float_cast,
53 float_to_int,53 int_from_float,
54 frame,54 frame,
55 Frame,55 Frame,
56 frame_address,56 frame_address,
...@@ -60,10 +60,10 @@ pub const Tag = enum {...@@ -60,10 +60,10 @@ pub const Tag = enum {
60 import,60 import,
61 in_comptime,61 in_comptime,
62 int_cast,62 int_cast,
63 int_to_enum,63 enum_from_int,
64 int_to_error,64 error_from_int,
65 int_to_float,65 float_from_int,
66 int_to_ptr,66 ptr_from_int,
67 max,67 max,
68 memcpy,68 memcpy,
69 memset,69 memset,
...@@ -76,7 +76,7 @@ pub const Tag = enum {...@@ -76,7 +76,7 @@ pub const Tag = enum {
76 pop_count,76 pop_count,
77 prefetch,77 prefetch,
78 ptr_cast,78 ptr_cast,
79 ptr_to_int,79 int_from_ptr,
80 rem,80 rem,
81 return_address,81 return_address,
82 select,82 select,
...@@ -238,9 +238,9 @@ pub const list = list: {...@@ -238,9 +238,9 @@ pub const list = list: {
238 },238 },
239 },239 },
240 .{240 .{
241 "@boolToInt",241 "@intFromBool",
242 .{242 .{
243 .tag = .bool_to_int,243 .tag = .int_from_bool,
244 .param_count = 1,244 .param_count = 1,
245 },245 },
246 },246 },
...@@ -425,9 +425,9 @@ pub const list = list: {...@@ -425,9 +425,9 @@ pub const list = list: {
425 },425 },
426 },426 },
427 .{427 .{
428 "@enumToInt",428 "@intFromEnum",
429 .{429 .{
430 .tag = .enum_to_int,430 .tag = .int_from_enum,
431 .param_count = 1,431 .param_count = 1,
432 },432 },
433 },433 },
...@@ -446,9 +446,9 @@ pub const list = list: {...@@ -446,9 +446,9 @@ pub const list = list: {
446 },446 },
447 },447 },
448 .{448 .{
449 "@errorToInt",449 "@intFromError",
450 .{450 .{
451 .tag = .error_to_int,451 .tag = .int_from_error,
452 .param_count = 1,452 .param_count = 1,
453 },453 },
454 },454 },
...@@ -506,9 +506,9 @@ pub const list = list: {...@@ -506,9 +506,9 @@ pub const list = list: {
506 },506 },
507 },507 },
508 .{508 .{
509 "@floatToInt",509 "@intFromFloat",
510 .{510 .{
511 .tag = .float_to_int,511 .tag = .int_from_float,
512 .param_count = 2,512 .param_count = 2,
513 },513 },
514 },514 },
...@@ -576,31 +576,31 @@ pub const list = list: {...@@ -576,31 +576,31 @@ pub const list = list: {
576 },576 },
577 },577 },
578 .{578 .{
579 "@intToEnum",579 "@enumFromInt",
580 .{580 .{
581 .tag = .int_to_enum,581 .tag = .enum_from_int,
582 .param_count = 2,582 .param_count = 2,
583 },583 },
584 },584 },
585 .{585 .{
586 "@intToError",586 "@errorFromInt",
587 .{587 .{
588 .tag = .int_to_error,588 .tag = .error_from_int,
589 .eval_to_error = .always,589 .eval_to_error = .always,
590 .param_count = 1,590 .param_count = 1,
591 },591 },
592 },592 },
593 .{593 .{
594 "@intToFloat",594 "@floatFromInt",
595 .{595 .{
596 .tag = .int_to_float,596 .tag = .float_from_int,
597 .param_count = 2,597 .param_count = 2,
598 },598 },
599 },599 },
600 .{600 .{
601 "@intToPtr",601 "@ptrFromInt",
602 .{602 .{
603 .tag = .int_to_ptr,603 .tag = .ptr_from_int,
604 .param_count = 2,604 .param_count = 2,
605 },605 },
606 },606 },
...@@ -689,9 +689,9 @@ pub const list = list: {...@@ -689,9 +689,9 @@ pub const list = list: {
689 },689 },
690 },690 },
691 .{691 .{
692 "@ptrToInt",692 "@intFromPtr",
693 .{693 .{
694 .tag = .ptr_to_int,694 .tag = .int_from_ptr,
695 .param_count = 1,695 .param_count = 1,
696 },696 },
697 },697 },
src/Liveness.zig+10-10
...@@ -371,9 +371,9 @@ pub fn categorizeOperand(...@@ -371,9 +371,9 @@ pub fn categorizeOperand(
371 .struct_field_ptr_index_2,371 .struct_field_ptr_index_2,
372 .struct_field_ptr_index_3,372 .struct_field_ptr_index_3,
373 .array_to_slice,373 .array_to_slice,
374 .float_to_int,374 .int_from_float,
375 .float_to_int_optimized,375 .int_from_float_optimized,
376 .int_to_float,376 .float_from_int,
377 .get_union_tag,377 .get_union_tag,
378 .clz,378 .clz,
379 .ctz,379 .ctz,
...@@ -407,8 +407,8 @@ pub fn categorizeOperand(...@@ -407,8 +407,8 @@ pub fn categorizeOperand(
407 .is_non_err,407 .is_non_err,
408 .is_err_ptr,408 .is_err_ptr,
409 .is_non_err_ptr,409 .is_non_err_ptr,
410 .ptrtoint,410 .int_from_ptr,
411 .bool_to_int,411 .int_from_bool,
412 .is_named_enum_value,412 .is_named_enum_value,
413 .tag_name,413 .tag_name,
414 .error_name,414 .error_name,
...@@ -1007,9 +1007,9 @@ fn analyzeInst(...@@ -1007,9 +1007,9 @@ fn analyzeInst(
1007 .struct_field_ptr_index_2,1007 .struct_field_ptr_index_2,
1008 .struct_field_ptr_index_3,1008 .struct_field_ptr_index_3,
1009 .array_to_slice,1009 .array_to_slice,
1010 .float_to_int,1010 .int_from_float,
1011 .float_to_int_optimized,1011 .int_from_float_optimized,
1012 .int_to_float,1012 .float_from_int,
1013 .get_union_tag,1013 .get_union_tag,
1014 .clz,1014 .clz,
1015 .ctz,1015 .ctz,
...@@ -1034,8 +1034,8 @@ fn analyzeInst(...@@ -1034,8 +1034,8 @@ fn analyzeInst(
1034 .is_non_err,1034 .is_non_err,
1035 .is_err_ptr,1035 .is_err_ptr,
1036 .is_non_err_ptr,1036 .is_non_err_ptr,
1037 .ptrtoint,1037 .int_from_ptr,
1038 .bool_to_int,1038 .int_from_bool,
1039 .is_named_enum_value,1039 .is_named_enum_value,
1040 .tag_name,1040 .tag_name,
1041 .error_name,1041 .error_name,
src/Liveness/Verify.zig+5-5
...@@ -97,9 +97,9 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -97,9 +97,9 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
97 .struct_field_ptr_index_2,97 .struct_field_ptr_index_2,
98 .struct_field_ptr_index_3,98 .struct_field_ptr_index_3,
99 .array_to_slice,99 .array_to_slice,
100 .float_to_int,100 .int_from_float,
101 .float_to_int_optimized,101 .int_from_float_optimized,
102 .int_to_float,102 .float_from_int,
103 .get_union_tag,103 .get_union_tag,
104 .clz,104 .clz,
105 .ctz,105 .ctz,
...@@ -123,8 +123,8 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -123,8 +123,8 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
123 .is_non_err,123 .is_non_err,
124 .is_err_ptr,124 .is_err_ptr,
125 .is_non_err_ptr,125 .is_non_err_ptr,
126 .ptrtoint,126 .int_from_ptr,
127 .bool_to_int,127 .int_from_bool,
128 .is_named_enum_value,128 .is_named_enum_value,
129 .tag_name,129 .tag_name,
130 .error_name,130 .error_name,
src/Sema.zig+26-26
...@@ -961,8 +961,8 @@ fn analyzeBodyInner(...@@ -961,8 +961,8 @@ fn analyzeBodyInner(
961 .elem_val_node => try sema.zirElemValNode(block, inst),961 .elem_val_node => try sema.zirElemValNode(block, inst),
962 .elem_type_index => try sema.zirElemTypeIndex(block, inst),962 .elem_type_index => try sema.zirElemTypeIndex(block, inst),
963 .enum_literal => try sema.zirEnumLiteral(block, inst),963 .enum_literal => try sema.zirEnumLiteral(block, inst),
964 .enum_to_int => try sema.zirEnumToInt(block, inst),964 .int_from_enum => try sema.zirIntFromEnum(block, inst),
965 .int_to_enum => try sema.zirIntToEnum(block, inst),965 .enum_from_int => try sema.zirEnumFromInt(block, inst),
966 .err_union_code => try sema.zirErrUnionCode(block, inst),966 .err_union_code => try sema.zirErrUnionCode(block, inst),
967 .err_union_code_ptr => try sema.zirErrUnionCodePtr(block, inst),967 .err_union_code_ptr => try sema.zirErrUnionCodePtr(block, inst),
968 .err_union_payload_unsafe => try sema.zirErrUnionPayload(block, inst),968 .err_union_payload_unsafe => try sema.zirErrUnionPayload(block, inst),
...@@ -1028,18 +1028,18 @@ fn analyzeBodyInner(...@@ -1028,18 +1028,18 @@ fn analyzeBodyInner(
1028 .union_init => try sema.zirUnionInit(block, inst),1028 .union_init => try sema.zirUnionInit(block, inst),
1029 .field_type => try sema.zirFieldType(block, inst),1029 .field_type => try sema.zirFieldType(block, inst),
1030 .field_type_ref => try sema.zirFieldTypeRef(block, inst),1030 .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),
1032 .align_of => try sema.zirAlignOf(block, inst),1032 .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),
1034 .embed_file => try sema.zirEmbedFile(block, inst),1034 .embed_file => try sema.zirEmbedFile(block, inst),
1035 .error_name => try sema.zirErrorName(block, inst),1035 .error_name => try sema.zirErrorName(block, inst),
1036 .tag_name => try sema.zirTagName(block, inst),1036 .tag_name => try sema.zirTagName(block, inst),
1037 .type_name => try sema.zirTypeName(block, inst),1037 .type_name => try sema.zirTypeName(block, inst),
1038 .frame_type => try sema.zirFrameType(block, inst),1038 .frame_type => try sema.zirFrameType(block, inst),
1039 .frame_size => try sema.zirFrameSize(block, inst),1039 .frame_size => try sema.zirFrameSize(block, inst),
1040 .float_to_int => try sema.zirFloatToInt(block, inst),1040 .int_from_float => try sema.zirIntFromFloat(block, inst),
1041 .int_to_float => try sema.zirIntToFloat(block, inst),1041 .float_from_int => try sema.zirFloatFromInt(block, inst),
1042 .int_to_ptr => try sema.zirIntToPtr(block, inst),1042 .ptr_from_int => try sema.zirPtrFromInt(block, inst),
1043 .float_cast => try sema.zirFloatCast(block, inst),1043 .float_cast => try sema.zirFloatCast(block, inst),
1044 .int_cast => try sema.zirIntCast(block, inst),1044 .int_cast => try sema.zirIntCast(block, inst),
1045 .ptr_cast => try sema.zirPtrCast(block, inst),1045 .ptr_cast => try sema.zirPtrCast(block, inst),
...@@ -1167,8 +1167,8 @@ fn analyzeBodyInner(...@@ -1167,8 +1167,8 @@ fn analyzeBodyInner(
1167 .err_set_cast => try sema.zirErrSetCast( block, extended),1167 .err_set_cast => try sema.zirErrSetCast( block, extended),
1168 .await_nosuspend => try sema.zirAwaitNosuspend( block, extended),1168 .await_nosuspend => try sema.zirAwaitNosuspend( block, extended),
1169 .select => try sema.zirSelect( block, extended),1169 .select => try sema.zirSelect( block, extended),
1170 .error_to_int => try sema.zirErrorToInt( block, extended),1170 .int_from_error => try sema.zirIntFromError( block, extended),
1171 .int_to_error => try sema.zirIntToError( block, extended),1171 .error_from_int => try sema.zirErrorFromInt( block, extended),
1172 .reify => try sema.zirReify( block, extended, inst),1172 .reify => try sema.zirReify( block, extended, inst),
1173 .builtin_async_call => try sema.zirBuiltinAsyncCall( block, extended),1173 .builtin_async_call => try sema.zirBuiltinAsyncCall( block, extended),
1174 .cmpxchg => try sema.zirCmpxchg( block, extended),1174 .cmpxchg => try sema.zirCmpxchg( block, extended),
...@@ -8116,7 +8116,7 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -8116,7 +8116,7 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
8116 } })).toValue());8116 } })).toValue());
8117}8117}
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 {
8120 const tracy = trace(@src());8120 const tracy = trace(@src());
8121 defer tracy.end();8121 defer tracy.end();
81228122
...@@ -8156,7 +8156,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat...@@ -8156,7 +8156,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
8156 return block.addBitCast(Type.err_int, operand);8156 return block.addBitCast(Type.err_int, operand);
8157}8157}
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 {
8160 const tracy = trace(@src());8160 const tracy = trace(@src());
8161 defer tracy.end();8161 defer tracy.end();
81628162
...@@ -8258,7 +8258,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8258,7 +8258,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8258 })).toValue());8258 })).toValue());
8259}8259}
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 {
8262 const mod = sema.mod;8262 const mod = sema.mod;
8263 const inst_data = sema.code.instructions.items(.data)[inst].un_node;8263 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
8264 const src = inst_data.src();8264 const src = inst_data.src();
...@@ -8303,7 +8303,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -8303,7 +8303,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
8303 return block.addBitCast(int_tag_ty, enum_tag);8303 return block.addBitCast(int_tag_ty, enum_tag);
8304}8304}
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 {
8307 const mod = sema.mod;8307 const mod = sema.mod;
8308 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;8308 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
8309 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;8309 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
...@@ -9518,7 +9518,7 @@ fn analyzeAs(...@@ -9518,7 +9518,7 @@ fn analyzeAs(
9518 };9518 };
9519}9519}
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 {
9522 const tracy = trace(@src());9522 const tracy = trace(@src());
9523 defer tracy.end();9523 defer tracy.end();
95249524
...@@ -9537,7 +9537,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -9537,7 +9537,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
9537 );9537 );
9538 }9538 }
9539 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);9539 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);
9540 return block.addUnOp(.ptrtoint, ptr);9540 return block.addUnOp(.int_from_ptr, ptr);
9541}9541}
95429542
9543fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {9543fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
...@@ -19426,7 +19426,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -19426,7 +19426,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
19426 return sema.addConstant(Type.comptime_int, val);19426 return sema.addConstant(Type.comptime_int, val);
19427}19427}
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 {
19430 const mod = sema.mod;19430 const mod = sema.mod;
19431 const inst_data = sema.code.instructions.items(.data)[inst].un_node;19431 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
19432 const operand = try sema.resolveInst(inst_data.operand);19432 const operand = try sema.resolveInst(inst_data.operand);
...@@ -19435,7 +19435,7 @@ fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -19435,7 +19435,7 @@ fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
19435 if (val.toBool()) return sema.addConstant(Type.u1, try mod.intValue(Type.u1, 1));19435 if (val.toBool()) return sema.addConstant(Type.u1, try mod.intValue(Type.u1, 1));
19436 return sema.addConstant(Type.u1, try mod.intValue(Type.u1, 0));19436 return sema.addConstant(Type.u1, try mod.intValue(Type.u1, 0));
19437 }19437 }
19438 return block.addUnOp(.bool_to_int, operand);19438 return block.addUnOp(.int_from_bool, operand);
19439}19439}
1944019440
19441fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {19441fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
...@@ -20748,7 +20748,7 @@ fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20748,7 +20748,7 @@ fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20748 return sema.failWithUseOfAsync(block, src);20748 return sema.failWithUseOfAsync(block, src);
20749}20749}
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 {
20752 const mod = sema.mod;20752 const mod = sema.mod;
20753 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;20753 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
20754 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;20754 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
...@@ -20776,9 +20776,9 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -20776,9 +20776,9 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
20776 }20776 }
20777 return sema.addConstant(dest_ty, try mod.intValue(dest_ty, 0));20777 return sema.addConstant(dest_ty, try mod.intValue(dest_ty, 0));
20778 }20778 }
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);
20780 if (block.wantSafety()) {20780 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);
20782 const diff = try block.addBinOp(.sub, operand, back);20782 const diff = try block.addBinOp(.sub, operand, back);
20783 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)));20783 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)));
20784 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)));20784 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!...@@ -20788,7 +20788,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
20788 return result;20788 return result;
20789}20789}
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 {
20792 const mod = sema.mod;20792 const mod = sema.mod;
20793 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;20793 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
20794 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;20794 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
...@@ -20809,10 +20809,10 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -20809,10 +20809,10 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
20809 }20809 }
2081020810
20811 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);20811 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);
20813}20813}
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 {
20816 const mod = sema.mod;20816 const mod = sema.mod;
20817 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;20817 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
20818 const src = inst_data.src();20818 const src = inst_data.src();
...@@ -21084,7 +21084,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -21084,7 +21084,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
21084 if (block.wantSafety() and operand_ty.ptrAllowsZero(mod) and !dest_ty.ptrAllowsZero(mod) and21084 if (block.wantSafety() and operand_ty.ptrAllowsZero(mod) and !dest_ty.ptrAllowsZero(mod) and
21085 (try sema.typeHasRuntimeBits(dest_ty.elemType2(mod)) or dest_ty.elemType2(mod).zigTypeTag(mod) == .Fn))21085 (try sema.typeHasRuntimeBits(dest_ty.elemType2(mod)) or dest_ty.elemType2(mod).zigTypeTag(mod) == .Fn))
21086 {21086 {
21087 const ptr_int = try block.addUnOp(.ptrtoint, ptr);21087 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
21088 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);21088 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
21089 const ok = if (operand_is_slice) ok: {21089 const ok = if (operand_is_slice) ok: {
21090 const len = try sema.analyzeSliceLen(block, operand_src, operand);21090 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...@@ -21265,7 +21265,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
21265 try sema.analyzeSlicePtr(block, ptr_src, ptr, ptr_ty)21265 try sema.analyzeSlicePtr(block, ptr_src, ptr, ptr_ty)
21266 else21266 else
21267 ptr;21267 ptr;
21268 const ptr_int = try block.addUnOp(.ptrtoint, actual_ptr);21268 const ptr_int = try block.addUnOp(.int_from_ptr, actual_ptr);
21269 const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);21269 const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);
21270 const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize);21270 const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize);
21271 const ok = if (ptr_ty.isSlice(mod)) ok: {21271 const ok = if (ptr_ty.isSlice(mod)) ok: {
...@@ -29504,7 +29504,7 @@ fn coerceCompatiblePtrs(...@@ -29504,7 +29504,7 @@ fn coerceCompatiblePtrs(
29504 try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty)29504 try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty)
29505 else29505 else
29506 inst;29506 inst;
29507 const ptr_int = try block.addUnOp(.ptrtoint, actual_ptr);29507 const ptr_int = try block.addUnOp(.int_from_ptr, actual_ptr);
29508 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);29508 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
29509 const ok = if (inst_ty.isSlice(mod)) ok: {29509 const ok = if (inst_ty.isSlice(mod)) ok: {
29510 const len = try sema.analyzeSliceLen(block, inst_src, inst);29510 const len = try sema.analyzeSliceLen(block, inst_src, inst);
src/Zir.zig+35-35
...@@ -749,9 +749,9 @@ pub const Inst = struct {...@@ -749,9 +749,9 @@ pub const Inst = struct {
749 /// Implements the `@bitSizeOf` builtin. Uses `un_node`.749 /// Implements the `@bitSizeOf` builtin. Uses `un_node`.
750 bit_size_of,750 bit_size_of,
751751
752 /// Implement builtin `@ptrToInt`. Uses `un_node`.752 /// Implement builtin `@intFromPtr`. Uses `un_node`.
753 /// Convert a pointer to a `usize` integer.753 /// Convert a pointer to a `usize` integer.
754 ptr_to_int,754 int_from_ptr,
755 /// Emit an error message and fail compilation.755 /// Emit an error message and fail compilation.
756 /// Uses the `un_node` field.756 /// Uses the `un_node` field.
757 compile_error,757 compile_error,
...@@ -761,11 +761,11 @@ pub const Inst = struct {...@@ -761,11 +761,11 @@ pub const Inst = struct {
761 set_eval_branch_quota,761 set_eval_branch_quota,
762 /// Converts an enum value into an integer. Resulting type will be the tag type762 /// Converts an enum value into an integer. Resulting type will be the tag type
763 /// of the enum. Uses `un_node`.763 /// of the enum. Uses `un_node`.
764 enum_to_int,764 int_from_enum,
765 /// Implement builtin `@alignOf`. Uses `un_node`.765 /// Implement builtin `@alignOf`. Uses `un_node`.
766 align_of,766 align_of,
767 /// Implement builtin `@boolToInt`. Uses `un_node`.767 /// Implement builtin `@intFromBool`. Uses `un_node`.
768 bool_to_int,768 int_from_bool,
769 /// Implement builtin `@embedFile`. Uses `un_node`.769 /// Implement builtin `@embedFile`. Uses `un_node`.
770 embed_file,770 embed_file,
771 /// Implement builtin `@errorName`. Uses `un_node`.771 /// Implement builtin `@errorName`. Uses `un_node`.
...@@ -814,18 +814,18 @@ pub const Inst = struct {...@@ -814,18 +814,18 @@ pub const Inst = struct {
814 /// Implement builtin `@frameSize`. Uses `un_node`.814 /// Implement builtin `@frameSize`. Uses `un_node`.
815 frame_size,815 frame_size,
816816
817 /// Implements the `@floatToInt` builtin.817 /// Implements the `@intFromFloat` builtin.
818 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.818 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
819 float_to_int,819 int_from_float,
820 /// Implements the `@intToFloat` builtin.820 /// Implements the `@floatFromInt` builtin.
821 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.821 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
822 int_to_float,822 float_from_int,
823 /// Implements the `@intToPtr` builtin.823 /// Implements the `@ptrFromInt` builtin.
824 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.824 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
825 int_to_ptr,825 ptr_from_int,
826 /// Converts an integer into an enum value.826 /// Converts an integer into an enum value.
827 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.827 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
828 int_to_enum,828 enum_from_int,
829 /// Convert a larger float type to any other float type, possibly causing829 /// Convert a larger float type to any other float type, possibly causing
830 /// a loss of precision.830 /// a loss of precision.
831 /// Uses the `pl_node` field. AST is the `@floatCast` syntax.831 /// Uses the `pl_node` field. AST is the `@floatCast` syntax.
...@@ -1136,14 +1136,14 @@ pub const Inst = struct {...@@ -1136,14 +1136,14 @@ pub const Inst = struct {
1136 .union_init,1136 .union_init,
1137 .field_type,1137 .field_type,
1138 .field_type_ref,1138 .field_type_ref,
1139 .int_to_enum,1139 .enum_from_int,
1140 .enum_to_int,1140 .int_from_enum,
1141 .type_info,1141 .type_info,
1142 .size_of,1142 .size_of,
1143 .bit_size_of,1143 .bit_size_of,
1144 .ptr_to_int,1144 .int_from_ptr,
1145 .align_of,1145 .align_of,
1146 .bool_to_int,1146 .int_from_bool,
1147 .embed_file,1147 .embed_file,
1148 .error_name,1148 .error_name,
1149 .set_runtime_safety,1149 .set_runtime_safety,
...@@ -1165,9 +1165,9 @@ pub const Inst = struct {...@@ -1165,9 +1165,9 @@ pub const Inst = struct {
1165 .type_name,1165 .type_name,
1166 .frame_type,1166 .frame_type,
1167 .frame_size,1167 .frame_size,
1168 .float_to_int,1168 .int_from_float,
1169 .int_to_float,1169 .float_from_int,
1170 .int_to_ptr,1170 .ptr_from_int,
1171 .float_cast,1171 .float_cast,
1172 .int_cast,1172 .int_cast,
1173 .ptr_cast,1173 .ptr_cast,
...@@ -1419,14 +1419,14 @@ pub const Inst = struct {...@@ -1419,14 +1419,14 @@ pub const Inst = struct {
1419 .union_init,1419 .union_init,
1420 .field_type,1420 .field_type,
1421 .field_type_ref,1421 .field_type_ref,
1422 .int_to_enum,1422 .enum_from_int,
1423 .enum_to_int,1423 .int_from_enum,
1424 .type_info,1424 .type_info,
1425 .size_of,1425 .size_of,
1426 .bit_size_of,1426 .bit_size_of,
1427 .ptr_to_int,1427 .int_from_ptr,
1428 .align_of,1428 .align_of,
1429 .bool_to_int,1429 .int_from_bool,
1430 .embed_file,1430 .embed_file,
1431 .error_name,1431 .error_name,
1432 .sqrt,1432 .sqrt,
...@@ -1447,9 +1447,9 @@ pub const Inst = struct {...@@ -1447,9 +1447,9 @@ pub const Inst = struct {
1447 .type_name,1447 .type_name,
1448 .frame_type,1448 .frame_type,
1449 .frame_size,1449 .frame_size,
1450 .float_to_int,1450 .int_from_float,
1451 .int_to_float,1451 .float_from_int,
1452 .int_to_ptr,1452 .ptr_from_int,
1453 .float_cast,1453 .float_cast,
1454 .int_cast,1454 .int_cast,
1455 .ptr_cast,1455 .ptr_cast,
...@@ -1679,12 +1679,12 @@ pub const Inst = struct {...@@ -1679,12 +1679,12 @@ pub const Inst = struct {
1679 .size_of = .un_node,1679 .size_of = .un_node,
1680 .bit_size_of = .un_node,1680 .bit_size_of = .un_node,
16811681
1682 .ptr_to_int = .un_node,1682 .int_from_ptr = .un_node,
1683 .compile_error = .un_node,1683 .compile_error = .un_node,
1684 .set_eval_branch_quota = .un_node,1684 .set_eval_branch_quota = .un_node,
1685 .enum_to_int = .un_node,1685 .int_from_enum = .un_node,
1686 .align_of = .un_node,1686 .align_of = .un_node,
1687 .bool_to_int = .un_node,1687 .int_from_bool = .un_node,
1688 .embed_file = .un_node,1688 .embed_file = .un_node,
1689 .error_name = .un_node,1689 .error_name = .un_node,
1690 .panic = .un_node,1690 .panic = .un_node,
...@@ -1709,10 +1709,10 @@ pub const Inst = struct {...@@ -1709,10 +1709,10 @@ pub const Inst = struct {
1709 .frame_type = .un_node,1709 .frame_type = .un_node,
1710 .frame_size = .un_node,1710 .frame_size = .un_node,
17111711
1712 .float_to_int = .pl_node,1712 .int_from_float = .pl_node,
1713 .int_to_float = .pl_node,1713 .float_from_int = .pl_node,
1714 .int_to_ptr = .pl_node,1714 .ptr_from_int = .pl_node,
1715 .int_to_enum = .pl_node,1715 .enum_from_int = .pl_node,
1716 .float_cast = .pl_node,1716 .float_cast = .pl_node,
1717 .int_cast = .pl_node,1717 .int_cast = .pl_node,
1718 .ptr_cast = .pl_node,1718 .ptr_cast = .pl_node,
...@@ -1933,10 +1933,10 @@ pub const Inst = struct {...@@ -1933,10 +1933,10 @@ pub const Inst = struct {
1933 select,1933 select,
1934 /// Implement builtin `@errToInt`.1934 /// Implement builtin `@errToInt`.
1935 /// `operand` is payload index to `UnNode`.1935 /// `operand` is payload index to `UnNode`.
1936 error_to_int,1936 int_from_error,
1937 /// Implement builtin `@intToError`.1937 /// Implement builtin `@intToError`.
1938 /// `operand` is payload index to `UnNode`.1938 /// `operand` is payload index to `UnNode`.
1939 int_to_error,1939 error_from_int,
1940 /// Implement builtin `@Type`.1940 /// Implement builtin `@Type`.
1941 /// `operand` is payload index to `UnNode`.1941 /// `operand` is payload index to `UnNode`.
1942 /// `small` contains `NameStrategy`.1942 /// `small` contains `NameStrategy`.
src/arch/aarch64/CodeGen.zig+11-11
...@@ -752,7 +752,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -752,7 +752,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
752 .fpext => try self.airFpext(inst),752 .fpext => try self.airFpext(inst),
753 .intcast => try self.airIntCast(inst),753 .intcast => try self.airIntCast(inst),
754 .trunc => try self.airTrunc(inst),754 .trunc => try self.airTrunc(inst),
755 .bool_to_int => try self.airBoolToInt(inst),755 .int_from_bool => try self.airIntFromBool(inst),
756 .is_non_null => try self.airIsNonNull(inst),756 .is_non_null => try self.airIsNonNull(inst),
757 .is_non_null_ptr => try self.airIsNonNullPtr(inst),757 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
758 .is_null => try self.airIsNull(inst),758 .is_null => try self.airIsNull(inst),
...@@ -764,7 +764,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -764,7 +764,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
764 .load => try self.airLoad(inst),764 .load => try self.airLoad(inst),
765 .loop => try self.airLoop(inst),765 .loop => try self.airLoop(inst),
766 .not => try self.airNot(inst),766 .not => try self.airNot(inst),
767 .ptrtoint => try self.airPtrToInt(inst),767 .int_from_ptr => try self.airIntFromPtr(inst),
768 .ret => try self.airRet(inst),768 .ret => try self.airRet(inst),
769 .ret_load => try self.airRetLoad(inst),769 .ret_load => try self.airRetLoad(inst),
770 .store => try self.airStore(inst, false),770 .store => try self.airStore(inst, false),
...@@ -772,8 +772,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -772,8 +772,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
772 .struct_field_ptr=> try self.airStructFieldPtr(inst),772 .struct_field_ptr=> try self.airStructFieldPtr(inst),
773 .struct_field_val=> try self.airStructFieldVal(inst),773 .struct_field_val=> try self.airStructFieldVal(inst),
774 .array_to_slice => try self.airArrayToSlice(inst),774 .array_to_slice => try self.airArrayToSlice(inst),
775 .int_to_float => try self.airIntToFloat(inst),775 .float_from_int => try self.airFloatFromInt(inst),
776 .float_to_int => try self.airFloatToInt(inst),776 .int_from_float => try self.airIntFromFloat(inst),
777 .cmpxchg_strong => try self.airCmpxchg(inst),777 .cmpxchg_strong => try self.airCmpxchg(inst),
778 .cmpxchg_weak => try self.airCmpxchg(inst),778 .cmpxchg_weak => try self.airCmpxchg(inst),
779 .atomic_rmw => try self.airAtomicRmw(inst),779 .atomic_rmw => try self.airAtomicRmw(inst),
...@@ -885,7 +885,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -885,7 +885,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
885 .cmp_neq_optimized,885 .cmp_neq_optimized,
886 .cmp_vector_optimized,886 .cmp_vector_optimized,
887 .reduce_optimized,887 .reduce_optimized,
888 .float_to_int_optimized,888 .int_from_float_optimized,
889 => return self.fail("TODO implement optimized float mode", .{}),889 => return self.fail("TODO implement optimized float mode", .{}),
890890
891 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),891 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
...@@ -1310,7 +1310,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {...@@ -1310,7 +1310,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
1310 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });1310 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
1311}1311}
13121312
1313fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {1313fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
1314 const un_op = self.air.instructions.items(.data)[inst].un_op;1314 const un_op = self.air.instructions.items(.data)[inst].un_op;
1315 const operand = try self.resolveInst(un_op);1315 const operand = try self.resolveInst(un_op);
1316 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;1316 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
...@@ -5903,7 +5903,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I...@@ -5903,7 +5903,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I
5903 }5903 }
5904}5904}
59055905
5906fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {5906fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
5907 const un_op = self.air.instructions.items(.data)[inst].un_op;5907 const un_op = self.air.instructions.items(.data)[inst].un_op;
5908 const result = try self.resolveInst(un_op);5908 const result = try self.resolveInst(un_op);
5909 return self.finishAir(inst, result, .{ un_op, .none, .none });5909 return self.finishAir(inst, result, .{ un_op, .none, .none });
...@@ -5950,17 +5950,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {...@@ -5950,17 +5950,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
5950 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });5950 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
5951}5951}
59525952
5953fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {5953fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
5954 const ty_op = self.air.instructions.items(.data)[inst].ty_op;5954 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 {}", .{
5956 self.target.cpu.arch,5956 self.target.cpu.arch,
5957 });5957 });
5958 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });5958 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
5959}5959}
59605960
5961fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {5961fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
5962 const ty_op = self.air.instructions.items(.data)[inst].ty_op;5962 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 {}", .{
5964 self.target.cpu.arch,5964 self.target.cpu.arch,
5965 });5965 });
5966 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });5966 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/arm/CodeGen.zig+11-11
...@@ -736,7 +736,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -736,7 +736,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
736 .fpext => try self.airFpext(inst),736 .fpext => try self.airFpext(inst),
737 .intcast => try self.airIntCast(inst),737 .intcast => try self.airIntCast(inst),
738 .trunc => try self.airTrunc(inst),738 .trunc => try self.airTrunc(inst),
739 .bool_to_int => try self.airBoolToInt(inst),739 .int_from_bool => try self.airIntFromBool(inst),
740 .is_non_null => try self.airIsNonNull(inst),740 .is_non_null => try self.airIsNonNull(inst),
741 .is_non_null_ptr => try self.airIsNonNullPtr(inst),741 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
742 .is_null => try self.airIsNull(inst),742 .is_null => try self.airIsNull(inst),
...@@ -748,7 +748,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -748,7 +748,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
748 .load => try self.airLoad(inst),748 .load => try self.airLoad(inst),
749 .loop => try self.airLoop(inst),749 .loop => try self.airLoop(inst),
750 .not => try self.airNot(inst),750 .not => try self.airNot(inst),
751 .ptrtoint => try self.airPtrToInt(inst),751 .int_from_ptr => try self.airIntFromPtr(inst),
752 .ret => try self.airRet(inst),752 .ret => try self.airRet(inst),
753 .ret_load => try self.airRetLoad(inst),753 .ret_load => try self.airRetLoad(inst),
754 .store => try self.airStore(inst, false),754 .store => try self.airStore(inst, false),
...@@ -756,8 +756,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -756,8 +756,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
756 .struct_field_ptr=> try self.airStructFieldPtr(inst),756 .struct_field_ptr=> try self.airStructFieldPtr(inst),
757 .struct_field_val=> try self.airStructFieldVal(inst),757 .struct_field_val=> try self.airStructFieldVal(inst),
758 .array_to_slice => try self.airArrayToSlice(inst),758 .array_to_slice => try self.airArrayToSlice(inst),
759 .int_to_float => try self.airIntToFloat(inst),759 .float_from_int => try self.airFloatFromInt(inst),
760 .float_to_int => try self.airFloatToInt(inst),760 .int_from_float => try self.airIntFromFloat(inst),
761 .cmpxchg_strong => try self.airCmpxchg(inst),761 .cmpxchg_strong => try self.airCmpxchg(inst),
762 .cmpxchg_weak => try self.airCmpxchg(inst),762 .cmpxchg_weak => try self.airCmpxchg(inst),
763 .atomic_rmw => try self.airAtomicRmw(inst),763 .atomic_rmw => try self.airAtomicRmw(inst),
...@@ -869,7 +869,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -869,7 +869,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
869 .cmp_neq_optimized,869 .cmp_neq_optimized,
870 .cmp_vector_optimized,870 .cmp_vector_optimized,
871 .reduce_optimized,871 .reduce_optimized,
872 .float_to_int_optimized,872 .int_from_float_optimized,
873 => return self.fail("TODO implement optimized float mode", .{}),873 => return self.fail("TODO implement optimized float mode", .{}),
874874
875 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),875 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
...@@ -1269,7 +1269,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {...@@ -1269,7 +1269,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
1269 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });1269 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
1270}1270}
12711271
1272fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {1272fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
1273 const un_op = self.air.instructions.items(.data)[inst].un_op;1273 const un_op = self.air.instructions.items(.data)[inst].un_op;
1274 const operand = try self.resolveInst(un_op);1274 const operand = try self.resolveInst(un_op);
1275 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;1275 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
...@@ -5857,7 +5857,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I...@@ -5857,7 +5857,7 @@ fn genSetStackArgument(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) I
5857 }5857 }
5858}5858}
58595859
5860fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {5860fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
5861 const un_op = self.air.instructions.items(.data)[inst].un_op;5861 const un_op = self.air.instructions.items(.data)[inst].un_op;
5862 const result = try self.resolveInst(un_op);5862 const result = try self.resolveInst(un_op);
5863 return self.finishAir(inst, result, .{ un_op, .none, .none });5863 return self.finishAir(inst, result, .{ un_op, .none, .none });
...@@ -5903,17 +5903,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {...@@ -5903,17 +5903,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
5903 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });5903 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
5904}5904}
59055905
5906fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {5906fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
5907 const ty_op = self.air.instructions.items(.data)[inst].ty_op;5907 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 {}", .{
5909 self.target.cpu.arch,5909 self.target.cpu.arch,
5910 });5910 });
5911 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });5911 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
5912}5912}
59135913
5914fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {5914fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
5915 const ty_op = self.air.instructions.items(.data)[inst].ty_op;5915 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 {}", .{
5917 self.target.cpu.arch,5917 self.target.cpu.arch,
5918 });5918 });
5919 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });5919 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/riscv64/CodeGen.zig+11-11
...@@ -566,7 +566,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -566,7 +566,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
566 .fpext => try self.airFpext(inst),566 .fpext => try self.airFpext(inst),
567 .intcast => try self.airIntCast(inst),567 .intcast => try self.airIntCast(inst),
568 .trunc => try self.airTrunc(inst),568 .trunc => try self.airTrunc(inst),
569 .bool_to_int => try self.airBoolToInt(inst),569 .int_from_bool => try self.airIntFromBool(inst),
570 .is_non_null => try self.airIsNonNull(inst),570 .is_non_null => try self.airIsNonNull(inst),
571 .is_non_null_ptr => try self.airIsNonNullPtr(inst),571 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
572 .is_null => try self.airIsNull(inst),572 .is_null => try self.airIsNull(inst),
...@@ -578,7 +578,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -578,7 +578,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
578 .load => try self.airLoad(inst),578 .load => try self.airLoad(inst),
579 .loop => try self.airLoop(inst),579 .loop => try self.airLoop(inst),
580 .not => try self.airNot(inst),580 .not => try self.airNot(inst),
581 .ptrtoint => try self.airPtrToInt(inst),581 .int_from_ptr => try self.airIntFromPtr(inst),
582 .ret => try self.airRet(inst),582 .ret => try self.airRet(inst),
583 .ret_load => try self.airRetLoad(inst),583 .ret_load => try self.airRetLoad(inst),
584 .store => try self.airStore(inst, false),584 .store => try self.airStore(inst, false),
...@@ -586,8 +586,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -586,8 +586,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
586 .struct_field_ptr=> try self.airStructFieldPtr(inst),586 .struct_field_ptr=> try self.airStructFieldPtr(inst),
587 .struct_field_val=> try self.airStructFieldVal(inst),587 .struct_field_val=> try self.airStructFieldVal(inst),
588 .array_to_slice => try self.airArrayToSlice(inst),588 .array_to_slice => try self.airArrayToSlice(inst),
589 .int_to_float => try self.airIntToFloat(inst),589 .float_from_int => try self.airFloatFromInt(inst),
590 .float_to_int => try self.airFloatToInt(inst),590 .int_from_float => try self.airIntFromFloat(inst),
591 .cmpxchg_strong => try self.airCmpxchg(inst),591 .cmpxchg_strong => try self.airCmpxchg(inst),
592 .cmpxchg_weak => try self.airCmpxchg(inst),592 .cmpxchg_weak => try self.airCmpxchg(inst),
593 .atomic_rmw => try self.airAtomicRmw(inst),593 .atomic_rmw => try self.airAtomicRmw(inst),
...@@ -699,7 +699,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -699,7 +699,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
699 .cmp_neq_optimized,699 .cmp_neq_optimized,
700 .cmp_vector_optimized,700 .cmp_vector_optimized,
701 .reduce_optimized,701 .reduce_optimized,
702 .float_to_int_optimized,702 .int_from_float_optimized,
703 => return self.fail("TODO implement optimized float mode", .{}),703 => return self.fail("TODO implement optimized float mode", .{}),
704704
705 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),705 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
...@@ -920,7 +920,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {...@@ -920,7 +920,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
920 // return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });920 // return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
921}921}
922922
923fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {923fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
924 const un_op = self.air.instructions.items(.data)[inst].un_op;924 const un_op = self.air.instructions.items(.data)[inst].un_op;
925 const operand = try self.resolveInst(un_op);925 const operand = try self.resolveInst(un_op);
926 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;926 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...@@ -2361,7 +2361,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
2361 }2361 }
2362}2362}
23632363
2364fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {2364fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
2365 const un_op = self.air.instructions.items(.data)[inst].un_op;2365 const un_op = self.air.instructions.items(.data)[inst].un_op;
2366 const result = try self.resolveInst(un_op);2366 const result = try self.resolveInst(un_op);
2367 return self.finishAir(inst, result, .{ un_op, .none, .none });2367 return self.finishAir(inst, result, .{ un_op, .none, .none });
...@@ -2394,17 +2394,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {...@@ -2394,17 +2394,17 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
2394 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });2394 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
2395}2395}
23962396
2397fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {2397fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
2398 const ty_op = self.air.instructions.items(.data)[inst].ty_op;2398 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 {}", .{
2400 self.target.cpu.arch,2400 self.target.cpu.arch,
2401 });2401 });
2402 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });2402 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
2403}2403}
24042404
2405fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {2405fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
2406 const ty_op = self.air.instructions.items(.data)[inst].ty_op;2406 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 {}", .{
2408 self.target.cpu.arch,2408 self.target.cpu.arch,
2409 });2409 });
2410 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });2410 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/sparc64/CodeGen.zig+11-11
...@@ -583,7 +583,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -583,7 +583,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
583 .fpext => @panic("TODO try self.airFpext(inst)"),583 .fpext => @panic("TODO try self.airFpext(inst)"),
584 .intcast => try self.airIntCast(inst),584 .intcast => try self.airIntCast(inst),
585 .trunc => try self.airTrunc(inst),585 .trunc => try self.airTrunc(inst),
586 .bool_to_int => try self.airBoolToInt(inst),586 .int_from_bool => try self.airIntFromBool(inst),
587 .is_non_null => try self.airIsNonNull(inst),587 .is_non_null => try self.airIsNonNull(inst),
588 .is_non_null_ptr => @panic("TODO try self.airIsNonNullPtr(inst)"),588 .is_non_null_ptr => @panic("TODO try self.airIsNonNullPtr(inst)"),
589 .is_null => try self.airIsNull(inst),589 .is_null => try self.airIsNull(inst),
...@@ -595,7 +595,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -595,7 +595,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
595 .load => try self.airLoad(inst),595 .load => try self.airLoad(inst),
596 .loop => try self.airLoop(inst),596 .loop => try self.airLoop(inst),
597 .not => try self.airNot(inst),597 .not => try self.airNot(inst),
598 .ptrtoint => try self.airPtrToInt(inst),598 .int_from_ptr => try self.airIntFromPtr(inst),
599 .ret => try self.airRet(inst),599 .ret => try self.airRet(inst),
600 .ret_load => try self.airRetLoad(inst),600 .ret_load => try self.airRetLoad(inst),
601 .store => try self.airStore(inst, false),601 .store => try self.airStore(inst, false),
...@@ -603,8 +603,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -603,8 +603,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
603 .struct_field_ptr=> try self.airStructFieldPtr(inst),603 .struct_field_ptr=> try self.airStructFieldPtr(inst),
604 .struct_field_val=> try self.airStructFieldVal(inst),604 .struct_field_val=> try self.airStructFieldVal(inst),
605 .array_to_slice => try self.airArrayToSlice(inst),605 .array_to_slice => try self.airArrayToSlice(inst),
606 .int_to_float => try self.airIntToFloat(inst),606 .float_from_int => try self.airFloatFromInt(inst),
607 .float_to_int => try self.airFloatToInt(inst),607 .int_from_float => try self.airIntFromFloat(inst),
608 .cmpxchg_strong,608 .cmpxchg_strong,
609 .cmpxchg_weak,609 .cmpxchg_weak,
610 => try self.airCmpxchg(inst),610 => try self.airCmpxchg(inst),
...@@ -717,7 +717,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -717,7 +717,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
717 .cmp_neq_optimized,717 .cmp_neq_optimized,
718 .cmp_vector_optimized,718 .cmp_vector_optimized,
719 .reduce_optimized,719 .reduce_optimized,
720 .float_to_int_optimized,720 .int_from_float_optimized,
721 => @panic("TODO implement optimized float mode"),721 => @panic("TODO implement optimized float mode"),
722722
723 .is_named_enum_value => @panic("TODO implement is_named_enum_value"),723 .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 {...@@ -1078,7 +1078,7 @@ fn airBinOp(self: *Self, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
1078 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });1078 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
1079}1079}
10801080
1081fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {1081fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
1082 const un_op = self.air.instructions.items(.data)[inst].un_op;1082 const un_op = self.air.instructions.items(.data)[inst].un_op;
1083 const operand = try self.resolveInst(un_op);1083 const operand = try self.resolveInst(un_op);
1084 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;1084 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else operand;
...@@ -1736,9 +1736,9 @@ fn airFence(self: *Self, inst: Air.Inst.Index) !void {...@@ -1736,9 +1736,9 @@ fn airFence(self: *Self, inst: Air.Inst.Index) !void {
1736 return self.finishAir(inst, .dead, .{ .none, .none, .none });1736 return self.finishAir(inst, .dead, .{ .none, .none, .none });
1737}1737}
17381738
1739fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {1739fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
1740 const ty_op = self.air.instructions.items(.data)[inst].ty_op;1740 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 {}", .{
1742 self.target.cpu.arch,1742 self.target.cpu.arch,
1743 });1743 });
1744 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });1744 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
...@@ -1769,9 +1769,9 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {...@@ -1769,9 +1769,9 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
1769 return self.fail("TODO implement intCast for {}", .{self.target.cpu.arch});1769 return self.fail("TODO implement intCast for {}", .{self.target.cpu.arch});
1770}1770}
17711771
1772fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {1772fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
1773 const ty_op = self.air.instructions.items(.data)[inst].ty_op;1773 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 {}", .{
1775 self.target.cpu.arch,1775 self.target.cpu.arch,
1776 });1776 });
1777 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });1777 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
...@@ -2276,7 +2276,7 @@ fn airPtrSlicePtrPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -2276,7 +2276,7 @@ fn airPtrSlicePtrPtr(self: *Self, inst: Air.Inst.Index) !void {
2276 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });2276 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
2277}2277}
22782278
2279fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {2279fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
2280 const un_op = self.air.instructions.items(.data)[inst].un_op;2280 const un_op = self.air.instructions.items(.data)[inst].un_op;
2281 const result = try self.resolveInst(un_op);2281 const result = try self.resolveInst(un_op);
2282 return self.finishAir(inst, result, .{ un_op, .none, .none });2282 return self.finishAir(inst, result, .{ un_op, .none, .none });
src/arch/wasm/CodeGen.zig+9-9
...@@ -1902,13 +1902,13 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -1902,13 +1902,13 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
1902 .trap => func.airTrap(inst),1902 .trap => func.airTrap(inst),
1903 .breakpoint => func.airBreakpoint(inst),1903 .breakpoint => func.airBreakpoint(inst),
1904 .br => func.airBr(inst),1904 .br => func.airBr(inst),
1905 .bool_to_int => func.airBoolToInt(inst),1905 .int_from_bool => func.airIntFromBool(inst),
1906 .cond_br => func.airCondBr(inst),1906 .cond_br => func.airCondBr(inst),
1907 .intcast => func.airIntcast(inst),1907 .intcast => func.airIntcast(inst),
1908 .fptrunc => func.airFptrunc(inst),1908 .fptrunc => func.airFptrunc(inst),
1909 .fpext => func.airFpext(inst),1909 .fpext => func.airFpext(inst),
1910 .float_to_int => func.airFloatToInt(inst),1910 .int_from_float => func.airIntFromFloat(inst),
1911 .int_to_float => func.airIntToFloat(inst),1911 .float_from_int => func.airFloatFromInt(inst),
1912 .get_union_tag => func.airGetUnionTag(inst),1912 .get_union_tag => func.airGetUnionTag(inst),
19131913
1914 .@"try" => func.airTry(inst),1914 .@"try" => func.airTry(inst),
...@@ -1951,7 +1951,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -1951,7 +1951,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
1951 .ptr_sub => func.airPtrBinOp(inst, .sub),1951 .ptr_sub => func.airPtrBinOp(inst, .sub),
1952 .ptr_elem_ptr => func.airPtrElemPtr(inst),1952 .ptr_elem_ptr => func.airPtrElemPtr(inst),
1953 .ptr_elem_val => func.airPtrElemVal(inst),1953 .ptr_elem_val => func.airPtrElemVal(inst),
1954 .ptrtoint => func.airPtrToInt(inst),1954 .int_from_ptr => func.airIntFromPtr(inst),
1955 .ret => func.airRet(inst),1955 .ret => func.airRet(inst),
1956 .ret_ptr => func.airRetPtr(inst),1956 .ret_ptr => func.airRetPtr(inst),
1957 .ret_load => func.airRetLoad(inst),1957 .ret_load => func.airRetLoad(inst),
...@@ -2061,7 +2061,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2061,7 +2061,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2061 .cmp_neq_optimized,2061 .cmp_neq_optimized,
2062 .cmp_vector_optimized,2062 .cmp_vector_optimized,
2063 .reduce_optimized,2063 .reduce_optimized,
2064 .float_to_int_optimized,2064 .int_from_float_optimized,
2065 => return func.fail("TODO implement optimized float mode", .{}),2065 => return func.fail("TODO implement optimized float mode", .{}),
20662066
2067 .work_item_id,2067 .work_item_id,
...@@ -4480,7 +4480,7 @@ fn trunc(func: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) Inner...@@ -4480,7 +4480,7 @@ fn trunc(func: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) Inner
4480 return result;4480 return result;
4481}4481}
44824482
4483fn airBoolToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4483fn airIntFromBool(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4484 const un_op = func.air.instructions.items(.data)[inst].un_op;4484 const un_op = func.air.instructions.items(.data)[inst].un_op;
4485 const operand = try func.resolveInst(un_op);4485 const operand = try func.resolveInst(un_op);
4486 const result = func.reuseOperand(un_op, operand);4486 const result = func.reuseOperand(un_op, operand);
...@@ -4511,7 +4511,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4511,7 +4511,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4511 func.finishAir(inst, slice_local, &.{ty_op.operand});4511 func.finishAir(inst, slice_local, &.{ty_op.operand});
4512}4512}
45134513
4514fn airPtrToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4514fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4515 const mod = func.bin_file.base.options.module.?;4515 const mod = func.bin_file.base.options.module.?;
4516 const un_op = func.air.instructions.items(.data)[inst].un_op;4516 const un_op = func.air.instructions.items(.data)[inst].un_op;
4517 const operand = try func.resolveInst(un_op);4517 const operand = try func.resolveInst(un_op);
...@@ -4812,7 +4812,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4812,7 +4812,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4812 func.finishAir(inst, elem_result, &.{ bin_op.lhs, bin_op.rhs });4812 func.finishAir(inst, elem_result, &.{ bin_op.lhs, bin_op.rhs });
4813}4813}
48144814
4815fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4815fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4816 const mod = func.bin_file.base.options.module.?;4816 const mod = func.bin_file.base.options.module.?;
4817 const ty_op = func.air.instructions.items(.data)[inst].ty_op;4817 const ty_op = func.air.instructions.items(.data)[inst].ty_op;
48184818
...@@ -4837,7 +4837,7 @@ fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4837,7 +4837,7 @@ fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4837 func.finishAir(inst, result, &.{ty_op.operand});4837 func.finishAir(inst, result, &.{ty_op.operand});
4838}4838}
48394839
4840fn airIntToFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4840fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4841 const mod = func.bin_file.base.options.module.?;4841 const mod = func.bin_file.base.options.module.?;
4842 const ty_op = func.air.instructions.items(.data)[inst].ty_op;4842 const ty_op = func.air.instructions.items(.data)[inst].ty_op;
48434843
src/arch/x86_64/CodeGen.zig+13-13
...@@ -1835,7 +1835,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -1835,7 +1835,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1835 .fpext => try self.airFpext(inst),1835 .fpext => try self.airFpext(inst),
1836 .intcast => try self.airIntCast(inst),1836 .intcast => try self.airIntCast(inst),
1837 .trunc => try self.airTrunc(inst),1837 .trunc => try self.airTrunc(inst),
1838 .bool_to_int => try self.airBoolToInt(inst),1838 .int_from_bool => try self.airIntFromBool(inst),
1839 .is_non_null => try self.airIsNonNull(inst),1839 .is_non_null => try self.airIsNonNull(inst),
1840 .is_non_null_ptr => try self.airIsNonNullPtr(inst),1840 .is_non_null_ptr => try self.airIsNonNullPtr(inst),
1841 .is_null => try self.airIsNull(inst),1841 .is_null => try self.airIsNull(inst),
...@@ -1846,7 +1846,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -1846,7 +1846,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1846 .is_err_ptr => try self.airIsErrPtr(inst),1846 .is_err_ptr => try self.airIsErrPtr(inst),
1847 .load => try self.airLoad(inst),1847 .load => try self.airLoad(inst),
1848 .loop => try self.airLoop(inst),1848 .loop => try self.airLoop(inst),
1849 .ptrtoint => try self.airPtrToInt(inst),1849 .int_from_ptr => try self.airIntFromPtr(inst),
1850 .ret => try self.airRet(inst),1850 .ret => try self.airRet(inst),
1851 .ret_load => try self.airRetLoad(inst),1851 .ret_load => try self.airRetLoad(inst),
1852 .store => try self.airStore(inst, false),1852 .store => try self.airStore(inst, false),
...@@ -1854,8 +1854,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -1854,8 +1854,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1854 .struct_field_ptr=> try self.airStructFieldPtr(inst),1854 .struct_field_ptr=> try self.airStructFieldPtr(inst),
1855 .struct_field_val=> try self.airStructFieldVal(inst),1855 .struct_field_val=> try self.airStructFieldVal(inst),
1856 .array_to_slice => try self.airArrayToSlice(inst),1856 .array_to_slice => try self.airArrayToSlice(inst),
1857 .int_to_float => try self.airIntToFloat(inst),1857 .float_from_int => try self.airFloatFromInt(inst),
1858 .float_to_int => try self.airFloatToInt(inst),1858 .int_from_float => try self.airIntFromFloat(inst),
1859 .cmpxchg_strong => try self.airCmpxchg(inst),1859 .cmpxchg_strong => try self.airCmpxchg(inst),
1860 .cmpxchg_weak => try self.airCmpxchg(inst),1860 .cmpxchg_weak => try self.airCmpxchg(inst),
1861 .atomic_rmw => try self.airAtomicRmw(inst),1861 .atomic_rmw => try self.airAtomicRmw(inst),
...@@ -1967,7 +1967,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -1967,7 +1967,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1967 .cmp_neq_optimized,1967 .cmp_neq_optimized,
1968 .cmp_vector_optimized,1968 .cmp_vector_optimized,
1969 .reduce_optimized,1969 .reduce_optimized,
1970 .float_to_int_optimized,1970 .int_from_float_optimized,
1971 => return self.fail("TODO implement optimized float mode", .{}),1971 => return self.fail("TODO implement optimized float mode", .{}),
19721972
1973 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),1973 .is_named_enum_value => return self.fail("TODO implement is_named_enum_value", .{}),
...@@ -2806,7 +2806,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {...@@ -2806,7 +2806,7 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
2806 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });2806 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
2807}2807}
28082808
2809fn airBoolToInt(self: *Self, inst: Air.Inst.Index) !void {2809fn airIntFromBool(self: *Self, inst: Air.Inst.Index) !void {
2810 const un_op = self.air.instructions.items(.data)[inst].un_op;2810 const un_op = self.air.instructions.items(.data)[inst].un_op;
2811 const ty = self.typeOfIndex(inst);2811 const ty = self.typeOfIndex(inst);
28122812
...@@ -10147,7 +10147,7 @@ fn genLazySymbolRef(...@@ -10147,7 +10147,7 @@ fn genLazySymbolRef(
10147 }10147 }
10148}10148}
1014910149
10150fn airPtrToInt(self: *Self, inst: Air.Inst.Index) !void {10150fn airIntFromPtr(self: *Self, inst: Air.Inst.Index) !void {
10151 const un_op = self.air.instructions.items(.data)[inst].un_op;10151 const un_op = self.air.instructions.items(.data)[inst].un_op;
10152 const result = result: {10152 const result = result: {
10153 // TODO: handle case where the operand is a slice not a raw pointer10153 // 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 {...@@ -10246,7 +10246,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
10246 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });10246 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
10247}10247}
1024810248
10249fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {10249fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
10250 const mod = self.bin_file.options.module.?;10250 const mod = self.bin_file.options.module.?;
10251 const ty_op = self.air.instructions.items(.data)[inst].ty_op;10251 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 {...@@ -10260,7 +10260,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
10260 .signed => src_bits,10260 .signed => src_bits,
10261 .unsigned => src_bits + 1,10261 .unsigned => src_bits + 1,
10262 }, 32), 8) catch unreachable;10262 }, 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 {}", .{
10264 src_ty.fmt(mod), dst_ty.fmt(mod),10264 src_ty.fmt(mod), dst_ty.fmt(mod),
10265 });10265 });
1026610266
...@@ -10287,7 +10287,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {...@@ -10287,7 +10287,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
10287 else => unreachable,10287 else => unreachable,
10288 },10288 },
10289 else => null,10289 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 {}", .{
10291 src_ty.fmt(mod), dst_ty.fmt(mod),10291 src_ty.fmt(mod), dst_ty.fmt(mod),
10292 });10292 });
10293 const dst_alias = dst_reg.to128();10293 const dst_alias = dst_reg.to128();
...@@ -10300,7 +10300,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {...@@ -10300,7 +10300,7 @@ fn airIntToFloat(self: *Self, inst: Air.Inst.Index) !void {
10300 return self.finishAir(inst, dst_mcv, .{ ty_op.operand, .none, .none });10300 return self.finishAir(inst, dst_mcv, .{ ty_op.operand, .none, .none });
10301}10301}
1030210302
10303fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {10303fn airIntFromFloat(self: *Self, inst: Air.Inst.Index) !void {
10304 const mod = self.bin_file.options.module.?;10304 const mod = self.bin_file.options.module.?;
10305 const ty_op = self.air.instructions.items(.data)[inst].ty_op;10305 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 {...@@ -10314,7 +10314,7 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
10314 .signed => dst_bits,10314 .signed => dst_bits,
10315 .unsigned => dst_bits + 1,10315 .unsigned => dst_bits + 1,
10316 }, 32), 8) catch unreachable;10316 }, 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 {}", .{
10318 src_ty.fmt(self.bin_file.options.module.?), dst_ty.fmt(self.bin_file.options.module.?),10318 src_ty.fmt(self.bin_file.options.module.?), dst_ty.fmt(self.bin_file.options.module.?),
10319 });10319 });
1032010320
...@@ -10340,7 +10340,7 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {...@@ -10340,7 +10340,7 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void {
10340 else => unreachable,10340 else => unreachable,
10341 },10341 },
10342 else => null,10342 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 {}", .{
10344 src_ty.fmt(self.bin_file.options.module.?), dst_ty.fmt(self.bin_file.options.module.?),10344 src_ty.fmt(self.bin_file.options.module.?), dst_ty.fmt(self.bin_file.options.module.?),
10345 }),10345 }),
10346 registerAlias(dst_reg, dst_size),10346 registerAlias(dst_reg, dst_size),
src/codegen/c.zig+7-7
...@@ -2943,7 +2943,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,...@@ -2943,7 +2943,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
2943 .dbg_stmt => try airDbgStmt(f, inst),2943 .dbg_stmt => try airDbgStmt(f, inst),
2944 .intcast => try airIntCast(f, inst),2944 .intcast => try airIntCast(f, inst),
2945 .trunc => try airTrunc(f, inst),2945 .trunc => try airTrunc(f, inst),
2946 .bool_to_int => try airBoolToInt(f, inst),2946 .int_from_bool => try airIntFromBool(f, inst),
2947 .load => try airLoad(f, inst),2947 .load => try airLoad(f, inst),
2948 .ret => try airRet(f, inst, false),2948 .ret => try airRet(f, inst, false),
2949 .ret_load => try airRet(f, inst, true),2949 .ret_load => try airRet(f, inst, true),
...@@ -3000,13 +3000,13 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,...@@ -3000,13 +3000,13 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
3000 .call_never_tail => try airCall(f, inst, .never_tail),3000 .call_never_tail => try airCall(f, inst, .never_tail),
3001 .call_never_inline => try airCall(f, inst, .never_inline),3001 .call_never_inline => try airCall(f, inst, .never_inline),
30023002
3003 .int_to_float,3003 .float_from_int,
3004 .float_to_int,3004 .int_from_float,
3005 .fptrunc,3005 .fptrunc,
3006 .fpext,3006 .fpext,
3007 => try airFloatCast(f, inst),3007 => try airFloatCast(f, inst),
30083008
3009 .ptrtoint => try airPtrToInt(f, inst),3009 .int_from_ptr => try airIntFromPtr(f, inst),
30103010
3011 .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)),3011 .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)),
3012 .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)),3012 .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)),
...@@ -3068,7 +3068,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,...@@ -3068,7 +3068,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
3068 .cmp_neq_optimized,3068 .cmp_neq_optimized,
3069 .cmp_vector_optimized,3069 .cmp_vector_optimized,
3070 .reduce_optimized,3070 .reduce_optimized,
3071 .float_to_int_optimized,3071 .int_from_float_optimized,
3072 => return f.fail("TODO implement optimized float mode", .{}),3072 => return f.fail("TODO implement optimized float mode", .{}),
30733073
3074 .is_named_enum_value => return f.fail("TODO: C backend: implement is_named_enum_value", .{}),3074 .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 {...@@ -3562,7 +3562,7 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue {
3562 return local;3562 return local;
3563}3563}
35643564
3565fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue {3565fn airIntFromBool(f: *Function, inst: Air.Inst.Index) !CValue {
3566 const un_op = f.air.instructions.items(.data)[inst].un_op;3566 const un_op = f.air.instructions.items(.data)[inst].un_op;
3567 const operand = try f.resolveInst(un_op);3567 const operand = try f.resolveInst(un_op);
3568 try reap(f, inst, &.{un_op});3568 try reap(f, inst, &.{un_op});
...@@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue {
5834 return local;5834 return local;
5835}5835}
58365836
5837fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue {5837fn airIntFromPtr(f: *Function, inst: Air.Inst.Index) !CValue {
5838 const mod = f.object.dg.module;5838 const mod = f.object.dg.module;
5839 const un_op = f.air.instructions.items(.data)[inst].un_op;5839 const un_op = f.air.instructions.items(.data)[inst].un_op;
58405840
src/codegen/llvm.zig+9-9
...@@ -4417,7 +4417,7 @@ pub const FuncGen = struct {...@@ -4417,7 +4417,7 @@ pub const FuncGen = struct {
4417 .ret_ptr => try self.airRetPtr(inst),4417 .ret_ptr => try self.airRetPtr(inst),
4418 .arg => try self.airArg(inst),4418 .arg => try self.airArg(inst),
4419 .bitcast => try self.airBitCast(inst),4419 .bitcast => try self.airBitCast(inst),
4420 .bool_to_int => try self.airBoolToInt(inst),4420 .int_from_bool => try self.airIntFromBool(inst),
4421 .block => try self.airBlock(inst),4421 .block => try self.airBlock(inst),
4422 .br => try self.airBr(inst),4422 .br => try self.airBr(inst),
4423 .switch_br => try self.airSwitchBr(inst),4423 .switch_br => try self.airSwitchBr(inst),
...@@ -4432,7 +4432,7 @@ pub const FuncGen = struct {...@@ -4432,7 +4432,7 @@ pub const FuncGen = struct {
4432 .trunc => try self.airTrunc(inst),4432 .trunc => try self.airTrunc(inst),
4433 .fptrunc => try self.airFptrunc(inst),4433 .fptrunc => try self.airFptrunc(inst),
4434 .fpext => try self.airFpext(inst),4434 .fpext => try self.airFpext(inst),
4435 .ptrtoint => try self.airPtrToInt(inst),4435 .int_from_ptr => try self.airIntFromPtr(inst),
4436 .load => try self.airLoad(body[i..]),4436 .load => try self.airLoad(body[i..]),
4437 .loop => try self.airLoop(inst),4437 .loop => try self.airLoop(inst),
4438 .not => try self.airNot(inst),4438 .not => try self.airNot(inst),
...@@ -4452,11 +4452,11 @@ pub const FuncGen = struct {...@@ -4452,11 +4452,11 @@ pub const FuncGen = struct {
4452 .ptr_slice_ptr_ptr => try self.airPtrSliceFieldPtr(inst, 0),4452 .ptr_slice_ptr_ptr => try self.airPtrSliceFieldPtr(inst, 0),
4453 .ptr_slice_len_ptr => try self.airPtrSliceFieldPtr(inst, 1),4453 .ptr_slice_len_ptr => try self.airPtrSliceFieldPtr(inst, 1),
44544454
4455 .float_to_int => try self.airFloatToInt(inst, false),4455 .int_from_float => try self.airIntFromFloat(inst, false),
4456 .float_to_int_optimized => try self.airFloatToInt(inst, true),4456 .int_from_float_optimized => try self.airIntFromFloat(inst, true),
44574457
4458 .array_to_slice => try self.airArrayToSlice(inst),4458 .array_to_slice => try self.airArrayToSlice(inst),
4459 .int_to_float => try self.airIntToFloat(inst),4459 .float_from_int => try self.airFloatFromInt(inst),
4460 .cmpxchg_weak => try self.airCmpxchg(inst, true),4460 .cmpxchg_weak => try self.airCmpxchg(inst, true),
4461 .cmpxchg_strong => try self.airCmpxchg(inst, false),4461 .cmpxchg_strong => try self.airCmpxchg(inst, false),
4462 .fence => try self.airFence(inst),4462 .fence => try self.airFence(inst),
...@@ -5456,7 +5456,7 @@ pub const FuncGen = struct {...@@ -5456,7 +5456,7 @@ pub const FuncGen = struct {
5456 return self.builder.buildInsertValue(partial, len, 1, "");5456 return self.builder.buildInsertValue(partial, len, 1, "");
5457 }5457 }
54585458
5459 fn airIntToFloat(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {5459 fn airFloatFromInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
5460 const mod = self.dg.module;5460 const mod = self.dg.module;
5461 const ty_op = self.air.instructions.items(.data)[inst].ty_op;5461 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
54625462
...@@ -5513,7 +5513,7 @@ pub const FuncGen = struct {...@@ -5513,7 +5513,7 @@ pub const FuncGen = struct {
5513 return self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");5513 return self.builder.buildCall(libc_fn.globalGetValueType(), libc_fn, &params, params.len, .C, .Auto, "");
5514 }5514 }
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 {
5517 self.builder.setFastMath(want_fast_math);5517 self.builder.setFastMath(want_fast_math);
55185518
5519 const mod = self.dg.module;5519 const mod = self.dg.module;
...@@ -7788,7 +7788,7 @@ pub const FuncGen = struct {...@@ -7788,7 +7788,7 @@ pub const FuncGen = struct {
7788 }7788 }
7789 }7789 }
77907790
7791 fn airPtrToInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {7791 fn airIntFromPtr(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
7792 const un_op = self.air.instructions.items(.data)[inst].un_op;7792 const un_op = self.air.instructions.items(.data)[inst].un_op;
7793 const operand = try self.resolveInst(un_op);7793 const operand = try self.resolveInst(un_op);
7794 const ptr_ty = self.typeOf(un_op);7794 const ptr_ty = self.typeOf(un_op);
...@@ -7922,7 +7922,7 @@ pub const FuncGen = struct {...@@ -7922,7 +7922,7 @@ pub const FuncGen = struct {
7922 return self.builder.buildBitCast(operand, llvm_dest_ty, "");7922 return self.builder.buildBitCast(operand, llvm_dest_ty, "");
7923 }7923 }
79247924
7925 fn airBoolToInt(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {7925 fn airIntFromBool(self: *FuncGen, inst: Air.Inst.Index) !?*llvm.Value {
7926 const un_op = self.air.instructions.items(.data)[inst].un_op;7926 const un_op = self.air.instructions.items(.data)[inst].un_op;
7927 const operand = try self.resolveInst(un_op);7927 const operand = try self.resolveInst(un_op);
7928 return operand;7928 return operand;
src/codegen/spirv.zig+6-6
...@@ -1721,9 +1721,9 @@ pub const DeclGen = struct {...@@ -1721,9 +1721,9 @@ pub const DeclGen = struct {
17211721
1722 .bitcast => try self.airBitCast(inst),1722 .bitcast => try self.airBitCast(inst),
1723 .intcast, .trunc => try self.airIntCast(inst),1723 .intcast, .trunc => try self.airIntCast(inst),
1724 .ptrtoint => try self.airPtrToInt(inst),1724 .int_from_ptr => try self.airIntFromPtr(inst),
1725 .int_to_float => try self.airIntToFloat(inst),1725 .float_from_int => try self.airFloatFromInt(inst),
1726 .float_to_int => try self.airFloatToInt(inst),1726 .int_from_float => try self.airIntFromFloat(inst),
1727 .not => try self.airNot(inst),1727 .not => try self.airNot(inst),
17281728
1729 .slice_ptr => try self.airSliceField(inst, 0),1729 .slice_ptr => try self.airSliceField(inst, 0),
...@@ -2329,7 +2329,7 @@ pub const DeclGen = struct {...@@ -2329,7 +2329,7 @@ pub const DeclGen = struct {
2329 return result_id;2329 return result_id;
2330 }2330 }
23312331
2332 fn airPtrToInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {2332 fn airIntFromPtr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2333 if (self.liveness.isUnused(inst)) return null;2333 if (self.liveness.isUnused(inst)) return null;
23342334
2335 const un_op = self.air.instructions.items(.data)[inst].un_op;2335 const un_op = self.air.instructions.items(.data)[inst].un_op;
...@@ -2345,7 +2345,7 @@ pub const DeclGen = struct {...@@ -2345,7 +2345,7 @@ pub const DeclGen = struct {
2345 return result_id;2345 return result_id;
2346 }2346 }
23472347
2348 fn airIntToFloat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {2348 fn airFloatFromInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2349 if (self.liveness.isUnused(inst)) return null;2349 if (self.liveness.isUnused(inst)) return null;
23502350
2351 const ty_op = self.air.instructions.items(.data)[inst].ty_op;2351 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
...@@ -2371,7 +2371,7 @@ pub const DeclGen = struct {...@@ -2371,7 +2371,7 @@ pub const DeclGen = struct {
2371 return result_id;2371 return result_id;
2372 }2372 }
23732373
2374 fn airFloatToInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {2374 fn airIntFromFloat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2375 if (self.liveness.isUnused(inst)) return null;2375 if (self.liveness.isUnused(inst)) return null;
23762376
2377 const ty_op = self.air.instructions.items(.data)[inst].ty_op;2377 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
src/print_air.zig+5-5
...@@ -183,8 +183,8 @@ const Writer = struct {...@@ -183,8 +183,8 @@ const Writer = struct {
183 .is_non_err,183 .is_non_err,
184 .is_err_ptr,184 .is_err_ptr,
185 .is_non_err_ptr,185 .is_non_err_ptr,
186 .ptrtoint,186 .int_from_ptr,
187 .bool_to_int,187 .int_from_bool,
188 .ret,188 .ret,
189 .ret_load,189 .ret_load,
190 .is_named_enum_value,190 .is_named_enum_value,
...@@ -254,10 +254,10 @@ const Writer = struct {...@@ -254,10 +254,10 @@ const Writer = struct {
254 .struct_field_ptr_index_2,254 .struct_field_ptr_index_2,
255 .struct_field_ptr_index_3,255 .struct_field_ptr_index_3,
256 .array_to_slice,256 .array_to_slice,
257 .int_to_float,257 .float_from_int,
258 .splat,258 .splat,
259 .float_to_int,259 .int_from_float,
260 .float_to_int_optimized,260 .int_from_float_optimized,
261 .get_union_tag,261 .get_union_tag,
262 .clz,262 .clz,
263 .ctz,263 .ctz,
src/print_zir.zig+9-9
...@@ -187,12 +187,12 @@ const Writer = struct {...@@ -187,12 +187,12 @@ const Writer = struct {
187 .size_of,187 .size_of,
188 .bit_size_of,188 .bit_size_of,
189 .typeof_log2_int_type,189 .typeof_log2_int_type,
190 .ptr_to_int,190 .int_from_ptr,
191 .compile_error,191 .compile_error,
192 .set_eval_branch_quota,192 .set_eval_branch_quota,
193 .enum_to_int,193 .int_from_enum,
194 .align_of,194 .align_of,
195 .bool_to_int,195 .int_from_bool,
196 .embed_file,196 .embed_file,
197 .error_name,197 .error_name,
198 .panic,198 .panic,
...@@ -321,10 +321,10 @@ const Writer = struct {...@@ -321,10 +321,10 @@ const Writer = struct {
321 .merge_error_sets,321 .merge_error_sets,
322 .bit_and,322 .bit_and,
323 .bit_or,323 .bit_or,
324 .float_to_int,324 .int_from_float,
325 .int_to_float,325 .float_from_int,
326 .int_to_ptr,326 .ptr_from_int,
327 .int_to_enum,327 .enum_from_int,
328 .float_cast,328 .float_cast,
329 .int_cast,329 .int_cast,
330 .ptr_cast,330 .ptr_cast,
...@@ -502,8 +502,8 @@ const Writer = struct {...@@ -502,8 +502,8 @@ const Writer = struct {
502 .set_align_stack,502 .set_align_stack,
503 .set_cold,503 .set_cold,
504 .wasm_memory_size,504 .wasm_memory_size,
505 .error_to_int,505 .int_from_error,
506 .int_to_error,506 .error_from_int,
507 .reify,507 .reify,
508 .c_va_copy,508 .c_va_copy,
509 .c_va_end,509 .c_va_end,
src/translate_c.zig+35-35
...@@ -845,7 +845,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co...@@ -845,7 +845,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co
845 error.OutOfMemory => |e| return e,845 error.OutOfMemory => |e| return e,
846 };846 };
847 if (!qualTypeIsBoolean(qual_type) and isBoolRes(init_node.?)) {847 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.?);
849 } else if (init_node.?.tag() == .string_literal and qualTypeIsCharStar(qual_type)) {849 } else if (init_node.?.tag() == .string_literal and qualTypeIsCharStar(qual_type)) {
850 init_node = try stringLiteralToCharStar(c, init_node.?);850 init_node = try stringLiteralToCharStar(c, init_node.?);
851 }851 }
...@@ -1753,16 +1753,16 @@ fn transBinaryOperator(...@@ -1753,16 +1753,16 @@ fn transBinaryOperator(
1753 const rhs_uncasted = try transExpr(c, scope, stmt.getRHS(), .used);1753 const rhs_uncasted = try transExpr(c, scope, stmt.getRHS(), .used);
17541754
1755 const lhs = if (isBoolRes(lhs_uncasted))1755 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)
1757 else if (isPointerDiffExpr)1757 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)
1759 else1759 else
1760 lhs_uncasted;1760 lhs_uncasted;
17611761
1762 const rhs = if (isBoolRes(rhs_uncasted))1762 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)
1764 else if (isPointerDiffExpr)1764 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)
1766 else1766 else
1767 rhs_uncasted;1767 rhs_uncasted;
17681768
...@@ -1944,7 +1944,7 @@ fn transDeclStmtOne(...@@ -1944,7 +1944,7 @@ fn transDeclStmtOne(
1944 else1944 else
1945 Tag.undefined_literal.init();1945 Tag.undefined_literal.init();
1946 if (!qualTypeIsBoolean(qual_type) and isBoolRes(init_node)) {1946 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);
1948 } else if (init_node.tag() == .string_literal and qualTypeIsCharStar(qual_type)) {1948 } else if (init_node.tag() == .string_literal and qualTypeIsCharStar(qual_type)) {
1949 const dst_type_node = try transQualType(c, scope, qual_type, loc);1949 const dst_type_node = try transQualType(c, scope, qual_type, loc);
1950 init_node = try removeCVQualifiers(c, dst_type_node, init_node);1950 init_node = try removeCVQualifiers(c, dst_type_node, init_node);
...@@ -2074,11 +2074,11 @@ fn transImplicitCastExpr(...@@ -2074,11 +2074,11 @@ fn transImplicitCastExpr(
2074 return Tag.null_literal.init();2074 return Tag.null_literal.init();
2075 },2075 },
2076 .PointerToBoolean => {2076 .PointerToBoolean => {
2077 // @ptrToInt(val) != 02077 // @intFromPtr(val) != 0
2078 const ptr_node = try transExpr(c, scope, sub_expr, .used);2078 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() });
2082 return maybeSuppressResult(c, result_used, ne);2082 return maybeSuppressResult(c, result_used, ne);
2083 },2083 },
2084 .IntegralToBoolean, .FloatingToBoolean => {2084 .IntegralToBoolean, .FloatingToBoolean => {
...@@ -2334,7 +2334,7 @@ fn transReturnStmt(...@@ -2334,7 +2334,7 @@ fn transReturnStmt(
2334 var rhs = try transExprCoercing(c, scope, val_expr, .used);2334 var rhs = try transExprCoercing(c, scope, val_expr, .used);
2335 const return_qt = scope.findBlockReturnType();2335 const return_qt = scope.findBlockReturnType();
2336 if (isBoolRes(rhs) and !qualTypeIsBoolean(return_qt)) {2336 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);
2338 }2338 }
2339 return Tag.@"return".create(c.arena, rhs);2339 return Tag.@"return".create(c.arena, rhs);
2340}2340}
...@@ -2493,7 +2493,7 @@ fn transCCast(...@@ -2493,7 +2493,7 @@ fn transCCast(
2493 var src_int_expr = expr;2493 var src_int_expr = expr;
24942494
2495 if (isBoolRes(src_int_expr)) {2495 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);
2497 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = src_int_expr });2497 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = src_int_expr });
2498 }2498 }
24992499
...@@ -2521,34 +2521,34 @@ fn transCCast(...@@ -2521,34 +2521,34 @@ fn transCCast(
2521 return Tag.bit_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr });2521 return Tag.bit_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
2522 }2522 }
2523 if (cIsInteger(dst_type) and qualTypeIsPtr(src_type)) {2523 if (cIsInteger(dst_type) and qualTypeIsPtr(src_type)) {
2524 // @intCast(dest_type, @ptrToInt(val))2524 // @intCast(dest_type, @intFromPtr(val))
2525 const ptr_to_int = try Tag.ptr_to_int.create(c.arena, expr);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 = ptr_to_int });2526 return Tag.int_cast.create(c.arena, .{ .lhs = dst_node, .rhs = int_from_ptr });
2527 }2527 }
2528 if (cIsInteger(src_type) and qualTypeIsPtr(dst_type)) {2528 if (cIsInteger(src_type) and qualTypeIsPtr(dst_type)) {
2529 // @intToPtr(dest_type, val)2529 // @ptrFromInt(dest_type, val)
2530 return Tag.int_to_ptr.create(c.arena, .{ .lhs = dst_node, .rhs = expr });2530 return Tag.ptr_from_int.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
2531 }2531 }
2532 if (cIsFloating(src_type) and cIsFloating(dst_type)) {2532 if (cIsFloating(src_type) and cIsFloating(dst_type)) {
2533 // @floatCast(dest_type, val)2533 // @floatCast(dest_type, val)
2534 return Tag.float_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr });2534 return Tag.float_cast.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
2535 }2535 }
2536 if (cIsFloating(src_type) and !cIsFloating(dst_type)) {2536 if (cIsFloating(src_type) and !cIsFloating(dst_type)) {
2537 // @floatToInt(dest_type, val)2537 // @intFromFloat(dest_type, val)
2538 return Tag.float_to_int.create(c.arena, .{ .lhs = dst_node, .rhs = expr });2538 return Tag.int_from_float.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
2539 }2539 }
2540 if (!cIsFloating(src_type) and cIsFloating(dst_type)) {2540 if (!cIsFloating(src_type) and cIsFloating(dst_type)) {
2541 var rhs = expr;2541 var rhs = expr;
2542 if (qualTypeIsBoolean(src_type)) rhs = try Tag.bool_to_int.create(c.arena, expr);2542 if (qualTypeIsBoolean(src_type)) rhs = try Tag.int_from_bool.create(c.arena, expr);
2543 // @intToFloat(dest_type, val)2543 // @floatFromInt(dest_type, val)
2544 return Tag.int_to_float.create(c.arena, .{ .lhs = dst_node, .rhs = rhs });2544 return Tag.float_from_int.create(c.arena, .{ .lhs = dst_node, .rhs = rhs });
2545 }2545 }
2546 if (qualTypeIsBoolean(src_type) and !qualTypeIsBoolean(dst_type)) {2546 if (qualTypeIsBoolean(src_type) and !qualTypeIsBoolean(dst_type)) {
2547 // @boolToInt returns either a comptime_int or a u12547 // @intFromBool returns a u1
2548 // TODO: if dst_type is 1 bit & signed (bitfield) we need @bitCast2548 // TODO: if dst_type is 1 bit & signed (bitfield) we need @bitCast
2549 // instead of @as2549 // instead of @as
2550 const bool_to_int = try Tag.bool_to_int.create(c.arena, expr);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 = bool_to_int });2551 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = int_from_bool });
2552 }2552 }
2553 // @as(dest_type, val)2553 // @as(dest_type, val)
2554 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = expr });2554 return Tag.as.create(c.arena, .{ .lhs = dst_node, .rhs = expr });
...@@ -3642,7 +3642,7 @@ fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result...@@ -3642,7 +3642,7 @@ fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result
3642 if (i < param_count) {3642 if (i < param_count) {
3643 const param_qt = fn_proto.getParamType(@intCast(c_uint, i));3643 const param_qt = fn_proto.getParamType(@intCast(c_uint, i));
3644 if (isBoolRes(arg) and cIsNativeInt(param_qt)) {3644 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);
3646 } else if (arg.tag() == .string_literal and qualTypeIsCharStar(param_qt)) {3646 } else if (arg.tag() == .string_literal and qualTypeIsCharStar(param_qt)) {
3647 const loc = @ptrCast(*const clang.Stmt, stmt).getBeginLoc();3647 const loc = @ptrCast(*const clang.Stmt, stmt).getBeginLoc();
3648 const dst_type_node = try transQualType(c, scope, param_qt, loc);3648 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...@@ -3774,7 +3774,7 @@ fn transUnaryOperator(c: *Context, scope: *Scope, stmt: *const clang.UnaryOperat
3774 const sub_expr_node = try transExpr(c, scope, op_expr, .used);3774 const sub_expr_node = try transExpr(c, scope, op_expr, .used);
3775 const to_negate = if (isBoolRes(sub_expr_node)) blk: {3775 const to_negate = if (isBoolRes(sub_expr_node)) blk: {
3776 const ty_node = try Tag.type.create(c.arena, "c_int");3776 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);
3778 break :blk try Tag.as.create(c.arena, .{ .lhs = ty_node, .rhs = int_node });3778 break :blk try Tag.as.create(c.arena, .{ .lhs = ty_node, .rhs = int_node });
3779 } else sub_expr_node;3779 } else sub_expr_node;
3780 return Tag.negate.create(c.arena, to_negate);3780 return Tag.negate.create(c.arena, to_negate);
...@@ -4028,8 +4028,8 @@ fn transCreateCompoundAssign(...@@ -4028,8 +4028,8 @@ fn transCreateCompoundAssign(
40284028
4029// Casting away const or volatile requires us to use @intToPtr4029// Casting away const or volatile requires us to use @intToPtr
4030fn removeCVQualifiers(c: *Context, dst_type_node: Node, expr: Node) Error!Node {4030fn 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);4031 const int_from_ptr = try Tag.int_from_ptr.create(c.arena, expr);
4032 return Tag.int_to_ptr.create(c.arena, .{ .lhs = dst_type_node, .rhs = ptr_to_int });4032 return Tag.ptr_from_int.create(c.arena, .{ .lhs = dst_type_node, .rhs = int_from_ptr });
4033}4033}
40344034
4035fn transCPtrCast(4035fn transCPtrCast(
...@@ -4132,12 +4132,12 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang...@@ -4132,12 +4132,12 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang
4132 const cond_node = try finishBoolExpr(c, &cond_scope.base, cond_expr.getBeginLoc(), ty, cond_ident, .used);4132 const cond_node = try finishBoolExpr(c, &cond_scope.base, cond_expr.getBeginLoc(), ty, cond_ident, .used);
4133 var then_body = cond_ident;4133 var then_body = cond_ident;
4134 if (!res_is_bool and isBoolRes(init_node)) {4134 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);
4136 }4136 }
41374137
4138 var else_body = try transExpr(c, &block_scope.base, false_expr, .used);4138 var else_body = try transExpr(c, &block_scope.base, false_expr, .used);
4139 if (!res_is_bool and isBoolRes(else_body)) {4139 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);
4141 }4141 }
4142 const if_node = try Tag.@"if".create(c.arena, .{4142 const if_node = try Tag.@"if".create(c.arena, .{
4143 .cond = cond_node,4143 .cond = cond_node,
...@@ -4173,12 +4173,12 @@ fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.Condi...@@ -4173,12 +4173,12 @@ fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.Condi
41734173
4174 var then_body = try transExpr(c, scope, true_expr, used);4174 var then_body = try transExpr(c, scope, true_expr, used);
4175 if (!res_is_bool and isBoolRes(then_body)) {4175 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);
4177 }4177 }
41784178
4179 var else_body = try transExpr(c, scope, false_expr, used);4179 var else_body = try transExpr(c, scope, false_expr, used);
4180 if (!res_is_bool and isBoolRes(else_body)) {4180 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);
4182 }4182 }
41834183
4184 const if_node = try Tag.@"if".create(c.arena, .{4184 const if_node = try Tag.@"if".create(c.arena, .{
...@@ -4556,7 +4556,7 @@ fn transCreateNodeAssign(...@@ -4556,7 +4556,7 @@ fn transCreateNodeAssign(
4556 const lhs_node = try transExpr(c, scope, lhs, .used);4556 const lhs_node = try transExpr(c, scope, lhs, .used);
4557 var rhs_node = try transExprCoercing(c, scope, rhs, .used);4557 var rhs_node = try transExprCoercing(c, scope, rhs, .used);
4558 if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) {4558 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);
4560 }4560 }
4561 return transCreateNodeInfixOp(c, .assign, lhs_node, rhs_node, .used);4561 return transCreateNodeInfixOp(c, .assign, lhs_node, rhs_node, .used);
4562 }4562 }
...@@ -4574,7 +4574,7 @@ fn transCreateNodeAssign(...@@ -4574,7 +4574,7 @@ fn transCreateNodeAssign(
4574 const tmp = try block_scope.reserveMangledName(c, "tmp");4574 const tmp = try block_scope.reserveMangledName(c, "tmp");
4575 var rhs_node = try transExpr(c, &block_scope.base, rhs, .used);4575 var rhs_node = try transExpr(c, &block_scope.base, rhs, .used);
4576 if (!exprIsBooleanType(lhs) and isBoolRes(rhs_node)) {4576 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);
4578 }4578 }
45794579
4580 const tmp_decl = try Tag.var_simple.create(c.arena, .{ .name = tmp, .init = rhs_node });4580 const tmp_decl = try Tag.var_simple.create(c.arena, .{ .name = tmp, .init = rhs_node });
...@@ -6092,7 +6092,7 @@ fn macroBoolToInt(c: *Context, node: Node) !Node {...@@ -6092,7 +6092,7 @@ fn macroBoolToInt(c: *Context, node: Node) !Node {
6092 return node;6092 return node;
6093 }6093 }
60946094
6095 return Tag.bool_to_int.create(c.arena, node);6095 return Tag.int_from_bool.create(c.arena, node);
6096}6096}
60976097
6098fn macroIntToBool(c: *Context, node: Node) !Node {6098fn macroIntToBool(c: *Context, node: Node) !Node {
src/translate_c/ast.zig+35-35
...@@ -128,8 +128,8 @@ pub const Node = extern union {...@@ -128,8 +128,8 @@ pub const Node = extern union {
128 signed_remainder,128 signed_remainder,
129 /// @divTrunc(lhs, rhs)129 /// @divTrunc(lhs, rhs)
130 div_trunc,130 div_trunc,
131 /// @boolToInt(operand)131 /// @intFromBool(operand)
132 bool_to_int,132 int_from_bool,
133 /// @as(lhs, rhs)133 /// @as(lhs, rhs)
134 as,134 as,
135 /// @truncate(lhs, rhs)135 /// @truncate(lhs, rhs)
...@@ -138,14 +138,14 @@ pub const Node = extern union {...@@ -138,14 +138,14 @@ pub const Node = extern union {
138 bit_cast,138 bit_cast,
139 /// @floatCast(lhs, rhs)139 /// @floatCast(lhs, rhs)
140 float_cast,140 float_cast,
141 /// @floatToInt(lhs, rhs)141 /// @intFromFloat(lhs, rhs)
142 float_to_int,142 int_from_float,
143 /// @intToFloat(lhs, rhs)143 /// @floatFromInt(lhs, rhs)
144 int_to_float,144 float_from_int,
145 /// @intToPtr(lhs, rhs)145 /// @ptrFromInt(lhs, rhs)
146 int_to_ptr,146 ptr_from_int,
147 /// @ptrToInt(operand)147 /// @intFromPtr(operand)
148 ptr_to_int,148 int_from_ptr,
149 /// @alignCast(lhs, rhs)149 /// @alignCast(lhs, rhs)
150 align_cast,150 align_cast,
151 /// @ptrCast(lhs, rhs)151 /// @ptrCast(lhs, rhs)
...@@ -263,7 +263,7 @@ pub const Node = extern union {...@@ -263,7 +263,7 @@ pub const Node = extern union {
263 .address_of,263 .address_of,
264 .unwrap,264 .unwrap,
265 .deref,265 .deref,
266 .ptr_to_int,266 .int_from_ptr,
267 .empty_array,267 .empty_array,
268 .while_true,268 .while_true,
269 .if_not_break,269 .if_not_break,
...@@ -271,7 +271,7 @@ pub const Node = extern union {...@@ -271,7 +271,7 @@ pub const Node = extern union {
271 .block_single,271 .block_single,
272 .helpers_sizeof,272 .helpers_sizeof,
273 .std_meta_alignment,273 .std_meta_alignment,
274 .bool_to_int,274 .int_from_bool,
275 .sizeof,275 .sizeof,
276 .alignof,276 .alignof,
277 .typeof,277 .typeof,
...@@ -319,9 +319,9 @@ pub const Node = extern union {...@@ -319,9 +319,9 @@ pub const Node = extern union {
319 .truncate,319 .truncate,
320 .bit_cast,320 .bit_cast,
321 .float_cast,321 .float_cast,
322 .float_to_int,322 .int_from_float,
323 .int_to_float,323 .float_from_int,
324 .int_to_ptr,324 .ptr_from_int,
325 .array_cat,325 .array_cat,
326 .ellipsis3,326 .ellipsis3,
327 .assign,327 .assign,
...@@ -1355,9 +1355,9 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -1355,9 +1355,9 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
1355 const payload = node.castTag(.div_trunc).?.data;1355 const payload = node.castTag(.div_trunc).?.data;
1356 return renderBuiltinCall(c, "@divTrunc", &.{ payload.lhs, payload.rhs });1356 return renderBuiltinCall(c, "@divTrunc", &.{ payload.lhs, payload.rhs });
1357 },1357 },
1358 .bool_to_int => {1358 .int_from_bool => {
1359 const payload = node.castTag(.bool_to_int).?.data;1359 const payload = node.castTag(.int_from_bool).?.data;
1360 return renderBuiltinCall(c, "@boolToInt", &.{payload});1360 return renderBuiltinCall(c, "@intFromBool", &.{payload});
1361 },1361 },
1362 .as => {1362 .as => {
1363 const payload = node.castTag(.as).?.data;1363 const payload = node.castTag(.as).?.data;
...@@ -1375,21 +1375,21 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -1375,21 +1375,21 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
1375 const payload = node.castTag(.float_cast).?.data;1375 const payload = node.castTag(.float_cast).?.data;
1376 return renderBuiltinCall(c, "@floatCast", &.{ payload.lhs, payload.rhs });1376 return renderBuiltinCall(c, "@floatCast", &.{ payload.lhs, payload.rhs });
1377 },1377 },
1378 .float_to_int => {1378 .int_from_float => {
1379 const payload = node.castTag(.float_to_int).?.data;1379 const payload = node.castTag(.int_from_float).?.data;
1380 return renderBuiltinCall(c, "@floatToInt", &.{ payload.lhs, payload.rhs });1380 return renderBuiltinCall(c, "@intFromFloat", &.{ payload.lhs, payload.rhs });
1381 },1381 },
1382 .int_to_float => {1382 .float_from_int => {
1383 const payload = node.castTag(.int_to_float).?.data;1383 const payload = node.castTag(.float_from_int).?.data;
1384 return renderBuiltinCall(c, "@intToFloat", &.{ payload.lhs, payload.rhs });1384 return renderBuiltinCall(c, "@floatFromInt", &.{ payload.lhs, payload.rhs });
1385 },1385 },
1386 .int_to_ptr => {1386 .ptr_from_int => {
1387 const payload = node.castTag(.int_to_ptr).?.data;1387 const payload = node.castTag(.ptr_from_int).?.data;
1388 return renderBuiltinCall(c, "@intToPtr", &.{ payload.lhs, payload.rhs });1388 return renderBuiltinCall(c, "@ptrFromInt", &.{ payload.lhs, payload.rhs });
1389 },1389 },
1390 .ptr_to_int => {1390 .int_from_ptr => {
1391 const payload = node.castTag(.ptr_to_int).?.data;1391 const payload = node.castTag(.int_from_ptr).?.data;
1392 return renderBuiltinCall(c, "@ptrToInt", &.{payload});1392 return renderBuiltinCall(c, "@intFromPtr", &.{payload});
1393 },1393 },
1394 .align_cast => {1394 .align_cast => {
1395 const payload = node.castTag(.align_cast).?.data;1395 const payload = node.castTag(.align_cast).?.data;
...@@ -2326,13 +2326,13 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {...@@ -2326,13 +2326,13 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
2326 .truncate,2326 .truncate,
2327 .bit_cast,2327 .bit_cast,
2328 .float_cast,2328 .float_cast,
2329 .float_to_int,2329 .int_from_float,
2330 .int_to_float,2330 .float_from_int,
2331 .int_to_ptr,2331 .ptr_from_int,
2332 .std_mem_zeroes,2332 .std_mem_zeroes,
2333 .std_math_Log2Int,2333 .std_math_Log2Int,
2334 .log2_int_type,2334 .log2_int_type,
2335 .ptr_to_int,2335 .int_from_ptr,
2336 .sizeof,2336 .sizeof,
2337 .alignof,2337 .alignof,
2338 .typeof,2338 .typeof,
...@@ -2371,7 +2371,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {...@@ -2371,7 +2371,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
2371 .call,2371 .call,
2372 .array_type,2372 .array_type,
2373 .null_sentinel_array_type,2373 .null_sentinel_array_type,
2374 .bool_to_int,2374 .int_from_bool,
2375 .div_exact,2375 .div_exact,
2376 .offset_of,2376 .offset_of,
2377 .shuffle,2377 .shuffle,