| OLD | NEW |
| 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// | 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 /// \file | 10 /// \file |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 266 } |
| 267 | 267 |
| 268 void InstMIPS32Label::emit(const Cfg *Func) const { | 268 void InstMIPS32Label::emit(const Cfg *Func) const { |
| 269 if (!BuildDefs::dump()) | 269 if (!BuildDefs::dump()) |
| 270 return; | 270 return; |
| 271 Ostream &Str = Func->getContext()->getStrEmit(); | 271 Ostream &Str = Func->getContext()->getStrEmit(); |
| 272 Str << getLabelName() << ":"; | 272 Str << getLabelName() << ":"; |
| 273 } | 273 } |
| 274 | 274 |
| 275 void InstMIPS32Label::emitIAS(const Cfg *Func) const { | 275 void InstMIPS32Label::emitIAS(const Cfg *Func) const { |
| 276 (void)Func; | 276 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 277 llvm_unreachable("Not yet implemented"); | 277 Asm->bindLocalLabel(this, Number); |
| 278 } | 278 } |
| 279 | 279 |
| 280 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) | 280 InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) |
| 281 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { | 281 : InstMIPS32(Func, InstMIPS32::Call, 1, Dest) { |
| 282 HasSideEffects = true; | 282 HasSideEffects = true; |
| 283 addSource(CallTarget); | 283 addSource(CallTarget); |
| 284 } | 284 } |
| 285 | 285 |
| 286 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) | 286 InstMIPS32Mov::InstMIPS32Mov(Cfg *Func, Variable *Dest, Operand *Src) |
| 287 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { | 287 : InstMIPS32(Func, InstMIPS32::Mov, 2, Dest) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 assert(RA->getRegNum() == RegMIPS32::Reg_RA); | 412 assert(RA->getRegNum() == RegMIPS32::Reg_RA); |
| 413 Ostream &Str = Func->getContext()->getStrEmit(); | 413 Ostream &Str = Func->getContext()->getStrEmit(); |
| 414 Str << "\t" | 414 Str << "\t" |
| 415 "jr" | 415 "jr" |
| 416 "\t"; | 416 "\t"; |
| 417 RA->emit(Func); | 417 RA->emit(Func); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void InstMIPS32Br::emitIAS(const Cfg *Func) const { | 420 void InstMIPS32Br::emitIAS(const Cfg *Func) const { |
| 421 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 421 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 422 if (isUnconditionalBranch()) { | 422 if (Label != nullptr) { |
| 423 // Intra-block branches are of kind bcc |
| 424 Asm->bcc(Predicate, getSrc(0), getSrc(1), |
| 425 Asm->getOrCreateLocalLabel(Label->getNumber())); |
| 426 } else if (isUnconditionalBranch()) { |
| 423 Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); | 427 Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); |
| 424 } else { | 428 } else { |
| 425 switch (Predicate) { | 429 switch (Predicate) { |
| 426 default: | 430 default: |
| 427 break; | 431 break; |
| 428 case CondMIPS32::EQ: | 432 case CondMIPS32::EQ: |
| 429 case CondMIPS32::NE: | 433 case CondMIPS32::NE: |
| 430 Asm->bcc(Predicate, getSrc(0), getSrc(1), | 434 Asm->bcc(Predicate, getSrc(0), getSrc(1), |
| 431 Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); | 435 Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); |
| 432 break; | 436 break; |
| 433 case CondMIPS32::EQZ: | 437 case CondMIPS32::EQZ: |
| 434 case CondMIPS32::NEZ: | 438 case CondMIPS32::NEZ: |
| 435 case CondMIPS32::LEZ: | 439 case CondMIPS32::LEZ: |
| 436 case CondMIPS32::LTZ: | 440 case CondMIPS32::LTZ: |
| 437 case CondMIPS32::GEZ: | 441 case CondMIPS32::GEZ: |
| 438 case CondMIPS32::GTZ: | 442 case CondMIPS32::GTZ: |
| 439 Asm->bzc(Predicate, getSrc(0), | 443 Asm->bzc(Predicate, getSrc(0), |
| 440 Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); | 444 Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); |
| 441 break; | 445 break; |
| 442 } | 446 } |
| 447 if (getTargetTrue()) { |
| 448 Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetTrue()->getIndex())); |
| 449 } |
| 443 } | 450 } |
| 444 } | 451 } |
| 445 | 452 |
| 446 void InstMIPS32Br::emit(const Cfg *Func) const { | 453 void InstMIPS32Br::emit(const Cfg *Func) const { |
| 447 if (!BuildDefs::dump()) | 454 if (!BuildDefs::dump()) |
| 448 return; | 455 return; |
| 449 Ostream &Str = Func->getContext()->getStrEmit(); | 456 Ostream &Str = Func->getContext()->getStrEmit(); |
| 450 Str << "\t" | 457 Str << "\t" |
| 451 "b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t"; | 458 "b" << InstMIPS32CondAttributes[Predicate].EmitString << "\t"; |
| 452 if (Label != nullptr) { | 459 if (Label != nullptr) { |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 Asm->xor_(getDest(), getSrc(0), getSrc(1)); | 1129 Asm->xor_(getDest(), getSrc(0), getSrc(1)); |
| 1123 } | 1130 } |
| 1124 | 1131 |
| 1125 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const { | 1132 template <> void InstMIPS32Xori::emitIAS(const Cfg *Func) const { |
| 1126 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); | 1133 auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); |
| 1127 Asm->xori(getDest(), getSrc(0), Imm); | 1134 Asm->xori(getDest(), getSrc(0), Imm); |
| 1128 } | 1135 } |
| 1129 | 1136 |
| 1130 } // end of namespace MIPS32 | 1137 } // end of namespace MIPS32 |
| 1131 } // end of namespace Ice | 1138 } // end of namespace Ice |
| OLD | NEW |