| author | |
| committer | |
| log | ca27055cdaa82fc26a8d9f8bf6a71de995adc539 |
| tree | 8a8bf8a5f6848a2c7a55deeecf5a1257fa4ed794 |
| parent | edc842ff18e19d8c07cde1199f72903356fbf77f |
33 files changed, 298 insertions(+), 298 deletions(-)
doc/langref.html.in+6-6| ... | ... | @@ -8977,15 +8977,15 @@ test "integer cast panic" { |
| 8977 | 8977 | </p> |
| 8978 | 8978 | {#header_close#} |
| 8979 | 8979 | |
| 8980 | {#header_open|@maximum#} | |
| 8981 | <pre>{#syntax#}@maximum(a: T, b: T) T{#endsyntax#}</pre> | |
| 8980 | {#header_open|@max#} | |
| 8981 | <pre>{#syntax#}@max(a: T, b: T) T{#endsyntax#}</pre> | |
| 8982 | 8982 | <p> |
| 8983 | 8983 | Returns the maximum value of {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#}. This builtin accepts integers, floats, and vectors of either. In the latter case, the operation is performed element wise. |
| 8984 | 8984 | </p> |
| 8985 | 8985 | <p> |
| 8986 | 8986 | NaNs are handled as follows: if one of the operands of a (pairwise) operation is NaN, the other operand is returned. If both operands are NaN, NaN is returned. |
| 8987 | 8987 | </p> |
| 8988 | {#see_also|@minimum|Vectors#} | |
| 8988 | {#see_also|@min|Vectors#} | |
| 8989 | 8989 | {#header_close#} |
| 8990 | 8990 | |
| 8991 | 8991 | {#header_open|@memcpy#} |
| ... | ... | @@ -9025,15 +9025,15 @@ mem.copy(u8, dest[0..byte_count], source[0..byte_count]);{#endsyntax#}</pre> |
| 9025 | 9025 | mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 9026 | 9026 | {#header_close#} |
| 9027 | 9027 | |
| 9028 | {#header_open|@minimum#} | |
| 9029 | <pre>{#syntax#}@minimum(a: T, b: T) T{#endsyntax#}</pre> | |
| 9028 | {#header_open|@min#} | |
| 9029 | <pre>{#syntax#}@min(a: T, b: T) T{#endsyntax#}</pre> | |
| 9030 | 9030 | <p> |
| 9031 | 9031 | Returns the minimum value of {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#}. This builtin accepts integers, floats, and vectors of either. In the latter case, the operation is performed element wise. |
| 9032 | 9032 | </p> |
| 9033 | 9033 | <p> |
| 9034 | 9034 | NaNs are handled as follows: if one of the operands of a (pairwise) operation is NaN, the other operand is returned. If both operands are NaN, NaN is returned. |
| 9035 | 9035 | </p> |
| 9036 | {#see_also|@maximum|Vectors#} | |
| 9036 | {#see_also|@max|Vectors#} | |
| 9037 | 9037 | {#header_close#} |
| 9038 | 9038 | |
| 9039 | 9039 | {#header_open|@wasmMemorySize#} |
lib/compiler_rt/float_to_int.zig+2-2| ... | ... | @@ -29,9 +29,9 @@ pub inline fn floatToInt(comptime I: type, a: anytype) I { |
| 29 | 29 | switch (@typeInfo(I).Int.signedness) { |
| 30 | 30 | .unsigned => { |
| 31 | 31 | if (negative) return 0; |
| 32 | if (@intCast(c_uint, exponent) >= @minimum(int_bits, max_exp)) return math.maxInt(I); | |
| 32 | if (@intCast(c_uint, exponent) >= @min(int_bits, max_exp)) return math.maxInt(I); | |
| 33 | 33 | }, |
| 34 | .signed => if (@intCast(c_uint, exponent) >= @minimum(int_bits - 1, max_exp)) { | |
| 34 | .signed => if (@intCast(c_uint, exponent) >= @min(int_bits - 1, max_exp)) { | |
| 35 | 35 | return if (negative) math.minInt(I) else math.maxInt(I); |
| 36 | 36 | }, |
| 37 | 37 | } |
lib/docs/main.js+150-150| ... | ... | @@ -456,9 +456,9 @@ var zigAnalysis; |
| 456 | 456 | let lastIsDecl = isDecl(last); |
| 457 | 457 | let lastIsType = isType(last); |
| 458 | 458 | let lastIsContainerType = isContainerType(last); |
| 459 | ||
| 460 | if (lastIsDecl){ | |
| 461 | renderDocTest(last); | |
| 459 | ||
| 460 | if (lastIsDecl) { | |
| 461 | renderDocTest(last); | |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | if (lastIsContainerType) { |
| ... | ... | @@ -487,9 +487,9 @@ var zigAnalysis; |
| 487 | 487 | } |
| 488 | 488 | return renderValue(last); |
| 489 | 489 | } |
| 490 | ||
| 490 | ||
| 491 | 491 | } |
| 492 | ||
| 492 | ||
| 493 | 493 | function renderDocTest(decl) { |
| 494 | 494 | if (!decl.decltest) return; |
| 495 | 495 | const astNode = getAstNode(decl.decltest); |
| ... | ... | @@ -1172,12 +1172,12 @@ var zigAnalysis; |
| 1172 | 1172 | payloadHtml += "intToError"; |
| 1173 | 1173 | break; |
| 1174 | 1174 | } |
| 1175 | case "maximum": { | |
| 1176 | payloadHtml += "maximum"; | |
| 1175 | case "max": { | |
| 1176 | payloadHtml += "max"; | |
| 1177 | 1177 | break; |
| 1178 | 1178 | } |
| 1179 | case "minimum": { | |
| 1180 | payloadHtml += "minimum"; | |
| 1179 | case "min": { | |
| 1180 | payloadHtml += "min"; | |
| 1181 | 1181 | break; |
| 1182 | 1182 | } |
| 1183 | 1183 | case "bit_not": { |
| ... | ... | @@ -2069,7 +2069,7 @@ var zigAnalysis; |
| 2069 | 2069 | if ( |
| 2070 | 2070 | rootIsStd && |
| 2071 | 2071 | typeObj === |
| 2072 | getType(zigAnalysis.packages[zigAnalysis.rootPkg].main) | |
| 2072 | getType(zigAnalysis.packages[zigAnalysis.rootPkg].main) | |
| 2073 | 2073 | ) { |
| 2074 | 2074 | name = "std"; |
| 2075 | 2075 | } else { |
| ... | ... | @@ -2328,7 +2328,7 @@ var zigAnalysis; |
| 2328 | 2328 | function renderSourceFileLink(decl) { |
| 2329 | 2329 | let srcNode = getAstNode(decl.src); |
| 2330 | 2330 | |
| 2331 | return "<a style=\"float: right;\" href=\"" + | |
| 2331 | return "<a style=\"float: right;\" href=\"" + | |
| 2332 | 2332 | sourceFileUrlTemplate.replace("{{file}}", |
| 2333 | 2333 | zigAnalysis.files[srcNode.file]).replace("{{line}}", srcNode.line + 1) + "\">[src]</a>"; |
| 2334 | 2334 | } |
| ... | ... | @@ -2888,12 +2888,12 @@ var zigAnalysis; |
| 2888 | 2888 | let cut = false; |
| 2889 | 2889 | |
| 2890 | 2890 | if (index < 0 || index > 80) { |
| 2891 | if (trimmed_docs.length > 80) { | |
| 2892 | index = 80; | |
| 2893 | cut = true; | |
| 2894 | } else { | |
| 2895 | index = trimmed_docs.length; | |
| 2896 | } | |
| 2891 | if (trimmed_docs.length > 80) { | |
| 2892 | index = 80; | |
| 2893 | cut = true; | |
| 2894 | } else { | |
| 2895 | index = trimmed_docs.length; | |
| 2896 | } | |
| 2897 | 2897 | } |
| 2898 | 2898 | |
| 2899 | 2899 | let slice = trimmed_docs.slice(0, index); |
| ... | ... | @@ -3527,7 +3527,7 @@ var zigAnalysis; |
| 3527 | 3527 | decltest: decl[4], |
| 3528 | 3528 | }; |
| 3529 | 3529 | } |
| 3530 | ||
| 3530 | ||
| 3531 | 3531 | function getAstNode(idx) { |
| 3532 | 3532 | const ast = zigAnalysis.astNodes[idx]; |
| 3533 | 3533 | return { |
| ... | ... | @@ -3541,141 +3541,141 @@ var zigAnalysis; |
| 3541 | 3541 | comptime: ast[7], |
| 3542 | 3542 | }; |
| 3543 | 3543 | } |
| 3544 | ||
| 3545 | function getType(idx){ | |
| 3544 | ||
| 3545 | function getType(idx) { | |
| 3546 | 3546 | const ty = zigAnalysis.types[idx]; |
| 3547 | switch(ty[0]) { | |
| 3548 | default: | |
| 3549 | throw "unhandled type kind!"; | |
| 3550 | case 0: // Unanalyzed | |
| 3551 | throw "unanalyzed type!"; | |
| 3552 | case 1: // Type | |
| 3553 | case 2: // Void | |
| 3554 | case 3: // Bool | |
| 3555 | case 4: // NoReturn | |
| 3556 | case 5: // Int | |
| 3557 | case 6: // Float | |
| 3558 | return { kind: ty[0], name: ty[1]}; | |
| 3559 | case 7: // Pointer | |
| 3560 | return { | |
| 3561 | kind: ty[0], | |
| 3562 | size: ty[1], | |
| 3563 | child: ty[2], | |
| 3564 | sentinel: ty[3], | |
| 3565 | align: ty[4], | |
| 3566 | address_space: ty[5], | |
| 3567 | bit_start: ty[6], | |
| 3568 | host_size: ty[7], | |
| 3569 | is_ref: ty[8], | |
| 3570 | is_allowzero: ty[9], | |
| 3571 | is_mutable: ty[10], | |
| 3572 | is_volatile: ty[11], | |
| 3573 | has_sentinel: ty[12], | |
| 3574 | has_align: ty[13], | |
| 3575 | has_addrspace: ty[14], | |
| 3576 | has_bit_range: ty[15], | |
| 3577 | }; | |
| 3578 | case 8: // Array | |
| 3579 | return { | |
| 3580 | kind: ty[0], | |
| 3581 | len: ty[1], | |
| 3582 | child: ty[2], | |
| 3583 | sentinel: ty[3], | |
| 3584 | }; | |
| 3585 | case 9: // Struct | |
| 3586 | return { | |
| 3587 | kind: ty[0], | |
| 3588 | name: ty[1], | |
| 3589 | src: ty[2], | |
| 3590 | privDecls: ty[3], | |
| 3591 | pubDecls: ty[4], | |
| 3592 | fields: ty[5], | |
| 3593 | line_number: ty[6], | |
| 3594 | outer_decl: ty[7], | |
| 3595 | }; | |
| 3596 | case 10: // ComptimeExpr | |
| 3597 | case 11: // ComptimeFloat | |
| 3598 | case 12: // ComptimeInt | |
| 3599 | case 13: // Undefined | |
| 3600 | case 14: // Null | |
| 3601 | return { kind: ty[0], name: ty[1] }; | |
| 3602 | case 15: // Optional | |
| 3603 | return { | |
| 3604 | kind: ty[0], | |
| 3605 | name: ty[1], | |
| 3606 | child: ty[2], | |
| 3607 | }; | |
| 3608 | case 16: // ErrorUnion | |
| 3609 | return { | |
| 3610 | kind: ty[0], | |
| 3611 | lhs: ty[1], | |
| 3612 | rhs: ty[2], | |
| 3613 | }; | |
| 3614 | case 17: // InferredErrorUnion | |
| 3615 | return { | |
| 3616 | kind: ty[0], | |
| 3617 | payload: ty[1], | |
| 3618 | }; | |
| 3619 | case 18: // ErrorSet | |
| 3620 | return { | |
| 3621 | kind: ty[0], | |
| 3622 | name: ty[1], | |
| 3623 | fields: ty[2], | |
| 3624 | }; | |
| 3625 | case 19: // Enum | |
| 3626 | return { | |
| 3627 | kind: ty[0], | |
| 3628 | name: ty[1], | |
| 3629 | src: ty[2], | |
| 3630 | privDecls: ty[3], | |
| 3631 | pubDecls: ty[4], | |
| 3632 | }; | |
| 3633 | case 20: // Union | |
| 3634 | return { | |
| 3635 | kind: ty[0], | |
| 3636 | name: ty[1], | |
| 3637 | src: ty[2], | |
| 3638 | privDecls: ty[3], | |
| 3639 | pubDecls: ty[4], | |
| 3640 | fields: ty[5], | |
| 3641 | }; | |
| 3642 | case 21: // Fn | |
| 3643 | return { | |
| 3644 | kind: ty[0], | |
| 3645 | name: ty[1], | |
| 3646 | src: ty[2], | |
| 3647 | ret: ty[3], | |
| 3648 | generic_ret: ty[4], | |
| 3649 | params: ty[5], | |
| 3650 | lib_name: ty[6], | |
| 3651 | is_var_args: ty[7], | |
| 3652 | is_inferred_error: ty[8], | |
| 3653 | has_lib_name: ty[9], | |
| 3654 | has_cc: ty[10], | |
| 3655 | cc: ty[11], | |
| 3656 | align: ty[12], | |
| 3657 | has_align: ty[13], | |
| 3658 | is_test: ty[14], | |
| 3659 | is_extern: ty[15], | |
| 3660 | }; | |
| 3661 | case 22: // BoundFn | |
| 3662 | return { kind: ty[0], name: ty[1] }; | |
| 3663 | case 23: // Opaque | |
| 3664 | return { | |
| 3665 | kind: ty[0], | |
| 3666 | name: ty[1], | |
| 3667 | src: ty[2], | |
| 3668 | privDecls: ty[3], | |
| 3669 | pubDecls: ty[4], | |
| 3670 | }; | |
| 3671 | case 24: // Frame | |
| 3672 | case 25: // AnyFrame | |
| 3673 | case 26: // Vector | |
| 3674 | case 27: // EnumLiteral | |
| 3675 | return { kind: ty[0], name: ty[1] }; | |
| 3547 | switch (ty[0]) { | |
| 3548 | default: | |
| 3549 | throw "unhandled type kind!"; | |
| 3550 | case 0: // Unanalyzed | |
| 3551 | throw "unanalyzed type!"; | |
| 3552 | case 1: // Type | |
| 3553 | case 2: // Void | |
| 3554 | case 3: // Bool | |
| 3555 | case 4: // NoReturn | |
| 3556 | case 5: // Int | |
| 3557 | case 6: // Float | |
| 3558 | return { kind: ty[0], name: ty[1] }; | |
| 3559 | case 7: // Pointer | |
| 3560 | return { | |
| 3561 | kind: ty[0], | |
| 3562 | size: ty[1], | |
| 3563 | child: ty[2], | |
| 3564 | sentinel: ty[3], | |
| 3565 | align: ty[4], | |
| 3566 | address_space: ty[5], | |
| 3567 | bit_start: ty[6], | |
| 3568 | host_size: ty[7], | |
| 3569 | is_ref: ty[8], | |
| 3570 | is_allowzero: ty[9], | |
| 3571 | is_mutable: ty[10], | |
| 3572 | is_volatile: ty[11], | |
| 3573 | has_sentinel: ty[12], | |
| 3574 | has_align: ty[13], | |
| 3575 | has_addrspace: ty[14], | |
| 3576 | has_bit_range: ty[15], | |
| 3577 | }; | |
| 3578 | case 8: // Array | |
| 3579 | return { | |
| 3580 | kind: ty[0], | |
| 3581 | len: ty[1], | |
| 3582 | child: ty[2], | |
| 3583 | sentinel: ty[3], | |
| 3584 | }; | |
| 3585 | case 9: // Struct | |
| 3586 | return { | |
| 3587 | kind: ty[0], | |
| 3588 | name: ty[1], | |
| 3589 | src: ty[2], | |
| 3590 | privDecls: ty[3], | |
| 3591 | pubDecls: ty[4], | |
| 3592 | fields: ty[5], | |
| 3593 | line_number: ty[6], | |
| 3594 | outer_decl: ty[7], | |
| 3595 | }; | |
| 3596 | case 10: // ComptimeExpr | |
| 3597 | case 11: // ComptimeFloat | |
| 3598 | case 12: // ComptimeInt | |
| 3599 | case 13: // Undefined | |
| 3600 | case 14: // Null | |
| 3601 | return { kind: ty[0], name: ty[1] }; | |
| 3602 | case 15: // Optional | |
| 3603 | return { | |
| 3604 | kind: ty[0], | |
| 3605 | name: ty[1], | |
| 3606 | child: ty[2], | |
| 3607 | }; | |
| 3608 | case 16: // ErrorUnion | |
| 3609 | return { | |
| 3610 | kind: ty[0], | |
| 3611 | lhs: ty[1], | |
| 3612 | rhs: ty[2], | |
| 3613 | }; | |
| 3614 | case 17: // InferredErrorUnion | |
| 3615 | return { | |
| 3616 | kind: ty[0], | |
| 3617 | payload: ty[1], | |
| 3618 | }; | |
| 3619 | case 18: // ErrorSet | |
| 3620 | return { | |
| 3621 | kind: ty[0], | |
| 3622 | name: ty[1], | |
| 3623 | fields: ty[2], | |
| 3624 | }; | |
| 3625 | case 19: // Enum | |
| 3626 | return { | |
| 3627 | kind: ty[0], | |
| 3628 | name: ty[1], | |
| 3629 | src: ty[2], | |
| 3630 | privDecls: ty[3], | |
| 3631 | pubDecls: ty[4], | |
| 3632 | }; | |
| 3633 | case 20: // Union | |
| 3634 | return { | |
| 3635 | kind: ty[0], | |
| 3636 | name: ty[1], | |
| 3637 | src: ty[2], | |
| 3638 | privDecls: ty[3], | |
| 3639 | pubDecls: ty[4], | |
| 3640 | fields: ty[5], | |
| 3641 | }; | |
| 3642 | case 21: // Fn | |
| 3643 | return { | |
| 3644 | kind: ty[0], | |
| 3645 | name: ty[1], | |
| 3646 | src: ty[2], | |
| 3647 | ret: ty[3], | |
| 3648 | generic_ret: ty[4], | |
| 3649 | params: ty[5], | |
| 3650 | lib_name: ty[6], | |
| 3651 | is_var_args: ty[7], | |
| 3652 | is_inferred_error: ty[8], | |
| 3653 | has_lib_name: ty[9], | |
| 3654 | has_cc: ty[10], | |
| 3655 | cc: ty[11], | |
| 3656 | align: ty[12], | |
| 3657 | has_align: ty[13], | |
| 3658 | is_test: ty[14], | |
| 3659 | is_extern: ty[15], | |
| 3660 | }; | |
| 3661 | case 22: // BoundFn | |
| 3662 | return { kind: ty[0], name: ty[1] }; | |
| 3663 | case 23: // Opaque | |
| 3664 | return { | |
| 3665 | kind: ty[0], | |
| 3666 | name: ty[1], | |
| 3667 | src: ty[2], | |
| 3668 | privDecls: ty[3], | |
| 3669 | pubDecls: ty[4], | |
| 3670 | }; | |
| 3671 | case 24: // Frame | |
| 3672 | case 25: // AnyFrame | |
| 3673 | case 26: // Vector | |
| 3674 | case 27: // EnumLiteral | |
| 3675 | return { kind: ty[0], name: ty[1] }; | |
| 3676 | 3676 | } |
| 3677 | 3677 | } |
| 3678 | ||
| 3678 | ||
| 3679 | 3679 | })(); |
| 3680 | 3680 | |
| 3681 | 3681 |
lib/std/Progress.zig+1-1| ... | ... | @@ -357,7 +357,7 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 357 | 357 | // we possibly wrote previously don't affect whether we truncate the line in `bufWrite`. |
| 358 | 358 | const unprintables = end; |
| 359 | 359 | end = 0; |
| 360 | self.output_buffer_slice = self.output_buffer[unprintables..@minimum(self.output_buffer.len, unprintables + self.max_width.?)]; | |
| 360 | self.output_buffer_slice = self.output_buffer[unprintables..@min(self.output_buffer.len, unprintables + self.max_width.?)]; | |
| 361 | 361 | |
| 362 | 362 | if (!self.done) { |
| 363 | 363 | var need_ellipsis = false; |
lib/std/build/InstallRawStep.zig+1-1| ... | ... | @@ -301,7 +301,7 @@ const HexWriter = struct { |
| 301 | 301 | const row_address = @intCast(u32, segment.physicalAddress + bytes_read); |
| 302 | 302 | |
| 303 | 303 | const remaining = segment.fileSize - bytes_read; |
| 304 | const to_read = @minimum(remaining, MAX_PAYLOAD_LEN); | |
| 304 | const to_read = @min(remaining, MAX_PAYLOAD_LEN); | |
| 305 | 305 | const did_read = try elf_file.preadAll(buf[0..to_read], segment.elfOffset + bytes_read); |
| 306 | 306 | if (did_read < to_read) return error.UnexpectedEOF; |
| 307 | 307 |
lib/std/compress/deflate/decompressor.zig+2-2| ... | ... | @@ -99,8 +99,8 @@ const HuffmanDecoder = struct { |
| 99 | 99 | if (min == 0) { |
| 100 | 100 | min = n; |
| 101 | 101 | } |
| 102 | min = @minimum(n, min); | |
| 103 | max = @maximum(n, max); | |
| 102 | min = @min(n, min); | |
| 103 | max = @max(n, max); | |
| 104 | 104 | count[n] += 1; |
| 105 | 105 | } |
| 106 | 106 |
lib/std/compress/deflate/huffman_code.zig+1-1| ... | ... | @@ -134,7 +134,7 @@ pub const HuffmanEncoder = struct { |
| 134 | 134 | |
| 135 | 135 | // The tree can't have greater depth than n - 1, no matter what. This |
| 136 | 136 | // saves a little bit of work in some small cases |
| 137 | max_bits = @minimum(max_bits, n - 1); | |
| 137 | max_bits = @min(max_bits, n - 1); | |
| 138 | 138 | |
| 139 | 139 | // Create information about each of the levels. |
| 140 | 140 | // A bogus "Level 0" whose sole purpose is so that |
lib/std/debug.zig+1-1| ... | ... | @@ -2087,7 +2087,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize |
| 2087 | 2087 | |
| 2088 | 2088 | const tty_config = detectTTYConfig(); |
| 2089 | 2089 | const stderr = io.getStdErr().writer(); |
| 2090 | const end = @minimum(t.index, size); | |
| 2090 | const end = @min(t.index, size); | |
| 2091 | 2091 | const debug_info = getSelfDebugInfo() catch |err| { |
| 2092 | 2092 | stderr.print( |
| 2093 | 2093 | "Unable to dump stack trace: Unable to open debug info: {s}\n", |
lib/std/heap.zig+2-2| ... | ... | @@ -315,7 +315,7 @@ const PageAllocator = struct { |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | const max_drop_len = alignment - @minimum(alignment, mem.page_size); | |
| 318 | const max_drop_len = alignment - @min(alignment, mem.page_size); | |
| 319 | 319 | const alloc_len = if (max_drop_len <= aligned_len - n) |
| 320 | 320 | aligned_len |
| 321 | 321 | else |
| ... | ... | @@ -554,7 +554,7 @@ const WasmPageAllocator = struct { |
| 554 | 554 | |
| 555 | 555 | fn freePages(start: usize, end: usize) void { |
| 556 | 556 | if (start < extendedOffset()) { |
| 557 | conventional.recycle(start, @minimum(extendedOffset(), end) - start); | |
| 557 | conventional.recycle(start, @min(extendedOffset(), end) - start); | |
| 558 | 558 | } |
| 559 | 559 | if (end > extendedOffset()) { |
| 560 | 560 | var new_end = end; |
lib/std/os.zig+13-13| ... | ... | @@ -642,7 +642,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 642 | 642 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 643 | 643 | else => math.maxInt(isize), |
| 644 | 644 | }; |
| 645 | const adjusted_len = @minimum(max_count, buf.len); | |
| 645 | const adjusted_len = @min(max_count, buf.len); | |
| 646 | 646 | |
| 647 | 647 | while (true) { |
| 648 | 648 | const rc = system.read(fd, buf.ptr, adjusted_len); |
| ... | ... | @@ -771,7 +771,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 771 | 771 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 772 | 772 | else => math.maxInt(isize), |
| 773 | 773 | }; |
| 774 | const adjusted_len = @minimum(max_count, buf.len); | |
| 774 | const adjusted_len = @min(max_count, buf.len); | |
| 775 | 775 | |
| 776 | 776 | const pread_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 777 | 777 | system.pread64 |
| ... | ... | @@ -1027,7 +1027,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 1027 | 1027 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 1028 | 1028 | else => math.maxInt(isize), |
| 1029 | 1029 | }; |
| 1030 | const adjusted_len = @minimum(max_count, bytes.len); | |
| 1030 | const adjusted_len = @min(max_count, bytes.len); | |
| 1031 | 1031 | |
| 1032 | 1032 | while (true) { |
| 1033 | 1033 | const rc = system.write(fd, bytes.ptr, adjusted_len); |
| ... | ... | @@ -1183,7 +1183,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 1183 | 1183 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 1184 | 1184 | else => math.maxInt(isize), |
| 1185 | 1185 | }; |
| 1186 | const adjusted_len = @minimum(max_count, bytes.len); | |
| 1186 | const adjusted_len = @min(max_count, bytes.len); | |
| 1187 | 1187 | |
| 1188 | 1188 | const pwrite_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 1189 | 1189 | system.pwrite64 |
| ... | ... | @@ -6006,8 +6006,8 @@ pub fn sendfile( |
| 6006 | 6006 | } |
| 6007 | 6007 | |
| 6008 | 6008 | // Here we match BSD behavior, making a zero count value send as many bytes as possible. |
| 6009 | const adjusted_count_tmp = if (in_len == 0) max_count else @minimum(in_len, @as(size_t, max_count)); | |
| 6010 | // TODO we should not need this cast; improve return type of @minimum | |
| 6009 | const adjusted_count_tmp = if (in_len == 0) max_count else @min(in_len, @as(size_t, max_count)); | |
| 6010 | // TODO we should not need this cast; improve return type of @min | |
| 6011 | 6011 | const adjusted_count = @intCast(usize, adjusted_count_tmp); |
| 6012 | 6012 | |
| 6013 | 6013 | const sendfile_sym = if (builtin.link_libc) |
| ... | ... | @@ -6091,7 +6091,7 @@ pub fn sendfile( |
| 6091 | 6091 | hdtr = &hdtr_data; |
| 6092 | 6092 | } |
| 6093 | 6093 | |
| 6094 | const adjusted_count = @minimum(in_len, max_count); | |
| 6094 | const adjusted_count = @min(in_len, max_count); | |
| 6095 | 6095 | |
| 6096 | 6096 | while (true) { |
| 6097 | 6097 | var sbytes: off_t = undefined; |
| ... | ... | @@ -6170,8 +6170,8 @@ pub fn sendfile( |
| 6170 | 6170 | hdtr = &hdtr_data; |
| 6171 | 6171 | } |
| 6172 | 6172 | |
| 6173 | const adjusted_count_temporary = @minimum(in_len, @as(u63, max_count)); | |
| 6174 | // TODO we should not need this int cast; improve the return type of `@minimum` | |
| 6173 | const adjusted_count_temporary = @min(in_len, @as(u63, max_count)); | |
| 6174 | // TODO we should not need this int cast; improve the return type of `@min` | |
| 6175 | 6175 | const adjusted_count = @intCast(u63, adjusted_count_temporary); |
| 6176 | 6176 | |
| 6177 | 6177 | while (true) { |
| ... | ... | @@ -6226,8 +6226,8 @@ pub fn sendfile( |
| 6226 | 6226 | rw: { |
| 6227 | 6227 | var buf: [8 * 4096]u8 = undefined; |
| 6228 | 6228 | // Here we match BSD behavior, making a zero count value send as many bytes as possible. |
| 6229 | const adjusted_count_tmp = if (in_len == 0) buf.len else @minimum(buf.len, in_len); | |
| 6230 | // TODO we should not need this cast; improve return type of @minimum | |
| 6229 | const adjusted_count_tmp = if (in_len == 0) buf.len else @min(buf.len, in_len); | |
| 6230 | // TODO we should not need this cast; improve return type of @min | |
| 6231 | 6231 | const adjusted_count = @intCast(usize, adjusted_count_tmp); |
| 6232 | 6232 | const amt_read = try pread(in_fd, buf[0..adjusted_count], in_offset); |
| 6233 | 6233 | if (amt_read == 0) { |
| ... | ... | @@ -6329,7 +6329,7 @@ pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len |
| 6329 | 6329 | } |
| 6330 | 6330 | |
| 6331 | 6331 | var buf: [8 * 4096]u8 = undefined; |
| 6332 | const adjusted_count = @minimum(buf.len, len); | |
| 6332 | const adjusted_count = @min(buf.len, len); | |
| 6333 | 6333 | const amt_read = try pread(fd_in, buf[0..adjusted_count], off_in); |
| 6334 | 6334 | // TODO without @as the line below fails to compile for wasm32-wasi: |
| 6335 | 6335 | // error: integer value 0 cannot be coerced to type 'os.PWriteError!usize' |
| ... | ... | @@ -6493,7 +6493,7 @@ pub fn dn_expand( |
| 6493 | 6493 | const end = msg.ptr + msg.len; |
| 6494 | 6494 | if (p == end or exp_dn.len == 0) return error.InvalidDnsPacket; |
| 6495 | 6495 | var dest = exp_dn.ptr; |
| 6496 | const dend = dest + @minimum(exp_dn.len, 254); | |
| 6496 | const dend = dest + @min(exp_dn.len, 254); | |
| 6497 | 6497 | // detect reference loop using an iteration counter |
| 6498 | 6498 | var i: usize = 0; |
| 6499 | 6499 | while (i < msg.len) : (i += 2) { |
lib/std/simd.zig+3-3| ... | ... | @@ -9,7 +9,7 @@ const builtin = @import("builtin"); |
| 9 | 9 | pub fn suggestVectorSizeForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ?usize { |
| 10 | 10 | // This is guesswork, if you have better suggestions can add it or edit the current here |
| 11 | 11 | // This can run in comptime only, but stage 1 fails at it, stage 2 can understand it |
| 12 | const element_bit_size = @maximum(8, std.math.ceilPowerOfTwo(u16, @bitSizeOf(T)) catch unreachable); | |
| 12 | const element_bit_size = @max(8, std.math.ceilPowerOfTwo(u16, @bitSizeOf(T)) catch unreachable); | |
| 13 | 13 | const vector_bit_size: u16 = blk: { |
| 14 | 14 | if (cpu.arch.isX86()) { |
| 15 | 15 | if (T == bool and std.Target.x86.featureSetHas(.prefer_mask_registers)) return 64; |
| ... | ... | @@ -405,8 +405,8 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a |
| 405 | 405 | .Xor => a ^ b, |
| 406 | 406 | .Add => a + b, |
| 407 | 407 | .Mul => a * b, |
| 408 | .Min => @minimum(a, b), | |
| 409 | .Max => @maximum(a, b), | |
| 408 | .Min => @min(a, b), | |
| 409 | .Max => @max(a, b), | |
| 410 | 410 | }; |
| 411 | 411 | } |
| 412 | 412 | }; |
src/AstGen.zig+6-6| ... | ... | @@ -2451,8 +2451,8 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As |
| 2451 | 2451 | .atomic_rmw, |
| 2452 | 2452 | .mul_add, |
| 2453 | 2453 | .field_parent_ptr, |
| 2454 | .maximum, | |
| 2455 | .minimum, | |
| 2454 | .max, | |
| 2455 | .min, | |
| 2456 | 2456 | .c_import, |
| 2457 | 2457 | .@"resume", |
| 2458 | 2458 | .@"await", |
| ... | ... | @@ -7875,19 +7875,19 @@ fn builtinCall( |
| 7875 | 7875 | return rvalue(gz, rl, result, node); |
| 7876 | 7876 | }, |
| 7877 | 7877 | |
| 7878 | .maximum => { | |
| 7878 | .max => { | |
| 7879 | 7879 | const a = try expr(gz, scope, .none, params[0]); |
| 7880 | 7880 | const b = try expr(gz, scope, .none, params[1]); |
| 7881 | const result = try gz.addPlNode(.maximum, node, Zir.Inst.Bin{ | |
| 7881 | const result = try gz.addPlNode(.max, node, Zir.Inst.Bin{ | |
| 7882 | 7882 | .lhs = a, |
| 7883 | 7883 | .rhs = b, |
| 7884 | 7884 | }); |
| 7885 | 7885 | return rvalue(gz, rl, result, node); |
| 7886 | 7886 | }, |
| 7887 | .minimum => { | |
| 7887 | .min => { | |
| 7888 | 7888 | const a = try expr(gz, scope, .none, params[0]); |
| 7889 | 7889 | const b = try expr(gz, scope, .none, params[1]); |
| 7890 | const result = try gz.addPlNode(.minimum, node, Zir.Inst.Bin{ | |
| 7890 | const result = try gz.addPlNode(.min, node, Zir.Inst.Bin{ | |
| 7891 | 7891 | .lhs = a, |
| 7892 | 7892 | .rhs = b, |
| 7893 | 7893 | }); |
src/Autodoc.zig+2-2| ... | ... | @@ -1349,8 +1349,8 @@ fn walkInstruction( |
| 1349 | 1349 | .frame_type, |
| 1350 | 1350 | .frame_size, |
| 1351 | 1351 | .ptr_to_int, |
| 1352 | .minimum, | |
| 1353 | .maximum, | |
| 1352 | .min, | |
| 1353 | .max, | |
| 1354 | 1354 | .bit_not, |
| 1355 | 1355 | // @check |
| 1356 | 1356 | .clz, |
src/BuiltinFn.zig+6-6| ... | ... | @@ -58,10 +58,10 @@ pub const Tag = enum { |
| 58 | 58 | int_to_error, |
| 59 | 59 | int_to_float, |
| 60 | 60 | int_to_ptr, |
| 61 | maximum, | |
| 61 | max, | |
| 62 | 62 | memcpy, |
| 63 | 63 | memset, |
| 64 | minimum, | |
| 64 | min, | |
| 65 | 65 | wasm_memory_size, |
| 66 | 66 | wasm_memory_grow, |
| 67 | 67 | mod, |
| ... | ... | @@ -556,9 +556,9 @@ pub const list = list: { |
| 556 | 556 | }, |
| 557 | 557 | }, |
| 558 | 558 | .{ |
| 559 | "@maximum", | |
| 559 | "@max", | |
| 560 | 560 | .{ |
| 561 | .tag = .maximum, | |
| 561 | .tag = .max, | |
| 562 | 562 | .param_count = 2, |
| 563 | 563 | }, |
| 564 | 564 | }, |
| ... | ... | @@ -577,9 +577,9 @@ pub const list = list: { |
| 577 | 577 | }, |
| 578 | 578 | }, |
| 579 | 579 | .{ |
| 580 | "@minimum", | |
| 580 | "@min", | |
| 581 | 581 | .{ |
| 582 | .tag = .minimum, | |
| 582 | .tag = .min, | |
| 583 | 583 | .param_count = 2, |
| 584 | 584 | }, |
| 585 | 585 | }, |
src/Module.zig+6-6| ... | ... | @@ -992,7 +992,7 @@ pub const Struct = struct { |
| 992 | 992 | if (field.ty.isAbiInt() and field.ty.intInfo(target).bits >= 128) { |
| 993 | 993 | // The C ABI requires 128 bit integer fields of structs |
| 994 | 994 | // to be 16-bytes aligned. |
| 995 | return @maximum(ty_abi_align, 16); | |
| 995 | return @max(ty_abi_align, 16); | |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | return ty_abi_align; |
| ... | ... | @@ -1326,7 +1326,7 @@ pub const Union = struct { |
| 1326 | 1326 | if (!field.ty.hasRuntimeBits()) continue; |
| 1327 | 1327 | |
| 1328 | 1328 | const field_align = field.normalAlignment(target); |
| 1329 | max_align = @maximum(max_align, field_align); | |
| 1329 | max_align = @max(max_align, field_align); | |
| 1330 | 1330 | } |
| 1331 | 1331 | return max_align; |
| 1332 | 1332 | } |
| ... | ... | @@ -1391,7 +1391,7 @@ pub const Union = struct { |
| 1391 | 1391 | most_aligned_field_size = field_size; |
| 1392 | 1392 | } |
| 1393 | 1393 | } |
| 1394 | payload_align = @maximum(payload_align, 1); | |
| 1394 | payload_align = @max(payload_align, 1); | |
| 1395 | 1395 | if (!have_tag or !u.tag_ty.hasRuntimeBits()) { |
| 1396 | 1396 | return .{ |
| 1397 | 1397 | .abi_size = std.mem.alignForwardGeneric(u64, payload_size, payload_align), |
| ... | ... | @@ -1409,7 +1409,7 @@ pub const Union = struct { |
| 1409 | 1409 | // Put the tag before or after the payload depending on which one's |
| 1410 | 1410 | // alignment is greater. |
| 1411 | 1411 | const tag_size = u.tag_ty.abiSize(target); |
| 1412 | const tag_align = @maximum(1, u.tag_ty.abiAlignment(target)); | |
| 1412 | const tag_align = @max(1, u.tag_ty.abiAlignment(target)); | |
| 1413 | 1413 | var size: u64 = 0; |
| 1414 | 1414 | var padding: u32 = undefined; |
| 1415 | 1415 | if (tag_align >= payload_align) { |
| ... | ... | @@ -1431,7 +1431,7 @@ pub const Union = struct { |
| 1431 | 1431 | } |
| 1432 | 1432 | return .{ |
| 1433 | 1433 | .abi_size = size, |
| 1434 | .abi_align = @maximum(tag_align, payload_align), | |
| 1434 | .abi_align = @max(tag_align, payload_align), | |
| 1435 | 1435 | .most_aligned_field = most_aligned_field, |
| 1436 | 1436 | .most_aligned_field_size = most_aligned_field_size, |
| 1437 | 1437 | .biggest_field = biggest_field, |
| ... | ... | @@ -5492,7 +5492,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air { |
| 5492 | 5492 | .func = func, |
| 5493 | 5493 | .fn_ret_ty = decl.ty.fnReturnType(), |
| 5494 | 5494 | .owner_func = func, |
| 5495 | .branch_quota = @maximum(func.branch_quota, Sema.default_branch_quota), | |
| 5495 | .branch_quota = @max(func.branch_quota, Sema.default_branch_quota), | |
| 5496 | 5496 | }; |
| 5497 | 5497 | defer sema.deinit(); |
| 5498 | 5498 |
src/Sema.zig+10-10| ... | ... | @@ -913,8 +913,8 @@ fn analyzeBodyInner( |
| 913 | 913 | .mod => try sema.zirMod(block, inst), |
| 914 | 914 | .rem => try sema.zirRem(block, inst), |
| 915 | 915 | |
| 916 | .maximum => try sema.zirMinMax(block, inst, .max), | |
| 917 | .minimum => try sema.zirMinMax(block, inst, .min), | |
| 916 | .max => try sema.zirMinMax(block, inst, .max), | |
| 917 | .min => try sema.zirMinMax(block, inst, .min), | |
| 918 | 918 | |
| 919 | 919 | .shl => try sema.zirShl(block, inst, .shl), |
| 920 | 920 | .shl_exact => try sema.zirShl(block, inst, .shl_exact), |
| ... | ... | @@ -3886,9 +3886,9 @@ fn validateUnionInit( |
| 3886 | 3886 | if (block_index > 0 and |
| 3887 | 3887 | field_ptr_air_inst == block.instructions.items[block_index - 1]) |
| 3888 | 3888 | { |
| 3889 | first_block_index = @minimum(first_block_index, block_index - 1); | |
| 3889 | first_block_index = @min(first_block_index, block_index - 1); | |
| 3890 | 3890 | } else { |
| 3891 | first_block_index = @minimum(first_block_index, block_index); | |
| 3891 | first_block_index = @min(first_block_index, block_index); | |
| 3892 | 3892 | } |
| 3893 | 3893 | init_val = try sema.resolveMaybeUndefValAllowVariables(block, init_src, bin_op.rhs); |
| 3894 | 3894 | break; |
| ... | ... | @@ -4097,9 +4097,9 @@ fn validateStructInit( |
| 4097 | 4097 | if (block_index > 0 and |
| 4098 | 4098 | field_ptr_air_inst == block.instructions.items[block_index - 1]) |
| 4099 | 4099 | { |
| 4100 | first_block_index = @minimum(first_block_index, block_index - 1); | |
| 4100 | first_block_index = @min(first_block_index, block_index - 1); | |
| 4101 | 4101 | } else { |
| 4102 | first_block_index = @minimum(first_block_index, block_index); | |
| 4102 | first_block_index = @min(first_block_index, block_index); | |
| 4103 | 4103 | } |
| 4104 | 4104 | if (try sema.resolveMaybeUndefValAllowVariables(block, field_src, bin_op.rhs)) |val| { |
| 4105 | 4105 | field_values[i] = val; |
| ... | ... | @@ -4278,7 +4278,7 @@ fn zirValidateArrayInit( |
| 4278 | 4278 | } |
| 4279 | 4279 | block_index -= 1; |
| 4280 | 4280 | } |
| 4281 | first_block_index = @minimum(first_block_index, block_index); | |
| 4281 | first_block_index = @min(first_block_index, block_index); | |
| 4282 | 4282 | |
| 4283 | 4283 | // If the next instructon is a store with a comptime operand, this element |
| 4284 | 4284 | // is comptime. |
| ... | ... | @@ -4606,7 +4606,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 4606 | 4606 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4607 | 4607 | const src = inst_data.src(); |
| 4608 | 4608 | const quota = @intCast(u32, try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime-known")); |
| 4609 | sema.branch_quota = @maximum(sema.branch_quota, quota); | |
| 4609 | sema.branch_quota = @max(sema.branch_quota, quota); | |
| 4610 | 4610 | } |
| 4611 | 4611 | |
| 4612 | 4612 | fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| ... | ... | @@ -6887,7 +6887,7 @@ fn instantiateGenericCall( |
| 6887 | 6887 | break :callee new_func; |
| 6888 | 6888 | } else gop.key_ptr.*; |
| 6889 | 6889 | |
| 6890 | callee.branch_quota = @maximum(callee.branch_quota, sema.branch_quota); | |
| 6890 | callee.branch_quota = @max(callee.branch_quota, sema.branch_quota); | |
| 6891 | 6891 | |
| 6892 | 6892 | const callee_inst = try sema.analyzeDeclVal(block, func_src, callee.owner_decl); |
| 6893 | 6893 | |
| ... | ... | @@ -20382,7 +20382,7 @@ fn analyzeMinMax( |
| 20382 | 20382 | ) CompileError!Air.Inst.Ref { |
| 20383 | 20383 | const simd_op = try sema.checkSimdBinOp(block, src, lhs, rhs, lhs_src, rhs_src); |
| 20384 | 20384 | |
| 20385 | // TODO @maximum(max_int, undefined) should return max_int | |
| 20385 | // TODO @max(max_int, undefined) should return max_int | |
| 20386 | 20386 | |
| 20387 | 20387 | const runtime_src = if (simd_op.lhs_val) |lhs_val| rs: { |
| 20388 | 20388 | if (lhs_val.isUndef()) return sema.addConstUndef(simd_op.result_ty); |
src/Zir.zig+10-10| ... | ... | @@ -924,12 +924,12 @@ pub const Inst = struct { |
| 924 | 924 | /// Implements the `@memset` builtin. |
| 925 | 925 | /// Uses the `pl_node` union field with payload `Memset`. |
| 926 | 926 | memset, |
| 927 | /// Implements the `@minimum` builtin. | |
| 927 | /// Implements the `@min` builtin. | |
| 928 | 928 | /// Uses the `pl_node` union field with payload `Bin` |
| 929 | minimum, | |
| 930 | /// Implements the `@maximum` builtin. | |
| 929 | min, | |
| 930 | /// Implements the `@max` builtin. | |
| 931 | 931 | /// Uses the `pl_node` union field with payload `Bin` |
| 932 | maximum, | |
| 932 | max, | |
| 933 | 933 | /// Implements the `@cImport` builtin. |
| 934 | 934 | /// Uses the `pl_node` union field with payload `Block`. |
| 935 | 935 | c_import, |
| ... | ... | @@ -1217,10 +1217,10 @@ pub const Inst = struct { |
| 1217 | 1217 | .mul_add, |
| 1218 | 1218 | .builtin_call, |
| 1219 | 1219 | .field_parent_ptr, |
| 1220 | .maximum, | |
| 1220 | .max, | |
| 1221 | 1221 | .memcpy, |
| 1222 | 1222 | .memset, |
| 1223 | .minimum, | |
| 1223 | .min, | |
| 1224 | 1224 | .c_import, |
| 1225 | 1225 | .@"resume", |
| 1226 | 1226 | .@"await", |
| ... | ... | @@ -1502,8 +1502,8 @@ pub const Inst = struct { |
| 1502 | 1502 | .mul_add, |
| 1503 | 1503 | .builtin_call, |
| 1504 | 1504 | .field_parent_ptr, |
| 1505 | .maximum, | |
| 1506 | .minimum, | |
| 1505 | .max, | |
| 1506 | .min, | |
| 1507 | 1507 | .c_import, |
| 1508 | 1508 | .@"resume", |
| 1509 | 1509 | .@"await", |
| ... | ... | @@ -1785,10 +1785,10 @@ pub const Inst = struct { |
| 1785 | 1785 | .mul_add = .pl_node, |
| 1786 | 1786 | .builtin_call = .pl_node, |
| 1787 | 1787 | .field_parent_ptr = .pl_node, |
| 1788 | .maximum = .pl_node, | |
| 1788 | .max = .pl_node, | |
| 1789 | 1789 | .memcpy = .pl_node, |
| 1790 | 1790 | .memset = .pl_node, |
| 1791 | .minimum = .pl_node, | |
| 1791 | .min = .pl_node, | |
| 1792 | 1792 | .c_import = .pl_node, |
| 1793 | 1793 | |
| 1794 | 1794 | .alloc = .un_node, |
src/arch/aarch64/CodeGen.zig+3-3| ... | ... | @@ -418,7 +418,7 @@ fn gen(self: *Self) !void { |
| 418 | 418 | |
| 419 | 419 | const stack_offset = mem.alignForwardGeneric(u32, self.next_stack_offset, ptr_bytes) + ptr_bytes; |
| 420 | 420 | self.next_stack_offset = stack_offset; |
| 421 | self.max_end_stack = @maximum(self.max_end_stack, self.next_stack_offset); | |
| 421 | self.max_end_stack = @max(self.max_end_stack, self.next_stack_offset); | |
| 422 | 422 | |
| 423 | 423 | try self.genSetStack(Type.usize, stack_offset, MCValue{ .register = ret_ptr_reg }); |
| 424 | 424 | self.ret_mcv = MCValue{ .stack_offset = stack_offset }; |
| ... | ... | @@ -885,7 +885,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: u32) !u |
| 885 | 885 | // TODO find a free slot instead of always appending |
| 886 | 886 | const offset = mem.alignForwardGeneric(u32, self.next_stack_offset, abi_align) + abi_size; |
| 887 | 887 | self.next_stack_offset = offset; |
| 888 | self.max_end_stack = @maximum(self.max_end_stack, self.next_stack_offset); | |
| 888 | self.max_end_stack = @max(self.max_end_stack, self.next_stack_offset); | |
| 889 | 889 | try self.stack.putNoClobber(self.gpa, offset, .{ |
| 890 | 890 | .inst = inst, |
| 891 | 891 | .size = abi_size, |
| ... | ... | @@ -3643,7 +3643,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void { |
| 3643 | 3643 | // TODO find a free slot instead of always appending |
| 3644 | 3644 | const offset = mem.alignForwardGeneric(u32, self.next_stack_offset, abi_align) + abi_size; |
| 3645 | 3645 | self.next_stack_offset = offset; |
| 3646 | self.max_end_stack = @maximum(self.max_end_stack, self.next_stack_offset); | |
| 3646 | self.max_end_stack = @max(self.max_end_stack, self.next_stack_offset); | |
| 3647 | 3647 | |
| 3648 | 3648 | const tmp_mcv = MCValue{ .stack_offset = offset }; |
| 3649 | 3649 | try self.load(tmp_mcv, ptr, ptr_ty); |
src/arch/arm/CodeGen.zig+1-1| ... | ... | @@ -895,7 +895,7 @@ fn allocMem( |
| 895 | 895 | // TODO find a free slot instead of always appending |
| 896 | 896 | const offset = mem.alignForwardGeneric(u32, self.next_stack_offset, abi_align) + abi_size; |
| 897 | 897 | self.next_stack_offset = offset; |
| 898 | self.max_end_stack = @maximum(self.max_end_stack, self.next_stack_offset); | |
| 898 | self.max_end_stack = @max(self.max_end_stack, self.next_stack_offset); | |
| 899 | 899 | |
| 900 | 900 | if (maybe_inst) |inst| { |
| 901 | 901 | try self.stack.putNoClobber(self.gpa, offset, .{ |
src/arch/x86_64/CodeGen.zig+2-2| ... | ... | @@ -418,7 +418,7 @@ fn gen(self: *Self) InnerError!void { |
| 418 | 418 | // spill it to stack immediately. |
| 419 | 419 | const stack_offset = mem.alignForwardGeneric(u32, self.next_stack_offset + 8, 8); |
| 420 | 420 | self.next_stack_offset = stack_offset; |
| 421 | self.max_end_stack = @maximum(self.max_end_stack, self.next_stack_offset); | |
| 421 | self.max_end_stack = @max(self.max_end_stack, self.next_stack_offset); | |
| 422 | 422 | |
| 423 | 423 | const ret_reg = abi.getCAbiIntParamRegs(self.target.*)[0]; |
| 424 | 424 | try self.genSetStack(Type.usize, @intCast(i32, stack_offset), MCValue{ .register = ret_reg }, .{}); |
| ... | ... | @@ -884,7 +884,7 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: u32) !u |
| 884 | 884 | // TODO find a free slot instead of always appending |
| 885 | 885 | const offset = mem.alignForwardGeneric(u32, self.next_stack_offset + abi_size, abi_align); |
| 886 | 886 | self.next_stack_offset = offset; |
| 887 | self.max_end_stack = @maximum(self.max_end_stack, self.next_stack_offset); | |
| 887 | self.max_end_stack = @max(self.max_end_stack, self.next_stack_offset); | |
| 888 | 888 | try self.stack.putNoClobber(self.gpa, offset, .{ |
| 889 | 889 | .inst = inst, |
| 890 | 890 | .size = abi_size, |
src/codegen/llvm.zig+13-13| ... | ... | @@ -996,7 +996,7 @@ pub const Object = struct { |
| 996 | 996 | const abi_size = @intCast(c_uint, param_ty.abiSize(target)); |
| 997 | 997 | const int_llvm_ty = dg.context.intType(abi_size * 8); |
| 998 | 998 | const int_ptr_llvm_ty = int_llvm_ty.pointerType(0); |
| 999 | const alignment = @maximum( | |
| 999 | const alignment = @max( | |
| 1000 | 1000 | param_ty.abiAlignment(target), |
| 1001 | 1001 | dg.object.target_data.abiAlignmentOfType(int_llvm_ty), |
| 1002 | 1002 | ); |
| ... | ... | @@ -1032,7 +1032,7 @@ pub const Object = struct { |
| 1032 | 1032 | if (ptr_info.@"align" != 0) { |
| 1033 | 1033 | dg.addArgAttrInt(llvm_func, llvm_arg_i, "align", ptr_info.@"align"); |
| 1034 | 1034 | } else { |
| 1035 | const elem_align = @maximum(ptr_info.pointee_type.abiAlignment(target), 1); | |
| 1035 | const elem_align = @max(ptr_info.pointee_type.abiAlignment(target), 1); | |
| 1036 | 1036 | dg.addArgAttrInt(llvm_func, llvm_arg_i, "align", elem_align); |
| 1037 | 1037 | } |
| 1038 | 1038 | const ptr_param = llvm_func.getParam(llvm_arg_i); |
| ... | ... | @@ -2869,7 +2869,7 @@ pub const DeclGen = struct { |
| 2869 | 2869 | if (field_val.tag() != .unreachable_value) continue; |
| 2870 | 2870 | |
| 2871 | 2871 | const field_align = field_ty.abiAlignment(target); |
| 2872 | big_align = @maximum(big_align, field_align); | |
| 2872 | big_align = @max(big_align, field_align); | |
| 2873 | 2873 | const prev_offset = offset; |
| 2874 | 2874 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 2875 | 2875 | |
| ... | ... | @@ -2935,7 +2935,7 @@ pub const DeclGen = struct { |
| 2935 | 2935 | const field_ty_align = field.ty.abiAlignment(target); |
| 2936 | 2936 | any_underaligned_fields = any_underaligned_fields or |
| 2937 | 2937 | field_align < field_ty_align; |
| 2938 | big_align = @maximum(big_align, field_align); | |
| 2938 | big_align = @max(big_align, field_align); | |
| 2939 | 2939 | const prev_offset = offset; |
| 2940 | 2940 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 2941 | 2941 | |
| ... | ... | @@ -3557,7 +3557,7 @@ pub const DeclGen = struct { |
| 3557 | 3557 | if (!field_ty.hasRuntimeBitsIgnoreComptime()) continue; |
| 3558 | 3558 | |
| 3559 | 3559 | const field_align = field_ty.abiAlignment(target); |
| 3560 | big_align = @maximum(big_align, field_align); | |
| 3560 | big_align = @max(big_align, field_align); | |
| 3561 | 3561 | const prev_offset = offset; |
| 3562 | 3562 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 3563 | 3563 | |
| ... | ... | @@ -3652,7 +3652,7 @@ pub const DeclGen = struct { |
| 3652 | 3652 | if (field.is_comptime or !field.ty.hasRuntimeBits()) continue; |
| 3653 | 3653 | |
| 3654 | 3654 | const field_align = field.alignment(target, struct_obj.layout); |
| 3655 | big_align = @maximum(big_align, field_align); | |
| 3655 | big_align = @max(big_align, field_align); | |
| 3656 | 3656 | const prev_offset = offset; |
| 3657 | 3657 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 3658 | 3658 | |
| ... | ... | @@ -4244,7 +4244,7 @@ pub const DeclGen = struct { |
| 4244 | 4244 | if (ptr_info.@"align" != 0) { |
| 4245 | 4245 | dg.addArgAttrInt(llvm_fn, llvm_arg_i, "align", ptr_info.@"align"); |
| 4246 | 4246 | } else { |
| 4247 | const elem_align = @maximum( | |
| 4247 | const elem_align = @max( | |
| 4248 | 4248 | ptr_info.pointee_type.abiAlignment(target), |
| 4249 | 4249 | 1, |
| 4250 | 4250 | ); |
| ... | ... | @@ -4710,7 +4710,7 @@ pub const FuncGen = struct { |
| 4710 | 4710 | } else { |
| 4711 | 4711 | // LLVM does not allow bitcasting structs so we must allocate |
| 4712 | 4712 | // a local, bitcast its pointer, store, and then load. |
| 4713 | const alignment = @maximum( | |
| 4713 | const alignment = @max( | |
| 4714 | 4714 | param_ty.abiAlignment(target), |
| 4715 | 4715 | self.dg.object.target_data.abiAlignmentOfType(int_llvm_ty), |
| 4716 | 4716 | ); |
| ... | ... | @@ -7778,7 +7778,7 @@ pub const FuncGen = struct { |
| 7778 | 7778 | |
| 7779 | 7779 | if (result_is_ref) { |
| 7780 | 7780 | // Bitcast the result pointer, then store. |
| 7781 | const alignment = @maximum(operand_ty.abiAlignment(target), inst_ty.abiAlignment(target)); | |
| 7781 | const alignment = @max(operand_ty.abiAlignment(target), inst_ty.abiAlignment(target)); | |
| 7782 | 7782 | const result_ptr = self.buildAlloca(llvm_dest_ty, alignment); |
| 7783 | 7783 | const operand_llvm_ty = try self.dg.lowerType(operand_ty); |
| 7784 | 7784 | const casted_ptr = self.builder.buildBitCast(result_ptr, operand_llvm_ty.pointerType(0), ""); |
| ... | ... | @@ -7791,7 +7791,7 @@ pub const FuncGen = struct { |
| 7791 | 7791 | // Both our operand and our result are values, not pointers, |
| 7792 | 7792 | // but LLVM won't let us bitcast struct values. |
| 7793 | 7793 | // Therefore, we store operand to bitcasted alloca, then load for result. |
| 7794 | const alignment = @maximum(operand_ty.abiAlignment(target), inst_ty.abiAlignment(target)); | |
| 7794 | const alignment = @max(operand_ty.abiAlignment(target), inst_ty.abiAlignment(target)); | |
| 7795 | 7795 | const result_ptr = self.buildAlloca(llvm_dest_ty, alignment); |
| 7796 | 7796 | const operand_llvm_ty = try self.dg.lowerType(operand_ty); |
| 7797 | 7797 | const casted_ptr = self.builder.buildBitCast(result_ptr, operand_llvm_ty.pointerType(0), ""); |
| ... | ... | @@ -9444,7 +9444,7 @@ pub const FuncGen = struct { |
| 9444 | 9444 | const elem_llvm_ty = try self.dg.lowerType(info.pointee_type); |
| 9445 | 9445 | if (isByRef(info.pointee_type)) { |
| 9446 | 9446 | const result_align = info.pointee_type.abiAlignment(target); |
| 9447 | const max_align = @maximum(result_align, ptr_alignment); | |
| 9447 | const max_align = @max(result_align, ptr_alignment); | |
| 9448 | 9448 | const result_ptr = self.buildAlloca(elem_llvm_ty, max_align); |
| 9449 | 9449 | const llvm_ptr_u8 = self.context.intType(8).pointerType(0); |
| 9450 | 9450 | const llvm_usize = self.context.intType(Type.usize.intInfo(target).bits); |
| ... | ... | @@ -9995,7 +9995,7 @@ fn llvmFieldIndex( |
| 9995 | 9995 | if (tuple.values[i].tag() != .unreachable_value) continue; |
| 9996 | 9996 | |
| 9997 | 9997 | const field_align = field_ty.abiAlignment(target); |
| 9998 | big_align = @maximum(big_align, field_align); | |
| 9998 | big_align = @max(big_align, field_align); | |
| 9999 | 9999 | const prev_offset = offset; |
| 10000 | 10000 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 10001 | 10001 | |
| ... | ... | @@ -10028,7 +10028,7 @@ fn llvmFieldIndex( |
| 10028 | 10028 | if (field.is_comptime or !field.ty.hasRuntimeBits()) continue; |
| 10029 | 10029 | |
| 10030 | 10030 | const field_align = field.alignment(target, layout); |
| 10031 | big_align = @maximum(big_align, field_align); | |
| 10031 | big_align = @max(big_align, field_align); | |
| 10032 | 10032 | const prev_offset = offset; |
| 10033 | 10033 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 10034 | 10034 |
src/link/Coff.zig+3-3| ... | ... | @@ -609,7 +609,7 @@ fn allocateAtom(self: *Coff, atom: *Atom, new_atom_size: u32, alignment: u32) !u |
| 609 | 609 | self.markRelocsDirtyByAddress(header.virtual_address + needed_size); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | header.virtual_size = @maximum(header.virtual_size, needed_size); | |
| 612 | header.virtual_size = @max(header.virtual_size, needed_size); | |
| 613 | 613 | header.size_of_raw_data = needed_size; |
| 614 | 614 | maybe_last_atom.* = atom; |
| 615 | 615 | } |
| ... | ... | @@ -1657,7 +1657,7 @@ fn writeBaseRelocations(self: *Coff) !void { |
| 1657 | 1657 | try self.growSectionVM(self.reloc_section_index.?, needed_size); |
| 1658 | 1658 | } |
| 1659 | 1659 | } |
| 1660 | header.virtual_size = @maximum(header.virtual_size, needed_size); | |
| 1660 | header.virtual_size = @max(header.virtual_size, needed_size); | |
| 1661 | 1661 | header.size_of_raw_data = needed_size; |
| 1662 | 1662 | |
| 1663 | 1663 | try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data); |
| ... | ... | @@ -1937,7 +1937,7 @@ pub fn padToIdeal(actual_size: anytype) @TypeOf(actual_size) { |
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | fn detectAllocCollision(self: *Coff, start: u32, size: u32) ?u32 { |
| 1940 | const headers_size = @maximum(self.getSizeOfHeaders(), self.page_size); | |
| 1940 | const headers_size = @max(self.getSizeOfHeaders(), self.page_size); | |
| 1941 | 1941 | if (start < headers_size) |
| 1942 | 1942 | return headers_size; |
| 1943 | 1943 |
src/link/Dwarf.zig+1-1| ... | ... | @@ -1898,7 +1898,7 @@ fn writeDbgInfoNopsToArrayList( |
| 1898 | 1898 | next_padding_size: usize, |
| 1899 | 1899 | trailing_zero: bool, |
| 1900 | 1900 | ) Allocator.Error!void { |
| 1901 | try buffer.resize(gpa, @maximum( | |
| 1901 | try buffer.resize(gpa, @max( | |
| 1902 | 1902 | buffer.items.len, |
| 1903 | 1903 | offset + content.len + next_padding_size + 1, |
| 1904 | 1904 | )); |
src/link/MachO.zig+3-3| ... | ... | @@ -3419,7 +3419,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 3419 | 3419 | if (self.header_segment_cmd_index == null) { |
| 3420 | 3420 | // The first __TEXT segment is immovable and covers MachO header and load commands. |
| 3421 | 3421 | self.header_segment_cmd_index = @intCast(u8, self.segments.items.len); |
| 3422 | const ideal_size = @maximum(self.base.options.headerpad_size orelse 0, default_headerpad_size); | |
| 3422 | const ideal_size = @max(self.base.options.headerpad_size orelse 0, default_headerpad_size); | |
| 3423 | 3423 | const needed_size = mem.alignForwardGeneric(u64, padToIdeal(ideal_size), self.page_size); |
| 3424 | 3424 | |
| 3425 | 3425 | log.debug("found __TEXT segment (header-only) free space 0x{x} to 0x{x}", .{ 0, needed_size }); |
| ... | ... | @@ -3647,7 +3647,7 @@ pub fn calcMinHeaderPad(self: *MachO) !u64 { |
| 3647 | 3647 | log.debug("headerpad_max_install_names minimum headerpad size 0x{x}", .{ |
| 3648 | 3648 | min_headerpad_size + @sizeOf(macho.mach_header_64), |
| 3649 | 3649 | }); |
| 3650 | padding = @maximum(padding, min_headerpad_size); | |
| 3650 | padding = @max(padding, min_headerpad_size); | |
| 3651 | 3651 | } |
| 3652 | 3652 | const offset = @sizeOf(macho.mach_header_64) + padding; |
| 3653 | 3653 | log.debug("actual headerpad size 0x{x}", .{offset}); |
| ... | ... | @@ -3980,7 +3980,7 @@ pub fn addAtomToSection(self: *MachO, atom: *Atom) !void { |
| 3980 | 3980 | const aligned_end_addr = mem.alignForwardGeneric(u64, section.header.size, atom_alignment); |
| 3981 | 3981 | const padding = aligned_end_addr - section.header.size; |
| 3982 | 3982 | section.header.size += padding + atom.size; |
| 3983 | section.header.@"align" = @maximum(section.header.@"align", atom.alignment); | |
| 3983 | section.header.@"align" = @max(section.header.@"align", atom.alignment); | |
| 3984 | 3984 | self.sections.set(sect_id, section); |
| 3985 | 3985 | } |
| 3986 | 3986 |
src/link/MachO/dead_strip.zig+1-1| ... | ... | @@ -284,7 +284,7 @@ fn prune(arena: Allocator, alive: std.AutoHashMap(*Atom, void), macho_file: *Mac |
| 284 | 284 | const aligned_end_addr = mem.alignForwardGeneric(u64, section.header.size, atom_alignment); |
| 285 | 285 | const padding = aligned_end_addr - section.header.size; |
| 286 | 286 | section.header.size += padding + atom.size; |
| 287 | section.header.@"align" = @maximum(section.header.@"align", atom.alignment); | |
| 287 | section.header.@"align" = @max(section.header.@"align", atom.alignment); | |
| 288 | 288 | |
| 289 | 289 | if (atom.next) |next| { |
| 290 | 290 | atom = next; |
src/print_zir.zig+2-2| ... | ... | @@ -342,8 +342,8 @@ const Writer = struct { |
| 342 | 342 | .reduce, |
| 343 | 343 | .bitcast, |
| 344 | 344 | .vector_type, |
| 345 | .maximum, | |
| 346 | .minimum, | |
| 345 | .max, | |
| 346 | .min, | |
| 347 | 347 | .elem_ptr_node, |
| 348 | 348 | .elem_val_node, |
| 349 | 349 | .elem_ptr, |
src/stage1/all_types.hpp+2-2| ... | ... | @@ -2996,8 +2996,8 @@ enum IrBinOp { |
| 2996 | 2996 | IrBinOpRemMod, |
| 2997 | 2997 | IrBinOpArrayCat, |
| 2998 | 2998 | IrBinOpArrayMult, |
| 2999 | IrBinOpMaximum, | |
| 3000 | IrBinOpMinimum, | |
| 2999 | IrBinOpMax, | |
| 3000 | IrBinOpMin, | |
| 3001 | 3001 | IrBinOpAddSat, |
| 3002 | 3002 | IrBinOpSubSat, |
| 3003 | 3003 | IrBinOpMultSat, |
src/stage1/astgen.cpp+2-2| ... | ... | @@ -4758,7 +4758,7 @@ static Stage1ZirInst *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, Ast |
| 4758 | 4758 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4759 | 4759 | return arg1_value; |
| 4760 | 4760 | |
| 4761 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpMaximum, arg0_value, arg1_value, true); | |
| 4761 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpMax, arg0_value, arg1_value, true); | |
| 4762 | 4762 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4763 | 4763 | } |
| 4764 | 4764 | case BuiltinFnIdMemcpy: |
| ... | ... | @@ -4813,7 +4813,7 @@ static Stage1ZirInst *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, Ast |
| 4813 | 4813 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4814 | 4814 | return arg1_value; |
| 4815 | 4815 | |
| 4816 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpMinimum, arg0_value, arg1_value, true); | |
| 4816 | Stage1ZirInst *bin_op = ir_build_bin_op(ag, scope, node, IrBinOpMin, arg0_value, arg1_value, true); | |
| 4817 | 4817 | return ir_lval_wrap(ag, scope, bin_op, lval, result_loc); |
| 4818 | 4818 | } |
| 4819 | 4819 | case BuiltinFnIdWasmMemorySize: |
src/stage1/codegen.cpp+6-6| ... | ... | @@ -3590,10 +3590,10 @@ static LLVMValueRef gen_soft_float_bin_op(CodeGen *g, LLVMValueRef op1_value, LL |
| 3590 | 3590 | snprintf(fn_name, sizeof(fn_name), "__ge%sf2", compiler_rt_type_abbrev); |
| 3591 | 3591 | res_icmp = EQ_ONE; |
| 3592 | 3592 | break; |
| 3593 | case IrBinOpMaximum: | |
| 3593 | case IrBinOpMax: | |
| 3594 | 3594 | snprintf(fn_name, sizeof(fn_name), "%sfmax%s", math_float_prefix, math_float_suffix); |
| 3595 | 3595 | break; |
| 3596 | case IrBinOpMinimum: | |
| 3596 | case IrBinOpMin: | |
| 3597 | 3597 | snprintf(fn_name, sizeof(fn_name), "%sfmin%s", math_float_prefix, math_float_suffix); |
| 3598 | 3598 | break; |
| 3599 | 3599 | case IrBinOpMult: |
| ... | ... | @@ -3864,7 +3864,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable, |
| 3864 | 3864 | case IrBinOpRemMod: |
| 3865 | 3865 | return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), |
| 3866 | 3866 | op1_value, op2_value, operand_type, RemKindMod); |
| 3867 | case IrBinOpMaximum: | |
| 3867 | case IrBinOpMax: | |
| 3868 | 3868 | if (scalar_type->id == ZigTypeIdFloat) { |
| 3869 | 3869 | return ZigLLVMBuildMaxNum(g->builder, op1_value, op2_value, ""); |
| 3870 | 3870 | } else if (scalar_type->id == ZigTypeIdInt) { |
| ... | ... | @@ -3876,7 +3876,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable, |
| 3876 | 3876 | } else { |
| 3877 | 3877 | zig_unreachable(); |
| 3878 | 3878 | } |
| 3879 | case IrBinOpMinimum: | |
| 3879 | case IrBinOpMin: | |
| 3880 | 3880 | if (scalar_type->id == ZigTypeIdFloat) { |
| 3881 | 3881 | return ZigLLVMBuildMinNum(g->builder, op1_value, op2_value, ""); |
| 3882 | 3882 | } else if (scalar_type->id == ZigTypeIdInt) { |
| ... | ... | @@ -10182,8 +10182,8 @@ static void define_builtin_fns(CodeGen *g) { |
| 10182 | 10182 | create_builtin_fn(g, BuiltinFnIdWasmMemoryGrow, "wasmMemoryGrow", 2); |
| 10183 | 10183 | create_builtin_fn(g, BuiltinFnIdSrc, "src", 0); |
| 10184 | 10184 | create_builtin_fn(g, BuiltinFnIdReduce, "reduce", 2); |
| 10185 | create_builtin_fn(g, BuiltinFnIdMaximum, "maximum", 2); | |
| 10186 | create_builtin_fn(g, BuiltinFnIdMinimum, "minimum", 2); | |
| 10185 | create_builtin_fn(g, BuiltinFnIdMaximum, "max", 2); | |
| 10186 | create_builtin_fn(g, BuiltinFnIdMinimum, "min", 2); | |
| 10187 | 10187 | create_builtin_fn(g, BuiltinFnIdPrefetch, "prefetch", 2); |
| 10188 | 10188 | create_builtin_fn(g, BuiltinFnIdAddrSpaceCast, "addrSpaceCast", 2); |
| 10189 | 10189 | } |
src/stage1/ir.cpp+6-6| ... | ... | @@ -10072,14 +10072,14 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, Scope *scope, AstNode *s |
| 10072 | 10072 | float_mod(out_val, op1_val, op2_val); |
| 10073 | 10073 | } |
| 10074 | 10074 | break; |
| 10075 | case IrBinOpMaximum: | |
| 10075 | case IrBinOpMax: | |
| 10076 | 10076 | if (is_int) { |
| 10077 | 10077 | bigint_max(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint); |
| 10078 | 10078 | } else { |
| 10079 | 10079 | float_max(out_val, op1_val, op2_val); |
| 10080 | 10080 | } |
| 10081 | 10081 | break; |
| 10082 | case IrBinOpMinimum: | |
| 10082 | case IrBinOpMin: | |
| 10083 | 10083 | if (is_int) { |
| 10084 | 10084 | bigint_min(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint); |
| 10085 | 10085 | } else { |
| ... | ... | @@ -10440,8 +10440,8 @@ static bool ok_float_op(IrBinOp op) { |
| 10440 | 10440 | case IrBinOpRemRem: |
| 10441 | 10441 | case IrBinOpRemMod: |
| 10442 | 10442 | case IrBinOpRemUnspecified: |
| 10443 | case IrBinOpMaximum: | |
| 10444 | case IrBinOpMinimum: | |
| 10443 | case IrBinOpMax: | |
| 10444 | case IrBinOpMin: | |
| 10445 | 10445 | return true; |
| 10446 | 10446 | |
| 10447 | 10447 | case IrBinOpBoolOr: |
| ... | ... | @@ -11451,8 +11451,8 @@ static Stage1AirInst *ir_analyze_instruction_bin_op(IrAnalyze *ira, Stage1ZirIns |
| 11451 | 11451 | case IrBinOpRemUnspecified: |
| 11452 | 11452 | case IrBinOpRemRem: |
| 11453 | 11453 | case IrBinOpRemMod: |
| 11454 | case IrBinOpMaximum: | |
| 11455 | case IrBinOpMinimum: | |
| 11454 | case IrBinOpMax: | |
| 11455 | case IrBinOpMin: | |
| 11456 | 11456 | case IrBinOpAddSat: |
| 11457 | 11457 | case IrBinOpSubSat: |
| 11458 | 11458 | case IrBinOpMultSat: |
src/stage1/ir_print.cpp+4-4| ... | ... | @@ -739,10 +739,10 @@ static const char *ir_bin_op_id_str(IrBinOp op_id) { |
| 739 | 739 | return "++"; |
| 740 | 740 | case IrBinOpArrayMult: |
| 741 | 741 | return "**"; |
| 742 | case IrBinOpMaximum: | |
| 743 | return "@maximum"; | |
| 744 | case IrBinOpMinimum: | |
| 745 | return "@minimum"; | |
| 742 | case IrBinOpMax: | |
| 743 | return "@max"; | |
| 744 | case IrBinOpMin: | |
| 745 | return "@min"; | |
| 746 | 746 | case IrBinOpAddSat: |
| 747 | 747 | return "@addWithSaturation"; |
| 748 | 748 | case IrBinOpSubSat: |
src/type.zig+13-13| ... | ... | @@ -2998,7 +2998,7 @@ pub const Type = extern union { |
| 2998 | 2998 | return child_type.abiAlignmentAdvanced(target, strat); |
| 2999 | 2999 | }, |
| 3000 | 3000 | .lazy => |arena| switch (try child_type.abiAlignmentAdvanced(target, strat)) { |
| 3001 | .scalar => |x| return AbiAlignmentAdvanced{ .scalar = @maximum(x, 1) }, | |
| 3001 | .scalar => |x| return AbiAlignmentAdvanced{ .scalar = @max(x, 1) }, | |
| 3002 | 3002 | .val => return AbiAlignmentAdvanced{ .val = try Value.Tag.lazy_align.create(arena, ty) }, |
| 3003 | 3003 | }, |
| 3004 | 3004 | } |
| ... | ... | @@ -3014,7 +3014,7 @@ pub const Type = extern union { |
| 3014 | 3014 | if (!(try data.payload.hasRuntimeBitsAdvanced(false, sema_kit))) { |
| 3015 | 3015 | return AbiAlignmentAdvanced{ .scalar = code_align }; |
| 3016 | 3016 | } |
| 3017 | return AbiAlignmentAdvanced{ .scalar = @maximum( | |
| 3017 | return AbiAlignmentAdvanced{ .scalar = @max( | |
| 3018 | 3018 | code_align, |
| 3019 | 3019 | (try data.payload.abiAlignmentAdvanced(target, strat)).scalar, |
| 3020 | 3020 | ) }; |
| ... | ... | @@ -3023,7 +3023,7 @@ pub const Type = extern union { |
| 3023 | 3023 | switch (try data.payload.abiAlignmentAdvanced(target, strat)) { |
| 3024 | 3024 | .scalar => |payload_align| { |
| 3025 | 3025 | return AbiAlignmentAdvanced{ |
| 3026 | .scalar = @maximum(code_align, payload_align), | |
| 3026 | .scalar = @max(code_align, payload_align), | |
| 3027 | 3027 | }; |
| 3028 | 3028 | }, |
| 3029 | 3029 | .val => {}, |
| ... | ... | @@ -3077,14 +3077,14 @@ pub const Type = extern union { |
| 3077 | 3077 | .lazy => |arena| return AbiAlignmentAdvanced{ .val = try Value.Tag.lazy_align.create(arena, ty) }, |
| 3078 | 3078 | }, |
| 3079 | 3079 | }; |
| 3080 | big_align = @maximum(big_align, field_align); | |
| 3080 | big_align = @max(big_align, field_align); | |
| 3081 | 3081 | |
| 3082 | 3082 | // This logic is duplicated in Module.Struct.Field.alignment. |
| 3083 | 3083 | if (struct_obj.layout == .Extern or target.ofmt == .c) { |
| 3084 | 3084 | if (field.ty.isAbiInt() and field.ty.intInfo(target).bits >= 128) { |
| 3085 | 3085 | // The C ABI requires 128 bit integer fields of structs |
| 3086 | 3086 | // to be 16-bytes aligned. |
| 3087 | big_align = @maximum(big_align, 16); | |
| 3087 | big_align = @max(big_align, 16); | |
| 3088 | 3088 | } |
| 3089 | 3089 | } |
| 3090 | 3090 | } |
| ... | ... | @@ -3099,7 +3099,7 @@ pub const Type = extern union { |
| 3099 | 3099 | if (val.tag() != .unreachable_value) continue; // comptime field |
| 3100 | 3100 | |
| 3101 | 3101 | switch (try field_ty.abiAlignmentAdvanced(target, strat)) { |
| 3102 | .scalar => |field_align| big_align = @maximum(big_align, field_align), | |
| 3102 | .scalar => |field_align| big_align = @max(big_align, field_align), | |
| 3103 | 3103 | .val => switch (strat) { |
| 3104 | 3104 | .eager => unreachable, // field type alignment not resolved |
| 3105 | 3105 | .sema_kit => unreachable, // passed to abiAlignmentAdvanced above |
| ... | ... | @@ -3194,7 +3194,7 @@ pub const Type = extern union { |
| 3194 | 3194 | .lazy => |arena| return AbiAlignmentAdvanced{ .val = try Value.Tag.lazy_align.create(arena, ty) }, |
| 3195 | 3195 | }, |
| 3196 | 3196 | }; |
| 3197 | max_align = @maximum(max_align, field_align); | |
| 3197 | max_align = @max(max_align, field_align); | |
| 3198 | 3198 | } |
| 3199 | 3199 | return AbiAlignmentAdvanced{ .scalar = max_align }; |
| 3200 | 3200 | } |
| ... | ... | @@ -3565,7 +3565,7 @@ pub const Type = extern union { |
| 3565 | 3565 | } |
| 3566 | 3566 | |
| 3567 | 3567 | fn intAbiAlignment(bits: u16, target: Target) u32 { |
| 3568 | return @minimum( | |
| 3568 | return @min( | |
| 3569 | 3569 | std.math.ceilPowerOfTwoPromote(u16, (bits + 7) / 8), |
| 3570 | 3570 | target.maxIntAlignment(), |
| 3571 | 3571 | ); |
| ... | ... | @@ -3648,7 +3648,7 @@ pub const Type = extern union { |
| 3648 | 3648 | |
| 3649 | 3649 | var size: u64 = 0; |
| 3650 | 3650 | for (union_obj.fields.values()) |field| { |
| 3651 | size = @maximum(size, try bitSizeAdvanced(field.ty, target, sema_kit)); | |
| 3651 | size = @max(size, try bitSizeAdvanced(field.ty, target, sema_kit)); | |
| 3652 | 3652 | } |
| 3653 | 3653 | return size; |
| 3654 | 3654 | }, |
| ... | ... | @@ -5760,7 +5760,7 @@ pub const Type = extern union { |
| 5760 | 5760 | } |
| 5761 | 5761 | |
| 5762 | 5762 | const field_align = field.alignment(it.target, it.struct_obj.layout); |
| 5763 | it.big_align = @maximum(it.big_align, field_align); | |
| 5763 | it.big_align = @max(it.big_align, field_align); | |
| 5764 | 5764 | const field_offset = std.mem.alignForwardGeneric(u64, it.offset, field_align); |
| 5765 | 5765 | it.offset = field_offset + field.ty.abiSize(it.target); |
| 5766 | 5766 | return FieldOffset{ .field = i, .offset = field_offset }; |
| ... | ... | @@ -5789,7 +5789,7 @@ pub const Type = extern union { |
| 5789 | 5789 | return field_offset.offset; |
| 5790 | 5790 | } |
| 5791 | 5791 | |
| 5792 | return std.mem.alignForwardGeneric(u64, it.offset, @maximum(it.big_align, 1)); | |
| 5792 | return std.mem.alignForwardGeneric(u64, it.offset, @max(it.big_align, 1)); | |
| 5793 | 5793 | }, |
| 5794 | 5794 | |
| 5795 | 5795 | .tuple, .anon_struct => { |
| ... | ... | @@ -5807,12 +5807,12 @@ pub const Type = extern union { |
| 5807 | 5807 | } |
| 5808 | 5808 | |
| 5809 | 5809 | const field_align = field_ty.abiAlignment(target); |
| 5810 | big_align = @maximum(big_align, field_align); | |
| 5810 | big_align = @max(big_align, field_align); | |
| 5811 | 5811 | offset = std.mem.alignForwardGeneric(u64, offset, field_align); |
| 5812 | 5812 | if (i == index) return offset; |
| 5813 | 5813 | offset += field_ty.abiSize(target); |
| 5814 | 5814 | } |
| 5815 | offset = std.mem.alignForwardGeneric(u64, offset, @maximum(big_align, 1)); | |
| 5815 | offset = std.mem.alignForwardGeneric(u64, offset, @max(big_align, 1)); | |
| 5816 | 5816 | return offset; |
| 5817 | 5817 | }, |
| 5818 | 5818 |
test/behavior/maximum_minimum.zig+14-14| ... | ... | @@ -4,7 +4,7 @@ const mem = std.mem; |
| 4 | 4 | const expect = std.testing.expect; |
| 5 | 5 | const expectEqual = std.testing.expectEqual; |
| 6 | 6 | |
| 7 | test "@maximum" { | |
| 7 | test "@max" { | |
| 8 | 8 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 9 | 9 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 10 | 10 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| ... | ... | @@ -14,15 +14,15 @@ test "@maximum" { |
| 14 | 14 | fn doTheTest() !void { |
| 15 | 15 | var x: i32 = 10; |
| 16 | 16 | var y: f32 = 0.68; |
| 17 | try expect(@as(i32, 10) == @maximum(@as(i32, -3), x)); | |
| 18 | try expect(@as(f32, 3.2) == @maximum(@as(f32, 3.2), y)); | |
| 17 | try expect(@as(i32, 10) == @max(@as(i32, -3), x)); | |
| 18 | try expect(@as(f32, 3.2) == @max(@as(f32, 3.2), y)); | |
| 19 | 19 | } |
| 20 | 20 | }; |
| 21 | 21 | try S.doTheTest(); |
| 22 | 22 | comptime try S.doTheTest(); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | test "@maximum on vectors" { | |
| 25 | test "@max on vectors" { | |
| 26 | 26 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 27 | 27 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 28 | 28 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| ... | ... | @@ -33,17 +33,17 @@ test "@maximum on vectors" { |
| 33 | 33 | fn doTheTest() !void { |
| 34 | 34 | var a: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; |
| 35 | 35 | var b: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; |
| 36 | var x = @maximum(a, b); | |
| 36 | var x = @max(a, b); | |
| 37 | 37 | try expect(mem.eql(i32, &@as([4]i32, x), &[4]i32{ 2147483647, 2147483647, 30, 40 })); |
| 38 | 38 | |
| 39 | 39 | var c: @Vector(4, f32) = [4]f32{ 0, 0.4, -2.4, 7.8 }; |
| 40 | 40 | var d: @Vector(4, f32) = [4]f32{ -0.23, 0.42, -0.64, 0.9 }; |
| 41 | var y = @maximum(c, d); | |
| 41 | var y = @max(c, d); | |
| 42 | 42 | try expect(mem.eql(f32, &@as([4]f32, y), &[4]f32{ 0, 0.42, -0.64, 7.8 })); |
| 43 | 43 | |
| 44 | 44 | var e: @Vector(2, f32) = [2]f32{ 0, std.math.qnan_f32 }; |
| 45 | 45 | var f: @Vector(2, f32) = [2]f32{ std.math.qnan_f32, 0 }; |
| 46 | var z = @maximum(e, f); | |
| 46 | var z = @max(e, f); | |
| 47 | 47 | try expect(mem.eql(f32, &@as([2]f32, z), &[2]f32{ 0, 0 })); |
| 48 | 48 | } |
| 49 | 49 | }; |
| ... | ... | @@ -51,7 +51,7 @@ test "@maximum on vectors" { |
| 51 | 51 | comptime try S.doTheTest(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | test "@minimum" { | |
| 54 | test "@min" { | |
| 55 | 55 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 56 | 56 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 57 | 57 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| ... | ... | @@ -61,15 +61,15 @@ test "@minimum" { |
| 61 | 61 | fn doTheTest() !void { |
| 62 | 62 | var x: i32 = 10; |
| 63 | 63 | var y: f32 = 0.68; |
| 64 | try expect(@as(i32, -3) == @minimum(@as(i32, -3), x)); | |
| 65 | try expect(@as(f32, 0.68) == @minimum(@as(f32, 3.2), y)); | |
| 64 | try expect(@as(i32, -3) == @min(@as(i32, -3), x)); | |
| 65 | try expect(@as(f32, 0.68) == @min(@as(f32, 3.2), y)); | |
| 66 | 66 | } |
| 67 | 67 | }; |
| 68 | 68 | try S.doTheTest(); |
| 69 | 69 | comptime try S.doTheTest(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | test "@minimum for vectors" { | |
| 72 | test "@min for vectors" { | |
| 73 | 73 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 74 | 74 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 75 | 75 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| ... | ... | @@ -80,17 +80,17 @@ test "@minimum for vectors" { |
| 80 | 80 | fn doTheTest() !void { |
| 81 | 81 | var a: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; |
| 82 | 82 | var b: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; |
| 83 | var x = @minimum(a, b); | |
| 83 | var x = @min(a, b); | |
| 84 | 84 | try expect(mem.eql(i32, &@as([4]i32, x), &[4]i32{ 1, -2, 3, 4 })); |
| 85 | 85 | |
| 86 | 86 | var c: @Vector(4, f32) = [4]f32{ 0, 0.4, -2.4, 7.8 }; |
| 87 | 87 | var d: @Vector(4, f32) = [4]f32{ -0.23, 0.42, -0.64, 0.9 }; |
| 88 | var y = @minimum(c, d); | |
| 88 | var y = @min(c, d); | |
| 89 | 89 | try expect(mem.eql(f32, &@as([4]f32, y), &[4]f32{ -0.23, 0.4, -2.4, 0.9 })); |
| 90 | 90 | |
| 91 | 91 | var e: @Vector(2, f32) = [2]f32{ 0, std.math.qnan_f32 }; |
| 92 | 92 | var f: @Vector(2, f32) = [2]f32{ std.math.qnan_f32, 0 }; |
| 93 | var z = @maximum(e, f); | |
| 93 | var z = @max(e, f); | |
| 94 | 94 | try expect(mem.eql(f32, &@as([2]f32, z), &[2]f32{ 0, 0 })); |
| 95 | 95 | } |
| 96 | 96 | }; |