Revert 75762, 75763, 75766..75769, 75772..75775, 75778, 75780, 75782 to repair broken LLVM-GCC build.
Will revert 75770 in the llvm-gcc trunk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75799 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
index b8a25a6..9721fdc 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
@@ -37,7 +37,7 @@
MCContext *Context;
MCStreamer *Streamer;
public:
- explicit X86ATTAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
+ explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {
Subtarget = &TM.getSubtarget<X86Subtarget>();
diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
index 3fad77e..40b24f3 100644
--- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
@@ -17,7 +17,6 @@
#include "X86ATTAsmPrinter.h"
#include "X86IntelAsmPrinter.h"
#include "X86Subtarget.h"
-#include "llvm/Target/TargetRegistry.h"
using namespace llvm;
/// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
@@ -25,7 +24,7 @@
/// machine description.
///
FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
- TargetMachine &tm,
+ X86TargetMachine &tm,
bool verbose) {
const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
@@ -46,10 +45,4 @@
int X86AsmPrinterForceLink = 0;
// Force static initialization.
-extern "C" void LLVMInitializeX86AsmPrinter() {
- extern Target TheX86_32Target;
- TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass);
-
- extern Target TheX86_64Target;
- TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass);
-}
+extern "C" void LLVMInitializeX86AsmPrinter() { }
diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h
index 603de3e..8872869 100644
--- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h
+++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h
@@ -25,7 +25,7 @@
namespace llvm {
struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
- explicit X86IntelAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
+ explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {}
diff --git a/lib/Target/X86/X86.h b/lib/Target/X86/X86.h
index 457e18a..ead4ce1 100644
--- a/lib/Target/X86/X86.h
+++ b/lib/Target/X86/X86.h
@@ -47,7 +47,7 @@
/// using the given target machine description.
///
FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
- TargetMachine &tm,
+ X86TargetMachine &tm,
bool Verbose);
/// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index c640847..40dc18d 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -31,18 +31,13 @@
int X86TargetMachineModule = 0;
// Register the target.
-extern Target TheX86_32Target;
static RegisterTarget<X86_32TargetMachine>
-X(TheX86_32Target, "x86", "32-bit X86: Pentium-Pro and above");
-
-extern Target TheX86_64Target;
+X("x86", "32-bit X86: Pentium-Pro and above");
static RegisterTarget<X86_64TargetMachine>
-Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64");
+Y("x86-64", "64-bit X86: EM64T and AMD64");
// Force static initialization.
-extern "C" void LLVMInitializeX86Target() {
-
-}
+extern "C" void LLVMInitializeX86Target() { }
// No assembler printer by default
X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0;
@@ -66,23 +61,78 @@
}
}
-X86_32TargetMachine::X86_32TargetMachine(const Target &T, const Module &M,
- const std::string &FS)
- : X86TargetMachine(T, M, FS, false) {
+unsigned X86_32TargetMachine::getJITMatchQuality() {
+#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
+ return 10;
+#endif
+ return 0;
+}
+
+unsigned X86_64TargetMachine::getJITMatchQuality() {
+#if defined(__x86_64__) || defined(_M_AMD64)
+ return 10;
+#endif
+ return 0;
+}
+
+unsigned X86_32TargetMachine::getModuleMatchQuality(const Module &M) {
+ // We strongly match "i[3-9]86-*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' &&
+ TT[4] == '-' && TT[1] - '3' < 6)
+ return 20;
+ // If the target triple is something non-X86, we don't match.
+ if (!TT.empty()) return 0;
+
+ if (M.getEndianness() == Module::LittleEndian &&
+ M.getPointerSize() == Module::Pointer32)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+ M.getPointerSize() != Module::AnyPointerSize)
+ return 0; // Match for some other target
+
+ return getJITMatchQuality()/2;
+}
+
+unsigned X86_64TargetMachine::getModuleMatchQuality(const Module &M) {
+ // We strongly match "x86_64-*".
+ std::string TT = M.getTargetTriple();
+ if (TT.size() >= 7 && TT[0] == 'x' && TT[1] == '8' && TT[2] == '6' &&
+ TT[3] == '_' && TT[4] == '6' && TT[5] == '4' && TT[6] == '-')
+ return 20;
+
+ // We strongly match "amd64-*".
+ if (TT.size() >= 6 && TT[0] == 'a' && TT[1] == 'm' && TT[2] == 'd' &&
+ TT[3] == '6' && TT[4] == '4' && TT[5] == '-')
+ return 20;
+
+ // If the target triple is something non-X86-64, we don't match.
+ if (!TT.empty()) return 0;
+
+ if (M.getEndianness() == Module::LittleEndian &&
+ M.getPointerSize() == Module::Pointer64)
+ return 10; // Weak match
+ else if (M.getEndianness() != Module::AnyEndianness ||
+ M.getPointerSize() != Module::AnyPointerSize)
+ return 0; // Match for some other target
+
+ return getJITMatchQuality()/2;
+}
+
+X86_32TargetMachine::X86_32TargetMachine(const Module &M, const std::string &FS)
+ : X86TargetMachine(M, FS, false) {
}
-X86_64TargetMachine::X86_64TargetMachine(const Target &T, const Module &M,
- const std::string &FS)
- : X86TargetMachine(T, M, FS, true) {
+X86_64TargetMachine::X86_64TargetMachine(const Module &M, const std::string &FS)
+ : X86TargetMachine(M, FS, true) {
}
/// X86TargetMachine ctor - Create an X86 target.
///
-X86TargetMachine::X86TargetMachine(const Target &T, const Module &M,
- const std::string &FS, bool is64Bit)
- : LLVMTargetMachine(T),
- Subtarget(M, FS, is64Bit),
+X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
+ bool is64Bit)
+ : Subtarget(M, FS, is64Bit),
DataLayout(Subtarget.getDataLayout()),
FrameInfo(TargetFrameInfo::StackGrowsDown,
Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4),
diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h
index da6811b..ea7a453 100644
--- a/lib/Target/X86/X86TargetMachine.h
+++ b/lib/Target/X86/X86TargetMachine.h
@@ -44,13 +44,12 @@
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
- TargetMachine &tm,
+ X86TargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
public:
- X86TargetMachine(const Target &T, const Module &M, const std::string &FS,
- bool is64Bit);
+ X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit);
virtual const X86InstrInfo *getInstrInfo() const { return &InstrInfo; }
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
@@ -67,6 +66,9 @@
return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
}
+ static unsigned getModuleMatchQuality(const Module &M);
+ static unsigned getJITMatchQuality();
+
static void registerAsmPrinter(AsmPrinterCtorFn F) {
AsmPrinterCtor = F;
}
@@ -99,7 +101,7 @@
///
class X86_32TargetMachine : public X86TargetMachine {
public:
- X86_32TargetMachine(const Target &T, const Module &M, const std::string &FS);
+ X86_32TargetMachine(const Module &M, const std::string &FS);
static unsigned getJITMatchQuality();
static unsigned getModuleMatchQuality(const Module &M);
@@ -109,7 +111,7 @@
///
class X86_64TargetMachine : public X86TargetMachine {
public:
- X86_64TargetMachine(const Target &T, const Module &M, const std::string &FS);
+ X86_64TargetMachine(const Module &M, const std::string &FS);
static unsigned getJITMatchQuality();
static unsigned getModuleMatchQuality(const Module &M);