| author | |
| committer | |
| log | cb48376bec1957997532c627db2caf2dc970c397 |
| tree | 724383ff256ec9e7c8a9a9e050c929a5bc93a191 |
| parent | 67580ede5ef7e087d030b96ad6c71c3fc5760e4c |
| signature |
There are several more that we could support here, but I didn't feel
like going down the rabbit-hole of figuring them out. In particular,
some of the Clang enum fields aren't specific enough for us, so we'll
have to switch on the target to figure out how to translate-c them. That
can be a future enhancement.4 files changed, 49 insertions(+), 6 deletions(-)
lib/compiler/aro_translate_c/ast.zig+4| ... | ... | @@ -560,6 +560,7 @@ pub const Payload = struct { |
| 560 | 560 | pub const CallingConvention = enum { |
| 561 | 561 | c, |
| 562 | 562 | x86_64_sysv, |
| 563 | x86_64_win, | |
| 563 | 564 | x86_stdcall, |
| 564 | 565 | x86_fastcall, |
| 565 | 566 | x86_thiscall, |
| ... | ... | @@ -567,6 +568,7 @@ pub const Payload = struct { |
| 567 | 568 | aarch64_vfabi, |
| 568 | 569 | arm_aapcs, |
| 569 | 570 | arm_aapcs_vfp, |
| 571 | m68k_rtd, | |
| 570 | 572 | }; |
| 571 | 573 | }; |
| 572 | 574 | |
| ... | ... | @@ -2834,6 +2836,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { |
| 2834 | 2836 | }); |
| 2835 | 2837 | }, |
| 2836 | 2838 | .x86_64_sysv, |
| 2839 | .x86_64_win, | |
| 2837 | 2840 | .x86_stdcall, |
| 2838 | 2841 | .x86_fastcall, |
| 2839 | 2842 | .x86_thiscall, |
| ... | ... | @@ -2841,6 +2844,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { |
| 2841 | 2844 | .aarch64_vfabi, |
| 2842 | 2845 | .arm_aapcs, |
| 2843 | 2846 | .arm_aapcs_vfp, |
| 2847 | .m68k_rtd, | |
| 2844 | 2848 | => cc_node: { |
| 2845 | 2849 | // .{ .foo = .{} } |
| 2846 | 2850 | _ = try c.addToken(.period, "."); |
src/Zcu.zig+15| ... | ... | @@ -3568,12 +3568,27 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu |
| 3568 | 3568 | } |
| 3569 | 3569 | } |
| 3570 | 3570 | break :ok switch (cc) { |
| 3571 | .x86_64_sysv, | |
| 3572 | .x86_64_win, | |
| 3571 | 3573 | .x86_64_vectorcall, |
| 3574 | .x86_64_regcall_v3_sysv, | |
| 3575 | .x86_64_regcall_v4_win, | |
| 3572 | 3576 | .x86_fastcall, |
| 3573 | 3577 | .x86_thiscall, |
| 3574 | 3578 | .x86_vectorcall, |
| 3579 | .x86_regcall_v3, | |
| 3580 | .x86_regcall_v4_win, | |
| 3581 | .aarch64_vfabi, | |
| 3582 | .aarch64_vfabi_sve, | |
| 3583 | .arm_aapcs, | |
| 3584 | .arm_aapcs_vfp, | |
| 3585 | .riscv64_lp64_v, | |
| 3586 | .riscv32_ilp32_v, | |
| 3587 | .m68k_rtd, | |
| 3575 | 3588 | => |opts| opts.incoming_stack_alignment == null, |
| 3576 | 3589 | |
| 3590 | .x86_sysv, | |
| 3591 | .x86_win, | |
| 3577 | 3592 | .x86_stdcall, |
| 3578 | 3593 | => |opts| opts.incoming_stack_alignment == null and opts.register_params == 0, |
| 3579 | 3594 |
src/codegen/c.zig+28-6| ... | ... | @@ -7605,16 +7605,38 @@ fn writeMemoryOrder(w: anytype, order: std.builtin.AtomicOrder) !void { |
| 7605 | 7605 | } |
| 7606 | 7606 | |
| 7607 | 7607 | fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8 { |
| 7608 | if (zcu.getTarget().cCallingConvention()) |ccc| { | |
| 7609 | if (cc.eql(ccc)) { | |
| 7610 | return null; | |
| 7611 | } | |
| 7612 | } | |
| 7608 | 7613 | return switch (cc) { |
| 7609 | 7614 | .auto, .naked => null, |
| 7615 | ||
| 7616 | .x86_64_sysv, .x86_sysv => "sysv_abi", | |
| 7617 | .x86_64_win, .x86_win => "ms_abi", | |
| 7610 | 7618 | .x86_stdcall => "stdcall", |
| 7611 | 7619 | .x86_fastcall => "fastcall", |
| 7612 | .x86_vectorcall, .x86_64_vectorcall => "vectorcall", | |
| 7613 | else => { | |
| 7614 | // `Zcu.callconvSupported` means this must be the C callconv. | |
| 7615 | assert(cc.eql(zcu.getTarget().cCallingConvention().?)); | |
| 7616 | return null; | |
| 7617 | }, | |
| 7620 | .x86_thiscall => "thiscall", | |
| 7621 | ||
| 7622 | .x86_vectorcall, | |
| 7623 | .x86_64_vectorcall, | |
| 7624 | => "vectorcall", | |
| 7625 | ||
| 7626 | .x86_64_regcall_v3_sysv, | |
| 7627 | .x86_64_regcall_v4_win, | |
| 7628 | .x86_regcall_v3, | |
| 7629 | .x86_regcall_v4_win, | |
| 7630 | => "regcall", | |
| 7631 | ||
| 7632 | .aarch64_vfabi => "aarch64_vector_pcs", | |
| 7633 | .aarch64_vfabi_sve => "aarch64_sve_pcs", | |
| 7634 | .arm_aapcs => "pcs(\"aapcs\")", | |
| 7635 | .arm_aapcs_vfp => "pcs(\"aapcs-vfp\")", | |
| 7636 | .riscv64_lp64_v, .riscv32_ilp32_v => "riscv_vector_cc", | |
| 7637 | .m68k_rtd => "m68k_rtd", | |
| 7638 | ||
| 7639 | else => unreachable, // `Zcu.callconvSupported` | |
| 7618 | 7640 | }; |
| 7619 | 7641 | } |
| 7620 | 7642 |
src/translate_c.zig+2| ... | ... | @@ -5005,6 +5005,7 @@ fn transCC( |
| 5005 | 5005 | return switch (clang_cc) { |
| 5006 | 5006 | .C => .c, |
| 5007 | 5007 | .X86_64SysV => .x86_64_sysv, |
| 5008 | .Win64 => .x86_64_win, | |
| 5008 | 5009 | .X86StdCall => .x86_stdcall, |
| 5009 | 5010 | .X86FastCall => .x86_fastcall, |
| 5010 | 5011 | .X86ThisCall => .x86_thiscall, |
| ... | ... | @@ -5012,6 +5013,7 @@ fn transCC( |
| 5012 | 5013 | .AArch64VectorCall => .aarch64_vfabi, |
| 5013 | 5014 | .AAPCS => .arm_aapcs, |
| 5014 | 5015 | .AAPCS_VFP => .arm_aapcs_vfp, |
| 5016 | .M68kRTD => .m68k_rtd, | |
| 5015 | 5017 | else => return fail( |
| 5016 | 5018 | c, |
| 5017 | 5019 | error.UnsupportedType, |