forked from OSchip/llvm-project
[X86] Use X86_MC::ParseX86Triple to add mode features to feature string in X86Subtarget::initSubtargetFeatures.
Remove mode flags from constructor and remove calls to ToggleFeature for the mode bits. By adding them to the feature string we handle initializing the mode member variables in X86Subtarget and the feature bits in MCSubtargetInfo in one shot.
This commit is contained in:
parent
db37937a47
commit
8158f0cefe
|
@ -231,15 +231,16 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
|
|||
if (CPU.empty())
|
||||
CPU = "generic";
|
||||
|
||||
std::string FullFS = std::string(FS);
|
||||
if (In64BitMode) {
|
||||
// SSE2 should default to enabled in 64-bit mode, but can be turned off
|
||||
// explicitly.
|
||||
if (!FullFS.empty())
|
||||
FullFS = "+sse2," + FullFS;
|
||||
else
|
||||
FullFS = "+sse2";
|
||||
}
|
||||
std::string FullFS = X86_MC::ParseX86Triple(TargetTriple);
|
||||
assert(!FullFS.empty() && "Failed to parse X86 triple");
|
||||
|
||||
// SSE2 should default to enabled in 64-bit mode, but can be turned off
|
||||
// explicitly.
|
||||
if (TargetTriple.isArch64Bit())
|
||||
FullFS += ",+sse2";
|
||||
|
||||
if (!FS.empty())
|
||||
FullFS = (Twine(FullFS) + "," + FS).str();
|
||||
|
||||
// Parse features string and set the CPU.
|
||||
ParseSubtargetFeatures(CPU, FullFS);
|
||||
|
@ -251,17 +252,6 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
|
|||
if (hasSSE42() || hasSSE4A())
|
||||
IsUAMem16Slow = false;
|
||||
|
||||
// It's important to keep the MCSubtargetInfo feature bits in sync with
|
||||
// target data structure which is shared with MC code emitter, etc.
|
||||
if (In64BitMode)
|
||||
ToggleFeature(X86::Mode64Bit);
|
||||
else if (In32BitMode)
|
||||
ToggleFeature(X86::Mode32Bit);
|
||||
else if (In16BitMode)
|
||||
ToggleFeature(X86::Mode16Bit);
|
||||
else
|
||||
llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!");
|
||||
|
||||
LLVM_DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
|
||||
<< ", 3DNowLevel " << X863DNowLevel << ", 64bit "
|
||||
<< HasX86_64 << "\n");
|
||||
|
@ -312,11 +302,6 @@ X86Subtarget::X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
|
|||
TM(TM), TargetTriple(TT), StackAlignOverride(StackAlignOverride),
|
||||
PreferVectorWidthOverride(PreferVectorWidthOverride),
|
||||
RequiredVectorWidth(RequiredVectorWidth),
|
||||
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
|
||||
In32BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||
TargetTriple.getEnvironment() != Triple::CODE16),
|
||||
In16BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||
TargetTriple.getEnvironment() == Triple::CODE16),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
|
||||
FrameLowering(*this, getStackAlignment()) {
|
||||
// Determine the PICStyle based on the target selected.
|
||||
|
|
|
@ -498,13 +498,13 @@ private:
|
|||
unsigned RequiredVectorWidth;
|
||||
|
||||
/// True if compiling for 64-bit, false for 16-bit or 32-bit.
|
||||
bool In64BitMode;
|
||||
bool In64BitMode = false;
|
||||
|
||||
/// True if compiling for 32-bit, false for 16-bit or 64-bit.
|
||||
bool In32BitMode;
|
||||
bool In32BitMode = false;
|
||||
|
||||
/// True if compiling for 16-bit, false for 32-bit or 64-bit.
|
||||
bool In16BitMode;
|
||||
bool In16BitMode = false;
|
||||
|
||||
/// Contains the Overhead of gather\scatter instructions
|
||||
int GatherOverhead = 1024;
|
||||
|
|
Loading…
Reference in New Issue