| ... | ... | @@ -3076,6 +3076,50 @@ pub const Object = struct { |
| 3076 | 3076 | for (cc_info.inreg_param_count..std.math.maxInt(u2)) |param_idx| { |
| 3077 | 3077 | _ = try attributes.removeParamAttr(param_idx, .inreg); |
| 3078 | 3078 | } |
| 3079 | |
| 3080 | switch (fn_info.cc) { |
| 3081 | inline .riscv64_interrupt, |
| 3082 | .riscv32_interrupt, |
| 3083 | .mips_interrupt, |
| 3084 | .mips64_interrupt, |
| 3085 | => |info| { |
| 3086 | try attributes.addFnAttr(.{ .string = .{ |
| 3087 | .kind = try o.builder.string("interrupt"), |
| 3088 | .value = try o.builder.string(@tagName(info.mode)), |
| 3089 | } }, &o.builder); |
| 3090 | }, |
| 3091 | .arm_interrupt, |
| 3092 | => |info| { |
| 3093 | try attributes.addFnAttr(.{ .string = .{ |
| 3094 | .kind = try o.builder.string("interrupt"), |
| 3095 | .value = try o.builder.string(switch (info.type) { |
| 3096 | .generic => "", |
| 3097 | .irq => "IRQ", |
| 3098 | .fiq => "FIQ", |
| 3099 | .swi => "SWI", |
| 3100 | .abort => "ABORT", |
| 3101 | .undef => "UNDEF", |
| 3102 | }), |
| 3103 | } }, &o.builder); |
| 3104 | }, |
| 3105 | // these function attributes serve as a backup against any mistakes LLVM makes. |
| 3106 | // clang sets both the function's calling convention and the function attributes |
| 3107 | // in its backend, so future patches to the AVR backend could end up checking only one, |
| 3108 | // possibly breaking our support. it's safer to just emit both. |
| 3109 | .avr_interrupt, .avr_signal, .csky_interrupt => { |
| 3110 | try attributes.addFnAttr(.{ .string = .{ |
| 3111 | .kind = try o.builder.string(switch (fn_info.cc) { |
| 3112 | .avr_interrupt, |
| 3113 | .csky_interrupt, |
| 3114 | => "interrupt", |
| 3115 | .avr_signal => "signal", |
| 3116 | else => unreachable, |
| 3117 | }), |
| 3118 | .value = .empty, |
| 3119 | } }, &o.builder); |
| 3120 | }, |
| 3121 | else => {}, |
| 3122 | } |
| 3079 | 3123 | } |
| 3080 | 3124 | |
| 3081 | 3125 | if (resolved.alignment != .none) |
| ... | ... | @@ -11609,9 +11653,13 @@ pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) ?Ca |
| 11609 | 11653 | const incoming_stack_alignment: ?u64, const register_params: u2 = switch (cc) { |
| 11610 | 11654 | inline else => |pl| switch (@TypeOf(pl)) { |
| 11611 | 11655 | void => .{ null, 0 }, |
| 11612 | | std.builtin.CallingConvention.CommonOptions => .{ pl.incoming_stack_alignment, 0 }, |
| 11656 | std.builtin.CallingConvention.ArmInterruptOptions, |
| 11657 | std.builtin.CallingConvention.RiscvInterruptOptions, |
| 11658 | std.builtin.CallingConvention.MipsInterruptOptions, |
| 11659 | std.builtin.CallingConvention.CommonOptions, |
| 11660 | => .{ pl.incoming_stack_alignment, 0 }, |
| 11613 | 11661 | std.builtin.CallingConvention.X86RegparmOptions => .{ pl.incoming_stack_alignment, pl.register_params }, |
| 11614 | | else => unreachable, |
| 11662 | else => @compileError("TODO: toLlvmCallConv" ++ @tagName(pl)), |
| 11615 | 11663 | }, |
| 11616 | 11664 | }; |
| 11617 | 11665 | return .{ |
| ... | ... | @@ -11676,6 +11724,15 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ |
| 11676 | 11724 | .nvptx_device => .ptx_device, |
| 11677 | 11725 | .nvptx_kernel => .ptx_kernel, |
| 11678 | 11726 | |
| 11727 | // Calling conventions which LLVM uses function attributes for. |
| 11728 | .riscv64_interrupt, |
| 11729 | .riscv32_interrupt, |
| 11730 | .arm_interrupt, |
| 11731 | .mips64_interrupt, |
| 11732 | .mips_interrupt, |
| 11733 | .csky_interrupt, |
| 11734 | => .ccc, |
| 11735 | |
| 11679 | 11736 | // All the calling conventions which LLVM does not have a general representation for. |
| 11680 | 11737 | // Note that these are often still supported through the `cCallingConvention` path above via `ccc`. |
| 11681 | 11738 | .x86_sysv, |
| ... | ... | @@ -11685,16 +11742,11 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ |
| 11685 | 11742 | .aarch64_aapcs_darwin, |
| 11686 | 11743 | .aarch64_aapcs_win, |
| 11687 | 11744 | .arm_aapcs16_vfp, |
| 11688 | | .arm_interrupt, |
| 11689 | 11745 | .mips64_n64, |
| 11690 | 11746 | .mips64_n32, |
| 11691 | | .mips64_interrupt, |
| 11692 | 11747 | .mips_o32, |
| 11693 | | .mips_interrupt, |
| 11694 | 11748 | .riscv64_lp64, |
| 11695 | | .riscv64_interrupt, |
| 11696 | 11749 | .riscv32_ilp32, |
| 11697 | | .riscv32_interrupt, |
| 11698 | 11750 | .sparc64_sysv, |
| 11699 | 11751 | .sparc_sysv, |
| 11700 | 11752 | .powerpc64_elf, |
| ... | ... | @@ -11709,7 +11761,6 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ |
| 11709 | 11761 | .avr_gnu, |
| 11710 | 11762 | .bpf_std, |
| 11711 | 11763 | .csky_sysv, |
| 11712 | | .csky_interrupt, |
| 11713 | 11764 | .hexagon_sysv, |
| 11714 | 11765 | .hexagon_sysv_hvx, |
| 11715 | 11766 | .lanai_sysv, |