chore: upgrade to zig v0.15.1
This commit is contained in:
109
src/arm.zig
109
src/arm.zig
@@ -6,8 +6,8 @@ const Bus = @import("lib.zig").Bus;
|
||||
const Scheduler = @import("lib.zig").Scheduler;
|
||||
const Coprocessor = @import("lib.zig").Coprocessor;
|
||||
|
||||
const Bitfield = @import("bitfield").Bitfield;
|
||||
const Bit = @import("bitfield").Bit;
|
||||
const Bitfield = @import("bitjuggle").Bitfield;
|
||||
const Bit = @import("bitjuggle").Boolean;
|
||||
|
||||
fn condition_lut(comptime isa: Architecture) [16]u16 {
|
||||
return [_]u16{
|
||||
@@ -158,64 +158,62 @@ pub fn Arm32(comptime isa: Architecture) type {
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: Is this a hack or idiomatic?
|
||||
// See https://github.com/ziglang/zig/blob/1a0e6bcdb140c844384d62b78a7f4247753f9ffd/lib/std/atomic/Atomic.zig#L156-L176
|
||||
pub usingnamespace if (is_v5te) struct {
|
||||
// FIXME: this is pretty NDS9 specific lol
|
||||
pub fn init(scheduler: Scheduler, bus: Bus, cp15: Coprocessor) Self {
|
||||
return .{
|
||||
.sched = scheduler,
|
||||
.bus = bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
pub const init = if (is_v5te) init9 else init7;
|
||||
pub const reset = if (is_v5te) reset9 else reset7;
|
||||
|
||||
.cp15 = cp15,
|
||||
.dtcm = .{},
|
||||
.itcm = .{},
|
||||
};
|
||||
}
|
||||
fn init9(scheduler: Scheduler, bus: Bus, cp15: Coprocessor) Self {
|
||||
return .{
|
||||
.sched = scheduler,
|
||||
.bus = bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
|
||||
// FIXME: Resetting disables logging (if enabled)
|
||||
pub fn reset(self: *Self) void {
|
||||
self.* = .{
|
||||
.sched = self.sched,
|
||||
.bus = self.bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
.cp15 = cp15,
|
||||
.dtcm = .{},
|
||||
.itcm = .{},
|
||||
};
|
||||
}
|
||||
|
||||
.dtcm = .{},
|
||||
.itcm = .{},
|
||||
.cp15 = self.cp15,
|
||||
};
|
||||
}
|
||||
} else struct {
|
||||
pub fn init(scheduler: Scheduler, bus: Bus) Self {
|
||||
return .{
|
||||
.sched = scheduler,
|
||||
.bus = bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
fn init7(scheduler: Scheduler, bus: Bus) Self {
|
||||
return .{
|
||||
.sched = scheduler,
|
||||
.bus = bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
|
||||
.cp15 = {},
|
||||
.dtcm = {},
|
||||
.itcm = {},
|
||||
};
|
||||
}
|
||||
.cp15 = {},
|
||||
.dtcm = {},
|
||||
.itcm = {},
|
||||
};
|
||||
}
|
||||
|
||||
// FIXME: Resetting disables logging (if enabled)
|
||||
pub fn reset(self: *Self) void {
|
||||
self.* = .{
|
||||
.sched = self.sched,
|
||||
.bus = self.bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
// FIXME: Resetting disables logging (if enabled)
|
||||
fn reset9(self: *Self) void {
|
||||
self.* = .{
|
||||
.sched = self.sched,
|
||||
.bus = self.bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
|
||||
.dtcm = {},
|
||||
.itcm = {},
|
||||
.cp15 = {},
|
||||
};
|
||||
}
|
||||
};
|
||||
.dtcm = .{},
|
||||
.itcm = .{},
|
||||
.cp15 = self.cp15,
|
||||
};
|
||||
}
|
||||
|
||||
// FIXME: Resetting disables logging (if enabled)
|
||||
fn reset7(self: *Self) void {
|
||||
self.* = .{
|
||||
.sched = self.sched,
|
||||
.bus = self.bus,
|
||||
.cpsr = .{ .raw = 0x0000_001F },
|
||||
.spsr = .{ .raw = 0x0000_0000 },
|
||||
|
||||
.dtcm = {},
|
||||
.itcm = {},
|
||||
.cp15 = {},
|
||||
};
|
||||
}
|
||||
|
||||
pub fn dbgRead(self: *const Self, comptime T: type, address: u32) T {
|
||||
if (is_v5te) {
|
||||
@@ -410,7 +408,8 @@ pub fn Arm32(comptime isa: Architecture) type {
|
||||
std.debug.print("spsr: 0x{X:0>8} ", .{self.spsr.raw});
|
||||
self.spsr.toString();
|
||||
|
||||
std.debug.print("pipeline: {??X:0>8}\n", .{self.pipe.stage});
|
||||
// FIXME(2025-09-22): Formatting here is wrong
|
||||
std.debug.print("pipeline: {any:0>8}\n", .{self.pipe.stage});
|
||||
|
||||
if (self.cpsr.t.read()) {
|
||||
const opcode = self.bus.dbgRead(u16, self.r[15] - 4);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub fn blockDataTransfer(comptime InstrFn: type, comptime P: bool, comptime U: bool, comptime S: bool, comptime W: bool, comptime L: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const sext = @import("zba-util").sext;
|
||||
const sext = @import("zba_util").sext;
|
||||
|
||||
pub fn branch(comptime InstrFn: type, comptime L: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
@@ -29,7 +29,7 @@ pub fn branch(comptime InstrFn: type, comptime L: bool) InstrFn {
|
||||
}
|
||||
|
||||
pub fn branchAndExchange(comptime InstrFn: type) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
pub fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const std = @import("std");
|
||||
const Bit = @import("bitfield").Bit;
|
||||
const Bit = @import("bitjuggle").Boolean;
|
||||
|
||||
const log = std.log.scoped(.coprocessor_handler);
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn dataTransfer(
|
||||
comptime W: bool,
|
||||
comptime L: bool,
|
||||
) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
@@ -80,7 +80,7 @@ pub fn dataTransfer(
|
||||
}
|
||||
|
||||
pub fn registerTransfer(comptime InstrFn: type, comptime opcode1: u3, comptime L: bool, comptime opcode2: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
@@ -147,7 +147,7 @@ pub fn registerTransfer(comptime InstrFn: type, comptime opcode1: u3, comptime L
|
||||
pub fn dataProcessing(comptime InstrFn: type, comptime opcode1: u4, comptime opcode2: u3) InstrFn {
|
||||
_ = opcode2;
|
||||
_ = opcode1;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -2,7 +2,7 @@ const exec = @import("../barrel_shifter.zig").exec;
|
||||
const ror = @import("../barrel_shifter.zig").ror;
|
||||
|
||||
pub fn dataProcessing(comptime InstrFn: type, comptime I: bool, comptime S: bool, comptime kind: u4) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
@@ -153,7 +153,7 @@ pub fn dataProcessing(comptime InstrFn: type, comptime I: bool, comptime S: bool
|
||||
}
|
||||
|
||||
fn undefinedTestBehaviour(cpu: *Arm32) void {
|
||||
@setCold(true);
|
||||
@branchHint(.cold);
|
||||
cpu.setCpsr(cpu.spsr.raw);
|
||||
}
|
||||
}.inner;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const std = @import("std");
|
||||
const sext = @import("zba-util").sext;
|
||||
const rotr = @import("zba-util").rotr;
|
||||
const sext = @import("zba_util").sext;
|
||||
const rotr = @import("zba_util").rotr;
|
||||
|
||||
const log = std.log.scoped(.half_and_signed_data_transfer);
|
||||
|
||||
pub fn halfAndSignedDataTransfer(comptime InstrFn: type, comptime P: bool, comptime U: bool, comptime I: bool, comptime W: bool, comptime L: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub fn multiply(comptime InstrFn: type, comptime L: bool, comptime U: bool, comptime A: bool, comptime S: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const std = @import("std");
|
||||
|
||||
const PSR = @import("../../../arm.zig").PSR;
|
||||
const rotr = @import("zba-util").rotr;
|
||||
const rotr = @import("zba_util").rotr;
|
||||
|
||||
const log = std.log.scoped(.ctrl_ext_space);
|
||||
|
||||
pub fn control(comptime InstrFn: type, comptime I: bool, comptime op: u6) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const shifter = @import("../barrel_shifter.zig");
|
||||
|
||||
const rotr = @import("zba-util").rotr;
|
||||
const rotr = @import("zba_util").rotr;
|
||||
|
||||
pub fn singleDataTransfer(comptime InstrFn: type, comptime I: bool, comptime P: bool, comptime U: bool, comptime B: bool, comptime W: bool, comptime L: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u32) void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub fn armSoftwareInterrupt(comptime InstrFn: type) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, _: u32) void {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const CPSR = @import("../../arm.zig").PSR;
|
||||
|
||||
const rotr = @import("zba-util").rotr;
|
||||
const rotr = @import("zba_util").rotr;
|
||||
|
||||
pub fn exec(comptime S: bool, cpu: anytype, opcode: u32) u32 {
|
||||
var result: u32 = undefined;
|
||||
@@ -70,7 +70,7 @@ pub fn immediate(comptime S: bool, cpu: anytype, opcode: u32) u32 {
|
||||
|
||||
pub fn lsl(comptime S: bool, cpsr: *CPSR, rm: u32, total_amount: u8) u32 {
|
||||
const amount: u5 = @truncate(total_amount);
|
||||
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
||||
const bit_count: u8 = @typeInfo(u32).int.bits;
|
||||
|
||||
var result: u32 = 0x0000_0000;
|
||||
if (total_amount < bit_count) {
|
||||
@@ -97,7 +97,7 @@ pub fn lsl(comptime S: bool, cpsr: *CPSR, rm: u32, total_amount: u8) u32 {
|
||||
|
||||
pub fn lsr(comptime S: bool, cpsr: *CPSR, rm: u32, total_amount: u32) u32 {
|
||||
const amount: u5 = @truncate(total_amount);
|
||||
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
||||
const bit_count: u8 = @typeInfo(u32).int.bits;
|
||||
|
||||
var result: u32 = 0x0000_0000;
|
||||
if (total_amount < bit_count) {
|
||||
@@ -121,7 +121,7 @@ pub fn lsr(comptime S: bool, cpsr: *CPSR, rm: u32, total_amount: u32) u32 {
|
||||
|
||||
pub fn asr(comptime S: bool, cpsr: *CPSR, rm: u32, total_amount: u8) u32 {
|
||||
const amount: u5 = @truncate(total_amount);
|
||||
const bit_count: u8 = @typeInfo(u32).Int.bits;
|
||||
const bit_count: u8 = @typeInfo(u32).int.bits;
|
||||
|
||||
var result: u32 = 0x0000_0000;
|
||||
if (total_amount < bit_count) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const asr = @import("../barrel_shifter.zig").asr;
|
||||
const ror = @import("../barrel_shifter.zig").ror;
|
||||
|
||||
pub fn fmt4(comptime InstrFn: type, comptime op: u4) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub fn fmt14(comptime InstrFn: type, comptime L: bool, comptime R: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -47,7 +47,7 @@ pub fn fmt14(comptime InstrFn: type, comptime L: bool, comptime R: bool) InstrFn
|
||||
}
|
||||
|
||||
pub fn fmt15(comptime InstrFn: type, comptime L: bool, comptime rb: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const sext = @import("zba-util").sext;
|
||||
const sext = @import("zba_util").sext;
|
||||
|
||||
pub fn fmt16(comptime InstrFn: type, comptime cond: u4) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -18,7 +18,7 @@ pub fn fmt16(comptime InstrFn: type, comptime cond: u4) InstrFn {
|
||||
}
|
||||
|
||||
pub fn linkExchange(comptime InstrFn: type, comptime H: u2) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
|
||||
@@ -5,7 +5,7 @@ const lsr = @import("../barrel_shifter.zig").lsr;
|
||||
const asr = @import("../barrel_shifter.zig").asr;
|
||||
|
||||
pub fn fmt1(comptime InstrFn: type, comptime op: u2, comptime offset: u5) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -53,7 +53,7 @@ pub fn fmt1(comptime InstrFn: type, comptime op: u2, comptime offset: u5) InstrF
|
||||
}
|
||||
|
||||
pub fn fmt5(comptime InstrFn: type, comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -119,7 +119,7 @@ pub fn fmt5(comptime InstrFn: type, comptime op: u2, comptime h1: u1, comptime h
|
||||
}
|
||||
|
||||
pub fn fmt2(comptime InstrFn: type, comptime I: bool, is_sub: bool, rn: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -153,7 +153,7 @@ pub fn fmt2(comptime InstrFn: type, comptime I: bool, is_sub: bool, rn: u3) Inst
|
||||
}
|
||||
|
||||
pub fn fmt3(comptime InstrFn: type, comptime op: u2, comptime rd: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -193,7 +193,7 @@ pub fn fmt3(comptime InstrFn: type, comptime op: u2, comptime rd: u3) InstrFn {
|
||||
}
|
||||
|
||||
pub fn fmt12(comptime InstrFn: type, comptime isSP: bool, comptime rd: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -206,7 +206,7 @@ pub fn fmt12(comptime InstrFn: type, comptime isSP: bool, comptime rd: u3) Instr
|
||||
}
|
||||
|
||||
pub fn fmt13(comptime InstrFn: type, comptime S: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -218,7 +218,7 @@ pub fn fmt13(comptime InstrFn: type, comptime S: bool) InstrFn {
|
||||
}
|
||||
|
||||
pub fn bkpt(comptime InstrFn: type) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, _: u16) void {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const rotr = @import("zba-util").rotr;
|
||||
const sext = @import("zba-util").sext;
|
||||
const rotr = @import("zba_util").rotr;
|
||||
const sext = @import("zba_util").sext;
|
||||
|
||||
pub fn fmt6(comptime InstrFn: type, comptime rd: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -16,7 +16,7 @@ pub fn fmt6(comptime InstrFn: type, comptime rd: u3) InstrFn {
|
||||
}
|
||||
|
||||
pub fn fmt78(comptime InstrFn: type, comptime op: u2, comptime T: bool) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -90,7 +90,7 @@ pub fn fmt78(comptime InstrFn: type, comptime op: u2, comptime T: bool) InstrFn
|
||||
}
|
||||
|
||||
pub fn fmt9(comptime InstrFn: type, comptime B: bool, comptime L: bool, comptime offset: u5) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -126,7 +126,7 @@ pub fn fmt9(comptime InstrFn: type, comptime B: bool, comptime L: bool, comptime
|
||||
}
|
||||
|
||||
pub fn fmt10(comptime InstrFn: type, comptime L: bool, comptime offset: u5) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
@@ -152,7 +152,7 @@ pub fn fmt10(comptime InstrFn: type, comptime L: bool, comptime offset: u5) Inst
|
||||
}
|
||||
|
||||
pub fn fmt11(comptime InstrFn: type, comptime L: bool, comptime rd: u3) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, opcode: u16) void {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub fn fmt17(comptime InstrFn: type) InstrFn {
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).Pointer.child).Fn.params[0].type.?).Pointer.child;
|
||||
const Arm32 = @typeInfo(@typeInfo(@typeInfo(InstrFn).pointer.child).@"fn".params[0].type.?).pointer.child;
|
||||
|
||||
return struct {
|
||||
fn inner(cpu: *Arm32, _: u16) void {
|
||||
|
||||
18
src/lib.zig
18
src/lib.zig
@@ -92,9 +92,9 @@ pub const Bus = struct {
|
||||
const P = @TypeOf(obj);
|
||||
const info = @typeInfo(P);
|
||||
|
||||
std.debug.assert(info == .Pointer); // `anytype` is a Pointer
|
||||
std.debug.assert(info.Pointer.size == .One); // Single-Item Pointer
|
||||
std.debug.assert(@typeInfo(info.Pointer.child) == .Struct); // Pointer Child is a `struct`
|
||||
std.debug.assert(info == .pointer); // `anytype` is a Pointer
|
||||
std.debug.assert(info.pointer.size == .one); // Single-Item Pointer
|
||||
std.debug.assert(@typeInfo(info.pointer.child) == .@"struct"); // Pointer Child is a `struct`
|
||||
|
||||
const impl = struct {
|
||||
fn read8(ptr: *anyopaque, address: u32) u8 {
|
||||
@@ -272,9 +272,9 @@ pub const Coprocessor = struct {
|
||||
const P = @TypeOf(obj);
|
||||
const info = @typeInfo(P);
|
||||
|
||||
std.debug.assert(info == .Pointer); // `anytype` is a Pointer
|
||||
std.debug.assert(info.Pointer.size == .One); // Single-Item Pointer
|
||||
std.debug.assert(@typeInfo(info.Pointer.child) == .Struct); // Pointer Child is a `struct`
|
||||
std.debug.assert(info == .pointer); // `anytype` is a Pointer
|
||||
std.debug.assert(info.pointer.size == .one); // Single-Item Pointer
|
||||
std.debug.assert(@typeInfo(info.pointer.child) == .@"struct"); // Pointer Child is a `struct`
|
||||
|
||||
const impl = struct {
|
||||
fn read(ptr: *anyopaque, op1: u3, cn: u4, cm: u4, op2: u3) u32 {
|
||||
@@ -351,9 +351,9 @@ pub const Scheduler = struct {
|
||||
const P = @TypeOf(obj);
|
||||
const info = @typeInfo(P);
|
||||
|
||||
std.debug.assert(info == .Pointer); // `anytype` is a Pointer
|
||||
std.debug.assert(info.Pointer.size == .One); // Single-Item Pointer
|
||||
std.debug.assert(@typeInfo(info.Pointer.child) == .Struct); // Pointer Child is a `struct`
|
||||
std.debug.assert(info == .pointer); // `anytype` is a Pointer
|
||||
std.debug.assert(info.pointer.size == .one); // Single-Item Pointer
|
||||
std.debug.assert(@typeInfo(info.pointer.child) == .@"struct"); // Pointer Child is a `struct`
|
||||
|
||||
const impl = struct {
|
||||
fn now(ptr: *anyopaque) u64 {
|
||||
|
||||
Reference in New Issue
Block a user