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

S390x

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

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

Fields

r: [16]Gpr

The numbered general-purpose registers r0 - r15.

psw: extern struct { mask: Gpr, addr: Gpr, }

The program counter.

Values

Functions

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

File

debug/cpu_context.zig:1469
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
const S390x = extern struct {
    /// The numbered general-purpose registers r0 - r15.
    r: [16]Gpr,
    /// The program counter.
    psw: extern struct {
        mask: Gpr,
        addr: Gpr,
    },

    pub const Gpr = u64;

    pub inline fn current() S390x {
        var ctx: S390x = undefined;
        asm volatile (
            \\ stmg %%r0, %%r15, 0(%%r2)
            \\ epsw %%r0, %%r1
            \\ stm %%r0, %%r1, 128(%%r2)
            \\ larl %%r0, .
            \\ stg %%r0, 136(%%r2)
            :
            : [ctx] "{r2}" (&ctx),
            : .{ .r0 = true, .r1 = true, .memory = true });
        return ctx;
    }

    pub fn getFp(ctx: *const S390x) usize {
        return ctx.r[11];
    }
    pub fn getPc(ctx: *const S390x) usize {
        return ctx.psw.addr;
    }

    pub fn dwarfRegisterBytes(ctx: *S390x, register_num: u16) DwarfRegisterError![]u8 {
        switch (register_num) {
            0...15 => return @ptrCast(&ctx.r[register_num]),
            64 => return @ptrCast(&ctx.psw.mask),
            65 => return @ptrCast(&ctx.psw.addr),

            16...31 => return error.UnsupportedRegister, // f0 - f15
            32...47 => return error.UnsupportedRegister, // cr0 - cr15
            48...63 => return error.UnsupportedRegister, // a0 - a15
            66...67 => return error.UnsupportedRegister, // z/OS stuff???
            68...83 => return error.UnsupportedRegister, // v16 - v31

            else => return error.InvalidRegister,
        }
    }
}