llvm.org GIT mirror llvm / 13bbe1f
Use the target options specified on a function to reset the back-end. During LTO, the target options on functions within the same Module may change. This would necessitate resetting some of the back-end. Do this for X86, because it's a Friday afternoon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178917 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
6 changed file(s) with 112 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
134134 const TargetLoweringObjectFile *TLOF);
135135 virtual ~TargetLoweringBase();
136136
137 protected:
138 /// \brief Initialize all of the actions to default values.
139 void initActions();
140
141 public:
137142 const TargetMachine &getTargetMachine() const { return TM; }
138143 const DataLayout *getDataLayout() const { return TD; }
139144 const TargetLoweringObjectFile &getObjFileLowering() const { return TLOF; }
850855 // the derived class constructor to configure this object for the target.
851856 //
852857
858 /// \brief Reset the operation actions based on target options.
859 virtual void resetOperationActions() {}
860
853861 protected:
854862 /// setBooleanContents - Specify how the target extends the result of a
855863 /// boolean value from i1 to a wider type. See getBooleanContents.
950958 RegClassForVT[VT.SimpleTy] = RC;
951959 }
952960
953 /// clearRegisterClasses - remove all register classes
961 /// clearRegisterClasses - Remove all register classes.
954962 void clearRegisterClasses() {
955 for (unsigned i = 0 ; i
956 RegClassForVT[i] = 0;
963 memset(RegClassForVT, 0,MVT::LAST_VALUETYPE * sizeof(TargetRegisterClass*));
964
957965 AvailableRegClasses.clear();
966 }
967
968 /// \brief Remove all operation actions.
969 void clearOperationActions() {
958970 }
959971
960972 /// findRepresentativeClass - Return the largest legal super-reg register class
207207 /// the value of this option.
208208 FPOpFusion::FPOpFusionMode AllowFPOpFusion;
209209
210 bool operator==(const TargetOptions &);
210211 };
211212 } // End llvm namespace
212213
619619 TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm,
620620 const TargetLoweringObjectFile *tlof)
621621 : TM(tm), TD(TM.getDataLayout()), TLOF(*tlof) {
622 initActions();
623
624 // Perform these initializations only once.
625 IsLittleEndian = TD->isLittleEndian();
626 PointerTy = MVT::getIntegerVT(8*TD->getPointerSize(0));
627 MaxStoresPerMemset = MaxStoresPerMemcpy = MaxStoresPerMemmove = 8;
628 MaxStoresPerMemsetOptSize = MaxStoresPerMemcpyOptSize
629 = MaxStoresPerMemmoveOptSize = 4;
630 UseUnderscoreSetJmp = false;
631 UseUnderscoreLongJmp = false;
632 SelectIsExpensive = false;
633 IntDivIsCheap = false;
634 Pow2DivIsCheap = false;
635 JumpIsExpensive = false;
636 PredictableSelectIsExpensive = false;
637 StackPointerRegisterToSaveRestore = 0;
638 ExceptionPointerRegister = 0;
639 ExceptionSelectorRegister = 0;
640 BooleanContents = UndefinedBooleanContent;
641 BooleanVectorContents = UndefinedBooleanContent;
642 SchedPreferenceInfo = Sched::ILP;
643 JumpBufSize = 0;
644 JumpBufAlignment = 0;
645 MinFunctionAlignment = 0;
646 PrefFunctionAlignment = 0;
647 PrefLoopAlignment = 0;
648 MinStackArgumentAlignment = 1;
649 ShouldFoldAtomicFences = false;
650 InsertFencesForAtomic = false;
651 SupportJumpTables = true;
652 MinimumJumpTableEntries = 4;
653
654 InitLibcallNames(LibcallRoutineNames, TM);
655 InitCmpLibcallCCs(CmpLibcallCCs);
656 InitLibcallCallingConvs(LibcallCallingConvs);
657 }
658
659 TargetLoweringBase::~TargetLoweringBase() {
660 delete &TLOF;
661 }
662
663 void TargetLoweringBase::initActions() {
622664 // All operations default to being supported.
623665 memset(OpActions, 0, sizeof(OpActions));
624666 memset(LoadExtActions, 0, sizeof(LoadExtActions));
625667 memset(TruncStoreActions, 0, sizeof(TruncStoreActions));
626668 memset(IndexedModeActions, 0, sizeof(IndexedModeActions));
627669 memset(CondCodeActions, 0, sizeof(CondCodeActions));
670 memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
671 memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray));
628672
629673 // Set default actions for various operations.
630674 for (unsigned VT = 0; VT != (unsigned)MVT::LAST_VALUETYPE; ++VT) {
701745 // here is to inform DAG Legalizer to replace DEBUGTRAP with TRAP.
702746 //
703747 setOperationAction(ISD::DEBUGTRAP, MVT::Other, Expand);
704
705 IsLittleEndian = TD->isLittleEndian();
706 PointerTy = MVT::getIntegerVT(8*TD->getPointerSize(0));
707 memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
708 memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray));
709 MaxStoresPerMemset = MaxStoresPerMemcpy = MaxStoresPerMemmove = 8;
710 MaxStoresPerMemsetOptSize = MaxStoresPerMemcpyOptSize
711 = MaxStoresPerMemmoveOptSize = 4;
712 UseUnderscoreSetJmp = false;
713 UseUnderscoreLongJmp = false;
714 SelectIsExpensive = false;
715 IntDivIsCheap = false;
716 Pow2DivIsCheap = false;
717 JumpIsExpensive = false;
718 PredictableSelectIsExpensive = false;
719 StackPointerRegisterToSaveRestore = 0;
720 ExceptionPointerRegister = 0;
721 ExceptionSelectorRegister = 0;
722 BooleanContents = UndefinedBooleanContent;
723 BooleanVectorContents = UndefinedBooleanContent;
724 SchedPreferenceInfo = Sched::ILP;
725 JumpBufSize = 0;
726 JumpBufAlignment = 0;
727 MinFunctionAlignment = 0;
728 PrefFunctionAlignment = 0;
729 PrefLoopAlignment = 0;
730 MinStackArgumentAlignment = 1;
731 ShouldFoldAtomicFences = false;
732 InsertFencesForAtomic = false;
733 SupportJumpTables = true;
734 MinimumJumpTableEntries = 4;
735
736 InitLibcallNames(LibcallRoutineNames, TM);
737 InitCmpLibcallCCs(CmpLibcallCCs);
738 InitLibcallCallingConvs(LibcallCallingConvs);
739 }
740
741 TargetLoweringBase::~TargetLoweringBase() {
742 delete &TLOF;
743748 }
744749
745750 MVT TargetLoweringBase::getScalarShiftAmountTy(EVT LHSTy) const {
4949 return TrapFuncName;
5050 }
5151
52 bool TargetOptions::operator==(const TargetOptions &TO) {
53 #define ARE_EQUAL(X) X == TO.X
54 return
55 ARE_EQUAL(UnsafeFPMath) &&
56 ARE_EQUAL(NoInfsFPMath) &&
57 ARE_EQUAL(NoNaNsFPMath) &&
58 ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
59 ARE_EQUAL(UseSoftFloat) &&
60 ARE_EQUAL(NoZerosInBSS) &&
61 ARE_EQUAL(JITExceptionHandling) &&
62 ARE_EQUAL(JITEmitDebugInfo) &&
63 ARE_EQUAL(JITEmitDebugInfoToDisk) &&
64 ARE_EQUAL(GuaranteedTailCallOpt) &&
65 ARE_EQUAL(DisableTailCalls) &&
66 ARE_EQUAL(StackAlignmentOverride) &&
67 ARE_EQUAL(RealignStack) &&
68 ARE_EQUAL(SSPBufferSize) &&
69 ARE_EQUAL(EnableFastISel) &&
70 ARE_EQUAL(PositionIndependentExecutable) &&
71 ARE_EQUAL(EnableSegmentedStacks) &&
72 ARE_EQUAL(UseInitArray) &&
73 ARE_EQUAL(TrapFuncName) &&
74 ARE_EQUAL(FloatABIType) &&
75 ARE_EQUAL(AllowFPOpFusion);
76 #undef ARE_EQUAL
77 }
162162 Subtarget = &TM.getSubtarget();
163163 X86ScalarSSEf64 = Subtarget->hasSSE2();
164164 X86ScalarSSEf32 = Subtarget->hasSSE1();
165
166165 RegInfo = TM.getRegisterInfo();
167166 TD = getDataLayout();
167
168 resetOperationActions();
169 }
170
171 void X86TargetLowering::resetOperationActions() {
172 const TargetMachine &TM = getTargetMachine();
173 static bool FirstTimeThrough = true;
174
175 // If none of the target options have changed, then we don't need to reset the
176 // operation actions.
177 if (!FirstTimeThrough && TO == TM.Options) return;
178
179 if (!FirstTimeThrough) {
180 // Reinitialize the actions.
181 initActions();
182 FirstTimeThrough = false;
183 }
184
185 TO = TM.Options;
168186
169187 // Set up the TargetLowering object.
170188 static const MVT IntVTs[] = { MVT::i8, MVT::i16, MVT::i32, MVT::i64 };
722722 SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot,
723723 SelectionDAG &DAG) const;
724724
725 /// \brief Reset the operation actions based on target options.
726 virtual void resetOperationActions();
727
725728 protected:
726729 std::pair
727730 findRepresentativeClass(MVT VT) const;
732735 const X86Subtarget *Subtarget;
733736 const X86RegisterInfo *RegInfo;
734737 const DataLayout *TD;
738
739 /// Used to store the TargetOptions so that we don't waste time resetting
740 /// the operation actions unless we have to.
741 TargetOptions TO;
735742
736743 /// X86ScalarSSEf32, X86ScalarSSEf64 - Select between SSE or x87
737744 /// floating point ops.