OLD | NEW |
1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===// | 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 } | 696 } |
697 | 697 |
698 bool TargetLowering::shouldOptimizeMemIntrins() { | 698 bool TargetLowering::shouldOptimizeMemIntrins() { |
699 return Ctx->getFlags().getOptLevel() >= Opt_1 || | 699 return Ctx->getFlags().getOptLevel() >= Opt_1 || |
700 Ctx->getFlags().getForceMemIntrinOpt(); | 700 Ctx->getFlags().getForceMemIntrinOpt(); |
701 } | 701 } |
702 | 702 |
703 void TargetLowering::scalarizeArithmetic(InstArithmetic::OpKind Kind, | 703 void TargetLowering::scalarizeArithmetic(InstArithmetic::OpKind Kind, |
704 Variable *Dest, Operand *Src0, | 704 Variable *Dest, Operand *Src0, |
705 Operand *Src1) { | 705 Operand *Src1) { |
706 assert(isVectorType(Dest->getType())); | 706 scalarizeInstruction(Dest, Src0, Src1, |
707 Type Ty = Dest->getType(); | 707 [this, Kind](Variable *Dest, Variable *Src0, |
708 Type ElementTy = typeElementType(Ty); | 708 Variable *Src1) { |
709 SizeT NumElements = typeNumElements(Ty); | 709 return Context.insert<InstArithmetic>(Kind, Dest, Src0, |
710 | 710 Src1); |
711 Operand *T = Ctx->getConstantUndef(Ty); | 711 }); |
712 for (SizeT I = 0; I < NumElements; ++I) { | |
713 Constant *Index = Ctx->getConstantInt32(I); | |
714 | |
715 // Extract the next two inputs. | |
716 Variable *Op0 = Func->makeVariable(ElementTy); | |
717 Context.insert<InstExtractElement>(Op0, Src0, Index); | |
718 Variable *Op1 = Func->makeVariable(ElementTy); | |
719 Context.insert<InstExtractElement>(Op1, Src1, Index); | |
720 | |
721 // Perform the arithmetic as a scalar operation. | |
722 Variable *Res = Func->makeVariable(ElementTy); | |
723 auto *Arith = Context.insert<InstArithmetic>(Kind, Res, Op0, Op1); | |
724 // We might have created an operation that needed a helper call. | |
725 genTargetHelperCallFor(Arith); | |
726 | |
727 // Insert the result into position. | |
728 Variable *DestT = Func->makeVariable(Ty); | |
729 Context.insert<InstInsertElement>(DestT, T, Res, Index); | |
730 T = DestT; | |
731 } | |
732 | |
733 Context.insert<InstAssign>(Dest, T); | |
734 } | 712 } |
735 | 713 |
736 void TargetLowering::emitWithoutPrefix(const ConstantRelocatable *C, | 714 void TargetLowering::emitWithoutPrefix(const ConstantRelocatable *C, |
737 const char *Suffix) const { | 715 const char *Suffix) const { |
738 if (!BuildDefs::dump()) | 716 if (!BuildDefs::dump()) |
739 return; | 717 return; |
740 Ostream &Str = Ctx->getStrEmit(); | 718 Ostream &Str = Ctx->getStrEmit(); |
741 const IceString &EmitStr = C->getEmitString(); | 719 const IceString &EmitStr = C->getEmitString(); |
742 if (!EmitStr.empty()) { | 720 if (!EmitStr.empty()) { |
743 // C has a custom emit string, so we use it instead of the canonical | 721 // C has a custom emit string, so we use it instead of the canonical |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 case Target_##X: \ | 874 case Target_##X: \ |
897 return ::X::createTargetHeaderLowering(Ctx); | 875 return ::X::createTargetHeaderLowering(Ctx); |
898 #include "llvm/Config/SZTargets.def" | 876 #include "llvm/Config/SZTargets.def" |
899 #undef SUBZERO_TARGET | 877 #undef SUBZERO_TARGET |
900 } | 878 } |
901 } | 879 } |
902 | 880 |
903 TargetHeaderLowering::~TargetHeaderLowering() = default; | 881 TargetHeaderLowering::~TargetHeaderLowering() = default; |
904 | 882 |
905 } // end of namespace Ice | 883 } // end of namespace Ice |
OLD | NEW |