| OLD | NEW |
| 1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===// | 1 //===- subzero/src/IceInstARM32.cpp - ARM32 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 // This file implements the InstARM32 and OperandARM32 classes, | 10 // This file implements the InstARM32 and OperandARM32 classes, |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 addSource(Source); | 274 addSource(Source); |
| 275 } | 275 } |
| 276 | 276 |
| 277 InstARM32Ret::InstARM32Ret(Cfg *Func, Variable *LR, Variable *Source) | 277 InstARM32Ret::InstARM32Ret(Cfg *Func, Variable *LR, Variable *Source) |
| 278 : InstARM32(Func, InstARM32::Ret, Source ? 2 : 1, nullptr) { | 278 : InstARM32(Func, InstARM32::Ret, Source ? 2 : 1, nullptr) { |
| 279 addSource(LR); | 279 addSource(LR); |
| 280 if (Source) | 280 if (Source) |
| 281 addSource(Source); | 281 addSource(Source); |
| 282 } | 282 } |
| 283 | 283 |
| 284 InstARM32Str::InstARM32Str(Cfg *Func, Variable *Value, OperandARM32Mem *Mem, |
| 285 CondARM32::Cond Predicate) |
| 286 : InstARM32Pred(Func, InstARM32::Str, 2, nullptr, Predicate) { |
| 287 addSource(Value); |
| 288 addSource(Mem); |
| 289 } |
| 290 |
| 284 InstARM32Umull::InstARM32Umull(Cfg *Func, Variable *DestLo, Variable *DestHi, | 291 InstARM32Umull::InstARM32Umull(Cfg *Func, Variable *DestLo, Variable *DestHi, |
| 285 Variable *Src0, Variable *Src1, | 292 Variable *Src0, Variable *Src1, |
| 286 CondARM32::Cond Predicate) | 293 CondARM32::Cond Predicate) |
| 287 : InstARM32Pred(Func, InstARM32::Umull, 2, DestLo, Predicate), | 294 : InstARM32Pred(Func, InstARM32::Umull, 2, DestLo, Predicate), |
| 288 // DestHi is expected to have a FakeDef inserted by the lowering code. | 295 // DestHi is expected to have a FakeDef inserted by the lowering code. |
| 289 DestHi(DestHi) { | 296 DestHi(DestHi) { |
| 290 addSource(Src0); | 297 addSource(Src0); |
| 291 addSource(Src1); | 298 addSource(Src1); |
| 292 } | 299 } |
| 293 | 300 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 320 Inst::dump(Func); | 327 Inst::dump(Func); |
| 321 } | 328 } |
| 322 | 329 |
| 323 template <> void InstARM32Mov::emit(const Cfg *Func) const { | 330 template <> void InstARM32Mov::emit(const Cfg *Func) const { |
| 324 if (!ALLOW_DUMP) | 331 if (!ALLOW_DUMP) |
| 325 return; | 332 return; |
| 326 Ostream &Str = Func->getContext()->getStrEmit(); | 333 Ostream &Str = Func->getContext()->getStrEmit(); |
| 327 assert(getSrcSize() == 1); | 334 assert(getSrcSize() == 1); |
| 328 Variable *Dest = getDest(); | 335 Variable *Dest = getDest(); |
| 329 if (Dest->hasReg()) { | 336 if (Dest->hasReg()) { |
| 330 const char *Opcode = "mov"; | 337 IceString Opcode = "mov"; |
| 331 Operand *Src0 = getSrc(0); | 338 Operand *Src0 = getSrc(0); |
| 332 if (const auto *Src0V = llvm::dyn_cast<Variable>(Src0)) { | 339 if (const auto *Src0V = llvm::dyn_cast<Variable>(Src0)) { |
| 333 if (!Src0V->hasReg()) { | 340 if (!Src0V->hasReg()) { |
| 334 Opcode = "ldr"; // Always load the full stack slot (vs ldrb, ldrh). | 341 Opcode = IceString("ldr"); // Always use the whole stack slot. |
| 335 } | 342 } |
| 336 } else { | 343 } else { |
| 337 // If Src isn't a variable, it shouldn't be a memory operand either | 344 if (llvm::isa<OperandARM32Mem>(Src0)) |
| 338 // (otherwise Opcode will have to be ldr). | 345 Opcode = IceString("ldr") + getWidthString(Dest->getType()); |
| 339 assert(!llvm::isa<OperandARM32Mem>(Src0)); | |
| 340 } | 346 } |
| 341 Str << "\t" << Opcode << getPredicate() << "\t"; | 347 Str << "\t" << Opcode << getPredicate() << "\t"; |
| 342 getDest()->emit(Func); | 348 getDest()->emit(Func); |
| 343 Str << ", "; | 349 Str << ", "; |
| 344 getSrc(0)->emit(Func); | 350 getSrc(0)->emit(Func); |
| 345 } else { | 351 } else { |
| 346 Variable *Src0 = llvm::cast<Variable>(getSrc(0)); | 352 Variable *Src0 = llvm::cast<Variable>(getSrc(0)); |
| 347 assert(Src0->hasReg()); | 353 assert(Src0->hasReg()); |
| 348 Str << "\t" | 354 Str << "\t" |
| 349 << "str" << getPredicate() << "\t"; | 355 << "str" << getPredicate() << "\t"; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 655 |
| 650 void InstARM32Ret::dump(const Cfg *Func) const { | 656 void InstARM32Ret::dump(const Cfg *Func) const { |
| 651 if (!ALLOW_DUMP) | 657 if (!ALLOW_DUMP) |
| 652 return; | 658 return; |
| 653 Ostream &Str = Func->getContext()->getStrDump(); | 659 Ostream &Str = Func->getContext()->getStrDump(); |
| 654 Type Ty = (getSrcSize() == 1 ? IceType_void : getSrc(0)->getType()); | 660 Type Ty = (getSrcSize() == 1 ? IceType_void : getSrc(0)->getType()); |
| 655 Str << "ret." << Ty << " "; | 661 Str << "ret." << Ty << " "; |
| 656 dumpSources(Func); | 662 dumpSources(Func); |
| 657 } | 663 } |
| 658 | 664 |
| 665 void InstARM32Str::emit(const Cfg *Func) const { |
| 666 if (!ALLOW_DUMP) |
| 667 return; |
| 668 Ostream &Str = Func->getContext()->getStrEmit(); |
| 669 assert(getSrcSize() == 2); |
| 670 Type Ty = getSrc(0)->getType(); |
| 671 Str << "\t" |
| 672 << "str" << getWidthString(Ty) << getPredicate() << "\t"; |
| 673 getSrc(0)->emit(Func); |
| 674 Str << ", "; |
| 675 getSrc(1)->emit(Func); |
| 676 } |
| 677 |
| 678 void InstARM32Str::emitIAS(const Cfg *Func) const { |
| 679 assert(getSrcSize() == 2); |
| 680 (void)Func; |
| 681 llvm_unreachable("Not yet implemented"); |
| 682 } |
| 683 |
| 684 void InstARM32Str::dump(const Cfg *Func) const { |
| 685 if (!ALLOW_DUMP) |
| 686 return; |
| 687 Ostream &Str = Func->getContext()->getStrDump(); |
| 688 dumpOpcodePred(Str, "str", getDest()->getType()); |
| 689 Str << " "; |
| 690 getSrc(1)->dump(Func); |
| 691 Str << ", "; |
| 692 getSrc(0)->dump(Func); |
| 693 } |
| 694 |
| 659 void InstARM32Umull::emit(const Cfg *Func) const { | 695 void InstARM32Umull::emit(const Cfg *Func) const { |
| 660 if (!ALLOW_DUMP) | 696 if (!ALLOW_DUMP) |
| 661 return; | 697 return; |
| 662 Ostream &Str = Func->getContext()->getStrEmit(); | 698 Ostream &Str = Func->getContext()->getStrEmit(); |
| 663 assert(getSrcSize() == 2); | 699 assert(getSrcSize() == 2); |
| 664 assert(getDest()->hasReg()); | 700 assert(getDest()->hasReg()); |
| 665 Str << "\t" | 701 Str << "\t" |
| 666 << "umull" << getPredicate() << "\t"; | 702 << "umull" << getPredicate() << "\t"; |
| 667 getDest()->emit(Func); | 703 getDest()->emit(Func); |
| 668 Str << ", "; | 704 Str << ", "; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 if (getShiftOp() != kNoShift) { | 835 if (getShiftOp() != kNoShift) { |
| 800 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; | 836 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; |
| 801 if (Func) | 837 if (Func) |
| 802 getShiftAmt()->dump(Func); | 838 getShiftAmt()->dump(Func); |
| 803 else | 839 else |
| 804 getShiftAmt()->dump(Str); | 840 getShiftAmt()->dump(Str); |
| 805 } | 841 } |
| 806 } | 842 } |
| 807 | 843 |
| 808 } // end of namespace Ice | 844 } // end of namespace Ice |
| OLD | NEW |