mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Use the 'target-features' and 'target-cpu' attributes to reset the subtarget features.
If two functions require different features (e.g., `-mno-sse' vs. `-msse') then we want to honor that, especially during LTO. We can do that by resetting the subtarget's features depending upon the 'target-feature' attribute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4fb25b7d79
commit
789cb5df9c
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
class MachineFunction;
|
||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
class SDep;
|
class SDep;
|
||||||
class SUnit;
|
class SUnit;
|
||||||
@ -73,6 +74,9 @@ public:
|
|||||||
// the latency of a schedule dependency.
|
// the latency of a schedule dependency.
|
||||||
virtual void adjustSchedDependency(SUnit *def, SUnit *use,
|
virtual void adjustSchedDependency(SUnit *def, SUnit *use,
|
||||||
SDep& dep) const { }
|
SDep& dep) const { }
|
||||||
|
|
||||||
|
/// \brief Reset the features for the subtarget.
|
||||||
|
virtual void resetSubtargetFeatures(const MachineFunction *MF) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -354,6 +354,10 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
|
|||||||
TTI = getAnalysisIfAvailable<TargetTransformInfo>();
|
TTI = getAnalysisIfAvailable<TargetTransformInfo>();
|
||||||
GFI = Fn.hasGC() ? &getAnalysis<GCModuleInfo>().getFunctionInfo(Fn) : 0;
|
GFI = Fn.hasGC() ? &getAnalysis<GCModuleInfo>().getFunctionInfo(Fn) : 0;
|
||||||
|
|
||||||
|
TargetSubtargetInfo &ST =
|
||||||
|
const_cast<TargetSubtargetInfo&>(TM.getSubtarget<TargetSubtargetInfo>());
|
||||||
|
ST.resetSubtargetFeatures(MF);
|
||||||
|
|
||||||
DEBUG(dbgs() << "\n\n\n=== " << Fn.getName() << "\n");
|
DEBUG(dbgs() << "\n\n\n=== " << Fn.getName() << "\n");
|
||||||
|
|
||||||
SplitCriticalSideEffectEdges(const_cast<Function&>(Fn), this);
|
SplitCriticalSideEffectEdges(const_cast<Function&>(Fn), this);
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#define DEBUG_TYPE "subtarget"
|
#define DEBUG_TYPE "subtarget"
|
||||||
#include "X86Subtarget.h"
|
#include "X86Subtarget.h"
|
||||||
#include "X86InstrInfo.h"
|
#include "X86InstrInfo.h"
|
||||||
|
#include "llvm/IR/Attributes.h"
|
||||||
|
#include "llvm/IR/Function.h"
|
||||||
#include "llvm/IR/GlobalValue.h"
|
#include "llvm/IR/GlobalValue.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
@ -324,46 +326,21 @@ void X86Subtarget::AutoDetectSubtargetFeatures() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
void X86Subtarget::resetSubtargetFeatures(const MachineFunction *MF) {
|
||||||
const std::string &FS,
|
AttributeSet FnAttrs = MF->getFunction()->getAttributes();
|
||||||
unsigned StackAlignOverride, bool is64Bit)
|
Attribute CPUAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex,
|
||||||
: X86GenSubtargetInfo(TT, CPU, FS)
|
"target-cpu");
|
||||||
, X86ProcFamily(Others)
|
Attribute FSAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex,
|
||||||
, PICStyle(PICStyles::None)
|
"target-features");
|
||||||
, X86SSELevel(NoMMXSSE)
|
std::string CPU =
|
||||||
, X863DNowLevel(NoThreeDNow)
|
!CPUAttr.hasAttribute(Attribute::None) ?CPUAttr.getValueAsString() : "";
|
||||||
, HasCMov(false)
|
std::string FS =
|
||||||
, HasX86_64(false)
|
!FSAttr.hasAttribute(Attribute::None) ? FSAttr.getValueAsString() : "";
|
||||||
, HasPOPCNT(false)
|
if (!FS.empty())
|
||||||
, HasSSE4A(false)
|
resetSubtargetFeatures(CPU, FS);
|
||||||
, HasAES(false)
|
}
|
||||||
, HasPCLMUL(false)
|
|
||||||
, HasFMA(false)
|
void X86Subtarget::resetSubtargetFeatures(StringRef CPU, StringRef FS) {
|
||||||
, HasFMA4(false)
|
|
||||||
, HasXOP(false)
|
|
||||||
, HasMOVBE(false)
|
|
||||||
, HasRDRAND(false)
|
|
||||||
, HasF16C(false)
|
|
||||||
, HasFSGSBase(false)
|
|
||||||
, HasLZCNT(false)
|
|
||||||
, HasBMI(false)
|
|
||||||
, HasBMI2(false)
|
|
||||||
, HasRTM(false)
|
|
||||||
, HasADX(false)
|
|
||||||
, IsBTMemSlow(false)
|
|
||||||
, IsUAMemFast(false)
|
|
||||||
, HasVectorUAMem(false)
|
|
||||||
, HasCmpxchg16b(false)
|
|
||||||
, UseLeaForSP(false)
|
|
||||||
, HasSlowDivide(false)
|
|
||||||
, PostRAScheduler(false)
|
|
||||||
, PadShortFunctions(false)
|
|
||||||
, stackAlignment(4)
|
|
||||||
// FIXME: this is a known good value for Yonah. How about others?
|
|
||||||
, MaxInlineSizeThreshold(128)
|
|
||||||
, TargetTriple(TT)
|
|
||||||
, In64BitMode(is64Bit) {
|
|
||||||
// Determine default and user specified characteristics
|
|
||||||
std::string CPUName = CPU;
|
std::string CPUName = CPU;
|
||||||
if (!FS.empty() || !CPU.empty()) {
|
if (!FS.empty() || !CPU.empty()) {
|
||||||
if (CPUName.empty()) {
|
if (CPUName.empty()) {
|
||||||
@ -440,6 +417,49 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
|||||||
stackAlignment = 16;
|
stackAlignment = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
||||||
|
const std::string &FS,
|
||||||
|
unsigned StackAlignOverride, bool is64Bit)
|
||||||
|
: X86GenSubtargetInfo(TT, CPU, FS)
|
||||||
|
, X86ProcFamily(Others)
|
||||||
|
, PICStyle(PICStyles::None)
|
||||||
|
, X86SSELevel(NoMMXSSE)
|
||||||
|
, X863DNowLevel(NoThreeDNow)
|
||||||
|
, HasCMov(false)
|
||||||
|
, HasX86_64(false)
|
||||||
|
, HasPOPCNT(false)
|
||||||
|
, HasSSE4A(false)
|
||||||
|
, HasAES(false)
|
||||||
|
, HasPCLMUL(false)
|
||||||
|
, HasFMA(false)
|
||||||
|
, HasFMA4(false)
|
||||||
|
, HasXOP(false)
|
||||||
|
, HasMOVBE(false)
|
||||||
|
, HasRDRAND(false)
|
||||||
|
, HasF16C(false)
|
||||||
|
, HasFSGSBase(false)
|
||||||
|
, HasLZCNT(false)
|
||||||
|
, HasBMI(false)
|
||||||
|
, HasBMI2(false)
|
||||||
|
, HasRTM(false)
|
||||||
|
, HasADX(false)
|
||||||
|
, IsBTMemSlow(false)
|
||||||
|
, IsUAMemFast(false)
|
||||||
|
, HasVectorUAMem(false)
|
||||||
|
, HasCmpxchg16b(false)
|
||||||
|
, UseLeaForSP(false)
|
||||||
|
, HasSlowDivide(false)
|
||||||
|
, PostRAScheduler(false)
|
||||||
|
, PadShortFunctions(false)
|
||||||
|
, stackAlignment(4)
|
||||||
|
// FIXME: this is a known good value for Yonah. How about others?
|
||||||
|
, MaxInlineSizeThreshold(128)
|
||||||
|
, TargetTriple(TT)
|
||||||
|
, StackAlignOverride(StackAlignOverride)
|
||||||
|
, In64BitMode(is64Bit) {
|
||||||
|
resetSubtargetFeatures(CPU, FS);
|
||||||
|
}
|
||||||
|
|
||||||
bool X86Subtarget::enablePostRAScheduler(
|
bool X86Subtarget::enablePostRAScheduler(
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
TargetSubtargetInfo::AntiDepBreakMode& Mode,
|
TargetSubtargetInfo::AntiDepBreakMode& Mode,
|
||||||
|
@ -168,11 +168,13 @@ protected:
|
|||||||
InstrItineraryData InstrItins;
|
InstrItineraryData InstrItins;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// StackAlignOverride - Override the stack alignment.
|
||||||
|
unsigned StackAlignOverride;
|
||||||
|
|
||||||
/// In64BitMode - True if compiling for 64-bit, false for 32-bit.
|
/// In64BitMode - True if compiling for 64-bit, false for 32-bit.
|
||||||
bool In64BitMode;
|
bool In64BitMode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// This constructor initializes the data members to match that
|
/// This constructor initializes the data members to match that
|
||||||
/// of the specified triple.
|
/// of the specified triple.
|
||||||
///
|
///
|
||||||
@ -197,6 +199,10 @@ public:
|
|||||||
/// instruction.
|
/// instruction.
|
||||||
void AutoDetectSubtargetFeatures();
|
void AutoDetectSubtargetFeatures();
|
||||||
|
|
||||||
|
/// \brief Reset the features for the X86 target.
|
||||||
|
virtual void resetSubtargetFeatures(const MachineFunction *MF);
|
||||||
|
void resetSubtargetFeatures(StringRef CPU, StringRef FS);
|
||||||
|
|
||||||
/// Is this x86_64? (disregarding specific ABI / programming model)
|
/// Is this x86_64? (disregarding specific ABI / programming model)
|
||||||
bool is64Bit() const {
|
bool is64Bit() const {
|
||||||
return In64BitMode;
|
return In64BitMode;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user