| Index: src/IceInstMIPS32.cpp
|
| diff --git a/src/IceInstMIPS32.cpp b/src/IceInstMIPS32.cpp
|
| index d26190cb407db19ddbbb1e1fdd811062e9f75343..fe2349d293ddb9ef3b28457966560e6afab925b7 100644
|
| --- a/src/IceInstMIPS32.cpp
|
| +++ b/src/IceInstMIPS32.cpp
|
| @@ -384,6 +384,32 @@ void InstMIPS32Ret::emit(const Cfg *Func) const {
|
| RA->emit(Func);
|
| }
|
|
|
| +void InstMIPS32Br::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + if (isUnconditionalBranch()) {
|
| + Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
|
| + } else {
|
| + switch (Predicate) {
|
| + default:
|
| + break;
|
| + case CondMIPS32::EQ:
|
| + case CondMIPS32::NE:
|
| + Asm->bcc(Predicate, getSrc(0), getSrc(1),
|
| + Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
|
| + break;
|
| + case CondMIPS32::EQZ:
|
| + case CondMIPS32::NEZ:
|
| + case CondMIPS32::LEZ:
|
| + case CondMIPS32::LTZ:
|
| + case CondMIPS32::GEZ:
|
| + case CondMIPS32::GTZ:
|
| + Asm->bzc(Predicate, getSrc(0),
|
| + Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
|
| + break;
|
| + }
|
| + }
|
| +}
|
| +
|
| void InstMIPS32Br::emit(const Cfg *Func) const {
|
| if (!BuildDefs::dump())
|
| return;
|
| @@ -486,8 +512,11 @@ void InstMIPS32Call::dump(const Cfg *Func) const {
|
| }
|
|
|
| void InstMIPS32Ret::emitIAS(const Cfg *Func) const {
|
| - (void)Func;
|
| - llvm_unreachable("Not yet implemented");
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + auto *RA = llvm::cast<Variable>(getSrc(0));
|
| + assert(RA->hasReg());
|
| + assert(RA->getRegNum() == RegMIPS32::Reg_RA);
|
| + Asm->ret();
|
| }
|
|
|
| void InstMIPS32Ret::dump(const Cfg *Func) const {
|
| @@ -693,5 +722,76 @@ void InstMIPS32Mov::emitSingleDestSingleSource(const Cfg *Func) const {
|
| llvm::report_fatal_error("mov cant copy stack to stack.");
|
| }
|
|
|
| +template <> void InstMIPS32Addiu::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->addiu(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Slti::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->slti(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Sltiu::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->sltiu(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Andi::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->andi(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Ori::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->ori(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->xori(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Sll::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->sll(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Srl::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->srl(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Sra::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->sra(getDest(), getSrc(0), (const uint32_t) Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Addu::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->addu(getDest(), getSrc(0), getSrc(1));
|
| +}
|
| +
|
| +template <> void InstMIPS32Slt::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + Asm->slt(getDest(), getSrc(0), getSrc(1));
|
| +}
|
| +
|
| +template <> void InstMIPS32Sw::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(1));
|
| + ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
|
| + uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
|
| + Asm->sw(getSrc(0), Mem->getBase(), Imm);
|
| +}
|
| +
|
| +template <> void InstMIPS32Lw::emitIAS(const Cfg *Func) const {
|
| + auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
|
| + auto *Mem = llvm::dyn_cast<OperandMIPS32Mem>(getSrc(0));
|
| + ConstantInteger32 *Offset = llvm::cast<ConstantInteger32>(Mem->getOffset());
|
| + uint32_t Imm = static_cast<uint32_t>(Offset->getValue());
|
| + Asm->lw(getDest(), Mem->getBase(), Imm);
|
| +}
|
| +
|
| } // end of namespace MIPS32
|
| } // end of namespace Ice
|
|
|