authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-05-02 21:56:04+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-05-16 22:47:53+07:00
log5d260eb573132194e802680803f225404a06b00e
treecb69d6f44adab99174cd4fd314c5dfbdabbe98f3
parent2770f9a03464dee1e11134054598a6e07c30a6e4

stage2: sparc64: Implement SPARCv9 subcc


2 files changed, 11 insertions(+), 1 deletions(-)

src/arch/sparc64/Emit.zig+3-1
......@@ -81,7 +81,7 @@ pub fn emitMir(
8181 .stx => try emit.mirArithmetic3Op(inst),
8282
8383 .sub => try emit.mirArithmetic3Op(inst),
84 .subcc => @panic("TODO implement sparcv9 subcc"),
84 .subcc => try emit.mirArithmetic3Op(inst),
8585
8686 .tcc => try emit.mirTrap(inst),
8787 }
......@@ -169,6 +169,7 @@ fn mirArithmetic3Op(emit: *Emit, inst: Mir.Inst.Index) !void {
169169 .stw => try emit.writeInstruction(Instruction.stw(i13, rs1, imm, rd)),
170170 .stx => try emit.writeInstruction(Instruction.stx(i13, rs1, imm, rd)),
171171 .sub => try emit.writeInstruction(Instruction.sub(i13, rs1, imm, rd)),
172 .subcc => try emit.writeInstruction(Instruction.subcc(i13, rs1, imm, rd)),
172173 else => unreachable,
173174 }
174175 } else {
......@@ -188,6 +189,7 @@ fn mirArithmetic3Op(emit: *Emit, inst: Mir.Inst.Index) !void {
188189 .stw => try emit.writeInstruction(Instruction.stw(Register, rs1, rs2, rd)),
189190 .stx => try emit.writeInstruction(Instruction.stx(Register, rs1, rs2, rd)),
190191 .sub => try emit.writeInstruction(Instruction.sub(Register, rs1, rs2, rd)),
192 .subcc => try emit.writeInstruction(Instruction.subcc(Register, rs1, rs2, rd)),
191193 else => unreachable,
192194 }
193195 }
src/arch/sparc64/bits.zig+8
......@@ -1261,6 +1261,14 @@ pub const Instruction = union(enum) {
12611261 };
12621262 }
12631263
1264 pub fn subcc(comptime s2: type, rs1: Register, rs2: s2, rd: Register) Instruction {
1265 return switch (s2) {
1266 Register => format3a(0b10, 0b01_0100, rs1, rs2, rd),
1267 i13 => format3b(0b10, 0b01_0100, rs1, rs2, rd),
1268 else => unreachable,
1269 };
1270 }
1271
12641272 pub fn trap(comptime s2: type, cond: ICondition, ccr: CCR, rs1: Register, rs2: s2) Instruction {
12651273 // Tcc instructions abuse the rd field to store the conditionals.
12661274 return switch (s2) {