authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-07-10 20:29:55-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-22 12:45:29-07:00
logd005ff16c6fe1a0ddb3997552d6cccf314e6d94f
treec0e59d4936509e17929315b0dda066887bae528b
parent803a1025bbfb8757589068ae29f6f2fc57a4f566

SPU-II: undefined0 inline asm


1 files changed, 23 insertions(+), 0 deletions(-)

src-self-hosted/codegen.zig+23
...@@ -1642,6 +1642,29 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {...@@ -1642,6 +1642,29 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1642 if (!inst.is_volatile and inst.base.isUnused())1642 if (!inst.is_volatile and inst.base.isUnused())
1643 return MCValue.dead;1643 return MCValue.dead;
1644 switch (arch) {1644 switch (arch) {
1645 .spu_2 => {
1646 if (inst.inputs.len > 0 or inst.output != null) {
1647 return self.fail(inst.base.src, "TODO implement inline asm inputs / outputs for SPU Mark II", .{});
1648 }
1649 if (mem.eql(u8, inst.asm_source, "undefined0")) {
1650 // Instructions are 16-bits, plus up to two sixteen bit immediates.
1651 // Upper three bits of first byte are the execution
1652 // condition; for now, only always (0b000) is supported.
1653 // Next, there are two two-bit sequences indicating inputs;
1654 // we only care to use zero (0b00).
1655 // The lowest bit of byte one indicates whether flags
1656 // should be updated; TODO: support that somehow.
1657 // In all, we use a zero byte for the first half of the
1658 // instruction.
1659 // The second byte is 0bOOCCCCCR; OO is output behavior (we
1660 // use zero, which discards the output), CCCCC is the
1661 // command (8 for undefined0), R is reserved.
1662 try self.code.appendSlice(&[_]u8{ 0x00, 0b00010000 });
1663 return MCValue.none;
1664 } else {
1665 return self.fail(inst.base.src, "TODO implement support for more SPU II assembly instructions", .{});
1666 }
1667 },
1645 .riscv64 => {1668 .riscv64 => {
1646 for (inst.inputs) |input, i| {1669 for (inst.inputs) |input, i| {
1647 if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') {1670 if (input.len < 3 or input[0] != '{' or input[input.len - 1] != '}') {