authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-04 12:16:20+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-05 14:54:31+02:00
log5b90bb103fa81de79d64033707fe16748240a7a0
tree3acbca0ba52a8fe25a732c0b75f6b2929631d7aa
parent3ed34b112f9e8039216ae9afdda2fc81b8eb3cb7
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: add loongarch(32,64)_preserve_none calling convention support


8 files changed, 17 insertions(+), 1 deletions(-)

lib/std/Target.zig+2
......@@ -1952,9 +1952,11 @@ pub const Cpu = struct {
19521952 => &.{.lanai},
19531953
19541954 .loongarch64_lp64,
1955 .loongarch64_preserve_none,
19551956 => &.{.loongarch64},
19561957
19571958 .loongarch32_ilp32,
1959 .loongarch32_preserve_none,
19581960 => &.{.loongarch32},
19591961
19601962 .m68k_sysv,
lib/std/lang.zig+2
......@@ -324,9 +324,11 @@ pub const CallingConvention = union(enum(u8)) {
324324
325325 /// The standard `loongarch64` calling convention.
326326 loongarch64_lp64: CommonOptions,
327 loongarch64_preserve_none: CommonOptions,
327328
328329 /// The standard `loongarch32` calling convention.
329330 loongarch32_ilp32: CommonOptions,
331 loongarch32_preserve_none: CommonOptions,
330332
331333 // Calling conventions for the `m68k` architecture.
332334 m68k_sysv: CommonOptions,
src/Zcu.zig+2
......@@ -4628,6 +4628,8 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.lang.CallingConvention) union(enum)
46284628 .avr_interrupt,
46294629 .avr_signal,
46304630 .ez80_tiflags,
4631 .loongarch32_preserve_none,
4632 .loongarch64_preserve_none,
46314633 .naked,
46324634 => true, // incoming stack alignment supported
46334635
src/codegen/c/type.zig+2
......@@ -142,6 +142,8 @@ pub const CType = union(enum) {
142142
143143 .x86_64_preserve_none,
144144 .aarch64_preserve_none,
145 .loongarch32_preserve_none,
146 .loongarch64_preserve_none,
145147 => .preserve_none,
146148
147149 .aarch64_vfabi => .aarch64_vector_pcs,
src/codegen/llvm.zig+2
......@@ -4305,6 +4305,8 @@ pub fn toLlvmCallConvTag(cc_tag: std.lang.CallingConvention.Tag, target: *const
43054305 .amdgcn_cs => .amdgpu_cs,
43064306 .nvptx_device => .ptx_device,
43074307 .nvptx_kernel => .ptx_kernel,
4308 .loongarch32_preserve_none => .preserve_nonecc,
4309 .loongarch64_preserve_none => .preserve_nonecc,
43084310
43094311 // Calling conventions which LLVM uses function attributes for.
43104312 .riscv64_interrupt,
src/link/Dwarf.zig+3
......@@ -4188,6 +4188,9 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
41884188 .riscv32_ilp32_v,
41894189 => .LLVM_RISCVVectorCall,
41904190
4191 .loongarch32_preserve_none => .LLVM_PreserveNone,
4192 .loongarch64_preserve_none => .LLVM_PreserveNone,
4193
41914194 .m68k_rtd => .LLVM_M68kRTD,
41924195
41934196 .sh_renesas => .GNU_renesas_sh,
test/c_abi/cfuncs.c+1-1
......@@ -16624,7 +16624,7 @@ struct ByRef __attribute__((sysv_abi)) c_explict_sys_v(struct ByRef in) {
1662416624}
1662516625#endif
1662616626
16627#if defined __x86_64__ || defined __aarch64__
16627#if defined __x86_64__ || defined __aarch64__ || defined __loongarch__
1662816628int __attribute__((preserve_none)) c_preserve_none(int x) {
1662916629 return x + 1;
1663016630}
test/c_abi/main.zig+3
......@@ -18045,6 +18045,9 @@ const preserve_none_cc: ?std.lang.CallingConvention = if (builtin.zig_backend !=
1804518045else switch (builtin.cpu.arch) {
1804618046 .x86_64 => .{ .x86_64_preserve_none = .{} },
1804718047 .aarch64, .aarch64_be => .{ .aarch64_preserve_none = .{} },
18048 // Supported in LLVM but not yet wired up in Clang.
18049 // .loongarch32 => .{ .loongarch32_preserve_none = .{} },
18050 // .loongarch64 => .{ .loongarch64_preserve_none = .{} },
1804818051 else => null,
1804918052};
1805018053