| ... | @@ -582,10 +582,9 @@ fn generateFloatMacros(w: anytype, prefix: []const u8, semantics: target_util.FP | ... | @@ -582,10 +582,9 @@ fn generateFloatMacros(w: anytype, prefix: []const u8, semantics: target_util.FP |
| 582 | }, | 582 | }, |
| 583 | ); | 583 | ); |
| 584 | | 584 | |
| 585 | var defPrefix = std.BoundedArray(u8, 32).init(0) catch unreachable; | 585 | var def_prefix_buf: [32]u8 = undefined; |
| 586 | defPrefix.writer().print("__{s}_", .{prefix}) catch return error.OutOfMemory; | 586 | const prefix_slice = std.fmt.bufPrint(&def_prefix_buf, "__{s}_", .{prefix}) catch |
| 587 | | 587 | return error.OutOfMemory; |
| 588 | const prefix_slice = defPrefix.constSlice(); | | |
| 589 | | 588 | |
| 590 | try w.print("#define {s}DENORM_MIN__ {s}{s}\n", .{ prefix_slice, denormMin, ext }); | 589 | try w.print("#define {s}DENORM_MIN__ {s}{s}\n", .{ prefix_slice, denormMin, ext }); |
| 591 | try w.print("#define {s}HAS_DENORM__\n", .{prefix_slice}); | 590 | try w.print("#define {s}HAS_DENORM__\n", .{prefix_slice}); |
| ... | @@ -770,18 +769,18 @@ fn generateExactWidthType(comp: *const Compilation, w: anytype, mapper: StrInt.T | ... | @@ -770,18 +769,18 @@ fn generateExactWidthType(comp: *const Compilation, w: anytype, mapper: StrInt.T |
| 770 | ty = if (unsigned) comp.types.int64.makeIntegerUnsigned() else comp.types.int64; | 769 | ty = if (unsigned) comp.types.int64.makeIntegerUnsigned() else comp.types.int64; |
| 771 | } | 770 | } |
| 772 | | 771 | |
| 773 | var prefix = std.BoundedArray(u8, 16).init(0) catch unreachable; | 772 | var buffer: [16]u8 = undefined; |
| 774 | prefix.writer().print("{s}{d}", .{ if (unsigned) "__UINT" else "__INT", width }) catch return error.OutOfMemory; | 773 | const suffix = "_TYPE__"; |
| | 774 | const full = std.fmt.bufPrint(&buffer, "{s}{d}{s}", .{ |
| | 775 | if (unsigned) "__UINT" else "__INT", width, suffix, |
| | 776 | }) catch return error.OutOfMemory; |
| 775 | | 777 | |
| 776 | { | 778 | try generateTypeMacro(w, mapper, full, ty, comp.langopts); |
| 777 | const len = prefix.len; | 779 | |
| 778 | defer prefix.resize(len) catch unreachable; // restoring previous size | 780 | const prefix = full[0 .. full.len - suffix.len]; // remove "_TYPE__" |
| 779 | prefix.appendSliceAssumeCapacity("_TYPE__"); | | |
| 780 | try generateTypeMacro(w, mapper, prefix.constSlice(), ty, comp.langopts); | | |
| 781 | } | | |
| 782 | | 781 | |
| 783 | try comp.generateFmt(prefix.constSlice(), w, ty); | 782 | try comp.generateFmt(prefix, w, ty); |
| 784 | try comp.generateSuffixMacro(prefix.constSlice(), w, ty); | 783 | try comp.generateSuffixMacro(prefix, w, ty); |
| 785 | } | 784 | } |
| 786 | | 785 | |
| 787 | pub fn hasFloat128(comp: *const Compilation) bool { | 786 | pub fn hasFloat128(comp: *const Compilation) bool { |
| ... | @@ -908,10 +907,12 @@ fn generateExactWidthIntMax(comp: *const Compilation, w: anytype, specifier: Typ | ... | @@ -908,10 +907,12 @@ fn generateExactWidthIntMax(comp: *const Compilation, w: anytype, specifier: Typ |
| 908 | ty = if (unsigned) comp.types.int64.makeIntegerUnsigned() else comp.types.int64; | 907 | ty = if (unsigned) comp.types.int64.makeIntegerUnsigned() else comp.types.int64; |
| 909 | } | 908 | } |
| 910 | | 909 | |
| 911 | var name = std.BoundedArray(u8, 6).init(0) catch unreachable; | 910 | var name_buffer: [6]u8 = undefined; |
| 912 | name.writer().print("{s}{d}", .{ if (unsigned) "UINT" else "INT", bit_count }) catch return error.OutOfMemory; | 911 | const name = std.fmt.bufPrint(&name_buffer, "{s}{d}", .{ |
| | 912 | if (unsigned) "UINT" else "INT", bit_count, |
| | 913 | }) catch return error.OutOfMemory; |
| 913 | | 914 | |
| 914 | return comp.generateIntMax(w, name.constSlice(), ty); | 915 | return comp.generateIntMax(w, name, ty); |
| 915 | } | 916 | } |
| 916 | | 917 | |
| 917 | fn generateIntWidth(comp: *Compilation, w: anytype, name: []const u8, ty: Type) !void { | 918 | fn generateIntWidth(comp: *Compilation, w: anytype, name: []const u8, ty: Type) !void { |