authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-08-21 18:19:23-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-22 12:45:29-07:00
logf448b518f874929dd219ed957c314889d5dbf0cf
tree6d3ca68ef607ef0e8059b00b4d01ac4011a60ba9
parent222e23c6786e0ac307524c6c91b41782111af82a

SPU-II: use undefined1 as breakpoint


2 files changed, 13 insertions(+), 2 deletions(-)

lib/std/spu/interpreter.zig+8-1
......@@ -11,6 +11,9 @@ pub fn Interpreter(comptime Bus: type) type {
1111 /// This is set to true when we hit an undefined0 instruction, allowing it to
1212 /// be used as a trap for testing purposes
1313 undefined0: bool = false,
14 /// This is set to true when we hit an undefined1 instruction, allowing it to
15 /// be used as a trap for testing purposes. undefined1 is used as a breakpoint.
16 undefined1: bool = false,
1417 bus: Bus,
1518
1619 pub fn ExecuteBlock(self: *@This(), comptime size: ?u32) !void {
......@@ -122,7 +125,11 @@ pub fn Interpreter(comptime Bus: type) type {
122125 // Break out of the loop, and let the caller decide what to do
123126 return;
124127 },
125 .undefined1 => return error.BadInstruction,
128 .undefined1 => {
129 self.undefined1 = true;
130 // Break out of the loop, and let the caller decide what to do
131 return;
132 },
126133 .signext => if ((val0 & 0x80) != 0)
127134 (val0 & 0xFF) | 0xFF00
128135 else
src-self-hosted/codegen.zig+5-1
......@@ -1265,7 +1265,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
12651265 .riscv64 => {
12661266 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.ebreak.toU32());
12671267 },
1268 .spu_2 => {},
1268 .spu_2 => {
1269 try self.code.resize(self.code.items.len + 2);
1270 var instr = Instruction{ .condition = .always, .input0 = .zero, .input1 = .zero, .modify_flags = false, .output = .discard, .command = .undefined1 };
1271 mem.writeIntLittle(u16, self.code.items[self.code.items.len - 2 ..][0..2], @bitCast(u16, instr));
1272 },
12691273 else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),
12701274 }
12711275 return .none;