authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-18 14:42:55-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-10-18 14:42:55-04:00
logb120c819dbd15b23cf5392a5d5bdd8d8af18ead0
tree87346d128a1cb6f2e5bc6983d9407676d1429f22
parent4962f36b0fe81a6cec7f2d2200f64255f37dbecd
parent71e0ab4ec7949432cd4d0281f67479d222084507
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #13055 from alichraghi/m2m

all: rename `@maximum` to `@max` and `@minimum` to `@min`

34 files changed, 307 insertions(+), 299 deletions(-)

doc/langref.html.in+6-6
......@@ -8977,15 +8977,15 @@ test "integer cast panic" {
89778977 </p>
89788978 {#header_close#}
89798979
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>
89828982 <p>
89838983 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.
89848984 </p>
89858985 <p>
89868986 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.
89878987 </p>
8988 {#see_also|@minimum|Vectors#}
8988 {#see_also|@min|Vectors#}
89898989 {#header_close#}
89908990
89918991 {#header_open|@memcpy#}
......@@ -9025,15 +9025,15 @@ mem.copy(u8, dest[0..byte_count], source[0..byte_count]);{#endsyntax#}</pre>
90259025mem.set(u8, dest, c);{#endsyntax#}</pre>
90269026 {#header_close#}
90279027
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>
90309030 <p>
90319031 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.
90329032 </p>
90339033 <p>
90349034 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.
90359035 </p>
9036 {#see_also|@maximum|Vectors#}
9036 {#see_also|@max|Vectors#}
90379037 {#header_close#}
90389038
90399039 {#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 {
2929 switch (@typeInfo(I).Int.signedness) {
3030 .unsigned => {
3131 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);
3333 },
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)) {
3535 return if (negative) math.minInt(I) else math.maxInt(I);
3636 },
3737 }
lib/docs/main.js+150-150
......@@ -456,9 +456,9 @@ var zigAnalysis;
456456 let lastIsDecl = isDecl(last);
457457 let lastIsType = isType(last);
458458 let lastIsContainerType = isContainerType(last);
459
460 if (lastIsDecl){
461 renderDocTest(last);
459
460 if (lastIsDecl) {
461 renderDocTest(last);
462462 }
463463
464464 if (lastIsContainerType) {
......@@ -487,9 +487,9 @@ var zigAnalysis;
487487 }
488488 return renderValue(last);
489489 }
490
490
491491 }
492
492
493493 function renderDocTest(decl) {
494494 if (!decl.decltest) return;
495495 const astNode = getAstNode(decl.decltest);
......@@ -1172,12 +1172,12 @@ var zigAnalysis;
11721172 payloadHtml += "intToError";
11731173 break;
11741174 }
1175 case "maximum": {
1176 payloadHtml += "maximum";
1175 case "max": {
1176 payloadHtml += "max";
11771177 break;
11781178 }
1179 case "minimum": {
1180 payloadHtml += "minimum";
1179 case "min": {
1180 payloadHtml += "min";
11811181 break;
11821182 }
11831183 case "bit_not": {
......@@ -2070,7 +2070,7 @@ var zigAnalysis;
20702070 if (
20712071 rootIsStd &&
20722072 typeObj ===
2073 getType(zigAnalysis.packages[zigAnalysis.rootPkg].main)
2073 getType(zigAnalysis.packages[zigAnalysis.rootPkg].main)
20742074 ) {
20752075 name = "std";
20762076 } else {
......@@ -2329,7 +2329,7 @@ var zigAnalysis;
23292329 function renderSourceFileLink(decl) {
23302330 let srcNode = getAstNode(decl.src);
23312331
2332 return "<a style=\"float: right;\" href=\"" +
2332 return "<a style=\"float: right;\" href=\"" +
23332333 sourceFileUrlTemplate.replace("{{file}}",
23342334 zigAnalysis.files[srcNode.file]).replace("{{line}}", srcNode.line + 1) + "\">[src]</a>";
23352335 }
......@@ -2889,12 +2889,12 @@ var zigAnalysis;
28892889 let cut = false;
28902890
28912891 if (index < 0 || index > 80) {
2892 if (trimmed_docs.length > 80) {
2893 index = 80;
2894 cut = true;
2895 } else {
2896 index = trimmed_docs.length;
2897 }
2892 if (trimmed_docs.length > 80) {
2893 index = 80;
2894 cut = true;
2895 } else {
2896 index = trimmed_docs.length;
2897 }
28982898 }
28992899
29002900 let slice = trimmed_docs.slice(0, index);
......@@ -3528,7 +3528,7 @@ var zigAnalysis;
35283528 decltest: decl[4],
35293529 };
35303530 }
3531
3531
35323532 function getAstNode(idx) {
35333533 const ast = zigAnalysis.astNodes[idx];
35343534 return {
......@@ -3542,141 +3542,141 @@ var zigAnalysis;
35423542 comptime: ast[7],
35433543 };
35443544 }
3545
3546 function getType(idx){
3545
3546 function getType(idx) {
35473547 const ty = zigAnalysis.types[idx];
3548 switch(ty[0]) {
3549 default:
3550 throw "unhandled type kind!";
3551 case 0: // Unanalyzed
3552 throw "unanalyzed type!";
3553 case 1: // Type
3554 case 2: // Void
3555 case 3: // Bool
3556 case 4: // NoReturn
3557 case 5: // Int
3558 case 6: // Float
3559 return { kind: ty[0], name: ty[1]};
3560 case 7: // Pointer
3561 return {
3562 kind: ty[0],
3563 size: ty[1],
3564 child: ty[2],
3565 sentinel: ty[3],
3566 align: ty[4],
3567 address_space: ty[5],
3568 bit_start: ty[6],
3569 host_size: ty[7],
3570 is_ref: ty[8],
3571 is_allowzero: ty[9],
3572 is_mutable: ty[10],
3573 is_volatile: ty[11],
3574 has_sentinel: ty[12],
3575 has_align: ty[13],
3576 has_addrspace: ty[14],
3577 has_bit_range: ty[15],
3578 };
3579 case 8: // Array
3580 return {
3581 kind: ty[0],
3582 len: ty[1],
3583 child: ty[2],
3584 sentinel: ty[3],
3585 };
3586 case 9: // Struct
3587 return {
3588 kind: ty[0],
3589 name: ty[1],
3590 src: ty[2],
3591 privDecls: ty[3],
3592 pubDecls: ty[4],
3593 fields: ty[5],
3594 line_number: ty[6],
3595 outer_decl: ty[7],
3596 };
3597 case 10: // ComptimeExpr
3598 case 11: // ComptimeFloat
3599 case 12: // ComptimeInt
3600 case 13: // Undefined
3601 case 14: // Null
3602 return { kind: ty[0], name: ty[1] };
3603 case 15: // Optional
3604 return {
3605 kind: ty[0],
3606 name: ty[1],
3607 child: ty[2],
3608 };
3609 case 16: // ErrorUnion
3610 return {
3611 kind: ty[0],
3612 lhs: ty[1],
3613 rhs: ty[2],
3614 };
3615 case 17: // InferredErrorUnion
3616 return {
3617 kind: ty[0],
3618 payload: ty[1],
3619 };
3620 case 18: // ErrorSet
3621 return {
3622 kind: ty[0],
3623 name: ty[1],
3624 fields: ty[2],
3625 };
3626 case 19: // Enum
3627 return {
3628 kind: ty[0],
3629 name: ty[1],
3630 src: ty[2],
3631 privDecls: ty[3],
3632 pubDecls: ty[4],
3633 };
3634 case 20: // Union
3635 return {
3636 kind: ty[0],
3637 name: ty[1],
3638 src: ty[2],
3639 privDecls: ty[3],
3640 pubDecls: ty[4],
3641 fields: ty[5],
3642 };
3643 case 21: // Fn
3644 return {
3645 kind: ty[0],
3646 name: ty[1],
3647 src: ty[2],
3648 ret: ty[3],
3649 generic_ret: ty[4],
3650 params: ty[5],
3651 lib_name: ty[6],
3652 is_var_args: ty[7],
3653 is_inferred_error: ty[8],
3654 has_lib_name: ty[9],
3655 has_cc: ty[10],
3656 cc: ty[11],
3657 align: ty[12],
3658 has_align: ty[13],
3659 is_test: ty[14],
3660 is_extern: ty[15],
3661 };
3662 case 22: // BoundFn
3663 return { kind: ty[0], name: ty[1] };
3664 case 23: // Opaque
3665 return {
3666 kind: ty[0],
3667 name: ty[1],
3668 src: ty[2],
3669 privDecls: ty[3],
3670 pubDecls: ty[4],
3671 };
3672 case 24: // Frame
3673 case 25: // AnyFrame
3674 case 26: // Vector
3675 case 27: // EnumLiteral
3676 return { kind: ty[0], name: ty[1] };
3548 switch (ty[0]) {
3549 default:
3550 throw "unhandled type kind!";
3551 case 0: // Unanalyzed
3552 throw "unanalyzed type!";
3553 case 1: // Type
3554 case 2: // Void
3555 case 3: // Bool
3556 case 4: // NoReturn
3557 case 5: // Int
3558 case 6: // Float
3559 return { kind: ty[0], name: ty[1] };
3560 case 7: // Pointer
3561 return {
3562 kind: ty[0],
3563 size: ty[1],
3564 child: ty[2],
3565 sentinel: ty[3],
3566 align: ty[4],
3567 address_space: ty[5],
3568 bit_start: ty[6],
3569 host_size: ty[7],
3570 is_ref: ty[8],
3571 is_allowzero: ty[9],
3572 is_mutable: ty[10],
3573 is_volatile: ty[11],
3574 has_sentinel: ty[12],
3575 has_align: ty[13],
3576 has_addrspace: ty[14],
3577 has_bit_range: ty[15],
3578 };
3579 case 8: // Array
3580 return {
3581 kind: ty[0],
3582 len: ty[1],
3583 child: ty[2],
3584 sentinel: ty[3],
3585 };
3586 case 9: // Struct
3587 return {
3588 kind: ty[0],
3589 name: ty[1],
3590 src: ty[2],
3591 privDecls: ty[3],
3592 pubDecls: ty[4],
3593 fields: ty[5],
3594 line_number: ty[6],
3595 outer_decl: ty[7],
3596 };
3597 case 10: // ComptimeExpr
3598 case 11: // ComptimeFloat
3599 case 12: // ComptimeInt
3600 case 13: // Undefined
3601 case 14: // Null
3602 return { kind: ty[0], name: ty[1] };
3603 case 15: // Optional
3604 return {
3605 kind: ty[0],
3606 name: ty[1],
3607 child: ty[2],
3608 };
3609 case 16: // ErrorUnion
3610 return {
3611 kind: ty[0],
3612 lhs: ty[1],
3613 rhs: ty[2],
3614 };
3615 case 17: // InferredErrorUnion
3616 return {
3617 kind: ty[0],
3618 payload: ty[1],
3619 };
3620 case 18: // ErrorSet
3621 return {
3622 kind: ty[0],
3623 name: ty[1],
3624 fields: ty[2],
3625 };
3626 case 19: // Enum
3627 return {
3628 kind: ty[0],
3629 name: ty[1],
3630 src: ty[2],
3631 privDecls: ty[3],
3632 pubDecls: ty[4],
3633 };
3634 case 20: // Union
3635 return {
3636 kind: ty[0],
3637 name: ty[1],
3638 src: ty[2],
3639 privDecls: ty[3],
3640 pubDecls: ty[4],
3641 fields: ty[5],
3642 };
3643 case 21: // Fn
3644 return {
3645 kind: ty[0],
3646 name: ty[1],
3647 src: ty[2],
3648 ret: ty[3],
3649 generic_ret: ty[4],
3650 params: ty[5],
3651 lib_name: ty[6],
3652 is_var_args: ty[7],
3653 is_inferred_error: ty[8],
3654 has_lib_name: ty[9],
3655 has_cc: ty[10],
3656 cc: ty[11],
3657 align: ty[12],
3658 has_align: ty[13],
3659 is_test: ty[14],
3660 is_extern: ty[15],
3661 };
3662 case 22: // BoundFn
3663 return { kind: ty[0], name: ty[1] };
3664 case 23: // Opaque
3665 return {
3666 kind: ty[0],
3667 name: ty[1],
3668 src: ty[2],
3669 privDecls: ty[3],
3670 pubDecls: ty[4],
3671 };
3672 case 24: // Frame
3673 case 25: // AnyFrame
3674 case 26: // Vector
3675 case 27: // EnumLiteral
3676 return { kind: ty[0], name: ty[1] };
36773677 }
36783678 }
3679
3679
36803680})();
36813681
36823682
lib/std/Progress.zig+1-1
......@@ -357,7 +357,7 @@ fn refreshWithHeldLock(self: *Progress) void {
357357 // we possibly wrote previously don't affect whether we truncate the line in `bufWrite`.
358358 const unprintables = end;
359359 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.?)];
361361
362362 if (!self.done) {
363363 var need_ellipsis = false;
lib/std/build/InstallRawStep.zig+1-1
......@@ -301,7 +301,7 @@ const HexWriter = struct {
301301 const row_address = @intCast(u32, segment.physicalAddress + bytes_read);
302302
303303 const remaining = segment.fileSize - bytes_read;
304 const to_read = @minimum(remaining, MAX_PAYLOAD_LEN);
304 const to_read = @min(remaining, MAX_PAYLOAD_LEN);
305305 const did_read = try elf_file.preadAll(buf[0..to_read], segment.elfOffset + bytes_read);
306306 if (did_read < to_read) return error.UnexpectedEOF;
307307
lib/std/compress/deflate/decompressor.zig+2-2
......@@ -99,8 +99,8 @@ const HuffmanDecoder = struct {
9999 if (min == 0) {
100100 min = n;
101101 }
102 min = @minimum(n, min);
103 max = @maximum(n, max);
102 min = @min(n, min);
103 max = @max(n, max);
104104 count[n] += 1;
105105 }
106106
lib/std/compress/deflate/huffman_code.zig+1-1
......@@ -134,7 +134,7 @@ pub const HuffmanEncoder = struct {
134134
135135 // The tree can't have greater depth than n - 1, no matter what. This
136136 // 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);
138138
139139 // Create information about each of the levels.
140140 // 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
20872087
20882088 const tty_config = detectTTYConfig();
20892089 const stderr = io.getStdErr().writer();
2090 const end = @minimum(t.index, size);
2090 const end = @min(t.index, size);
20912091 const debug_info = getSelfDebugInfo() catch |err| {
20922092 stderr.print(
20932093 "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 {
315315 }
316316 }
317317
318 const max_drop_len = alignment - @minimum(alignment, mem.page_size);
318 const max_drop_len = alignment - @min(alignment, mem.page_size);
319319 const alloc_len = if (max_drop_len <= aligned_len - n)
320320 aligned_len
321321 else
......@@ -554,7 +554,7 @@ const WasmPageAllocator = struct {
554554
555555 fn freePages(start: usize, end: usize) void {
556556 if (start < extendedOffset()) {
557 conventional.recycle(start, @minimum(extendedOffset(), end) - start);
557 conventional.recycle(start, @min(extendedOffset(), end) - start);
558558 }
559559 if (end > extendedOffset()) {
560560 var new_end = end;
lib/std/os.zig+13-13
......@@ -642,7 +642,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
642642 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
643643 else => math.maxInt(isize),
644644 };
645 const adjusted_len = @minimum(max_count, buf.len);
645 const adjusted_len = @min(max_count, buf.len);
646646
647647 while (true) {
648648 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 {
771771 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
772772 else => math.maxInt(isize),
773773 };
774 const adjusted_len = @minimum(max_count, buf.len);
774 const adjusted_len = @min(max_count, buf.len);
775775
776776 const pread_sym = if (builtin.os.tag == .linux and builtin.link_libc)
777777 system.pread64
......@@ -1027,7 +1027,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
10271027 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
10281028 else => math.maxInt(isize),
10291029 };
1030 const adjusted_len = @minimum(max_count, bytes.len);
1030 const adjusted_len = @min(max_count, bytes.len);
10311031
10321032 while (true) {
10331033 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 {
11831183 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
11841184 else => math.maxInt(isize),
11851185 };
1186 const adjusted_len = @minimum(max_count, bytes.len);
1186 const adjusted_len = @min(max_count, bytes.len);
11871187
11881188 const pwrite_sym = if (builtin.os.tag == .linux and builtin.link_libc)
11891189 system.pwrite64
......@@ -6006,8 +6006,8 @@ pub fn sendfile(
60066006 }
60076007
60086008 // 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
60116011 const adjusted_count = @intCast(usize, adjusted_count_tmp);
60126012
60136013 const sendfile_sym = if (builtin.link_libc)
......@@ -6091,7 +6091,7 @@ pub fn sendfile(
60916091 hdtr = &hdtr_data;
60926092 }
60936093
6094 const adjusted_count = @minimum(in_len, max_count);
6094 const adjusted_count = @min(in_len, max_count);
60956095
60966096 while (true) {
60976097 var sbytes: off_t = undefined;
......@@ -6170,8 +6170,8 @@ pub fn sendfile(
61706170 hdtr = &hdtr_data;
61716171 }
61726172
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`
61756175 const adjusted_count = @intCast(u63, adjusted_count_temporary);
61766176
61776177 while (true) {
......@@ -6226,8 +6226,8 @@ pub fn sendfile(
62266226 rw: {
62276227 var buf: [8 * 4096]u8 = undefined;
62286228 // 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
62316231 const adjusted_count = @intCast(usize, adjusted_count_tmp);
62326232 const amt_read = try pread(in_fd, buf[0..adjusted_count], in_offset);
62336233 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
63296329 }
63306330
63316331 var buf: [8 * 4096]u8 = undefined;
6332 const adjusted_count = @minimum(buf.len, len);
6332 const adjusted_count = @min(buf.len, len);
63336333 const amt_read = try pread(fd_in, buf[0..adjusted_count], off_in);
63346334 // TODO without @as the line below fails to compile for wasm32-wasi:
63356335 // error: integer value 0 cannot be coerced to type 'os.PWriteError!usize'
......@@ -6493,7 +6493,7 @@ pub fn dn_expand(
64936493 const end = msg.ptr + msg.len;
64946494 if (p == end or exp_dn.len == 0) return error.InvalidDnsPacket;
64956495 var dest = exp_dn.ptr;
6496 const dend = dest + @minimum(exp_dn.len, 254);
6496 const dend = dest + @min(exp_dn.len, 254);
64976497 // detect reference loop using an iteration counter
64986498 var i: usize = 0;
64996499 while (i < msg.len) : (i += 2) {
lib/std/simd.zig+3-3
......@@ -9,7 +9,7 @@ const builtin = @import("builtin");
99pub fn suggestVectorSizeForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ?usize {
1010 // This is guesswork, if you have better suggestions can add it or edit the current here
1111 // 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);
1313 const vector_bit_size: u16 = blk: {
1414 if (cpu.arch.isX86()) {
1515 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
405405 .Xor => a ^ b,
406406 .Add => a + b,
407407 .Mul => a * b,
408 .Min => @minimum(a, b),
409 .Max => @maximum(a, b),
408 .Min => @min(a, b),
409 .Max => @max(a, b),
410410 };
411411 }
412412 };
lib/std/zig/render.zig+9-1
......@@ -1236,7 +1236,15 @@ fn renderBuiltinCall(
12361236) Error!void {
12371237 const token_tags = tree.tokens.items(.tag);
12381238
1239 try renderToken(ais, tree, builtin_token, .none); // @name
1239 // TODO remove before release of 0.11.0
1240 const slice = tree.tokenSlice(builtin_token);
1241 if (mem.eql(u8, slice, "@maximum")) {
1242 try ais.writer().writeAll("@max");
1243 } else if (mem.eql(u8, slice, "@minimum")) {
1244 try ais.writer().writeAll("@min");
1245 } else {
1246 try renderToken(ais, tree, builtin_token, .none); // @name
1247 }
12401248
12411249 if (params.len == 0) {
12421250 try renderToken(ais, tree, builtin_token + 1, .none); // (
src/AstGen.zig+6-6
......@@ -2451,8 +2451,8 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
24512451 .atomic_rmw,
24522452 .mul_add,
24532453 .field_parent_ptr,
2454 .maximum,
2455 .minimum,
2454 .max,
2455 .min,
24562456 .c_import,
24572457 .@"resume",
24582458 .@"await",
......@@ -7875,19 +7875,19 @@ fn builtinCall(
78757875 return rvalue(gz, rl, result, node);
78767876 },
78777877
7878 .maximum => {
7878 .max => {
78797879 const a = try expr(gz, scope, .none, params[0]);
78807880 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{
78827882 .lhs = a,
78837883 .rhs = b,
78847884 });
78857885 return rvalue(gz, rl, result, node);
78867886 },
7887 .minimum => {
7887 .min => {
78887888 const a = try expr(gz, scope, .none, params[0]);
78897889 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{
78917891 .lhs = a,
78927892 .rhs = b,
78937893 });
src/Autodoc.zig+2-2
......@@ -1349,8 +1349,8 @@ fn walkInstruction(
13491349 .frame_type,
13501350 .frame_size,
13511351 .ptr_to_int,
1352 .minimum,
1353 .maximum,
1352 .min,
1353 .max,
13541354 .bit_not,
13551355 // @check
13561356 .clz,
src/BuiltinFn.zig+6-6
......@@ -58,10 +58,10 @@ pub const Tag = enum {
5858 int_to_error,
5959 int_to_float,
6060 int_to_ptr,
61 maximum,
61 max,
6262 memcpy,
6363 memset,
64 minimum,
64 min,
6565 wasm_memory_size,
6666 wasm_memory_grow,
6767 mod,
......@@ -556,9 +556,9 @@ pub const list = list: {
556556 },
557557 },
558558 .{
559 "@maximum",
559 "@max",
560560 .{
561 .tag = .maximum,
561 .tag = .max,
562562 .param_count = 2,
563563 },
564564 },
......@@ -577,9 +577,9 @@ pub const list = list: {
577577 },
578578 },
579579 .{
580 "@minimum",
580 "@min",
581581 .{
582 .tag = .minimum,
582 .tag = .min,
583583 .param_count = 2,
584584 },
585585 },
src/Module.zig+6-6
......@@ -992,7 +992,7 @@ pub const Struct = struct {
992992 if (field.ty.isAbiInt() and field.ty.intInfo(target).bits >= 128) {
993993 // The C ABI requires 128 bit integer fields of structs
994994 // to be 16-bytes aligned.
995 return @maximum(ty_abi_align, 16);
995 return @max(ty_abi_align, 16);
996996 }
997997
998998 return ty_abi_align;
......@@ -1326,7 +1326,7 @@ pub const Union = struct {
13261326 if (!field.ty.hasRuntimeBits()) continue;
13271327
13281328 const field_align = field.normalAlignment(target);
1329 max_align = @maximum(max_align, field_align);
1329 max_align = @max(max_align, field_align);
13301330 }
13311331 return max_align;
13321332 }
......@@ -1391,7 +1391,7 @@ pub const Union = struct {
13911391 most_aligned_field_size = field_size;
13921392 }
13931393 }
1394 payload_align = @maximum(payload_align, 1);
1394 payload_align = @max(payload_align, 1);
13951395 if (!have_tag or !u.tag_ty.hasRuntimeBits()) {
13961396 return .{
13971397 .abi_size = std.mem.alignForwardGeneric(u64, payload_size, payload_align),
......@@ -1409,7 +1409,7 @@ pub const Union = struct {
14091409 // Put the tag before or after the payload depending on which one's
14101410 // alignment is greater.
14111411 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));
14131413 var size: u64 = 0;
14141414 var padding: u32 = undefined;
14151415 if (tag_align >= payload_align) {
......@@ -1431,7 +1431,7 @@ pub const Union = struct {
14311431 }
14321432 return .{
14331433 .abi_size = size,
1434 .abi_align = @maximum(tag_align, payload_align),
1434 .abi_align = @max(tag_align, payload_align),
14351435 .most_aligned_field = most_aligned_field,
14361436 .most_aligned_field_size = most_aligned_field_size,
14371437 .biggest_field = biggest_field,
......@@ -5492,7 +5492,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {
54925492 .func = func,
54935493 .fn_ret_ty = decl.ty.fnReturnType(),
54945494 .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),
54965496 };
54975497 defer sema.deinit();
54985498
src/Sema.zig+10-10
......@@ -913,8 +913,8 @@ fn analyzeBodyInner(
913913 .mod => try sema.zirMod(block, inst),
914914 .rem => try sema.zirRem(block, inst),
915915
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),
918918
919919 .shl => try sema.zirShl(block, inst, .shl),
920920 .shl_exact => try sema.zirShl(block, inst, .shl_exact),
......@@ -3886,9 +3886,9 @@ fn validateUnionInit(
38863886 if (block_index > 0 and
38873887 field_ptr_air_inst == block.instructions.items[block_index - 1])
38883888 {
3889 first_block_index = @minimum(first_block_index, block_index - 1);
3889 first_block_index = @min(first_block_index, block_index - 1);
38903890 } else {
3891 first_block_index = @minimum(first_block_index, block_index);
3891 first_block_index = @min(first_block_index, block_index);
38923892 }
38933893 init_val = try sema.resolveMaybeUndefValAllowVariables(block, init_src, bin_op.rhs);
38943894 break;
......@@ -4097,9 +4097,9 @@ fn validateStructInit(
40974097 if (block_index > 0 and
40984098 field_ptr_air_inst == block.instructions.items[block_index - 1])
40994099 {
4100 first_block_index = @minimum(first_block_index, block_index - 1);
4100 first_block_index = @min(first_block_index, block_index - 1);
41014101 } else {
4102 first_block_index = @minimum(first_block_index, block_index);
4102 first_block_index = @min(first_block_index, block_index);
41034103 }
41044104 if (try sema.resolveMaybeUndefValAllowVariables(block, field_src, bin_op.rhs)) |val| {
41054105 field_values[i] = val;
......@@ -4278,7 +4278,7 @@ fn zirValidateArrayInit(
42784278 }
42794279 block_index -= 1;
42804280 }
4281 first_block_index = @minimum(first_block_index, block_index);
4281 first_block_index = @min(first_block_index, block_index);
42824282
42834283 // If the next instructon is a store with a comptime operand, this element
42844284 // is comptime.
......@@ -4606,7 +4606,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
46064606 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
46074607 const src = inst_data.src();
46084608 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);
46104610}
46114611
46124612fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
......@@ -6887,7 +6887,7 @@ fn instantiateGenericCall(
68876887 break :callee new_func;
68886888 } else gop.key_ptr.*;
68896889
6890 callee.branch_quota = @maximum(callee.branch_quota, sema.branch_quota);
6890 callee.branch_quota = @max(callee.branch_quota, sema.branch_quota);
68916891
68926892 const callee_inst = try sema.analyzeDeclVal(block, func_src, callee.owner_decl);
68936893
......@@ -20396,7 +20396,7 @@ fn analyzeMinMax(
2039620396) CompileError!Air.Inst.Ref {
2039720397 const simd_op = try sema.checkSimdBinOp(block, src, lhs, rhs, lhs_src, rhs_src);
2039820398
20399 // TODO @maximum(max_int, undefined) should return max_int
20399 // TODO @max(max_int, undefined) should return max_int
2040020400
2040120401 const runtime_src = if (simd_op.lhs_val) |lhs_val| rs: {
2040220402 if (lhs_val.isUndef()) return sema.addConstUndef(simd_op.result_ty);
src/Zir.zig+10-10
......@@ -924,12 +924,12 @@ pub const Inst = struct {
924924 /// Implements the `@memset` builtin.
925925 /// Uses the `pl_node` union field with payload `Memset`.
926926 memset,
927 /// Implements the `@minimum` builtin.
927 /// Implements the `@min` builtin.
928928 /// Uses the `pl_node` union field with payload `Bin`
929 minimum,
930 /// Implements the `@maximum` builtin.
929 min,
930 /// Implements the `@max` builtin.
931931 /// Uses the `pl_node` union field with payload `Bin`
932 maximum,
932 max,
933933 /// Implements the `@cImport` builtin.
934934 /// Uses the `pl_node` union field with payload `Block`.
935935 c_import,
......@@ -1217,10 +1217,10 @@ pub const Inst = struct {
12171217 .mul_add,
12181218 .builtin_call,
12191219 .field_parent_ptr,
1220 .maximum,
1220 .max,
12211221 .memcpy,
12221222 .memset,
1223 .minimum,
1223 .min,
12241224 .c_import,
12251225 .@"resume",
12261226 .@"await",
......@@ -1502,8 +1502,8 @@ pub const Inst = struct {
15021502 .mul_add,
15031503 .builtin_call,
15041504 .field_parent_ptr,
1505 .maximum,
1506 .minimum,
1505 .max,
1506 .min,
15071507 .c_import,
15081508 .@"resume",
15091509 .@"await",
......@@ -1785,10 +1785,10 @@ pub const Inst = struct {
17851785 .mul_add = .pl_node,
17861786 .builtin_call = .pl_node,
17871787 .field_parent_ptr = .pl_node,
1788 .maximum = .pl_node,
1788 .max = .pl_node,
17891789 .memcpy = .pl_node,
17901790 .memset = .pl_node,
1791 .minimum = .pl_node,
1791 .min = .pl_node,
17921792 .c_import = .pl_node,
17931793
17941794 .alloc = .un_node,
src/arch/aarch64/CodeGen.zig+3-3
......@@ -418,7 +418,7 @@ fn gen(self: *Self) !void {
418418
419419 const stack_offset = mem.alignForwardGeneric(u32, self.next_stack_offset, ptr_bytes) + ptr_bytes;
420420 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);
422422
423423 try self.genSetStack(Type.usize, stack_offset, MCValue{ .register = ret_ptr_reg });
424424 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
885885 // TODO find a free slot instead of always appending
886886 const offset = mem.alignForwardGeneric(u32, self.next_stack_offset, abi_align) + abi_size;
887887 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);
889889 try self.stack.putNoClobber(self.gpa, offset, .{
890890 .inst = inst,
891891 .size = abi_size,
......@@ -3643,7 +3643,7 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void {
36433643 // TODO find a free slot instead of always appending
36443644 const offset = mem.alignForwardGeneric(u32, self.next_stack_offset, abi_align) + abi_size;
36453645 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);
36473647
36483648 const tmp_mcv = MCValue{ .stack_offset = offset };
36493649 try self.load(tmp_mcv, ptr, ptr_ty);
src/arch/arm/CodeGen.zig+1-1
......@@ -895,7 +895,7 @@ fn allocMem(
895895 // TODO find a free slot instead of always appending
896896 const offset = mem.alignForwardGeneric(u32, self.next_stack_offset, abi_align) + abi_size;
897897 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);
899899
900900 if (maybe_inst) |inst| {
901901 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 {
418418 // spill it to stack immediately.
419419 const stack_offset = mem.alignForwardGeneric(u32, self.next_stack_offset + 8, 8);
420420 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);
422422
423423 const ret_reg = abi.getCAbiIntParamRegs(self.target.*)[0];
424424 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
884884 // TODO find a free slot instead of always appending
885885 const offset = mem.alignForwardGeneric(u32, self.next_stack_offset + abi_size, abi_align);
886886 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);
888888 try self.stack.putNoClobber(self.gpa, offset, .{
889889 .inst = inst,
890890 .size = abi_size,
src/codegen/llvm.zig+13-13
......@@ -996,7 +996,7 @@ pub const Object = struct {
996996 const abi_size = @intCast(c_uint, param_ty.abiSize(target));
997997 const int_llvm_ty = dg.context.intType(abi_size * 8);
998998 const int_ptr_llvm_ty = int_llvm_ty.pointerType(0);
999 const alignment = @maximum(
999 const alignment = @max(
10001000 param_ty.abiAlignment(target),
10011001 dg.object.target_data.abiAlignmentOfType(int_llvm_ty),
10021002 );
......@@ -1032,7 +1032,7 @@ pub const Object = struct {
10321032 if (ptr_info.@"align" != 0) {
10331033 dg.addArgAttrInt(llvm_func, llvm_arg_i, "align", ptr_info.@"align");
10341034 } 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);
10361036 dg.addArgAttrInt(llvm_func, llvm_arg_i, "align", elem_align);
10371037 }
10381038 const ptr_param = llvm_func.getParam(llvm_arg_i);
......@@ -2869,7 +2869,7 @@ pub const DeclGen = struct {
28692869 if (field_val.tag() != .unreachable_value) continue;
28702870
28712871 const field_align = field_ty.abiAlignment(target);
2872 big_align = @maximum(big_align, field_align);
2872 big_align = @max(big_align, field_align);
28732873 const prev_offset = offset;
28742874 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
28752875
......@@ -2935,7 +2935,7 @@ pub const DeclGen = struct {
29352935 const field_ty_align = field.ty.abiAlignment(target);
29362936 any_underaligned_fields = any_underaligned_fields or
29372937 field_align < field_ty_align;
2938 big_align = @maximum(big_align, field_align);
2938 big_align = @max(big_align, field_align);
29392939 const prev_offset = offset;
29402940 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
29412941
......@@ -3557,7 +3557,7 @@ pub const DeclGen = struct {
35573557 if (!field_ty.hasRuntimeBitsIgnoreComptime()) continue;
35583558
35593559 const field_align = field_ty.abiAlignment(target);
3560 big_align = @maximum(big_align, field_align);
3560 big_align = @max(big_align, field_align);
35613561 const prev_offset = offset;
35623562 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
35633563
......@@ -3652,7 +3652,7 @@ pub const DeclGen = struct {
36523652 if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;
36533653
36543654 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);
36563656 const prev_offset = offset;
36573657 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
36583658
......@@ -4244,7 +4244,7 @@ pub const DeclGen = struct {
42444244 if (ptr_info.@"align" != 0) {
42454245 dg.addArgAttrInt(llvm_fn, llvm_arg_i, "align", ptr_info.@"align");
42464246 } else {
4247 const elem_align = @maximum(
4247 const elem_align = @max(
42484248 ptr_info.pointee_type.abiAlignment(target),
42494249 1,
42504250 );
......@@ -4710,7 +4710,7 @@ pub const FuncGen = struct {
47104710 } else {
47114711 // LLVM does not allow bitcasting structs so we must allocate
47124712 // a local, bitcast its pointer, store, and then load.
4713 const alignment = @maximum(
4713 const alignment = @max(
47144714 param_ty.abiAlignment(target),
47154715 self.dg.object.target_data.abiAlignmentOfType(int_llvm_ty),
47164716 );
......@@ -7778,7 +7778,7 @@ pub const FuncGen = struct {
77787778
77797779 if (result_is_ref) {
77807780 // 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));
77827782 const result_ptr = self.buildAlloca(llvm_dest_ty, alignment);
77837783 const operand_llvm_ty = try self.dg.lowerType(operand_ty);
77847784 const casted_ptr = self.builder.buildBitCast(result_ptr, operand_llvm_ty.pointerType(0), "");
......@@ -7791,7 +7791,7 @@ pub const FuncGen = struct {
77917791 // Both our operand and our result are values, not pointers,
77927792 // but LLVM won't let us bitcast struct values.
77937793 // 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));
77957795 const result_ptr = self.buildAlloca(llvm_dest_ty, alignment);
77967796 const operand_llvm_ty = try self.dg.lowerType(operand_ty);
77977797 const casted_ptr = self.builder.buildBitCast(result_ptr, operand_llvm_ty.pointerType(0), "");
......@@ -9444,7 +9444,7 @@ pub const FuncGen = struct {
94449444 const elem_llvm_ty = try self.dg.lowerType(info.pointee_type);
94459445 if (isByRef(info.pointee_type)) {
94469446 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);
94489448 const result_ptr = self.buildAlloca(elem_llvm_ty, max_align);
94499449 const llvm_ptr_u8 = self.context.intType(8).pointerType(0);
94509450 const llvm_usize = self.context.intType(Type.usize.intInfo(target).bits);
......@@ -9995,7 +9995,7 @@ fn llvmFieldIndex(
99959995 if (tuple.values[i].tag() != .unreachable_value) continue;
99969996
99979997 const field_align = field_ty.abiAlignment(target);
9998 big_align = @maximum(big_align, field_align);
9998 big_align = @max(big_align, field_align);
99999999 const prev_offset = offset;
1000010000 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
1000110001
......@@ -10028,7 +10028,7 @@ fn llvmFieldIndex(
1002810028 if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;
1002910029
1003010030 const field_align = field.alignment(target, layout);
10031 big_align = @maximum(big_align, field_align);
10031 big_align = @max(big_align, field_align);
1003210032 const prev_offset = offset;
1003310033 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
1003410034
src/link/Coff.zig+3-3
......@@ -609,7 +609,7 @@ fn allocateAtom(self: *Coff, atom: *Atom, new_atom_size: u32, alignment: u32) !u
609609 self.markRelocsDirtyByAddress(header.virtual_address + needed_size);
610610 }
611611
612 header.virtual_size = @maximum(header.virtual_size, needed_size);
612 header.virtual_size = @max(header.virtual_size, needed_size);
613613 header.size_of_raw_data = needed_size;
614614 maybe_last_atom.* = atom;
615615 }
......@@ -1657,7 +1657,7 @@ fn writeBaseRelocations(self: *Coff) !void {
16571657 try self.growSectionVM(self.reloc_section_index.?, needed_size);
16581658 }
16591659 }
1660 header.virtual_size = @maximum(header.virtual_size, needed_size);
1660 header.virtual_size = @max(header.virtual_size, needed_size);
16611661 header.size_of_raw_data = needed_size;
16621662
16631663 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) {
19371937}
19381938
19391939fn 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);
19411941 if (start < headers_size)
19421942 return headers_size;
19431943
src/link/Dwarf.zig+1-1
......@@ -1898,7 +1898,7 @@ fn writeDbgInfoNopsToArrayList(
18981898 next_padding_size: usize,
18991899 trailing_zero: bool,
19001900) Allocator.Error!void {
1901 try buffer.resize(gpa, @maximum(
1901 try buffer.resize(gpa, @max(
19021902 buffer.items.len,
19031903 offset + content.len + next_padding_size + 1,
19041904 ));
src/link/MachO.zig+3-3
......@@ -3419,7 +3419,7 @@ pub fn populateMissingMetadata(self: *MachO) !void {
34193419 if (self.header_segment_cmd_index == null) {
34203420 // The first __TEXT segment is immovable and covers MachO header and load commands.
34213421 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);
34233423 const needed_size = mem.alignForwardGeneric(u64, padToIdeal(ideal_size), self.page_size);
34243424
34253425 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 {
36473647 log.debug("headerpad_max_install_names minimum headerpad size 0x{x}", .{
36483648 min_headerpad_size + @sizeOf(macho.mach_header_64),
36493649 });
3650 padding = @maximum(padding, min_headerpad_size);
3650 padding = @max(padding, min_headerpad_size);
36513651 }
36523652 const offset = @sizeOf(macho.mach_header_64) + padding;
36533653 log.debug("actual headerpad size 0x{x}", .{offset});
......@@ -3980,7 +3980,7 @@ pub fn addAtomToSection(self: *MachO, atom: *Atom) !void {
39803980 const aligned_end_addr = mem.alignForwardGeneric(u64, section.header.size, atom_alignment);
39813981 const padding = aligned_end_addr - section.header.size;
39823982 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);
39843984 self.sections.set(sect_id, section);
39853985}
39863986
src/link/MachO/dead_strip.zig+1-1
......@@ -284,7 +284,7 @@ fn prune(arena: Allocator, alive: std.AutoHashMap(*Atom, void), macho_file: *Mac
284284 const aligned_end_addr = mem.alignForwardGeneric(u64, section.header.size, atom_alignment);
285285 const padding = aligned_end_addr - section.header.size;
286286 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);
288288
289289 if (atom.next) |next| {
290290 atom = next;
src/print_zir.zig+2-2
......@@ -342,8 +342,8 @@ const Writer = struct {
342342 .reduce,
343343 .bitcast,
344344 .vector_type,
345 .maximum,
346 .minimum,
345 .max,
346 .min,
347347 .elem_ptr_node,
348348 .elem_val_node,
349349 .elem_ptr,
src/stage1/all_types.hpp+2-2
......@@ -2996,8 +2996,8 @@ enum IrBinOp {
29962996 IrBinOpRemMod,
29972997 IrBinOpArrayCat,
29982998 IrBinOpArrayMult,
2999 IrBinOpMaximum,
3000 IrBinOpMinimum,
2999 IrBinOpMax,
3000 IrBinOpMin,
30013001 IrBinOpAddSat,
30023002 IrBinOpSubSat,
30033003 IrBinOpMultSat,
src/stage1/astgen.cpp+2-2
......@@ -4758,7 +4758,7 @@ static Stage1ZirInst *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, Ast
47584758 if (arg1_value == ag->codegen->invalid_inst_src)
47594759 return arg1_value;
47604760
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);
47624762 return ir_lval_wrap(ag, scope, bin_op, lval, result_loc);
47634763 }
47644764 case BuiltinFnIdMemcpy:
......@@ -4813,7 +4813,7 @@ static Stage1ZirInst *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, Ast
48134813 if (arg1_value == ag->codegen->invalid_inst_src)
48144814 return arg1_value;
48154815
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);
48174817 return ir_lval_wrap(ag, scope, bin_op, lval, result_loc);
48184818 }
48194819 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
35903590 snprintf(fn_name, sizeof(fn_name), "__ge%sf2", compiler_rt_type_abbrev);
35913591 res_icmp = EQ_ONE;
35923592 break;
3593 case IrBinOpMaximum:
3593 case IrBinOpMax:
35943594 snprintf(fn_name, sizeof(fn_name), "%sfmax%s", math_float_prefix, math_float_suffix);
35953595 break;
3596 case IrBinOpMinimum:
3596 case IrBinOpMin:
35973597 snprintf(fn_name, sizeof(fn_name), "%sfmin%s", math_float_prefix, math_float_suffix);
35983598 break;
35993599 case IrBinOpMult:
......@@ -3864,7 +3864,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable,
38643864 case IrBinOpRemMod:
38653865 return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
38663866 op1_value, op2_value, operand_type, RemKindMod);
3867 case IrBinOpMaximum:
3867 case IrBinOpMax:
38683868 if (scalar_type->id == ZigTypeIdFloat) {
38693869 return ZigLLVMBuildMaxNum(g->builder, op1_value, op2_value, "");
38703870 } else if (scalar_type->id == ZigTypeIdInt) {
......@@ -3876,7 +3876,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable,
38763876 } else {
38773877 zig_unreachable();
38783878 }
3879 case IrBinOpMinimum:
3879 case IrBinOpMin:
38803880 if (scalar_type->id == ZigTypeIdFloat) {
38813881 return ZigLLVMBuildMinNum(g->builder, op1_value, op2_value, "");
38823882 } else if (scalar_type->id == ZigTypeIdInt) {
......@@ -10182,8 +10182,8 @@ static void define_builtin_fns(CodeGen *g) {
1018210182 create_builtin_fn(g, BuiltinFnIdWasmMemoryGrow, "wasmMemoryGrow", 2);
1018310183 create_builtin_fn(g, BuiltinFnIdSrc, "src", 0);
1018410184 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);
1018710187 create_builtin_fn(g, BuiltinFnIdPrefetch, "prefetch", 2);
1018810188 create_builtin_fn(g, BuiltinFnIdAddrSpaceCast, "addrSpaceCast", 2);
1018910189}
src/stage1/ir.cpp+6-6
......@@ -10072,14 +10072,14 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, Scope *scope, AstNode *s
1007210072 float_mod(out_val, op1_val, op2_val);
1007310073 }
1007410074 break;
10075 case IrBinOpMaximum:
10075 case IrBinOpMax:
1007610076 if (is_int) {
1007710077 bigint_max(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
1007810078 } else {
1007910079 float_max(out_val, op1_val, op2_val);
1008010080 }
1008110081 break;
10082 case IrBinOpMinimum:
10082 case IrBinOpMin:
1008310083 if (is_int) {
1008410084 bigint_min(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
1008510085 } else {
......@@ -10440,8 +10440,8 @@ static bool ok_float_op(IrBinOp op) {
1044010440 case IrBinOpRemRem:
1044110441 case IrBinOpRemMod:
1044210442 case IrBinOpRemUnspecified:
10443 case IrBinOpMaximum:
10444 case IrBinOpMinimum:
10443 case IrBinOpMax:
10444 case IrBinOpMin:
1044510445 return true;
1044610446
1044710447 case IrBinOpBoolOr:
......@@ -11451,8 +11451,8 @@ static Stage1AirInst *ir_analyze_instruction_bin_op(IrAnalyze *ira, Stage1ZirIns
1145111451 case IrBinOpRemUnspecified:
1145211452 case IrBinOpRemRem:
1145311453 case IrBinOpRemMod:
11454 case IrBinOpMaximum:
11455 case IrBinOpMinimum:
11454 case IrBinOpMax:
11455 case IrBinOpMin:
1145611456 case IrBinOpAddSat:
1145711457 case IrBinOpSubSat:
1145811458 case IrBinOpMultSat:
src/stage1/ir_print.cpp+4-4
......@@ -739,10 +739,10 @@ static const char *ir_bin_op_id_str(IrBinOp op_id) {
739739 return "++";
740740 case IrBinOpArrayMult:
741741 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";
746746 case IrBinOpAddSat:
747747 return "@addWithSaturation";
748748 case IrBinOpSubSat:
src/type.zig+13-13
......@@ -2998,7 +2998,7 @@ pub const Type = extern union {
29982998 return child_type.abiAlignmentAdvanced(target, strat);
29992999 },
30003000 .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) },
30023002 .val => return AbiAlignmentAdvanced{ .val = try Value.Tag.lazy_align.create(arena, ty) },
30033003 },
30043004 }
......@@ -3014,7 +3014,7 @@ pub const Type = extern union {
30143014 if (!(try data.payload.hasRuntimeBitsAdvanced(false, sema_kit))) {
30153015 return AbiAlignmentAdvanced{ .scalar = code_align };
30163016 }
3017 return AbiAlignmentAdvanced{ .scalar = @maximum(
3017 return AbiAlignmentAdvanced{ .scalar = @max(
30183018 code_align,
30193019 (try data.payload.abiAlignmentAdvanced(target, strat)).scalar,
30203020 ) };
......@@ -3023,7 +3023,7 @@ pub const Type = extern union {
30233023 switch (try data.payload.abiAlignmentAdvanced(target, strat)) {
30243024 .scalar => |payload_align| {
30253025 return AbiAlignmentAdvanced{
3026 .scalar = @maximum(code_align, payload_align),
3026 .scalar = @max(code_align, payload_align),
30273027 };
30283028 },
30293029 .val => {},
......@@ -3077,14 +3077,14 @@ pub const Type = extern union {
30773077 .lazy => |arena| return AbiAlignmentAdvanced{ .val = try Value.Tag.lazy_align.create(arena, ty) },
30783078 },
30793079 };
3080 big_align = @maximum(big_align, field_align);
3080 big_align = @max(big_align, field_align);
30813081
30823082 // This logic is duplicated in Module.Struct.Field.alignment.
30833083 if (struct_obj.layout == .Extern or target.ofmt == .c) {
30843084 if (field.ty.isAbiInt() and field.ty.intInfo(target).bits >= 128) {
30853085 // The C ABI requires 128 bit integer fields of structs
30863086 // to be 16-bytes aligned.
3087 big_align = @maximum(big_align, 16);
3087 big_align = @max(big_align, 16);
30883088 }
30893089 }
30903090 }
......@@ -3099,7 +3099,7 @@ pub const Type = extern union {
30993099 if (val.tag() != .unreachable_value) continue; // comptime field
31003100
31013101 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),
31033103 .val => switch (strat) {
31043104 .eager => unreachable, // field type alignment not resolved
31053105 .sema_kit => unreachable, // passed to abiAlignmentAdvanced above
......@@ -3194,7 +3194,7 @@ pub const Type = extern union {
31943194 .lazy => |arena| return AbiAlignmentAdvanced{ .val = try Value.Tag.lazy_align.create(arena, ty) },
31953195 },
31963196 };
3197 max_align = @maximum(max_align, field_align);
3197 max_align = @max(max_align, field_align);
31983198 }
31993199 return AbiAlignmentAdvanced{ .scalar = max_align };
32003200 }
......@@ -3565,7 +3565,7 @@ pub const Type = extern union {
35653565 }
35663566
35673567 fn intAbiAlignment(bits: u16, target: Target) u32 {
3568 return @minimum(
3568 return @min(
35693569 std.math.ceilPowerOfTwoPromote(u16, (bits + 7) / 8),
35703570 target.maxIntAlignment(),
35713571 );
......@@ -3648,7 +3648,7 @@ pub const Type = extern union {
36483648
36493649 var size: u64 = 0;
36503650 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));
36523652 }
36533653 return size;
36543654 },
......@@ -5760,7 +5760,7 @@ pub const Type = extern union {
57605760 }
57615761
57625762 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);
57645764 const field_offset = std.mem.alignForwardGeneric(u64, it.offset, field_align);
57655765 it.offset = field_offset + field.ty.abiSize(it.target);
57665766 return FieldOffset{ .field = i, .offset = field_offset };
......@@ -5789,7 +5789,7 @@ pub const Type = extern union {
57895789 return field_offset.offset;
57905790 }
57915791
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));
57935793 },
57945794
57955795 .tuple, .anon_struct => {
......@@ -5807,12 +5807,12 @@ pub const Type = extern union {
58075807 }
58085808
58095809 const field_align = field_ty.abiAlignment(target);
5810 big_align = @maximum(big_align, field_align);
5810 big_align = @max(big_align, field_align);
58115811 offset = std.mem.alignForwardGeneric(u64, offset, field_align);
58125812 if (i == index) return offset;
58135813 offset += field_ty.abiSize(target);
58145814 }
5815 offset = std.mem.alignForwardGeneric(u64, offset, @maximum(big_align, 1));
5815 offset = std.mem.alignForwardGeneric(u64, offset, @max(big_align, 1));
58165816 return offset;
58175817 },
58185818
test/behavior/maximum_minimum.zig+14-14
......@@ -4,7 +4,7 @@ const mem = std.mem;
44const expect = std.testing.expect;
55const expectEqual = std.testing.expectEqual;
66
7test "@maximum" {
7test "@max" {
88 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
99 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
1010 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
......@@ -14,15 +14,15 @@ test "@maximum" {
1414 fn doTheTest() !void {
1515 var x: i32 = 10;
1616 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));
1919 }
2020 };
2121 try S.doTheTest();
2222 comptime try S.doTheTest();
2323}
2424
25test "@maximum on vectors" {
25test "@max on vectors" {
2626 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
2727 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
2828 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
......@@ -33,17 +33,17 @@ test "@maximum on vectors" {
3333 fn doTheTest() !void {
3434 var a: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
3535 var b: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };
36 var x = @maximum(a, b);
36 var x = @max(a, b);
3737 try expect(mem.eql(i32, &@as([4]i32, x), &[4]i32{ 2147483647, 2147483647, 30, 40 }));
3838
3939 var c: @Vector(4, f32) = [4]f32{ 0, 0.4, -2.4, 7.8 };
4040 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);
4242 try expect(mem.eql(f32, &@as([4]f32, y), &[4]f32{ 0, 0.42, -0.64, 7.8 }));
4343
4444 var e: @Vector(2, f32) = [2]f32{ 0, std.math.qnan_f32 };
4545 var f: @Vector(2, f32) = [2]f32{ std.math.qnan_f32, 0 };
46 var z = @maximum(e, f);
46 var z = @max(e, f);
4747 try expect(mem.eql(f32, &@as([2]f32, z), &[2]f32{ 0, 0 }));
4848 }
4949 };
......@@ -51,7 +51,7 @@ test "@maximum on vectors" {
5151 comptime try S.doTheTest();
5252}
5353
54test "@minimum" {
54test "@min" {
5555 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
5656 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
5757 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
......@@ -61,15 +61,15 @@ test "@minimum" {
6161 fn doTheTest() !void {
6262 var x: i32 = 10;
6363 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));
6666 }
6767 };
6868 try S.doTheTest();
6969 comptime try S.doTheTest();
7070}
7171
72test "@minimum for vectors" {
72test "@min for vectors" {
7373 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
7474 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
7575 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
......@@ -80,17 +80,17 @@ test "@minimum for vectors" {
8080 fn doTheTest() !void {
8181 var a: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
8282 var b: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };
83 var x = @minimum(a, b);
83 var x = @min(a, b);
8484 try expect(mem.eql(i32, &@as([4]i32, x), &[4]i32{ 1, -2, 3, 4 }));
8585
8686 var c: @Vector(4, f32) = [4]f32{ 0, 0.4, -2.4, 7.8 };
8787 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);
8989 try expect(mem.eql(f32, &@as([4]f32, y), &[4]f32{ -0.23, 0.4, -2.4, 0.9 }));
9090
9191 var e: @Vector(2, f32) = [2]f32{ 0, std.math.qnan_f32 };
9292 var f: @Vector(2, f32) = [2]f32{ std.math.qnan_f32, 0 };
93 var z = @maximum(e, f);
93 var z = @max(e, f);
9494 try expect(mem.eql(f32, &@as([2]f32, z), &[2]f32{ 0, 0 }));
9595 }
9696 };