| ... | ... | @@ -79,7 +79,7 @@ pub fn emitMir( |
| 79 | 79 | .dbg_epilogue_begin => try emit.mirDebugEpilogueBegin(), |
| 80 | 80 | |
| 81 | 81 | .add => try emit.mirArithmetic3Op(inst), |
| 82 | | .addcc => @panic("TODO implement sparc64 addcc"), |
| 82 | .addcc => try emit.mirArithmetic3Op(inst), |
| 83 | 83 | |
| 84 | 84 | .bpr => try emit.mirConditionalBranch(inst), |
| 85 | 85 | .bpcc => try emit.mirConditionalBranch(inst), |
| ... | ... | @@ -95,7 +95,7 @@ pub fn emitMir( |
| 95 | 95 | |
| 96 | 96 | .@"or" => try emit.mirArithmetic3Op(inst), |
| 97 | 97 | |
| 98 | | .movcc => @panic("TODO implement sparc64 movcc"), |
| 98 | .movcc => try emit.mirConditionalMove(inst), |
| 99 | 99 | |
| 100 | 100 | .mulx => try emit.mirArithmetic3Op(inst), |
| 101 | 101 | |
| ... | ... | @@ -212,6 +212,7 @@ fn mirArithmetic3Op(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 212 | 212 | const imm = data.rs2_or_imm.imm; |
| 213 | 213 | switch (tag) { |
| 214 | 214 | .add => try emit.writeInstruction(Instruction.add(i13, rs1, imm, rd)), |
| 215 | .addcc => try emit.writeInstruction(Instruction.addcc(i13, rs1, imm, rd)), |
| 215 | 216 | .jmpl => try emit.writeInstruction(Instruction.jmpl(i13, rs1, imm, rd)), |
| 216 | 217 | .ldub => try emit.writeInstruction(Instruction.ldub(i13, rs1, imm, rd)), |
| 217 | 218 | .lduh => try emit.writeInstruction(Instruction.lduh(i13, rs1, imm, rd)), |
| ... | ... | @@ -233,6 +234,7 @@ fn mirArithmetic3Op(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 233 | 234 | const rs2 = data.rs2_or_imm.rs2; |
| 234 | 235 | switch (tag) { |
| 235 | 236 | .add => try emit.writeInstruction(Instruction.add(Register, rs1, rs2, rd)), |
| 237 | .addcc => try emit.writeInstruction(Instruction.addcc(Register, rs1, rs2, rd)), |
| 236 | 238 | .jmpl => try emit.writeInstruction(Instruction.jmpl(Register, rs1, rs2, rd)), |
| 237 | 239 | .ldub => try emit.writeInstruction(Instruction.ldub(Register, rs1, rs2, rd)), |
| 238 | 240 | .lduh => try emit.writeInstruction(Instruction.lduh(Register, rs1, rs2, rd)), |
| ... | ... | @@ -297,6 +299,34 @@ fn mirConditionalBranch(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 297 | 299 | } |
| 298 | 300 | } |
| 299 | 301 | |
| 302 | fn mirConditionalMove(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 303 | const tag = emit.mir.instructions.items(.tag)[inst]; |
| 304 | |
| 305 | switch (tag) { |
| 306 | .movcc => { |
| 307 | const data = emit.mir.instructions.items(.data)[inst].conditional_move; |
| 308 | if (data.is_imm) { |
| 309 | try emit.writeInstruction(Instruction.movcc( |
| 310 | i11, |
| 311 | data.cond, |
| 312 | data.ccr, |
| 313 | data.rs2_or_imm.imm, |
| 314 | data.rd, |
| 315 | )); |
| 316 | } else { |
| 317 | try emit.writeInstruction(Instruction.movcc( |
| 318 | Register, |
| 319 | data.cond, |
| 320 | data.ccr, |
| 321 | data.rs2_or_imm.rs2, |
| 322 | data.rd, |
| 323 | )); |
| 324 | } |
| 325 | }, |
| 326 | else => unreachable, |
| 327 | } |
| 328 | } |
| 329 | |
| 300 | 330 | fn mirNop(emit: *Emit) !void { |
| 301 | 331 | try emit.writeInstruction(Instruction.nop()); |
| 302 | 332 | } |