| ... | @@ -258,42 +258,6 @@ pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) { | ... | @@ -258,42 +258,6 @@ pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) { |
| 258 | return .{ .data = ident }; | 258 | return .{ .data = ident }; |
| 259 | } | 259 | } |
| 260 | | 260 | |
| 261 | // Returns true if `formatIdent` would make any edits to ident. | | |
| 262 | // This must be kept in sync with `formatIdent`. | | |
| 263 | pub fn isMangledIdent(ident: []const u8, solo: bool) bool { | | |
| 264 | if (solo and isReservedIdent(ident)) return true; | | |
| 265 | for (ident, 0..) |c, i| { | | |
| 266 | switch (c) { | | |
| 267 | 'a'...'z', 'A'...'Z', '_' => {}, | | |
| 268 | '0'...'9' => if (i == 0) return true, | | |
| 269 | else => return true, | | |
| 270 | } | | |
| 271 | } | | |
| 272 | return false; | | |
| 273 | } | | |
| 274 | | | |
| 275 | const DeclVisibility = enum { | | |
| 276 | global, | | |
| 277 | global_mangled, | | |
| 278 | local, | | |
| 279 | | | |
| 280 | fn renderFwd(visibility: DeclVisibility, w: anytype) !void { | | |
| 281 | try w.writeAll(switch (visibility) { | | |
| 282 | .global => "zig_extern ", | | |
| 283 | // MSVC doesn't support exporting `static` functions, so they need special treatment | | |
| 284 | .global_mangled => "zig_extern_mangled ", | | |
| 285 | .local => "static ", | | |
| 286 | }); | | |
| 287 | } | | |
| 288 | | | |
| 289 | fn renderDef(visibility: DeclVisibility, w: anytype) !void { | | |
| 290 | return switch (visibility) { | | |
| 291 | .global => {}, | | |
| 292 | else => visibility.renderFwd(w), | | |
| 293 | }; | | |
| 294 | } | | |
| 295 | }; | | |
| 296 | | | |
| 297 | /// This data is available when outputting .c code for a `InternPool.Index` | 261 | /// This data is available when outputting .c code for a `InternPool.Index` |
| 298 | /// that corresponds to `func`. | 262 | /// that corresponds to `func`. |
| 299 | /// It is not available when generating .h file. | 263 | /// It is not available when generating .h file. |
| ... | @@ -566,7 +530,6 @@ pub const DeclGen = struct { | ... | @@ -566,7 +530,6 @@ pub const DeclGen = struct { |
| 566 | is_naked_fn: bool, | 530 | is_naked_fn: bool, |
| 567 | /// This is a borrowed reference from `link.C`. | 531 | /// This is a borrowed reference from `link.C`. |
| 568 | fwd_decl: std.ArrayList(u8), | 532 | fwd_decl: std.ArrayList(u8), |
| 569 | | | |
| 570 | error_msg: ?*Module.ErrorMsg, | 533 | error_msg: ?*Module.ErrorMsg, |
| 571 | ctypes: CType.Store, | 534 | ctypes: CType.Store, |
| 572 | /// Keeps track of anonymous decls that need to be rendered before this | 535 | /// Keeps track of anonymous decls that need to be rendered before this |
| ... | @@ -1668,7 +1631,7 @@ pub const DeclGen = struct { | ... | @@ -1668,7 +1631,7 @@ pub const DeclGen = struct { |
| 1668 | | 1631 | |
| 1669 | switch (name) { | 1632 | switch (name) { |
| 1670 | .export_index => |export_index| try dg.renderDeclName(w, fn_decl_index, export_index), | 1633 | .export_index => |export_index| try dg.renderDeclName(w, fn_decl_index, export_index), |
| 1671 | .string => |string| try w.print("{ }", .{fmtIdent(string)}), | 1634 | .string => |string| try w.writeAll(string), |
| 1672 | } | 1635 | } |
| 1673 | | 1636 | |
| 1674 | try renderTypeSuffix( | 1637 | try renderTypeSuffix( |
| ... | @@ -1880,26 +1843,12 @@ pub const DeclGen = struct { | ... | @@ -1880,26 +1843,12 @@ pub const DeclGen = struct { |
| 1880 | try renderTypeSuffix(dg.pass, store.*, mod, w, cty_idx, .suffix, .{}); | 1843 | try renderTypeSuffix(dg.pass, store.*, mod, w, cty_idx, .suffix, .{}); |
| 1881 | } | 1844 | } |
| 1882 | | 1845 | |
| 1883 | fn declVisibility(dg: *DeclGen, tv: TypedValue) DeclVisibility { | 1846 | fn declIsGlobal(dg: *DeclGen, tv: TypedValue) bool { |
| 1884 | const mod = dg.module; | 1847 | const mod = dg.module; |
| 1885 | return switch (mod.intern_pool.indexToKey(tv.val.ip_index)) { | 1848 | return switch (mod.intern_pool.indexToKey(tv.val.ip_index)) { |
| 1886 | .variable => |variable| { | 1849 | .variable => |variable| mod.decl_exports.contains(variable.decl), |
| 1887 | if (mod.decl_exports.get(variable.decl)) |exports| { | 1850 | .extern_func => true, |
| 1888 | return if (isMangledIdent(dg.module.intern_pool.stringToSlice(exports.items[0].opts.name), true)) | 1851 | .func => |func| mod.decl_exports.contains(func.owner_decl), |
| 1889 | .global_mangled | | |
| 1890 | else | | |
| 1891 | .global; | | |
| 1892 | } else return .local; | | |
| 1893 | }, | | |
| 1894 | .extern_func => .global, | | |
| 1895 | .func => |func| { | | |
| 1896 | if (mod.decl_exports.get(func.owner_decl)) |exports| { | | |
| 1897 | return if (isMangledIdent(dg.module.intern_pool.stringToSlice(exports.items[0].opts.name), true)) | | |
| 1898 | .global_mangled | | |
| 1899 | else | | |
| 1900 | .global; | | |
| 1901 | } else return .local; | | |
| 1902 | }, | | |
| 1903 | else => unreachable, | 1852 | else => unreachable, |
| 1904 | }; | 1853 | }; |
| 1905 | } | 1854 | } |
| ... | @@ -1984,8 +1933,8 @@ pub const DeclGen = struct { | ... | @@ -1984,8 +1933,8 @@ pub const DeclGen = struct { |
| 1984 | fn renderFwdDecl(dg: *DeclGen, decl_index: InternPool.DeclIndex, variable: InternPool.Key.Variable) !void { | 1933 | fn renderFwdDecl(dg: *DeclGen, decl_index: InternPool.DeclIndex, variable: InternPool.Key.Variable) !void { |
| 1985 | const decl = dg.module.declPtr(decl_index); | 1934 | const decl = dg.module.declPtr(decl_index); |
| 1986 | const fwd = dg.fwd_decl.writer(); | 1935 | const fwd = dg.fwd_decl.writer(); |
| 1987 | const visibility = if (variable.is_extern) .global else dg.declVisibility(.{ .ty = decl.ty, .val = decl.val }); | 1936 | const is_global = dg.declIsGlobal(.{ .ty = decl.ty, .val = decl.val }) or variable.is_extern; |
| 1988 | try visibility.renderFwd(fwd); | 1937 | try fwd.writeAll(if (is_global) "zig_extern " else "static "); |
| 1989 | const export_weak_linkage = if (dg.module.decl_exports.get(decl_index)) |exports| | 1938 | const export_weak_linkage = if (dg.module.decl_exports.get(decl_index)) |exports| |
| 1990 | exports.items[0].opts.linkage == .Weak | 1939 | exports.items[0].opts.linkage == .Weak |
| 1991 | else | 1940 | else |
| ... | @@ -2009,7 +1958,7 @@ pub const DeclGen = struct { | ... | @@ -2009,7 +1958,7 @@ pub const DeclGen = struct { |
| 2009 | try mod.markDeclAlive(decl); | 1958 | try mod.markDeclAlive(decl); |
| 2010 | | 1959 | |
| 2011 | if (mod.decl_exports.get(decl_index)) |exports| { | 1960 | if (mod.decl_exports.get(decl_index)) |exports| { |
| 2012 | try writer.print("{ }", .{fmtIdent(mod.intern_pool.stringToSlice(exports.items[export_index].opts.name))}); | 1961 | try writer.print("{}", .{exports.items[export_index].opts.name.fmt(&mod.intern_pool)}); |
| 2013 | } else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| { | 1962 | } else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| { |
| 2014 | try writer.print("{}", .{mod.declPtr(extern_decl_index).name.fmt(&mod.intern_pool)}); | 1963 | try writer.print("{}", .{mod.declPtr(extern_decl_index).name.fmt(&mod.intern_pool)}); |
| 2015 | } else { | 1964 | } else { |
| ... | @@ -2649,19 +2598,16 @@ fn genExports(o: *Object) !void { | ... | @@ -2649,19 +2598,16 @@ fn genExports(o: *Object) !void { |
| 2649 | const fwd = o.dg.fwd_decl.writer(); | 2598 | const fwd = o.dg.fwd_decl.writer(); |
| 2650 | | 2599 | |
| 2651 | const exports = mod.decl_exports.get(decl_index) orelse return; | 2600 | const exports = mod.decl_exports.get(decl_index) orelse return; |
| 2652 | | 2601 | if (exports.items.len < 2) return; |
| 2653 | const is_mangled = isMangledIdent(ip.stringToSlice(exports.items[0].opts.name), true); | | |
| 2654 | if (exports.items.len < 2 and !is_mangled) return; | | |
| 2655 | | 2602 | |
| 2656 | switch (ip.indexToKey(tv.val.toIntern())) { | 2603 | switch (ip.indexToKey(tv.val.toIntern())) { |
| 2657 | .func => { | 2604 | .func => { |
| 2658 | const start_i = 1 - @intFromBool(is_mangled); | 2605 | for (exports.items[1..], 1..) |@"export", i| { |
| 2659 | for (exports.items[start_i..], start_i..) |@"export", i| { | | |
| 2660 | try fwd.writeAll("zig_export("); | 2606 | try fwd.writeAll("zig_export("); |
| 2661 | if (exports.items[i].opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage_fn "); | 2607 | if (exports.items[i].opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage_fn "); |
| 2662 | try o.dg.renderFunctionSignature(fwd, decl_index, .forward, .{ .export_index = @as(u32, @intCast(i)) }); | 2608 | try o.dg.renderFunctionSignature(fwd, decl_index, .forward, .{ .export_index = @as(u32, @intCast(i)) }); |
| 2663 | try fwd.print(", { }, {s});\n", .{ | 2609 | try fwd.print(", {s}, {s});\n", .{ |
| 2664 | fmtIdent(ip.stringToSlice(exports.items[0].opts.name)), | 2610 | fmtStringLiteral(ip.stringToSlice(exports.items[0].opts.name), null), |
| 2665 | fmtStringLiteral(ip.stringToSlice(@"export".opts.name), null), | 2611 | fmtStringLiteral(ip.stringToSlice(@"export".opts.name), null), |
| 2666 | }); | 2612 | }); |
| 2667 | } | 2613 | } |
| ... | @@ -2671,8 +2617,7 @@ fn genExports(o: *Object) !void { | ... | @@ -2671,8 +2617,7 @@ fn genExports(o: *Object) !void { |
| 2671 | unreachable; | 2617 | unreachable; |
| 2672 | }, | 2618 | }, |
| 2673 | .variable => |variable| { | 2619 | .variable => |variable| { |
| 2674 | const start_i = 1 - @intFromBool(is_mangled); | 2620 | for (exports.items[1..], 1..) |@"export", i| { |
| 2675 | for (exports.items[start_i..], start_i..) |@"export", i| { | | |
| 2676 | try fwd.writeAll("zig_export("); | 2621 | try fwd.writeAll("zig_export("); |
| 2677 | if (exports.items[i].opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage "); | 2622 | if (exports.items[i].opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage "); |
| 2678 | const alias = ip.stringToSlice(@"export".opts.name); | 2623 | const alias = ip.stringToSlice(@"export".opts.name); |
| ... | @@ -2684,8 +2629,8 @@ fn genExports(o: *Object) !void { | ... | @@ -2684,8 +2629,8 @@ fn genExports(o: *Object) !void { |
| 2684 | decl.alignment, | 2629 | decl.alignment, |
| 2685 | .complete, | 2630 | .complete, |
| 2686 | ); | 2631 | ); |
| 2687 | try fwd.print(", { }, {s});\n", .{ | 2632 | try fwd.print(", {s}, {s});\n", .{ |
| 2688 | fmtIdent(ip.stringToSlice(exports.items[0].opts.name)), | 2633 | fmtStringLiteral(ip.stringToSlice(exports.items[0].opts.name), null), |
| 2689 | fmtStringLiteral(alias, null), | 2634 | fmtStringLiteral(alias, null), |
| 2690 | }); | 2635 | }); |
| 2691 | } | 2636 | } |
| ... | @@ -2797,10 +2742,9 @@ pub fn genFunc(f: *Function) !void { | ... | @@ -2797,10 +2742,9 @@ pub fn genFunc(f: *Function) !void { |
| 2797 | o.code_header = std.ArrayList(u8).init(gpa); | 2742 | o.code_header = std.ArrayList(u8).init(gpa); |
| 2798 | defer o.code_header.deinit(); | 2743 | defer o.code_header.deinit(); |
| 2799 | | 2744 | |
| 2800 | const visibility = o.dg.declVisibility(tv); | 2745 | const is_global = o.dg.declIsGlobal(tv); |
| 2801 | const fwd_decl_writer = o.dg.fwd_decl.writer(); | 2746 | const fwd_decl_writer = o.dg.fwd_decl.writer(); |
| 2802 | try visibility.renderFwd(fwd_decl_writer); | 2747 | try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static "); |
| 2803 | | | |
| 2804 | if (mod.decl_exports.get(decl_index)) |exports| | 2748 | if (mod.decl_exports.get(decl_index)) |exports| |
| 2805 | if (exports.items[0].opts.linkage == .Weak) try fwd_decl_writer.writeAll("zig_weak_linkage_fn "); | 2749 | if (exports.items[0].opts.linkage == .Weak) try fwd_decl_writer.writeAll("zig_weak_linkage_fn "); |
| 2806 | try o.dg.renderFunctionSignature(fwd_decl_writer, decl_index, .forward, .{ .export_index = 0 }); | 2750 | try o.dg.renderFunctionSignature(fwd_decl_writer, decl_index, .forward, .{ .export_index = 0 }); |
| ... | @@ -2808,7 +2752,7 @@ pub fn genFunc(f: *Function) !void { | ... | @@ -2808,7 +2752,7 @@ pub fn genFunc(f: *Function) !void { |
| 2808 | try genExports(o); | 2752 | try genExports(o); |
| 2809 | | 2753 | |
| 2810 | try o.indent_writer.insertNewline(); | 2754 | try o.indent_writer.insertNewline(); |
| 2811 | try visibility.renderDef(o.writer()); | 2755 | if (!is_global) try o.writer().writeAll("static "); |
| 2812 | try o.dg.renderFunctionSignature(o.writer(), decl_index, .complete, .{ .export_index = 0 }); | 2756 | try o.dg.renderFunctionSignature(o.writer(), decl_index, .complete, .{ .export_index = 0 }); |
| 2813 | try o.writer().writeByte(' '); | 2757 | try o.writer().writeByte(' '); |
| 2814 | | 2758 | |
| ... | @@ -2892,9 +2836,9 @@ pub fn genDecl(o: *Object) !void { | ... | @@ -2892,9 +2836,9 @@ pub fn genDecl(o: *Object) !void { |
| 2892 | | 2836 | |
| 2893 | if (variable.is_extern) return; | 2837 | if (variable.is_extern) return; |
| 2894 | | 2838 | |
| 2895 | const visibility = if (variable.is_extern) .global else o.dg.declVisibility(tv); | 2839 | const is_global = o.dg.declIsGlobal(tv) or variable.is_extern; |
| 2896 | const w = o.writer(); | 2840 | const w = o.writer(); |
| 2897 | try visibility.renderDef(w); | 2841 | if (!is_global) try w.writeAll("static "); |
| 2898 | if (variable.is_weak_linkage) try w.writeAll("zig_weak_linkage "); | 2842 | if (variable.is_weak_linkage) try w.writeAll("zig_weak_linkage "); |
| 2899 | if (variable.is_threadlocal) try w.writeAll("zig_threadlocal "); | 2843 | if (variable.is_threadlocal) try w.writeAll("zig_threadlocal "); |
| 2900 | if (mod.intern_pool.stringToSliceUnwrap(decl.@"linksection")) |s| | 2844 | if (mod.intern_pool.stringToSliceUnwrap(decl.@"linksection")) |s| |
| ... | @@ -2907,21 +2851,16 @@ pub fn genDecl(o: *Object) !void { | ... | @@ -2907,21 +2851,16 @@ pub fn genDecl(o: *Object) !void { |
| 2907 | try w.writeByte(';'); | 2851 | try w.writeByte(';'); |
| 2908 | try o.indent_writer.insertNewline(); | 2852 | try o.indent_writer.insertNewline(); |
| 2909 | } else { | 2853 | } else { |
| 2910 | const visibility: DeclVisibility = if (o.dg.module.decl_exports.get(decl_index)) |exports| b: { | 2854 | const is_global = o.dg.module.decl_exports.contains(decl_index); |
| 2911 | break :b if (isMangledIdent(o.dg.module.intern_pool.stringToSlice(exports.items[0].opts.name), true)) | | |
| 2912 | .global_mangled | | |
| 2913 | else | | |
| 2914 | .global; | | |
| 2915 | } else .local; | | |
| 2916 | const decl_c_value = .{ .decl = decl_index }; | 2855 | const decl_c_value = .{ .decl = decl_index }; |
| 2917 | return genDeclValue(o, tv, visibility, decl_c_value, decl.alignment, decl.@"linksection"); | 2856 | return genDeclValue(o, tv, is_global, decl_c_value, decl.alignment, decl.@"linksection"); |
| 2918 | } | 2857 | } |
| 2919 | } | 2858 | } |
| 2920 | | 2859 | |
| 2921 | pub fn genDeclValue( | 2860 | pub fn genDeclValue( |
| 2922 | o: *Object, | 2861 | o: *Object, |
| 2923 | tv: TypedValue, | 2862 | tv: TypedValue, |
| 2924 | visibility: DeclVisibility, | 2863 | is_global: bool, |
| 2925 | decl_c_value: CValue, | 2864 | decl_c_value: CValue, |
| 2926 | alignment: Alignment, | 2865 | alignment: Alignment, |
| 2927 | link_section: InternPool.OptionalNullTerminatedString, | 2866 | link_section: InternPool.OptionalNullTerminatedString, |
| ... | @@ -2929,13 +2868,12 @@ pub fn genDeclValue( | ... | @@ -2929,13 +2868,12 @@ pub fn genDeclValue( |
| 2929 | const mod = o.dg.module; | 2868 | const mod = o.dg.module; |
| 2930 | const fwd_decl_writer = o.dg.fwd_decl.writer(); | 2869 | const fwd_decl_writer = o.dg.fwd_decl.writer(); |
| 2931 | | 2870 | |
| 2932 | try visibility.renderFwd(fwd_decl_writer); | 2871 | try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static "); |
| 2933 | try o.dg.renderTypeAndName(fwd_decl_writer, tv.ty, decl_c_value, Const, alignment, .complete); | 2872 | try o.dg.renderTypeAndName(fwd_decl_writer, tv.ty, decl_c_value, Const, alignment, .complete); |
| 2934 | try fwd_decl_writer.writeAll(";\n"); | 2873 | try fwd_decl_writer.writeAll(";\n"); |
| 2935 | | 2874 | |
| 2936 | const w = o.writer(); | 2875 | const w = o.writer(); |
| 2937 | try visibility.renderDef(w); | 2876 | if (!is_global) try w.writeAll("static "); |
| 2938 | | | |
| 2939 | if (mod.intern_pool.stringToSliceUnwrap(link_section)) |s| | 2877 | if (mod.intern_pool.stringToSliceUnwrap(link_section)) |s| |
| 2940 | try w.print("zig_linksection(\"{s}\", ", .{s}); | 2878 | try w.print("zig_linksection(\"{s}\", ", .{s}); |
| 2941 | try o.dg.renderTypeAndName(w, tv.ty, decl_c_value, Const, alignment, .complete); | 2879 | try o.dg.renderTypeAndName(w, tv.ty, decl_c_value, Const, alignment, .complete); |
| ... | @@ -2960,14 +2898,11 @@ pub fn genHeader(dg: *DeclGen) error{ AnalysisFail, OutOfMemory }!void { | ... | @@ -2960,14 +2898,11 @@ pub fn genHeader(dg: *DeclGen) error{ AnalysisFail, OutOfMemory }!void { |
| 2960 | | 2898 | |
| 2961 | switch (tv.ty.zigTypeTag(mod)) { | 2899 | switch (tv.ty.zigTypeTag(mod)) { |
| 2962 | .Fn => { | 2900 | .Fn => { |
| 2963 | const visibility = dg.declVisibility(tv); | 2901 | const is_global = dg.declIsGlobal(tv); |
| 2964 | switch (visibility) { | 2902 | if (is_global) { |
| 2965 | .global, .global_mangled => { | 2903 | try writer.writeAll("zig_extern "); |
| 2966 | try visibility.renderFwd(writer); | 2904 | try dg.renderFunctionSignature(writer, dg.pass.decl, .complete, .{ .export_index = 0 }); |
| 2967 | try dg.renderFunctionSignature(writer, dg.pass.decl, .complete, .{ .export_index = 0 }); | 2905 | try dg.fwd_decl.appendSlice(";\n"); |
| 2968 | try dg.fwd_decl.appendSlice(";\n"); | | |
| 2969 | }, | | |
| 2970 | .local => {}, | | |
| 2971 | } | 2906 | } |
| 2972 | }, | 2907 | }, |
| 2973 | else => {}, | 2908 | else => {}, |
| ... | @@ -6960,9 +6895,9 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6960,9 +6895,9 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6960 | try f.writeCValue(writer, accum, .Other); | 6895 | try f.writeCValue(writer, accum, .Other); |
| 6961 | switch (op) { | 6896 | switch (op) { |
| 6962 | .float_op => |func| { | 6897 | .float_op => |func| { |
| 6963 | try writer.writeAll(" = zig_float_fn_"); | 6898 | try writer.writeAll(" = zig_libc_name_"); |
| 6964 | try f.object.dg.renderTypeForBuiltinFnName(writer, scalar_ty); | 6899 | try f.object.dg.renderTypeForBuiltinFnName(writer, scalar_ty); |
| 6965 | try writer.print("_{s}(", .{func.operation}); | 6900 | try writer.print("({s})(", .{func.operation}); |
| 6966 | try f.writeCValue(writer, accum, .FunctionArgument); | 6901 | try f.writeCValue(writer, accum, .FunctionArgument); |
| 6967 | try writer.writeAll(", "); | 6902 | try writer.writeAll(", "); |
| 6968 | try f.writeCValue(writer, operand, .Other); | 6903 | try f.writeCValue(writer, operand, .Other); |
| ... | @@ -7294,9 +7229,11 @@ fn unFloatOp(f: *Function, inst: Air.Inst.Index, operand: CValue, ty: Type, oper | ... | @@ -7294,9 +7229,11 @@ fn unFloatOp(f: *Function, inst: Air.Inst.Index, operand: CValue, ty: Type, oper |
| 7294 | const v = try Vectorize.start(f, inst, writer, ty); | 7229 | const v = try Vectorize.start(f, inst, writer, ty); |
| 7295 | try f.writeCValue(writer, local, .Other); | 7230 | try f.writeCValue(writer, local, .Other); |
| 7296 | try v.elem(f, writer); | 7231 | try v.elem(f, writer); |
| 7297 | try writer.writeAll(" = zig_float_fn_"); | 7232 | try writer.writeAll(" = zig_libc_name_"); |
| 7298 | try f.object.dg.renderTypeForBuiltinFnName(writer, scalar_ty); | 7233 | try f.object.dg.renderTypeForBuiltinFnName(writer, scalar_ty); |
| 7299 | try writer.print("_{s}(", .{operation}); | 7234 | try writer.writeByte('('); |
| | 7235 | try writer.writeAll(operation); |
| | 7236 | try writer.writeAll(")("); |
| 7300 | try f.writeCValue(writer, operand, .FunctionArgument); | 7237 | try f.writeCValue(writer, operand, .FunctionArgument); |
| 7301 | try v.elem(f, writer); | 7238 | try v.elem(f, writer); |
| 7302 | try writer.writeAll(");\n"); | 7239 | try writer.writeAll(");\n"); |
| ... | @@ -7331,9 +7268,11 @@ fn airBinFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVa | ... | @@ -7331,9 +7268,11 @@ fn airBinFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVa |
| 7331 | const v = try Vectorize.start(f, inst, writer, inst_ty); | 7268 | const v = try Vectorize.start(f, inst, writer, inst_ty); |
| 7332 | try f.writeCValue(writer, local, .Other); | 7269 | try f.writeCValue(writer, local, .Other); |
| 7333 | try v.elem(f, writer); | 7270 | try v.elem(f, writer); |
| 7334 | try writer.writeAll(" = zig_float_fn_"); | 7271 | try writer.writeAll(" = zig_libc_name_"); |
| 7335 | try f.object.dg.renderTypeForBuiltinFnName(writer, inst_scalar_ty); | 7272 | try f.object.dg.renderTypeForBuiltinFnName(writer, inst_scalar_ty); |
| 7336 | try writer.print("_{s}(", .{operation}); | 7273 | try writer.writeByte('('); |
| | 7274 | try writer.writeAll(operation); |
| | 7275 | try writer.writeAll(")("); |
| 7337 | try f.writeCValue(writer, lhs, .FunctionArgument); | 7276 | try f.writeCValue(writer, lhs, .FunctionArgument); |
| 7338 | try v.elem(f, writer); | 7277 | try v.elem(f, writer); |
| 7339 | try writer.writeAll(", "); | 7278 | try writer.writeAll(", "); |
| ... | @@ -7363,9 +7302,9 @@ fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -7363,9 +7302,9 @@ fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7363 | const v = try Vectorize.start(f, inst, writer, inst_ty); | 7302 | const v = try Vectorize.start(f, inst, writer, inst_ty); |
| 7364 | try f.writeCValue(writer, local, .Other); | 7303 | try f.writeCValue(writer, local, .Other); |
| 7365 | try v.elem(f, writer); | 7304 | try v.elem(f, writer); |
| 7366 | try writer.writeAll(" = zig_float_fn_"); | 7305 | try writer.writeAll(" = zig_libc_name_"); |
| 7367 | try f.object.dg.renderTypeForBuiltinFnName(writer, inst_scalar_ty); | 7306 | try f.object.dg.renderTypeForBuiltinFnName(writer, inst_scalar_ty); |
| 7368 | try writer.writeAll("_fma("); | 7307 | try writer.writeAll("(fma)("); |
| 7369 | try f.writeCValue(writer, mulend1, .FunctionArgument); | 7308 | try f.writeCValue(writer, mulend1, .FunctionArgument); |
| 7370 | try v.elem(f, writer); | 7309 | try v.elem(f, writer); |
| 7371 | try writer.writeAll(", "); | 7310 | try writer.writeAll(", "); |