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 {...@@ -11,6 +11,9 @@ pub fn Interpreter(comptime Bus: type) type {
11 /// This is set to true when we hit an undefined0 instruction, allowing it to11 /// This is set to true when we hit an undefined0 instruction, allowing it to
12 /// be used as a trap for testing purposes12 /// be used as a trap for testing purposes
13 undefined0: bool = false,13 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,
14 bus: Bus,17 bus: Bus,
1518
16 pub fn ExecuteBlock(self: *@This(), comptime size: ?u32) !void {19 pub fn ExecuteBlock(self: *@This(), comptime size: ?u32) !void {
...@@ -122,7 +125,11 @@ pub fn Interpreter(comptime Bus: type) type {...@@ -122,7 +125,11 @@ pub fn Interpreter(comptime Bus: type) type {
122 // Break out of the loop, and let the caller decide what to do125 // Break out of the loop, and let the caller decide what to do
123 return;126 return;
124 },127 },
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 },
126 .signext => if ((val0 & 0x80) != 0)133 .signext => if ((val0 & 0x80) != 0)
127 (val0 & 0xFF) | 0xFF00134 (val0 & 0xFF) | 0xFF00
128 else135 else
src-self-hosted/codegen.zig+5-1
...@@ -1265,7 +1265,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -1265,7 +1265,11 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1265 .riscv64 => {1265 .riscv64 => {
1266 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.ebreak.toU32());1266 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.ebreak.toU32());
1267 },1267 },
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 },
1269 else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),1273 else => return self.fail(src, "TODO implement @breakpoint() for {}", .{self.target.cpu.arch}),
1270 }1274 }
1271 return .none;1275 return .none;