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