Zig 0.17.0-dev (Split by item) 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.
std › debug › cpu_context › Kvx Private Struct Kvx Doc Source Private Struct std.debug.cpu_context.Kvx
const Kvx = extern struct Fields Values Functions File debug/cpu_context.zig: 639
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710 const Kvx = extern struct {
r : [64 ]Gpr ,
pc : Gpr ,
ra : Gpr ,
pub const Gpr = u64 ;
pub inline fn current () Kvx {
var ctx : Kvx = undefined ;
asm volatile (
\\ so (0)[$r32] = $r0r1r2r3
\\ ;;
\\ so (32)[$r32] = $r4r5r6r7
\\ ;;
\\ so (64)[$r32] = $r8r9r10r11
\\ ;;
\\ so (96)[$r32] = $r12r13r14r15
\\ ;;
\\ so (128)[$r32] = $r16r17r18r19
\\ ;;
\\ so (160)[$r32] = $r20r21r22r23
\\ ;;
\\ so (192)[$r32] = $r24r25r26r27
\\ ;;
\\ so (224)[$r32] = $r28r29r30r31
\\ ;;
\\ so (256)[$r32] = $r32r33r34r35
\\ ;;
\\ so (288)[$r32] = $r36r37r38r39
\\ ;;
\\ so (320)[$r32] = $r40r41r42r43
\\ ;;
\\ so (352)[$r32] = $r44r45r46r47
\\ ;;
\\ so (384)[$r32] = $r48r49r50r51
\\ ;;
\\ so (416)[$r32] = $r52r53r54r55
\\ ;;
\\ so (448)[$r32] = $r56r57r58r59
\\ get $r34 = $pc
\\ ;;
\\ so (480)[$r32] = $r60r61r62r63
\\ get $r35 = $ra
\\ ;;
\\ sq (512)[$r32] = $r34r35
:
: [ctx ] "{r32}" (&ctx ),
: .{ .r34 = true , .r35 = true , .memory = true });
return ctx ;
}
pub fn getFp (ctx : *const Kvx ) usize {
return ctx .r [14 ];
}
pub fn getPc (ctx : *const Kvx ) usize {
return ctx .pc ;
}
pub fn dwarfRegisterBytes (ctx : *Kvx , register_num : u16 ) DwarfRegisterError ![]u8 {
switch (register_num ) {
0 ...63 => return @ptrCast (&ctx .r [register_num ]),
64 => return @ptrCast (&ctx .pc ),
67 => return @ptrCast (&ctx .ra ),
65 ...66 => return error .UnsupportedRegister , // SFRs
68 ...255 => return error .UnsupportedRegister , // SFRs
256 ...767 => return error .UnsupportedRegister , // XCRs
else => return error .InvalidRegister ,
}
}
}
This is an
extern structso that inline assembly incurrentcan use field offsets.