Commit f448b518f8
Changed files (2)
lib
std
src-self-hosted
lib/std/spu/interpreter.zig
@@ -11,6 +11,9 @@ pub fn Interpreter(comptime Bus: type) type {
/// This is set to true when we hit an undefined0 instruction, allowing it to
/// be used as a trap for testing purposes
undefined0: bool = false,
+ /// This is set to true when we hit an undefined1 instruction, allowing it to
+ /// be used as a trap for testing purposes. undefined1 is used as a breakpoint.
+ undefined1: bool = false,
bus: Bus,
pub fn ExecuteBlock(self: *@This(), comptime size: ?u32) !void {
@@ -122,7 +125,11 @@ pub fn Interpreter(comptime Bus: type) type {
// Break out of the loop, and let the caller decide what to do
return;
},
- .undefined1 => return error.BadInstruction,
+ .undefined1 => {
+ self.undefined1 = true;
+ // Break out of the loop, and let the caller decide what to do
+ return;
+ },
.signext => if ((val0 & 0x80) != 0)
(val0 & 0xFF) | 0xFF00
else
src-self-hosted/codegen.zig
@@ -1265,7 +1265,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
.riscv64 => {
mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.ebreak.toU32());
},
- .spu_2 => {},
+ .spu_2 => {
+ try self.code.resize(self.code.items.len + 2);
+ var instr = Instruction{ .condition = .always, .input0 = .zero, .input1 = .zero, .modify_flags = false, .output = .discard, .command = .undefined1 };
+ mem.writeIntLittle(u16, self.code.items[self.code.items.len - 2 ..][0..2], @bitCast(u16, instr));
+ },
else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),
}
return .none;