| OLD | NEW |
| 1 //===- subzero/src/IceInst.cpp - High-level instruction implementation ----===// | 1 //===- subzero/src/IceInst.cpp - High-level 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 Inst class, primarily the various | 10 // This file implements the Inst class, primarily the various |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 llvm_unreachable("Phi operand not found for specified target node"); | 392 llvm_unreachable("Phi operand not found for specified target node"); |
| 393 } | 393 } |
| 394 | 394 |
| 395 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new | 395 // Change "a=phi(...)" to "a_phi=phi(...)" and return a new |
| 396 // instruction "a=a_phi". | 396 // instruction "a=a_phi". |
| 397 Inst *InstPhi::lower(Cfg *Func) { | 397 Inst *InstPhi::lower(Cfg *Func) { |
| 398 Variable *Dest = getDest(); | 398 Variable *Dest = getDest(); |
| 399 assert(Dest); | 399 assert(Dest); |
| 400 Variable *NewSrc = Func->makeVariable(Dest->getType()); | 400 Variable *NewSrc = Func->makeVariable(Dest->getType()); |
| 401 if (ALLOW_DUMP) | 401 if (BuildDefs::dump()) |
| 402 NewSrc->setName(Func, Dest->getName(Func) + "_phi"); | 402 NewSrc->setName(Func, Dest->getName(Func) + "_phi"); |
| 403 this->Dest = NewSrc; | 403 this->Dest = NewSrc; |
| 404 return InstAssign::create(Func, Dest, NewSrc); | 404 return InstAssign::create(Func, Dest, NewSrc); |
| 405 } | 405 } |
| 406 | 406 |
| 407 InstRet::InstRet(Cfg *Func, Operand *RetValue) | 407 InstRet::InstRet(Cfg *Func, Operand *RetValue) |
| 408 : InstHighLevel(Func, Ret, RetValue ? 1 : 0, nullptr) { | 408 : InstHighLevel(Func, Ret, RetValue ? 1 : 0, nullptr) { |
| 409 if (RetValue) | 409 if (RetValue) |
| 410 addSource(RetValue); | 410 addSource(RetValue); |
| 411 } | 411 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 504 |
| 505 Type InstCall::getReturnType() const { | 505 Type InstCall::getReturnType() const { |
| 506 if (Dest == nullptr) | 506 if (Dest == nullptr) |
| 507 return IceType_void; | 507 return IceType_void; |
| 508 return Dest->getType(); | 508 return Dest->getType(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 // ======================== Dump routines ======================== // | 511 // ======================== Dump routines ======================== // |
| 512 | 512 |
| 513 void Inst::dumpDecorated(const Cfg *Func) const { | 513 void Inst::dumpDecorated(const Cfg *Func) const { |
| 514 if (!ALLOW_DUMP) | 514 if (!BuildDefs::dump()) |
| 515 return; | 515 return; |
| 516 Ostream &Str = Func->getContext()->getStrDump(); | 516 Ostream &Str = Func->getContext()->getStrDump(); |
| 517 if (!Func->isVerbose(IceV_Deleted) && (isDeleted() || isRedundantAssign())) | 517 if (!Func->isVerbose(IceV_Deleted) && (isDeleted() || isRedundantAssign())) |
| 518 return; | 518 return; |
| 519 if (Func->isVerbose(IceV_InstNumbers)) { | 519 if (Func->isVerbose(IceV_InstNumbers)) { |
| 520 char buf[30]; | 520 char buf[30]; |
| 521 InstNumberT Number = getNumber(); | 521 InstNumberT Number = getNumber(); |
| 522 if (Number == NumberDeleted) | 522 if (Number == NumberDeleted) |
| 523 snprintf(buf, llvm::array_lengthof(buf), "[XXX]"); | 523 snprintf(buf, llvm::array_lengthof(buf), "[XXX]"); |
| 524 else | 524 else |
| 525 snprintf(buf, llvm::array_lengthof(buf), "[%3d]", Number); | 525 snprintf(buf, llvm::array_lengthof(buf), "[%3d]", Number); |
| 526 Str << buf; | 526 Str << buf; |
| 527 } | 527 } |
| 528 Str << " "; | 528 Str << " "; |
| 529 if (isDeleted()) | 529 if (isDeleted()) |
| 530 Str << " //"; | 530 Str << " //"; |
| 531 dump(Func); | 531 dump(Func); |
| 532 dumpExtras(Func); | 532 dumpExtras(Func); |
| 533 Str << "\n"; | 533 Str << "\n"; |
| 534 } | 534 } |
| 535 | 535 |
| 536 void Inst::dump(const Cfg *Func) const { | 536 void Inst::dump(const Cfg *Func) const { |
| 537 if (!ALLOW_DUMP) | 537 if (!BuildDefs::dump()) |
| 538 return; | 538 return; |
| 539 Ostream &Str = Func->getContext()->getStrDump(); | 539 Ostream &Str = Func->getContext()->getStrDump(); |
| 540 dumpDest(Func); | 540 dumpDest(Func); |
| 541 Str << " =~ "; | 541 Str << " =~ "; |
| 542 dumpSources(Func); | 542 dumpSources(Func); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void Inst::dumpExtras(const Cfg *Func) const { | 545 void Inst::dumpExtras(const Cfg *Func) const { |
| 546 if (!ALLOW_DUMP) | 546 if (!BuildDefs::dump()) |
| 547 return; | 547 return; |
| 548 Ostream &Str = Func->getContext()->getStrDump(); | 548 Ostream &Str = Func->getContext()->getStrDump(); |
| 549 bool First = true; | 549 bool First = true; |
| 550 // Print "LIVEEND={a,b,c}" for all source operands whose live ranges | 550 // Print "LIVEEND={a,b,c}" for all source operands whose live ranges |
| 551 // are known to end at this instruction. | 551 // are known to end at this instruction. |
| 552 if (Func->isVerbose(IceV_Liveness)) { | 552 if (Func->isVerbose(IceV_Liveness)) { |
| 553 for (SizeT I = 0; I < getSrcSize(); ++I) { | 553 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 554 Operand *Src = getSrc(I); | 554 Operand *Src = getSrc(I); |
| 555 SizeT NumVars = Src->getNumVars(); | 555 SizeT NumVars = Src->getNumVars(); |
| 556 for (SizeT J = 0; J < NumVars; ++J) { | 556 for (SizeT J = 0; J < NumVars; ++J) { |
| 557 const Variable *Var = Src->getVar(J); | 557 const Variable *Var = Src->getVar(J); |
| 558 if (isLastUse(Var)) { | 558 if (isLastUse(Var)) { |
| 559 if (First) | 559 if (First) |
| 560 Str << " // LIVEEND={"; | 560 Str << " // LIVEEND={"; |
| 561 else | 561 else |
| 562 Str << ","; | 562 Str << ","; |
| 563 Var->dump(Func); | 563 Var->dump(Func); |
| 564 First = false; | 564 First = false; |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 } | 567 } |
| 568 if (!First) | 568 if (!First) |
| 569 Str << "}"; | 569 Str << "}"; |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 void Inst::dumpSources(const Cfg *Func) const { | 573 void Inst::dumpSources(const Cfg *Func) const { |
| 574 if (!ALLOW_DUMP) | 574 if (!BuildDefs::dump()) |
| 575 return; | 575 return; |
| 576 Ostream &Str = Func->getContext()->getStrDump(); | 576 Ostream &Str = Func->getContext()->getStrDump(); |
| 577 for (SizeT I = 0; I < getSrcSize(); ++I) { | 577 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 578 if (I > 0) | 578 if (I > 0) |
| 579 Str << ", "; | 579 Str << ", "; |
| 580 getSrc(I)->dump(Func); | 580 getSrc(I)->dump(Func); |
| 581 } | 581 } |
| 582 } | 582 } |
| 583 | 583 |
| 584 void Inst::emitSources(const Cfg *Func) const { | 584 void Inst::emitSources(const Cfg *Func) const { |
| 585 if (!ALLOW_DUMP) | 585 if (!BuildDefs::dump()) |
| 586 return; | 586 return; |
| 587 Ostream &Str = Func->getContext()->getStrEmit(); | 587 Ostream &Str = Func->getContext()->getStrEmit(); |
| 588 for (SizeT I = 0; I < getSrcSize(); ++I) { | 588 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 589 if (I > 0) | 589 if (I > 0) |
| 590 Str << ", "; | 590 Str << ", "; |
| 591 getSrc(I)->emit(Func); | 591 getSrc(I)->emit(Func); |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 | 594 |
| 595 void Inst::dumpDest(const Cfg *Func) const { | 595 void Inst::dumpDest(const Cfg *Func) const { |
| 596 if (!ALLOW_DUMP) | 596 if (!BuildDefs::dump()) |
| 597 return; | 597 return; |
| 598 if (getDest()) | 598 if (getDest()) |
| 599 getDest()->dump(Func); | 599 getDest()->dump(Func); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void InstAlloca::dump(const Cfg *Func) const { | 602 void InstAlloca::dump(const Cfg *Func) const { |
| 603 if (!ALLOW_DUMP) | 603 if (!BuildDefs::dump()) |
| 604 return; | 604 return; |
| 605 Ostream &Str = Func->getContext()->getStrDump(); | 605 Ostream &Str = Func->getContext()->getStrDump(); |
| 606 dumpDest(Func); | 606 dumpDest(Func); |
| 607 Str << " = alloca i8, i32 "; | 607 Str << " = alloca i8, i32 "; |
| 608 getSizeInBytes()->dump(Func); | 608 getSizeInBytes()->dump(Func); |
| 609 if (getAlignInBytes()) | 609 if (getAlignInBytes()) |
| 610 Str << ", align " << getAlignInBytes(); | 610 Str << ", align " << getAlignInBytes(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 void InstArithmetic::dump(const Cfg *Func) const { | 613 void InstArithmetic::dump(const Cfg *Func) const { |
| 614 if (!ALLOW_DUMP) | 614 if (!BuildDefs::dump()) |
| 615 return; | 615 return; |
| 616 Ostream &Str = Func->getContext()->getStrDump(); | 616 Ostream &Str = Func->getContext()->getStrDump(); |
| 617 dumpDest(Func); | 617 dumpDest(Func); |
| 618 Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " " | 618 Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " " |
| 619 << getDest()->getType() << " "; | 619 << getDest()->getType() << " "; |
| 620 dumpSources(Func); | 620 dumpSources(Func); |
| 621 } | 621 } |
| 622 | 622 |
| 623 void InstAssign::dump(const Cfg *Func) const { | 623 void InstAssign::dump(const Cfg *Func) const { |
| 624 if (!ALLOW_DUMP) | 624 if (!BuildDefs::dump()) |
| 625 return; | 625 return; |
| 626 Ostream &Str = Func->getContext()->getStrDump(); | 626 Ostream &Str = Func->getContext()->getStrDump(); |
| 627 dumpDest(Func); | 627 dumpDest(Func); |
| 628 Str << " = " << getDest()->getType() << " "; | 628 Str << " = " << getDest()->getType() << " "; |
| 629 dumpSources(Func); | 629 dumpSources(Func); |
| 630 } | 630 } |
| 631 | 631 |
| 632 void InstBr::dump(const Cfg *Func) const { | 632 void InstBr::dump(const Cfg *Func) const { |
| 633 if (!ALLOW_DUMP) | 633 if (!BuildDefs::dump()) |
| 634 return; | 634 return; |
| 635 Ostream &Str = Func->getContext()->getStrDump(); | 635 Ostream &Str = Func->getContext()->getStrDump(); |
| 636 dumpDest(Func); | 636 dumpDest(Func); |
| 637 Str << "br "; | 637 Str << "br "; |
| 638 if (!isUnconditional()) { | 638 if (!isUnconditional()) { |
| 639 Str << "i1 "; | 639 Str << "i1 "; |
| 640 getCondition()->dump(Func); | 640 getCondition()->dump(Func); |
| 641 Str << ", label %" << getTargetTrue()->getName() << ", "; | 641 Str << ", label %" << getTargetTrue()->getName() << ", "; |
| 642 } | 642 } |
| 643 Str << "label %" << getTargetFalse()->getName(); | 643 Str << "label %" << getTargetFalse()->getName(); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void InstCall::dump(const Cfg *Func) const { | 646 void InstCall::dump(const Cfg *Func) const { |
| 647 if (!ALLOW_DUMP) | 647 if (!BuildDefs::dump()) |
| 648 return; | 648 return; |
| 649 Ostream &Str = Func->getContext()->getStrDump(); | 649 Ostream &Str = Func->getContext()->getStrDump(); |
| 650 if (getDest()) { | 650 if (getDest()) { |
| 651 dumpDest(Func); | 651 dumpDest(Func); |
| 652 Str << " = "; | 652 Str << " = "; |
| 653 } | 653 } |
| 654 Str << "call "; | 654 Str << "call "; |
| 655 if (getDest()) | 655 if (getDest()) |
| 656 Str << getDest()->getType(); | 656 Str << getDest()->getType(); |
| 657 else | 657 else |
| (...skipping 12 matching lines...) Expand all Loading... |
| 670 | 670 |
| 671 const char *InstCast::getCastName(InstCast::OpKind Kind) { | 671 const char *InstCast::getCastName(InstCast::OpKind Kind) { |
| 672 size_t Index = static_cast<size_t>(Kind); | 672 size_t Index = static_cast<size_t>(Kind); |
| 673 if (Index < InstCast::OpKind::_num) | 673 if (Index < InstCast::OpKind::_num) |
| 674 return InstCastAttributes[Index].DisplayString; | 674 return InstCastAttributes[Index].DisplayString; |
| 675 llvm_unreachable("Invalid InstCast::OpKind"); | 675 llvm_unreachable("Invalid InstCast::OpKind"); |
| 676 return "???"; | 676 return "???"; |
| 677 } | 677 } |
| 678 | 678 |
| 679 void InstCast::dump(const Cfg *Func) const { | 679 void InstCast::dump(const Cfg *Func) const { |
| 680 if (!ALLOW_DUMP) | 680 if (!BuildDefs::dump()) |
| 681 return; | 681 return; |
| 682 Ostream &Str = Func->getContext()->getStrDump(); | 682 Ostream &Str = Func->getContext()->getStrDump(); |
| 683 dumpDest(Func); | 683 dumpDest(Func); |
| 684 Str << " = " << getCastName(getCastKind()) << " " << getSrc(0)->getType() | 684 Str << " = " << getCastName(getCastKind()) << " " << getSrc(0)->getType() |
| 685 << " "; | 685 << " "; |
| 686 dumpSources(Func); | 686 dumpSources(Func); |
| 687 Str << " to " << getDest()->getType(); | 687 Str << " to " << getDest()->getType(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 void InstIcmp::dump(const Cfg *Func) const { | 690 void InstIcmp::dump(const Cfg *Func) const { |
| 691 if (!ALLOW_DUMP) | 691 if (!BuildDefs::dump()) |
| 692 return; | 692 return; |
| 693 Ostream &Str = Func->getContext()->getStrDump(); | 693 Ostream &Str = Func->getContext()->getStrDump(); |
| 694 dumpDest(Func); | 694 dumpDest(Func); |
| 695 Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " " | 695 Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " " |
| 696 << getSrc(0)->getType() << " "; | 696 << getSrc(0)->getType() << " "; |
| 697 dumpSources(Func); | 697 dumpSources(Func); |
| 698 } | 698 } |
| 699 | 699 |
| 700 void InstExtractElement::dump(const Cfg *Func) const { | 700 void InstExtractElement::dump(const Cfg *Func) const { |
| 701 if (!ALLOW_DUMP) | 701 if (!BuildDefs::dump()) |
| 702 return; | 702 return; |
| 703 Ostream &Str = Func->getContext()->getStrDump(); | 703 Ostream &Str = Func->getContext()->getStrDump(); |
| 704 dumpDest(Func); | 704 dumpDest(Func); |
| 705 Str << " = extractelement "; | 705 Str << " = extractelement "; |
| 706 Str << getSrc(0)->getType() << " "; | 706 Str << getSrc(0)->getType() << " "; |
| 707 getSrc(0)->dump(Func); | 707 getSrc(0)->dump(Func); |
| 708 Str << ", "; | 708 Str << ", "; |
| 709 Str << getSrc(1)->getType() << " "; | 709 Str << getSrc(1)->getType() << " "; |
| 710 getSrc(1)->dump(Func); | 710 getSrc(1)->dump(Func); |
| 711 } | 711 } |
| 712 | 712 |
| 713 void InstInsertElement::dump(const Cfg *Func) const { | 713 void InstInsertElement::dump(const Cfg *Func) const { |
| 714 if (!ALLOW_DUMP) | 714 if (!BuildDefs::dump()) |
| 715 return; | 715 return; |
| 716 Ostream &Str = Func->getContext()->getStrDump(); | 716 Ostream &Str = Func->getContext()->getStrDump(); |
| 717 dumpDest(Func); | 717 dumpDest(Func); |
| 718 Str << " = insertelement "; | 718 Str << " = insertelement "; |
| 719 Str << getSrc(0)->getType() << " "; | 719 Str << getSrc(0)->getType() << " "; |
| 720 getSrc(0)->dump(Func); | 720 getSrc(0)->dump(Func); |
| 721 Str << ", "; | 721 Str << ", "; |
| 722 Str << getSrc(1)->getType() << " "; | 722 Str << getSrc(1)->getType() << " "; |
| 723 getSrc(1)->dump(Func); | 723 getSrc(1)->dump(Func); |
| 724 Str << ", "; | 724 Str << ", "; |
| 725 Str << getSrc(2)->getType() << " "; | 725 Str << getSrc(2)->getType() << " "; |
| 726 getSrc(2)->dump(Func); | 726 getSrc(2)->dump(Func); |
| 727 } | 727 } |
| 728 | 728 |
| 729 void InstFcmp::dump(const Cfg *Func) const { | 729 void InstFcmp::dump(const Cfg *Func) const { |
| 730 if (!ALLOW_DUMP) | 730 if (!BuildDefs::dump()) |
| 731 return; | 731 return; |
| 732 Ostream &Str = Func->getContext()->getStrDump(); | 732 Ostream &Str = Func->getContext()->getStrDump(); |
| 733 dumpDest(Func); | 733 dumpDest(Func); |
| 734 Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " " | 734 Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " " |
| 735 << getSrc(0)->getType() << " "; | 735 << getSrc(0)->getType() << " "; |
| 736 dumpSources(Func); | 736 dumpSources(Func); |
| 737 } | 737 } |
| 738 | 738 |
| 739 void InstLoad::dump(const Cfg *Func) const { | 739 void InstLoad::dump(const Cfg *Func) const { |
| 740 if (!ALLOW_DUMP) | 740 if (!BuildDefs::dump()) |
| 741 return; | 741 return; |
| 742 Ostream &Str = Func->getContext()->getStrDump(); | 742 Ostream &Str = Func->getContext()->getStrDump(); |
| 743 dumpDest(Func); | 743 dumpDest(Func); |
| 744 Type Ty = getDest()->getType(); | 744 Type Ty = getDest()->getType(); |
| 745 Str << " = load " << Ty << ", " << Ty << "* "; | 745 Str << " = load " << Ty << ", " << Ty << "* "; |
| 746 dumpSources(Func); | 746 dumpSources(Func); |
| 747 Str << ", align " << typeAlignInBytes(Ty); | 747 Str << ", align " << typeAlignInBytes(Ty); |
| 748 } | 748 } |
| 749 | 749 |
| 750 void InstStore::dump(const Cfg *Func) const { | 750 void InstStore::dump(const Cfg *Func) const { |
| 751 if (!ALLOW_DUMP) | 751 if (!BuildDefs::dump()) |
| 752 return; | 752 return; |
| 753 Ostream &Str = Func->getContext()->getStrDump(); | 753 Ostream &Str = Func->getContext()->getStrDump(); |
| 754 Type Ty = getData()->getType(); | 754 Type Ty = getData()->getType(); |
| 755 dumpDest(Func); | 755 dumpDest(Func); |
| 756 if (Dest) | 756 if (Dest) |
| 757 Str << " = "; | 757 Str << " = "; |
| 758 Str << "store " << Ty << " "; | 758 Str << "store " << Ty << " "; |
| 759 getData()->dump(Func); | 759 getData()->dump(Func); |
| 760 Str << ", " << Ty << "* "; | 760 Str << ", " << Ty << "* "; |
| 761 getAddr()->dump(Func); | 761 getAddr()->dump(Func); |
| 762 Str << ", align " << typeAlignInBytes(Ty); | 762 Str << ", align " << typeAlignInBytes(Ty); |
| 763 if (getRmwBeacon()) { | 763 if (getRmwBeacon()) { |
| 764 Str << ", beacon "; | 764 Str << ", beacon "; |
| 765 getRmwBeacon()->dump(Func); | 765 getRmwBeacon()->dump(Func); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 | 768 |
| 769 void InstSwitch::dump(const Cfg *Func) const { | 769 void InstSwitch::dump(const Cfg *Func) const { |
| 770 if (!ALLOW_DUMP) | 770 if (!BuildDefs::dump()) |
| 771 return; | 771 return; |
| 772 Ostream &Str = Func->getContext()->getStrDump(); | 772 Ostream &Str = Func->getContext()->getStrDump(); |
| 773 Type Ty = getComparison()->getType(); | 773 Type Ty = getComparison()->getType(); |
| 774 Str << "switch " << Ty << " "; | 774 Str << "switch " << Ty << " "; |
| 775 getSrc(0)->dump(Func); | 775 getSrc(0)->dump(Func); |
| 776 Str << ", label %" << getLabelDefault()->getName() << " [\n"; | 776 Str << ", label %" << getLabelDefault()->getName() << " [\n"; |
| 777 for (SizeT I = 0; I < getNumCases(); ++I) { | 777 for (SizeT I = 0; I < getNumCases(); ++I) { |
| 778 Str << " " << Ty << " " << static_cast<int64_t>(getValue(I)) | 778 Str << " " << Ty << " " << static_cast<int64_t>(getValue(I)) |
| 779 << ", label %" << getLabel(I)->getName() << "\n"; | 779 << ", label %" << getLabel(I)->getName() << "\n"; |
| 780 } | 780 } |
| 781 Str << " ]"; | 781 Str << " ]"; |
| 782 } | 782 } |
| 783 | 783 |
| 784 void InstPhi::dump(const Cfg *Func) const { | 784 void InstPhi::dump(const Cfg *Func) const { |
| 785 if (!ALLOW_DUMP) | 785 if (!BuildDefs::dump()) |
| 786 return; | 786 return; |
| 787 Ostream &Str = Func->getContext()->getStrDump(); | 787 Ostream &Str = Func->getContext()->getStrDump(); |
| 788 dumpDest(Func); | 788 dumpDest(Func); |
| 789 Str << " = phi " << getDest()->getType() << " "; | 789 Str << " = phi " << getDest()->getType() << " "; |
| 790 for (SizeT I = 0; I < getSrcSize(); ++I) { | 790 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 791 if (I > 0) | 791 if (I > 0) |
| 792 Str << ", "; | 792 Str << ", "; |
| 793 Str << "[ "; | 793 Str << "[ "; |
| 794 getSrc(I)->dump(Func); | 794 getSrc(I)->dump(Func); |
| 795 Str << ", %" << Labels[I]->getName() << " ]"; | 795 Str << ", %" << Labels[I]->getName() << " ]"; |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 | 798 |
| 799 void InstRet::dump(const Cfg *Func) const { | 799 void InstRet::dump(const Cfg *Func) const { |
| 800 if (!ALLOW_DUMP) | 800 if (!BuildDefs::dump()) |
| 801 return; | 801 return; |
| 802 Ostream &Str = Func->getContext()->getStrDump(); | 802 Ostream &Str = Func->getContext()->getStrDump(); |
| 803 Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void; | 803 Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void; |
| 804 Str << "ret " << Ty; | 804 Str << "ret " << Ty; |
| 805 if (hasRetValue()) { | 805 if (hasRetValue()) { |
| 806 Str << " "; | 806 Str << " "; |
| 807 dumpSources(Func); | 807 dumpSources(Func); |
| 808 } | 808 } |
| 809 } | 809 } |
| 810 | 810 |
| 811 void InstSelect::dump(const Cfg *Func) const { | 811 void InstSelect::dump(const Cfg *Func) const { |
| 812 if (!ALLOW_DUMP) | 812 if (!BuildDefs::dump()) |
| 813 return; | 813 return; |
| 814 Ostream &Str = Func->getContext()->getStrDump(); | 814 Ostream &Str = Func->getContext()->getStrDump(); |
| 815 dumpDest(Func); | 815 dumpDest(Func); |
| 816 Operand *Condition = getCondition(); | 816 Operand *Condition = getCondition(); |
| 817 Operand *TrueOp = getTrueOperand(); | 817 Operand *TrueOp = getTrueOperand(); |
| 818 Operand *FalseOp = getFalseOperand(); | 818 Operand *FalseOp = getFalseOperand(); |
| 819 Str << " = select " << Condition->getType() << " "; | 819 Str << " = select " << Condition->getType() << " "; |
| 820 Condition->dump(Func); | 820 Condition->dump(Func); |
| 821 Str << ", " << TrueOp->getType() << " "; | 821 Str << ", " << TrueOp->getType() << " "; |
| 822 TrueOp->dump(Func); | 822 TrueOp->dump(Func); |
| 823 Str << ", " << FalseOp->getType() << " "; | 823 Str << ", " << FalseOp->getType() << " "; |
| 824 FalseOp->dump(Func); | 824 FalseOp->dump(Func); |
| 825 } | 825 } |
| 826 | 826 |
| 827 void InstUnreachable::dump(const Cfg *Func) const { | 827 void InstUnreachable::dump(const Cfg *Func) const { |
| 828 if (!ALLOW_DUMP) | 828 if (!BuildDefs::dump()) |
| 829 return; | 829 return; |
| 830 Ostream &Str = Func->getContext()->getStrDump(); | 830 Ostream &Str = Func->getContext()->getStrDump(); |
| 831 Str << "unreachable"; | 831 Str << "unreachable"; |
| 832 } | 832 } |
| 833 | 833 |
| 834 void InstBundleLock::emit(const Cfg *Func) const { | 834 void InstBundleLock::emit(const Cfg *Func) const { |
| 835 if (!ALLOW_DUMP) | 835 if (!BuildDefs::dump()) |
| 836 return; | 836 return; |
| 837 Ostream &Str = Func->getContext()->getStrEmit(); | 837 Ostream &Str = Func->getContext()->getStrEmit(); |
| 838 Str << "\t.bundle_lock"; | 838 Str << "\t.bundle_lock"; |
| 839 switch (BundleOption) { | 839 switch (BundleOption) { |
| 840 case Opt_None: | 840 case Opt_None: |
| 841 break; | 841 break; |
| 842 case Opt_AlignToEnd: | 842 case Opt_AlignToEnd: |
| 843 Str << "\talign_to_end"; | 843 Str << "\talign_to_end"; |
| 844 break; | 844 break; |
| 845 } | 845 } |
| 846 } | 846 } |
| 847 | 847 |
| 848 void InstBundleLock::dump(const Cfg *Func) const { | 848 void InstBundleLock::dump(const Cfg *Func) const { |
| 849 if (!ALLOW_DUMP) | 849 if (!BuildDefs::dump()) |
| 850 return; | 850 return; |
| 851 Ostream &Str = Func->getContext()->getStrDump(); | 851 Ostream &Str = Func->getContext()->getStrDump(); |
| 852 Str << "bundle_lock"; | 852 Str << "bundle_lock"; |
| 853 switch (BundleOption) { | 853 switch (BundleOption) { |
| 854 case Opt_None: | 854 case Opt_None: |
| 855 break; | 855 break; |
| 856 case Opt_AlignToEnd: | 856 case Opt_AlignToEnd: |
| 857 Str << " align_to_end"; | 857 Str << " align_to_end"; |
| 858 break; | 858 break; |
| 859 } | 859 } |
| 860 } | 860 } |
| 861 | 861 |
| 862 void InstBundleUnlock::emit(const Cfg *Func) const { | 862 void InstBundleUnlock::emit(const Cfg *Func) const { |
| 863 if (!ALLOW_DUMP) | 863 if (!BuildDefs::dump()) |
| 864 return; | 864 return; |
| 865 Ostream &Str = Func->getContext()->getStrEmit(); | 865 Ostream &Str = Func->getContext()->getStrEmit(); |
| 866 Str << "\t.bundle_unlock"; | 866 Str << "\t.bundle_unlock"; |
| 867 } | 867 } |
| 868 | 868 |
| 869 void InstBundleUnlock::dump(const Cfg *Func) const { | 869 void InstBundleUnlock::dump(const Cfg *Func) const { |
| 870 if (!ALLOW_DUMP) | 870 if (!BuildDefs::dump()) |
| 871 return; | 871 return; |
| 872 Ostream &Str = Func->getContext()->getStrDump(); | 872 Ostream &Str = Func->getContext()->getStrDump(); |
| 873 Str << "bundle_unlock"; | 873 Str << "bundle_unlock"; |
| 874 } | 874 } |
| 875 | 875 |
| 876 void InstFakeDef::emit(const Cfg *Func) const { | 876 void InstFakeDef::emit(const Cfg *Func) const { |
| 877 if (!ALLOW_DUMP) | 877 if (!BuildDefs::dump()) |
| 878 return; | 878 return; |
| 879 // Go ahead and "emit" these for now, since they are relatively | 879 // Go ahead and "emit" these for now, since they are relatively |
| 880 // rare. | 880 // rare. |
| 881 Ostream &Str = Func->getContext()->getStrEmit(); | 881 Ostream &Str = Func->getContext()->getStrEmit(); |
| 882 Str << "\t# "; | 882 Str << "\t# "; |
| 883 getDest()->emit(Func); | 883 getDest()->emit(Func); |
| 884 Str << " = def.pseudo "; | 884 Str << " = def.pseudo "; |
| 885 emitSources(Func); | 885 emitSources(Func); |
| 886 } | 886 } |
| 887 | 887 |
| 888 void InstFakeDef::dump(const Cfg *Func) const { | 888 void InstFakeDef::dump(const Cfg *Func) const { |
| 889 if (!ALLOW_DUMP) | 889 if (!BuildDefs::dump()) |
| 890 return; | 890 return; |
| 891 Ostream &Str = Func->getContext()->getStrDump(); | 891 Ostream &Str = Func->getContext()->getStrDump(); |
| 892 dumpDest(Func); | 892 dumpDest(Func); |
| 893 Str << " = def.pseudo "; | 893 Str << " = def.pseudo "; |
| 894 dumpSources(Func); | 894 dumpSources(Func); |
| 895 } | 895 } |
| 896 | 896 |
| 897 void InstFakeUse::emit(const Cfg *Func) const { (void)Func; } | 897 void InstFakeUse::emit(const Cfg *Func) const { (void)Func; } |
| 898 | 898 |
| 899 void InstFakeUse::dump(const Cfg *Func) const { | 899 void InstFakeUse::dump(const Cfg *Func) const { |
| 900 if (!ALLOW_DUMP) | 900 if (!BuildDefs::dump()) |
| 901 return; | 901 return; |
| 902 Ostream &Str = Func->getContext()->getStrDump(); | 902 Ostream &Str = Func->getContext()->getStrDump(); |
| 903 Str << "use.pseudo "; | 903 Str << "use.pseudo "; |
| 904 dumpSources(Func); | 904 dumpSources(Func); |
| 905 } | 905 } |
| 906 | 906 |
| 907 void InstFakeKill::emit(const Cfg *Func) const { (void)Func; } | 907 void InstFakeKill::emit(const Cfg *Func) const { (void)Func; } |
| 908 | 908 |
| 909 void InstFakeKill::dump(const Cfg *Func) const { | 909 void InstFakeKill::dump(const Cfg *Func) const { |
| 910 if (!ALLOW_DUMP) | 910 if (!BuildDefs::dump()) |
| 911 return; | 911 return; |
| 912 Ostream &Str = Func->getContext()->getStrDump(); | 912 Ostream &Str = Func->getContext()->getStrDump(); |
| 913 if (Linked->isDeleted()) | 913 if (Linked->isDeleted()) |
| 914 Str << "// "; | 914 Str << "// "; |
| 915 Str << "kill.pseudo scratch_regs"; | 915 Str << "kill.pseudo scratch_regs"; |
| 916 } | 916 } |
| 917 | 917 |
| 918 void InstTarget::dump(const Cfg *Func) const { | 918 void InstTarget::dump(const Cfg *Func) const { |
| 919 if (!ALLOW_DUMP) | 919 if (!BuildDefs::dump()) |
| 920 return; | 920 return; |
| 921 Ostream &Str = Func->getContext()->getStrDump(); | 921 Ostream &Str = Func->getContext()->getStrDump(); |
| 922 Str << "[TARGET] "; | 922 Str << "[TARGET] "; |
| 923 Inst::dump(Func); | 923 Inst::dump(Func); |
| 924 } | 924 } |
| 925 | 925 |
| 926 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { | 926 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { |
| 927 const auto SrcVar = llvm::dyn_cast<const Variable>(Source); | 927 const auto SrcVar = llvm::dyn_cast<const Variable>(Source); |
| 928 if (!SrcVar) | 928 if (!SrcVar) |
| 929 return false; | 929 return false; |
| 930 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { | 930 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { |
| 931 // TODO: On x86-64, instructions like "mov eax, eax" are used to | 931 // TODO: On x86-64, instructions like "mov eax, eax" are used to |
| 932 // clear the upper 32 bits of rax. We need to recognize and | 932 // clear the upper 32 bits of rax. We need to recognize and |
| 933 // preserve these. | 933 // preserve these. |
| 934 return true; | 934 return true; |
| 935 } | 935 } |
| 936 if (!Dest->hasReg() && !SrcVar->hasReg() && | 936 if (!Dest->hasReg() && !SrcVar->hasReg() && |
| 937 Dest->getStackOffset() == SrcVar->getStackOffset()) | 937 Dest->getStackOffset() == SrcVar->getStackOffset()) |
| 938 return true; | 938 return true; |
| 939 return false; | 939 return false; |
| 940 } | 940 } |
| 941 | 941 |
| 942 } // end of namespace Ice | 942 } // end of namespace Ice |
| OLD | NEW |