| 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 InstCall *Call = | 693 InstCall *Call = |
| 694 InstCall::create(Func, MaxSrcs, Dest, CallTarget, HasTailCall); | 694 InstCall::create(Func, MaxSrcs, Dest, CallTarget, HasTailCall); |
| 695 return Call; | 695 return Call; |
| 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, |
| 704 Variable *Dest, Operand *Src0, |
| 705 Operand *Src1) { |
| 706 assert(isVectorType(Dest->getType())); |
| 707 Type Ty = Dest->getType(); |
| 708 Type ElementTy = typeElementType(Ty); |
| 709 SizeT NumElements = typeNumElements(Ty); |
| 710 |
| 711 Operand *T = Ctx->getConstantUndef(Ty); |
| 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 } |
| 735 |
| 703 void TargetLowering::emitWithoutPrefix(const ConstantRelocatable *C, | 736 void TargetLowering::emitWithoutPrefix(const ConstantRelocatable *C, |
| 704 const char *Suffix) const { | 737 const char *Suffix) const { |
| 705 if (!BuildDefs::dump()) | 738 if (!BuildDefs::dump()) |
| 706 return; | 739 return; |
| 707 Ostream &Str = Ctx->getStrEmit(); | 740 Ostream &Str = Ctx->getStrEmit(); |
| 708 const IceString &EmitStr = C->getEmitString(); | 741 const IceString &EmitStr = C->getEmitString(); |
| 709 if (!EmitStr.empty()) { | 742 if (!EmitStr.empty()) { |
| 710 // C has a custom emit string, so we use it instead of the canonical | 743 // C has a custom emit string, so we use it instead of the canonical |
| 711 // Name + Offset form. | 744 // Name + Offset form. |
| 712 Str << EmitStr; | 745 Str << EmitStr; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 case Target_##X: \ | 896 case Target_##X: \ |
| 864 return ::X::createTargetHeaderLowering(Ctx); | 897 return ::X::createTargetHeaderLowering(Ctx); |
| 865 #include "llvm/Config/SZTargets.def" | 898 #include "llvm/Config/SZTargets.def" |
| 866 #undef SUBZERO_TARGET | 899 #undef SUBZERO_TARGET |
| 867 } | 900 } |
| 868 } | 901 } |
| 869 | 902 |
| 870 TargetHeaderLowering::~TargetHeaderLowering() = default; | 903 TargetHeaderLowering::~TargetHeaderLowering() = default; |
| 871 | 904 |
| 872 } // end of namespace Ice | 905 } // end of namespace Ice |
| OLD | NEW |