Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Struct

Lanai

Private Struct
std.debug.cpu_context.Lanai
const Lanai = extern struct

This is an extern struct so that inline assembly in current can use field offsets.

Fields

r: [32]Gpr

Values

Functions

pub inline fn current() Lanai
pub fn getFp(ctx: *const Lanai) usize
pub fn getPc(ctx: *const Lanai) usize
pub fn dwarfRegisterBytes(ctx: *Lanai, register_num: u16) DwarfRegisterError![]u8

File

debug/cpu_context.zig:713
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
const Lanai = extern struct {
    r: [32]Gpr,

    pub const Gpr = u32;

    pub inline fn current() Lanai {
        var ctx: Lanai = undefined;
        asm volatile (
            \\ st %%r0, 0[%%r9]
            \\ st %%r1, 4[%%r9]
            \\ st %%r2, 8[%%r9]
            \\ st %%r3, 12[%%r9]
            \\ st %%r4, 16[%%r9]
            \\ st %%r5, 20[%%r9]
            \\ st %%r6, 24[%%r9]
            \\ st %%r7, 28[%%r9]
            \\ st %%r8, 32[%%r9]
            \\ st %%r9, 36[%%r9]
            \\ st %%r10, 40[%%r9]
            \\ st %%r11, 44[%%r9]
            \\ st %%r12, 48[%%r9]
            \\ st %%r13, 52[%%r9]
            \\ st %%r14, 56[%%r9]
            \\ st %%r15, 60[%%r9]
            \\ st %%r16, 64[%%r9]
            \\ st %%r17, 68[%%r9]
            \\ st %%r18, 72[%%r9]
            \\ st %%r19, 76[%%r9]
            \\ st %%r20, 80[%%r9]
            \\ st %%r21, 84[%%r9]
            \\ st %%r22, 88[%%r9]
            \\ st %%r23, 92[%%r9]
            \\ st %%r24, 96[%%r9]
            \\ st %%r25, 100[%%r9]
            \\ st %%r26, 104[%%r9]
            \\ st %%r27, 108[%%r9]
            \\ st %%r28, 112[%%r9]
            \\ st %%r29, 116[%%r9]
            \\ st %%r30, 120[%%r9]
            \\ st %%r31, 124[%%r9]
            :
            : [ctx] "{r9}" (&ctx),
            : .{ .memory = true });
        return ctx;
    }

    pub fn getFp(ctx: *const Lanai) usize {
        return ctx.r[5];
    }
    pub fn getPc(ctx: *const Lanai) usize {
        return ctx.r[2];
    }

    pub fn dwarfRegisterBytes(ctx: *Lanai, register_num: u16) DwarfRegisterError![]u8 {
        switch (register_num) {
            0...31 => return @ptrCast(&ctx.r[register_num]),

            else => return error.InvalidRegister,
        }
    }
}