Commit afe5fe22 by Stefan Maksimovic Committed by Jim Stichnoth

Subzero, MIPS32: Fix conditional mov instructions

This patch implements changes needed for conditional mov instructions to fix problem with failing crosstest and invalid register allocation. Problem is visible from icmp test examples, causing cross test for icmp to fail. Eg: Incorrect, before this change: 674: 00653026 xor a2,v1,a1 678: 00a3182b sltu v1,a1,v1 67c: 0082102b sltu v0,a0,v0 680: 0043180a movz v1,v0,v0 Correct, aftrer this change: 674: 00653026 xor a2,v1,a1 678: 00a3182b sltu v1,a1,v1 67c: 0082102b sltu v0,a0,v0 680: 0046180a movz v1,v0,a2 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/2394773004 . Patch from Stefan Maksimovic <makdstefan@gmail.com>.
parent 033dda7e
......@@ -971,7 +971,7 @@ template <> void InstMIPS32Mov_s::emitIAS(const Cfg *Func) const {
template <> void InstMIPS32Movf::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
Asm->movf(getDest(), getSrc(1), getSrc(2));
Asm->movf(getDest(), getSrc(0), getSrc(1));
}
template <> void InstMIPS32Movn::emitIAS(const Cfg *Func) const {
......@@ -991,7 +991,7 @@ template <> void InstMIPS32Movn_s::emitIAS(const Cfg *Func) const {
template <> void InstMIPS32Movt::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
Asm->movt(getDest(), getSrc(1), getSrc(2));
Asm->movt(getDest(), getSrc(0), getSrc(1));
}
template <> void InstMIPS32Movz::emitIAS(const Cfg *Func) const {
......
......@@ -1065,13 +1065,13 @@ public:
if (!BuildDefs::dump())
return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3);
assert(getSrcSize() == 2);
Str << "\t" << Opcode << "\t";
getDest()->emit(Func);
Str << ", ";
getSrc(1)->emit(Func);
getSrc(0)->emit(Func);
Str << ", ";
getSrc(2)->emit(Func);
getSrc(1)->emit(Func);
}
void emitIAS(const Cfg *Func) const override {
......@@ -1094,8 +1094,7 @@ public:
private:
InstMIPS32MovConditional(Cfg *Func, Variable *Dest, Variable *Src,
Operand *FCC)
: InstMIPS32(Func, K, 3, Dest) {
addSource(Dest);
: InstMIPS32(Func, K, 2, Dest) {
addSource(Src);
addSource(FCC);
}
......@@ -1148,11 +1147,11 @@ using InstMIPS32Mflo = InstMIPS32UnaryopGPR<InstMIPS32::Mflo>;
using InstMIPS32Mov_d = InstMIPS32TwoAddrFPR<InstMIPS32::Mov_d>;
using InstMIPS32Mov_s = InstMIPS32TwoAddrFPR<InstMIPS32::Mov_s>;
using InstMIPS32Movf = InstMIPS32MovConditional<InstMIPS32::Movf>;
using InstMIPS32Movn = InstMIPS32MovConditional<InstMIPS32::Movn>;
using InstMIPS32Movn = InstMIPS32ThreeAddrGPR<InstMIPS32::Movn>;
using InstMIPS32Movn_d = InstMIPS32ThreeAddrGPR<InstMIPS32::Movn_d>;
using InstMIPS32Movn_s = InstMIPS32ThreeAddrGPR<InstMIPS32::Movn_s>;
using InstMIPS32Movt = InstMIPS32MovConditional<InstMIPS32::Movt>;
using InstMIPS32Movz = InstMIPS32MovConditional<InstMIPS32::Movz>;
using InstMIPS32Movz = InstMIPS32ThreeAddrGPR<InstMIPS32::Movz>;
using InstMIPS32Movz_d = InstMIPS32ThreeAddrGPR<InstMIPS32::Movz_d>;
using InstMIPS32Movz_s = InstMIPS32ThreeAddrGPR<InstMIPS32::Movz_s>;
using InstMIPS32Mtc1 = InstMIPS32TwoAddrGPR<InstMIPS32::Mtc1>;
......
......@@ -365,38 +365,36 @@ public:
Context.insert<InstMIPS32Mov_s>(Dest, Src);
}
void _movf(Variable *Src0, Variable *Src1, Operand *FCC) {
auto *Instr = Context.insert<InstMIPS32Movf>(Src0, Src1, FCC);
Instr->setDestRedefined();
void _movf(Variable *Dest, Variable *Src0, Operand *FCC) {
Context.insert<InstMIPS32Movf>(Dest, Src0, FCC)->setDestRedefined();
}
void _movn(Variable *Dest, Variable *Src0, Variable *Src1) {
Context.insert<InstMIPS32Movn>(Dest, Src0, Src1);
Context.insert<InstMIPS32Movn>(Dest, Src0, Src1)->setDestRedefined();
}
void _movn_d(Variable *Dest, Variable *Src0, Variable *Src1) {
Context.insert<InstMIPS32Movn_d>(Dest, Src0, Src1);
Context.insert<InstMIPS32Movn_d>(Dest, Src0, Src1)->setDestRedefined();
}
void _movn_s(Variable *Dest, Variable *Src0, Variable *Src1) {
Context.insert<InstMIPS32Movn_s>(Dest, Src0, Src1);
Context.insert<InstMIPS32Movn_s>(Dest, Src0, Src1)->setDestRedefined();
}
void _movt(Variable *Src0, Variable *Src1, Operand *FCC) {
auto *Instr = Context.insert<InstMIPS32Movt>(Src0, Src1, FCC);
Instr->setDestRedefined();
void _movt(Variable *Dest, Variable *Src0, Operand *FCC) {
Context.insert<InstMIPS32Movt>(Dest, Src0, FCC)->setDestRedefined();
}
void _movz(Variable *Dest, Variable *Src0, Variable *Src1) {
Context.insert<InstMIPS32Movz>(Dest, Src0, Src1);
Context.insert<InstMIPS32Movz>(Dest, Src0, Src1)->setDestRedefined();
}
void _movz_d(Variable *Dest, Variable *Src0, Variable *Src1) {
Context.insert<InstMIPS32Movz_d>(Dest, Src0, Src1);
Context.insert<InstMIPS32Movz_d>(Dest, Src0, Src1)->setDestRedefined();
}
void _movz_s(Variable *Dest, Variable *Src0, Variable *Src1) {
Context.insert<InstMIPS32Movz_s>(Dest, Src0, Src1);
Context.insert<InstMIPS32Movz_s>(Dest, Src0, Src1)->setDestRedefined();
}
void _mtc1(Variable *Dest, Variable *Src) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment