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

Arc

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

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

Fields

r: [32]Gpr

The numbered general-purpose registers r0 - r31.

pcl: Gpr

Values

Functions

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

File

debug/cpu_context.zig:384
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
const Arc = extern struct {
    /// The numbered general-purpose registers r0 - r31.
    r: [32]Gpr,
    pcl: Gpr,

    pub const Gpr = u32;

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

    pub fn getFp(ctx: *const Arc) usize {
        return ctx.r[27];
    }
    pub fn getPc(ctx: *const Arc) usize {
        return ctx.pcl;
    }

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

            32...57 => return error.UnsupportedRegister, // Extension Core Registers
            58...127 => return error.UnsupportedRegister, // Reserved
            128...159 => return error.UnsupportedRegister, // f0 - f31

            else => return error.InvalidRegister,
        }
    }
}