Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===// | 1 //===- subzero/src/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===// |
| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 } | 340 } |
| 341 void _addps(Variable *Dest, Operand *Src0) { | 341 void _addps(Variable *Dest, Operand *Src0) { |
| 342 Context.insert(Traits::Insts::Addps::create(Func, Dest, Src0)); | 342 Context.insert(Traits::Insts::Addps::create(Func, Dest, Src0)); |
| 343 } | 343 } |
| 344 void _addss(Variable *Dest, Operand *Src0) { | 344 void _addss(Variable *Dest, Operand *Src0) { |
| 345 Context.insert(Traits::Insts::Addss::create(Func, Dest, Src0)); | 345 Context.insert(Traits::Insts::Addss::create(Func, Dest, Src0)); |
| 346 } | 346 } |
| 347 void _and(Variable *Dest, Operand *Src0) { | 347 void _and(Variable *Dest, Operand *Src0) { |
| 348 Context.insert(Traits::Insts::And::create(Func, Dest, Src0)); | 348 Context.insert(Traits::Insts::And::create(Func, Dest, Src0)); |
| 349 } | 349 } |
| 350 void _andnps(Variable *Dest, Operand *Src0) { | |
| 351 Context.insert(Traits::Insts::Andnps::create(Func, Dest, Src0)); | |
| 352 } | |
| 353 void _andps(Variable *Dest, Operand *Src0) { | |
| 354 Context.insert(Traits::Insts::Andps::create(Func, Dest, Src0)); | |
| 355 } | |
| 350 void _and_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) { | 356 void _and_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) { |
| 351 Context.insert(Traits::Insts::AndRMW::create(Func, DestSrc0, Src1)); | 357 Context.insert(Traits::Insts::AndRMW::create(Func, DestSrc0, Src1)); |
| 352 } | 358 } |
| 353 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) { | 359 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) { |
| 354 Context.insert(Traits::Insts::Blendvps::create(Func, Dest, Src0, Src1)); | 360 Context.insert(Traits::Insts::Blendvps::create(Func, Dest, Src0, Src1)); |
| 355 } | 361 } |
| 356 void _br(typename Traits::Cond::BrCond Condition, CfgNode *TargetTrue, | 362 void _br(typename Traits::Cond::BrCond Condition, CfgNode *TargetTrue, |
| 357 CfgNode *TargetFalse) { | 363 CfgNode *TargetFalse) { |
| 358 Context.insert(Traits::Insts::Br::create( | 364 Context.insert(Traits::Insts::Br::create( |
| 359 Func, TargetTrue, TargetFalse, Condition, Traits::Insts::Br::Far)); | 365 Func, TargetTrue, TargetFalse, Condition, Traits::Insts::Br::Far)); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 Inst *NewInst = Traits::Insts::Mov::create(Func, Dest, Src0); | 487 Inst *NewInst = Traits::Insts::Mov::create(Func, Dest, Src0); |
| 482 NewInst->setDestRedefined(); | 488 NewInst->setDestRedefined(); |
| 483 Context.insert(NewInst); | 489 Context.insert(NewInst); |
| 484 } | 490 } |
| 485 void _movd(Variable *Dest, Operand *Src0) { | 491 void _movd(Variable *Dest, Operand *Src0) { |
| 486 Context.insert(Traits::Insts::Movd::create(Func, Dest, Src0)); | 492 Context.insert(Traits::Insts::Movd::create(Func, Dest, Src0)); |
| 487 } | 493 } |
| 488 void _movp(Variable *Dest, Operand *Src0) { | 494 void _movp(Variable *Dest, Operand *Src0) { |
| 489 Context.insert(Traits::Insts::Movp::create(Func, Dest, Src0)); | 495 Context.insert(Traits::Insts::Movp::create(Func, Dest, Src0)); |
| 490 } | 496 } |
| 497 void _movp_redefined(Variable *Dest, Operand *Src0) { | |
| 498 Inst *NewInst = Traits::Insts::Movp::create(Func, Dest, Src0); | |
| 499 NewInst->setDestRedefined(); | |
| 500 Context.insert(NewInst); | |
| 501 } | |
| 491 void _movq(Variable *Dest, Operand *Src0) { | 502 void _movq(Variable *Dest, Operand *Src0) { |
| 492 Context.insert(Traits::Insts::Movq::create(Func, Dest, Src0)); | 503 Context.insert(Traits::Insts::Movq::create(Func, Dest, Src0)); |
| 493 } | 504 } |
| 494 void _movss(Variable *Dest, Variable *Src0) { | 505 void _movss(Variable *Dest, Variable *Src0) { |
| 495 Context.insert(Traits::Insts::MovssRegs::create(Func, Dest, Src0)); | 506 Context.insert(Traits::Insts::MovssRegs::create(Func, Dest, Src0)); |
| 496 } | 507 } |
| 497 void _movsx(Variable *Dest, Operand *Src0) { | 508 void _movsx(Variable *Dest, Operand *Src0) { |
| 498 Context.insert(Traits::Insts::Movsx::create(Func, Dest, Src0)); | 509 Context.insert(Traits::Insts::Movsx::create(Func, Dest, Src0)); |
| 499 } | 510 } |
| 500 void _movzx(Variable *Dest, Operand *Src0) { | 511 void _movzx(Variable *Dest, Operand *Src0) { |
| 501 Context.insert(Traits::Insts::Movzx::create(Func, Dest, Src0)); | 512 Context.insert(Traits::Insts::Movzx::create(Func, Dest, Src0)); |
| 502 } | 513 } |
| 514 void _maxss(Variable *Dest, Operand *Src0) { | |
| 515 Context.insert(Traits::Insts::Maxss::create(Func, Dest, Src0)); | |
| 516 } | |
| 517 void _minss(Variable *Dest, Operand *Src0) { | |
| 518 Context.insert(Traits::Insts::Minss::create(Func, Dest, Src0)); | |
| 519 } | |
| 503 void _mul(Variable *Dest, Variable *Src0, Operand *Src1) { | 520 void _mul(Variable *Dest, Variable *Src0, Operand *Src1) { |
| 504 Context.insert(Traits::Insts::Mul::create(Func, Dest, Src0, Src1)); | 521 Context.insert(Traits::Insts::Mul::create(Func, Dest, Src0, Src1)); |
| 505 } | 522 } |
| 506 void _mulps(Variable *Dest, Operand *Src0) { | 523 void _mulps(Variable *Dest, Operand *Src0) { |
| 507 Context.insert(Traits::Insts::Mulps::create(Func, Dest, Src0)); | 524 Context.insert(Traits::Insts::Mulps::create(Func, Dest, Src0)); |
| 508 } | 525 } |
| 509 void _mulss(Variable *Dest, Operand *Src0) { | 526 void _mulss(Variable *Dest, Operand *Src0) { |
| 510 Context.insert(Traits::Insts::Mulss::create(Func, Dest, Src0)); | 527 Context.insert(Traits::Insts::Mulss::create(Func, Dest, Src0)); |
| 511 } | 528 } |
| 512 void _neg(Variable *SrcDest) { | 529 void _neg(Variable *SrcDest) { |
| 513 Context.insert(Traits::Insts::Neg::create(Func, SrcDest)); | 530 Context.insert(Traits::Insts::Neg::create(Func, SrcDest)); |
| 514 } | 531 } |
| 515 void _nop(SizeT Variant) { | 532 void _nop(SizeT Variant) { |
| 516 Context.insert(Traits::Insts::Nop::create(Func, Variant)); | 533 Context.insert(Traits::Insts::Nop::create(Func, Variant)); |
| 517 } | 534 } |
| 518 void _or(Variable *Dest, Operand *Src0) { | 535 void _or(Variable *Dest, Operand *Src0) { |
| 519 Context.insert(Traits::Insts::Or::create(Func, Dest, Src0)); | 536 Context.insert(Traits::Insts::Or::create(Func, Dest, Src0)); |
| 520 } | 537 } |
| 538 void _orps(Variable *Dest, Operand *Src0) { | |
| 539 Context.insert(Traits::Insts::Orps::create(Func, Dest, Src0)); | |
| 540 } | |
| 521 void _or_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) { | 541 void _or_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) { |
| 522 Context.insert(Traits::Insts::OrRMW::create(Func, DestSrc0, Src1)); | 542 Context.insert(Traits::Insts::OrRMW::create(Func, DestSrc0, Src1)); |
| 523 } | 543 } |
| 524 void _padd(Variable *Dest, Operand *Src0) { | 544 void _padd(Variable *Dest, Operand *Src0) { |
| 525 Context.insert(Traits::Insts::Padd::create(Func, Dest, Src0)); | 545 Context.insert(Traits::Insts::Padd::create(Func, Dest, Src0)); |
| 526 } | 546 } |
| 527 void _pand(Variable *Dest, Operand *Src0) { | 547 void _pand(Variable *Dest, Operand *Src0) { |
| 528 Context.insert(Traits::Insts::Pand::create(Func, Dest, Src0)); | 548 Context.insert(Traits::Insts::Pand::create(Func, Dest, Src0)); |
| 529 } | 549 } |
| 530 void _pandn(Variable *Dest, Operand *Src0) { | 550 void _pandn(Variable *Dest, Operand *Src0) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 // The xchg modifies Dest and Src -- model that update with a | 676 // The xchg modifies Dest and Src -- model that update with a |
| 657 // FakeDef/FakeUse. | 677 // FakeDef/FakeUse. |
| 658 Context.insert( | 678 Context.insert( |
| 659 InstFakeDef::create(Func, Src, llvm::dyn_cast<Variable>(Dest))); | 679 InstFakeDef::create(Func, Src, llvm::dyn_cast<Variable>(Dest))); |
| 660 _set_dest_redefined(); | 680 _set_dest_redefined(); |
| 661 Context.insert(InstFakeUse::create(Func, Src)); | 681 Context.insert(InstFakeUse::create(Func, Src)); |
| 662 } | 682 } |
| 663 void _xor(Variable *Dest, Operand *Src0) { | 683 void _xor(Variable *Dest, Operand *Src0) { |
| 664 Context.insert(Traits::Insts::Xor::create(Func, Dest, Src0)); | 684 Context.insert(Traits::Insts::Xor::create(Func, Dest, Src0)); |
| 665 } | 685 } |
| 686 void _xorps(Variable *Dest, Operand *Src0) { | |
| 687 Context.insert(Traits::Insts::Xorps::create(Func, Dest, Src0)); | |
| 688 } | |
| 666 void _xor_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) { | 689 void _xor_rmw(typename Traits::X86OperandMem *DestSrc0, Operand *Src1) { |
| 667 Context.insert(Traits::Insts::XorRMW::create(Func, DestSrc0, Src1)); | 690 Context.insert(Traits::Insts::XorRMW::create(Func, DestSrc0, Src1)); |
| 668 } | 691 } |
| 669 | 692 |
| 670 void _iaca_start() { | 693 void _iaca_start() { |
| 671 if (!BuildDefs::minimal()) | 694 if (!BuildDefs::minimal()) |
| 672 Context.insert(Traits::Insts::IacaStart::create(Func)); | 695 Context.insert(Traits::Insts::IacaStart::create(Func)); |
| 673 } | 696 } |
| 674 void _iaca_end() { | 697 void _iaca_end() { |
| 675 if (!BuildDefs::minimal()) | 698 if (!BuildDefs::minimal()) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 | 768 |
| 746 template <typename... Args> | 769 template <typename... Args> |
| 747 void dispatchToConcrete(void (Machine::*Method)(Args...), Args &&... args) { | 770 void dispatchToConcrete(void (Machine::*Method)(Args...), Args &&... args) { |
| 748 (static_cast<Machine *>(this)->*Method)(std::forward<Args>(args)...); | 771 (static_cast<Machine *>(this)->*Method)(std::forward<Args>(args)...); |
| 749 } | 772 } |
| 750 | 773 |
| 751 void lowerShift64(InstArithmetic::OpKind Op, Operand *Src0Lo, Operand *Src0Hi, | 774 void lowerShift64(InstArithmetic::OpKind Op, Operand *Src0Lo, Operand *Src0Hi, |
| 752 Operand *Src1Lo, Variable *DestLo, Variable *DestHi); | 775 Operand *Src1Lo, Variable *DestLo, Variable *DestHi); |
| 753 | 776 |
| 754 /// Emit the code for a combined operation and branch, or set the destination | 777 /// Emit the code for a combined operation and branch, or set the destination |
| 755 /// variable of the operation if Br == nullptr. | 778 /// variable of the operation if Br == nullptr. |
|
John
2015/12/07 13:07:44
The comment needs to be updated.
sehr
2015/12/15 20:45:44
Done.
| |
| 756 void lowerIcmpAndBr(const InstIcmp *Icmp, const InstBr *Br); | 779 void lowerIcmpAndConsumer(const InstIcmp *Icmp, const Inst *Consumer); |
| 757 void lowerFcmpAndBr(const InstFcmp *Fcmp, const InstBr *Br); | 780 void lowerFcmpAndConsumer(const InstFcmp *Fcmp, const Inst *Consumer); |
| 758 void lowerArithAndBr(const InstArithmetic *Arith, const InstBr *Br); | 781 void lowerArithAndConsumer(const InstArithmetic *Arith, const Inst *Consumer); |
| 759 | 782 |
| 760 /// Emit a setcc instruction if Br == nullptr; otherwise emit a branch. | 783 /// Emit a setcc instruction if Consumer == nullptr; otherwise emit a |
| 761 void setccOrBr(typename Traits::Cond::BrCond Condition, Variable *Dest, | 784 /// specialized version of Consumer. |
| 762 const InstBr *Br); | 785 void setccOrConsumer(typename Traits::Cond::BrCond Condition, Variable *Dest, |
| 786 const Inst *Consumer); | |
| 763 | 787 |
| 764 /// Emit a mov [1|0] instruction if Br == nullptr; otherwise emit a branch. | 788 /// Emit a mov [1|0] instruction if Consumer == nullptr; otherwise emit a |
| 765 void movOrBr(bool IcmpResult, Variable *Dest, const InstBr *Br); | 789 /// specialized version of Consumer. |
| 790 void movOrConsumer(bool IcmpResult, Variable *Dest, const Inst *Consumer); | |
| 791 | |
| 792 /// Emit the code for instructions with a vector type. | |
| 793 void lowerIcmpVector(const InstIcmp *Icmp); | |
| 794 void lowerFcmpVector(const InstFcmp *Icmp); | |
| 795 void lowerSelectVector(const InstSelect *Inst); | |
| 796 | |
| 797 /// Helpers for select lowering. | |
| 798 void lowerSelectMove(Variable *Dest, typename Traits::Cond::BrCond Cond, | |
| 799 Operand *SrcT, Operand *SrcF); | |
| 800 void lowerSelectIntMove(Variable *Dest, typename Traits::Cond::BrCond Cond, | |
| 801 Operand *SrcT, Operand *SrcF); | |
| 802 /// Generic helper to move an arbitrary type from Src to Dest. | |
| 803 void lowerMove(Variable *Dest, Operand *Src, bool IsRedefinition); | |
| 804 | |
| 805 /// Optimizations for idiom recognition. | |
| 806 bool lowerOptimizeFcmpSelect(const InstFcmp *Fcmp, const InstSelect *Select); | |
| 766 | 807 |
| 767 /// Complains loudly if invoked because the cpu can handle 64-bit types | 808 /// Complains loudly if invoked because the cpu can handle 64-bit types |
| 768 /// natively. | 809 /// natively. |
| 769 template <typename T = Traits> | 810 template <typename T = Traits> |
| 770 typename std::enable_if<T::Is64Bit, void>::type lowerIcmp64(const InstIcmp *, | 811 typename std::enable_if<T::Is64Bit, void>::type lowerIcmp64(const InstIcmp *, |
| 771 const InstBr *) { | 812 const Inst *) { |
| 772 llvm::report_fatal_error( | 813 llvm::report_fatal_error( |
| 773 "Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)"); | 814 "Hey, yo! This is x86-64. Watcha doin'? (lowerIcmp64)"); |
| 774 } | 815 } |
| 775 /// x86lowerIcmp64 handles 64-bit icmp lowering. | 816 /// x86lowerIcmp64 handles 64-bit icmp lowering. |
| 776 template <typename T = Traits> | 817 template <typename T = Traits> |
| 777 typename std::enable_if<!T::Is64Bit, void>::type | 818 typename std::enable_if<!T::Is64Bit, void>::type |
| 778 lowerIcmp64(const InstIcmp *Icmp, const InstBr *Br); | 819 lowerIcmp64(const InstIcmp *Icmp, const Inst *Consumer); |
| 779 | 820 |
| 780 BoolFolding FoldingInfo; | 821 BoolFolding FoldingInfo; |
| 781 }; | 822 }; |
| 782 } // end of namespace X86Internal | 823 } // end of namespace X86Internal |
| 783 } // end of namespace Ice | 824 } // end of namespace Ice |
| 784 | 825 |
| 785 #include "IceTargetLoweringX86BaseImpl.h" | 826 #include "IceTargetLoweringX86BaseImpl.h" |
| 786 | 827 |
| 787 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H | 828 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H |
| OLD | NEW |