Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/IceTargetLoweringX86Base.h

Issue 1497033002: Fuse icmp/fcmp with select (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 void _insertps(Variable *Dest, Operand *Src0, Operand *Src1) { 467 void _insertps(Variable *Dest, Operand *Src0, Operand *Src1) {
462 Context.insert(Traits::Insts::Insertps::create(Func, Dest, Src0, Src1)); 468 Context.insert(Traits::Insts::Insertps::create(Func, Dest, Src0, Src1));
463 } 469 }
464 void _jmp(Operand *Target) { 470 void _jmp(Operand *Target) {
465 Context.insert(Traits::Insts::Jmp::create(Func, Target)); 471 Context.insert(Traits::Insts::Jmp::create(Func, Target));
466 } 472 }
467 void _lea(Variable *Dest, Operand *Src0) { 473 void _lea(Variable *Dest, Operand *Src0) {
468 Context.insert(Traits::Insts::Lea::create(Func, Dest, Src0)); 474 Context.insert(Traits::Insts::Lea::create(Func, Dest, Src0));
469 } 475 }
470 void _mfence() { Context.insert(Traits::Insts::Mfence::create(Func)); } 476 void _mfence() { Context.insert(Traits::Insts::Mfence::create(Func)); }
477 /// Moves can be used to redefine registers, creating "partial kills" for
478 /// liveness. Mark where moves are used in this way.
479 void _redefined(Inst *MovInst, bool IsRedefinition = true) {
480 if (IsRedefinition)
481 MovInst->setDestRedefined();
482 }
471 /// If Dest=nullptr is passed in, then a new variable is created, marked as 483 /// If Dest=nullptr is passed in, then a new variable is created, marked as
472 /// infinite register allocation weight, and returned through the in/out Dest 484 /// infinite register allocation weight, and returned through the in/out Dest
473 /// argument. 485 /// argument.
474 void _mov(Variable *&Dest, Operand *Src0, 486 Inst *_mov(Variable *&Dest, Operand *Src0,
475 int32_t RegNum = Variable::NoRegister) { 487 int32_t RegNum = Variable::NoRegister) {
476 if (Dest == nullptr) 488 if (Dest == nullptr)
477 Dest = makeReg(Src0->getType(), RegNum); 489 Dest = makeReg(Src0->getType(), RegNum);
478 Context.insert(Traits::Insts::Mov::create(Func, Dest, Src0)); 490 Inst *NewInst = Traits::Insts::Mov::create(Func, Dest, Src0);
491 Context.insert(NewInst);
492 return NewInst;
479 } 493 }
480 void _mov_redefined(Variable *Dest, Operand *Src0) { 494 Inst * _movp(Variable *Dest, Operand *Src0) {
Jim Stichnoth 2015/12/16 01:00:37 It's gone - nice!
sehr 2015/12/16 01:34:04 Yep, except for ARM -- need Joao's help for that.
481 Inst *NewInst = Traits::Insts::Mov::create(Func, Dest, Src0); 495 Inst *NewInst = Traits::Insts::Movp::create(Func, Dest, Src0);
482 NewInst->setDestRedefined();
483 Context.insert(NewInst); 496 Context.insert(NewInst);
497 return NewInst;
484 } 498 }
485 void _movd(Variable *Dest, Operand *Src0) { 499 void _movd(Variable *Dest, Operand *Src0) {
486 Context.insert(Traits::Insts::Movd::create(Func, Dest, Src0)); 500 Context.insert(Traits::Insts::Movd::create(Func, Dest, Src0));
487 } 501 }
488 void _movp(Variable *Dest, Operand *Src0) {
489 Context.insert(Traits::Insts::Movp::create(Func, Dest, Src0));
490 }
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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 767 }
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 consumer instruction, or set
755 /// variable of the operation if Br == nullptr. 778 /// the destination variable of the operation if Consumer == nullptr.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698