forked from OSchip/llvm-project
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. llvm-svn: 178917
This commit is contained in:
parent
81c46d0809
commit
eb108bad50
|
@ -135,6 +135,11 @@ public:
|
|||
const TargetLoweringObjectFile *TLOF);
|
||||
virtual ~TargetLoweringBase();
|
||||
|
||||
protected:
|
||||
/// \brief Initialize all of the actions to default values.
|
||||
void initActions();
|
||||
|
||||
public:
|
||||
const TargetMachine &getTargetMachine() const { return TM; }
|
||||
const DataLayout *getDataLayout() const { return TD; }
|
||||
const TargetLoweringObjectFile &getObjFileLowering() const { return TLOF; }
|
||||
|
@ -851,6 +856,9 @@ public:
|
|||
// the derived class constructor to configure this object for the target.
|
||||
//
|
||||
|
||||
/// \brief Reset the operation actions based on target options.
|
||||
virtual void resetOperationActions() {}
|
||||
|
||||
protected:
|
||||
/// setBooleanContents - Specify how the target extends the result of a
|
||||
/// boolean value from i1 to a wider type. See getBooleanContents.
|
||||
|
@ -951,13 +959,17 @@ protected:
|
|||
RegClassForVT[VT.SimpleTy] = RC;
|
||||
}
|
||||
|
||||
/// clearRegisterClasses - remove all register classes
|
||||
/// clearRegisterClasses - Remove all register classes.
|
||||
void clearRegisterClasses() {
|
||||
for (unsigned i = 0 ; i<array_lengthof(RegClassForVT); i++)
|
||||
RegClassForVT[i] = 0;
|
||||
memset(RegClassForVT, 0,MVT::LAST_VALUETYPE * sizeof(TargetRegisterClass*));
|
||||
|
||||
AvailableRegClasses.clear();
|
||||
}
|
||||
|
||||
/// \brief Remove all operation actions.
|
||||
void clearOperationActions() {
|
||||
}
|
||||
|
||||
/// findRepresentativeClass - Return the largest legal super-reg register class
|
||||
/// of the register class for the specified type and its associated "cost".
|
||||
virtual std::pair<const TargetRegisterClass*, uint8_t>
|
||||
|
|
|
@ -208,6 +208,7 @@ namespace llvm {
|
|||
/// the value of this option.
|
||||
FPOpFusion::FPOpFusionMode AllowFPOpFusion;
|
||||
|
||||
bool operator==(const TargetOptions &);
|
||||
};
|
||||
} // End llvm namespace
|
||||
|
||||
|
|
|
@ -620,12 +620,56 @@ static void InitCmpLibcallCCs(ISD::CondCode *CCs) {
|
|||
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm,
|
||||
const TargetLoweringObjectFile *tlof)
|
||||
: TM(tm), TD(TM.getDataLayout()), TLOF(*tlof) {
|
||||
initActions();
|
||||
|
||||
// Perform these initializations only once.
|
||||
IsLittleEndian = TD->isLittleEndian();
|
||||
PointerTy = MVT::getIntegerVT(8*TD->getPointerSize(0));
|
||||
MaxStoresPerMemset = MaxStoresPerMemcpy = MaxStoresPerMemmove = 8;
|
||||
MaxStoresPerMemsetOptSize = MaxStoresPerMemcpyOptSize
|
||||
= MaxStoresPerMemmoveOptSize = 4;
|
||||
UseUnderscoreSetJmp = false;
|
||||
UseUnderscoreLongJmp = false;
|
||||
SelectIsExpensive = false;
|
||||
IntDivIsCheap = false;
|
||||
Pow2DivIsCheap = false;
|
||||
JumpIsExpensive = false;
|
||||
PredictableSelectIsExpensive = false;
|
||||
StackPointerRegisterToSaveRestore = 0;
|
||||
ExceptionPointerRegister = 0;
|
||||
ExceptionSelectorRegister = 0;
|
||||
BooleanContents = UndefinedBooleanContent;
|
||||
BooleanVectorContents = UndefinedBooleanContent;
|
||||
SchedPreferenceInfo = Sched::ILP;
|
||||
JumpBufSize = 0;
|
||||
JumpBufAlignment = 0;
|
||||
MinFunctionAlignment = 0;
|
||||
PrefFunctionAlignment = 0;
|
||||
PrefLoopAlignment = 0;
|
||||
MinStackArgumentAlignment = 1;
|
||||
ShouldFoldAtomicFences = false;
|
||||
InsertFencesForAtomic = false;
|
||||
SupportJumpTables = true;
|
||||
MinimumJumpTableEntries = 4;
|
||||
|
||||
InitLibcallNames(LibcallRoutineNames, TM);
|
||||
InitCmpLibcallCCs(CmpLibcallCCs);
|
||||
InitLibcallCallingConvs(LibcallCallingConvs);
|
||||
}
|
||||
|
||||
TargetLoweringBase::~TargetLoweringBase() {
|
||||
delete &TLOF;
|
||||
}
|
||||
|
||||
void TargetLoweringBase::initActions() {
|
||||
// All operations default to being supported.
|
||||
memset(OpActions, 0, sizeof(OpActions));
|
||||
memset(LoadExtActions, 0, sizeof(LoadExtActions));
|
||||
memset(TruncStoreActions, 0, sizeof(TruncStoreActions));
|
||||
memset(IndexedModeActions, 0, sizeof(IndexedModeActions));
|
||||
memset(CondCodeActions, 0, sizeof(CondCodeActions));
|
||||
memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
|
||||
memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray));
|
||||
|
||||
// Set default actions for various operations.
|
||||
for (unsigned VT = 0; VT != (unsigned)MVT::LAST_VALUETYPE; ++VT) {
|
||||
|
@ -702,45 +746,6 @@ TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm,
|
|||
// here is to inform DAG Legalizer to replace DEBUGTRAP with TRAP.
|
||||
//
|
||||
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Expand);
|
||||
|
||||
IsLittleEndian = TD->isLittleEndian();
|
||||
PointerTy = MVT::getIntegerVT(8*TD->getPointerSize(0));
|
||||
memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
|
||||
memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray));
|
||||
MaxStoresPerMemset = MaxStoresPerMemcpy = MaxStoresPerMemmove = 8;
|
||||
MaxStoresPerMemsetOptSize = MaxStoresPerMemcpyOptSize
|
||||
= MaxStoresPerMemmoveOptSize = 4;
|
||||
UseUnderscoreSetJmp = false;
|
||||
UseUnderscoreLongJmp = false;
|
||||
SelectIsExpensive = false;
|
||||
IntDivIsCheap = false;
|
||||
Pow2DivIsCheap = false;
|
||||
JumpIsExpensive = false;
|
||||
PredictableSelectIsExpensive = false;
|
||||
StackPointerRegisterToSaveRestore = 0;
|
||||
ExceptionPointerRegister = 0;
|
||||
ExceptionSelectorRegister = 0;
|
||||
BooleanContents = UndefinedBooleanContent;
|
||||
BooleanVectorContents = UndefinedBooleanContent;
|
||||
SchedPreferenceInfo = Sched::ILP;
|
||||
JumpBufSize = 0;
|
||||
JumpBufAlignment = 0;
|
||||
MinFunctionAlignment = 0;
|
||||
PrefFunctionAlignment = 0;
|
||||
PrefLoopAlignment = 0;
|
||||
MinStackArgumentAlignment = 1;
|
||||
ShouldFoldAtomicFences = false;
|
||||
InsertFencesForAtomic = false;
|
||||
SupportJumpTables = true;
|
||||
MinimumJumpTableEntries = 4;
|
||||
|
||||
InitLibcallNames(LibcallRoutineNames, TM);
|
||||
InitCmpLibcallCCs(CmpLibcallCCs);
|
||||
InitLibcallCallingConvs(LibcallCallingConvs);
|
||||
}
|
||||
|
||||
TargetLoweringBase::~TargetLoweringBase() {
|
||||
delete &TLOF;
|
||||
}
|
||||
|
||||
MVT TargetLoweringBase::getScalarShiftAmountTy(EVT LHSTy) const {
|
||||
|
|
|
@ -50,3 +50,29 @@ StringRef TargetOptions::getTrapFunctionName() const {
|
|||
return TrapFuncName;
|
||||
}
|
||||
|
||||
bool TargetOptions::operator==(const TargetOptions &TO) {
|
||||
#define ARE_EQUAL(X) X == TO.X
|
||||
return
|
||||
ARE_EQUAL(UnsafeFPMath) &&
|
||||
ARE_EQUAL(NoInfsFPMath) &&
|
||||
ARE_EQUAL(NoNaNsFPMath) &&
|
||||
ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
|
||||
ARE_EQUAL(UseSoftFloat) &&
|
||||
ARE_EQUAL(NoZerosInBSS) &&
|
||||
ARE_EQUAL(JITExceptionHandling) &&
|
||||
ARE_EQUAL(JITEmitDebugInfo) &&
|
||||
ARE_EQUAL(JITEmitDebugInfoToDisk) &&
|
||||
ARE_EQUAL(GuaranteedTailCallOpt) &&
|
||||
ARE_EQUAL(DisableTailCalls) &&
|
||||
ARE_EQUAL(StackAlignmentOverride) &&
|
||||
ARE_EQUAL(RealignStack) &&
|
||||
ARE_EQUAL(SSPBufferSize) &&
|
||||
ARE_EQUAL(EnableFastISel) &&
|
||||
ARE_EQUAL(PositionIndependentExecutable) &&
|
||||
ARE_EQUAL(EnableSegmentedStacks) &&
|
||||
ARE_EQUAL(UseInitArray) &&
|
||||
ARE_EQUAL(TrapFuncName) &&
|
||||
ARE_EQUAL(FloatABIType) &&
|
||||
ARE_EQUAL(AllowFPOpFusion);
|
||||
#undef ARE_EQUAL
|
||||
}
|
||||
|
|
|
@ -163,10 +163,28 @@ X86TargetLowering::X86TargetLowering(X86TargetMachine &TM)
|
|||
Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
X86ScalarSSEf64 = Subtarget->hasSSE2();
|
||||
X86ScalarSSEf32 = Subtarget->hasSSE1();
|
||||
|
||||
RegInfo = TM.getRegisterInfo();
|
||||
TD = getDataLayout();
|
||||
|
||||
resetOperationActions();
|
||||
}
|
||||
|
||||
void X86TargetLowering::resetOperationActions() {
|
||||
const TargetMachine &TM = getTargetMachine();
|
||||
static bool FirstTimeThrough = true;
|
||||
|
||||
// If none of the target options have changed, then we don't need to reset the
|
||||
// operation actions.
|
||||
if (!FirstTimeThrough && TO == TM.Options) return;
|
||||
|
||||
if (!FirstTimeThrough) {
|
||||
// Reinitialize the actions.
|
||||
initActions();
|
||||
FirstTimeThrough = false;
|
||||
}
|
||||
|
||||
TO = TM.Options;
|
||||
|
||||
// Set up the TargetLowering object.
|
||||
static const MVT IntVTs[] = { MVT::i8, MVT::i16, MVT::i32, MVT::i64 };
|
||||
|
||||
|
|
|
@ -723,6 +723,9 @@ namespace llvm {
|
|||
SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot,
|
||||
SelectionDAG &DAG) const;
|
||||
|
||||
/// \brief Reset the operation actions based on target options.
|
||||
virtual void resetOperationActions();
|
||||
|
||||
protected:
|
||||
std::pair<const TargetRegisterClass*, uint8_t>
|
||||
findRepresentativeClass(MVT VT) const;
|
||||
|
@ -734,6 +737,10 @@ namespace llvm {
|
|||
const X86RegisterInfo *RegInfo;
|
||||
const DataLayout *TD;
|
||||
|
||||
/// Used to store the TargetOptions so that we don't waste time resetting
|
||||
/// the operation actions unless we have to.
|
||||
TargetOptions TO;
|
||||
|
||||
/// X86ScalarSSEf32, X86ScalarSSEf64 - Select between SSE or x87
|
||||
/// floating point ops.
|
||||
/// When SSE is available, use it for f32 operations.
|
||||
|
|
Loading…
Reference in New Issue