pub fn dwarfRegisterBytes(ctx: *Powerpc, register_num: u16) DwarfRegisterError![]u8 {
// References:
//
// * System V Application Binary Interface - PowerPC Processor Supplement §3-46
// * Power Architecture 32-bit Application Binary Interface Supplement 1.0 - Linux & Embedded §3.4
// * 64-bit ELF V2 ABI Specification - Power Architecture Revision 1.5 §2.4
//
// Are we having fun yet?
if (Gpr == u64) switch (register_num) {
65 => return @ptrCast(&ctx.lr), // lr
66 => return error.UnsupportedRegister, // ctr
68...75 => return error.UnsupportedRegister, // cr0 - cr7
76 => return error.UnsupportedRegister, // xer
77...108 => return error.UnsupportedRegister, // vr0 - vr31
109 => return error.UnsupportedRegister, // vrsave (LLVM)
110 => return error.UnsupportedRegister, // vscr
114 => return error.UnsupportedRegister, // tfhar
115 => return error.UnsupportedRegister, // tfiar
116 => return error.UnsupportedRegister, // texasr
else => {},
} else switch (register_num) {
65 => return @ptrCast(&ctx.lr), // fpscr (SVR4 / EABI), or lr if you ask LLVM
108 => return @ptrCast(&ctx.lr),
64 => return error.UnsupportedRegister, // cr
66 => return error.UnsupportedRegister, // msr (SVR4 / EABI), or ctr if you ask LLVM
68...75 => return error.UnsupportedRegister, // cr0 - cr7 if you ask LLVM
76 => return error.UnsupportedRegister, // xer if you ask LLVM
99 => return error.UnsupportedRegister, // acc
100 => return error.UnsupportedRegister, // mq
101 => return error.UnsupportedRegister, // xer
102...107 => return error.UnsupportedRegister, // SPRs
109 => return error.UnsupportedRegister, // ctr
110...111 => return error.UnsupportedRegister, // SPRs
112 => return error.UnsupportedRegister, // spefscr
113...1123 => return error.UnsupportedRegister, // SPRs
1124...1155 => return error.UnsupportedRegister, // SPE v0 - v31
1200...1231 => return error.UnsupportedRegister, // SPE upper r0 - r31
3072...4095 => return error.UnsupportedRegister, // DCRs
4096...5120 => return error.UnsupportedRegister, // PMRs
else => {},
}
switch (register_num) {
0...31 => return @ptrCast(&ctx.r[register_num]),
67 => return @ptrCast(&ctx.pc),
32...63 => return error.UnsupportedRegister, // f0 - f31
else => return error.InvalidRegister,
}
}