authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-20 19:47:51+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-23 09:27:17+02:00
log4fa453ce20ceaee254a7d127a4a99be2260ec605
tree01106dafc6584838f788a8073af01ad4e71dacb8
parentabf40caeb7d85d8fc842fe82215b19902b749481
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.builtin: add CallingConvention.microblaze_interrupt

Only supported in CBE.

8 files changed, 49 insertions(+), 0 deletions(-)

lib/std/Target.zig+1
......@@ -1904,6 +1904,7 @@ pub const Cpu = struct {
19041904 => &.{.m68k},
19051905
19061906 .microblaze_std,
1907 .microblaze_interrupt,
19071908 => &.{ .microblaze, .microblazeel },
19081909
19091910 .msp430_eabi,
lib/std/builtin.zig+20
......@@ -323,6 +323,7 @@ pub const CallingConvention = union(enum(u8)) {
323323
324324 /// The standard `microblaze`/`microblazeel` calling convention.
325325 microblaze_std: CommonOptions,
326 microblaze_interrupt: MicroblazeInterruptOptions,
326327
327328 /// The standard `msp430` calling convention.
328329 msp430_eabi: CommonOptions,
......@@ -421,6 +422,25 @@ pub const CallingConvention = union(enum(u8)) {
421422 };
422423 };
423424
425 /// Options for the `microblaze_interrupt` calling convention.
426 pub const MicroblazeInterruptOptions = struct {
427 /// The boundary the stack is aligned to when the function is called.
428 /// `null` means the default for this calling convention.
429 incoming_stack_alignment: ?u64 = null,
430 type: InterruptType = .regular,
431
432 pub const InterruptType = enum(u2) {
433 /// User exception; return with `rtsd`.
434 user,
435 /// Regular interrupt; return with `rtid`.
436 regular,
437 /// Fast interrupt; return with `rtid`.
438 fast,
439 /// Software breakpoint; return with `rtbd`.
440 breakpoint,
441 };
442 };
443
424444 /// Options for the `mips_interrupt` and `mips64_interrupt` calling conventions.
425445 pub const MipsInterruptOptions = struct {
426446 /// The boundary the stack is aligned to when the function is called.
src/InternPool.zig+9
......@@ -12960,6 +12960,11 @@ const PackedCallingConvention = packed struct(u18) {
1296012960 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
1296112961 .extra = @intFromEnum(pl.type),
1296212962 },
12963 std.builtin.CallingConvention.MicroblazeInterruptOptions => .{
12964 .tag = tag,
12965 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
12966 .extra = @intFromEnum(pl.type),
12967 },
1296312968 std.builtin.CallingConvention.MipsInterruptOptions => .{
1296412969 .tag = tag,
1296512970 .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
......@@ -12997,6 +13002,10 @@ const PackedCallingConvention = packed struct(u18) {
1299713002 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
1299813003 .type = @enumFromInt(cc.extra),
1299913004 },
13005 std.builtin.CallingConvention.MicroblazeInterruptOptions => .{
13006 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
13007 .type = @enumFromInt(cc.extra),
13008 },
1300013009 std.builtin.CallingConvention.MipsInterruptOptions => .{
1300113010 .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
1300213011 .mode = @enumFromInt(cc.extra),
src/Sema.zig+6
......@@ -9135,6 +9135,7 @@ fn callConvIsCallable(cc: std.builtin.CallingConvention.Tag) bool {
91359135 .avr_signal,
91369136 .csky_interrupt,
91379137 .m68k_interrupt,
9138 .microblaze_interrupt,
91389139 .mips_interrupt,
91399140 .mips64_interrupt,
91409141 .msp430_interrupt,
......@@ -9295,6 +9296,7 @@ fn funcCommon(
92959296 },
92969297 .arc_interrupt,
92979298 .arm_interrupt,
9299 .microblaze_interrupt,
92989300 .mips64_interrupt,
92999301 .mips_interrupt,
93009302 .riscv64_interrupt,
......@@ -9530,6 +9532,7 @@ fn finishFunc(
95309532 .avr_interrupt,
95319533 .csky_interrupt,
95329534 .m68k_interrupt,
9535 .microblaze_interrupt,
95339536 .msp430_interrupt,
95349537 .avr_signal,
95359538 => if (return_type.zigTypeTag(zcu) != .void and return_type.zigTypeTag(zcu) != .noreturn) {
......@@ -30057,6 +30060,9 @@ fn callconvCoerceAllowed(
3005730060 std.builtin.CallingConvention.ArmInterruptOptions => {
3005830061 if (src_data.type != dest_data.type) return false;
3005930062 },
30063 std.builtin.CallingConvention.MicroblazeInterruptOptions => {
30064 if (src_data.type != dest_data.type) return false;
30065 },
3006030066 std.builtin.CallingConvention.MipsInterruptOptions => {
3006130067 if (src_data.mode != dest_data.mode) return false;
3006230068 },
src/Zcu.zig+3
......@@ -4438,6 +4438,9 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
44384438 .arm_interrupt,
44394439 => |opts| opts.incoming_stack_alignment == null,
44404440
4441 .microblaze_interrupt,
4442 => |opts| opts.incoming_stack_alignment == null,
4443
44414444 .mips_interrupt,
44424445 .mips64_interrupt,
44434446 => |opts| opts.incoming_stack_alignment == null,
src/codegen/c.zig+7
......@@ -8092,6 +8092,13 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8
80928092
80938093 .avr_signal => "signal",
80948094
8095 .microblaze_interrupt => |opts| switch (opts.type) {
8096 .user => "save_volatiles",
8097 .regular => "interrupt_handler",
8098 .fast => "fast_interrupt",
8099 .breakpoint => "break_handler",
8100 },
8101
80958102 .mips_interrupt,
80968103 .mips64_interrupt,
80978104 => |opts| switch (opts.mode) {
src/codegen/llvm.zig+2
......@@ -11837,6 +11837,7 @@ pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: *const std.Targ
1183711837 std.builtin.CallingConvention.ArcInterruptOptions,
1183811838 std.builtin.CallingConvention.ArmInterruptOptions,
1183911839 std.builtin.CallingConvention.RiscvInterruptOptions,
11840 std.builtin.CallingConvention.MicroblazeInterruptOptions,
1184011841 std.builtin.CallingConvention.MipsInterruptOptions,
1184111842 std.builtin.CallingConvention.CommonOptions,
1184211843 => .{ pl.incoming_stack_alignment, 0 },
......@@ -11926,6 +11927,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
1192611927 .aarch64_aapcs_win,
1192711928 .alpha_osf,
1192811929 .microblaze_std,
11930 .microblaze_interrupt,
1192911931 .mips64_n64,
1193011932 .mips64_n32,
1193111933 .mips_o32,
src/link/Dwarf.zig+1
......@@ -3925,6 +3925,7 @@ fn updateLazyType(
39253925 .avr_interrupt,
39263926 .csky_interrupt,
39273927 .m68k_interrupt,
3928 .microblaze_interrupt,
39283929 .msp430_interrupt,
39293930 => .normal,
39303931