mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 23:29:51 +00:00
Fix last bits of MC layer issues. llvm-mc doesn't need to initialize TargetMachine's anymore.
llvm-svn: 135963
This commit is contained in:
parent
17bad936f7
commit
1d04cd9b26
@ -89,6 +89,7 @@ namespace llvm {
|
||||
typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T,
|
||||
const std::string &TT);
|
||||
typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T,
|
||||
const MCRegisterInfo &MRI,
|
||||
const MCAsmInfo &MAI);
|
||||
typedef TargetAsmParser *(*AsmParserCtorTy)(MCSubtargetInfo &STI,
|
||||
MCAsmParser &P);
|
||||
@ -333,10 +334,11 @@ namespace llvm {
|
||||
|
||||
/// createAsmLexer - Create a target specific assembly lexer.
|
||||
///
|
||||
TargetAsmLexer *createAsmLexer(const MCAsmInfo &MAI) const {
|
||||
TargetAsmLexer *createAsmLexer(const MCRegisterInfo &MRI,
|
||||
const MCAsmInfo &MAI) const {
|
||||
if (!AsmLexerCtorFn)
|
||||
return 0;
|
||||
return AsmLexerCtorFn(*this, MAI);
|
||||
return AsmLexerCtorFn(*this, MRI, MAI);
|
||||
}
|
||||
|
||||
/// createAsmParser - Create a target specific assembly parser.
|
||||
@ -989,8 +991,9 @@ namespace llvm {
|
||||
}
|
||||
|
||||
private:
|
||||
static TargetAsmLexer *Allocator(const Target &T, const MCAsmInfo &MAI) {
|
||||
return new AsmLexerImpl(T, MAI);
|
||||
static TargetAsmLexer *Allocator(const Target &T, const MCRegisterInfo &MRI,
|
||||
const MCAsmInfo &MAI) {
|
||||
return new AsmLexerImpl(T, MRI, MAI);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "llvm/Support/MemoryObject.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include "llvm/Target/TargetSelect.h"
|
||||
using namespace llvm;
|
||||
|
||||
@ -107,7 +105,6 @@ void EDDisassembler::initialize() {
|
||||
sInitialized = true;
|
||||
|
||||
InitializeAllTargetInfos();
|
||||
InitializeAllTargets();
|
||||
InitializeAllTargetMCs();
|
||||
InitializeAllAsmPrinters();
|
||||
InitializeAllAsmParsers();
|
||||
@ -170,29 +167,18 @@ EDDisassembler::EDDisassembler(CPUKey &key) :
|
||||
if (!Tgt)
|
||||
return;
|
||||
|
||||
std::string CPU;
|
||||
std::string featureString;
|
||||
TargetMachine.reset(Tgt->createTargetMachine(tripleString, CPU,
|
||||
featureString));
|
||||
MRI.reset(Tgt->createMCRegInfo(tripleString));
|
||||
|
||||
// FIXME: It shouldn't be using TargetRegisterInfo!
|
||||
const TargetRegisterInfo *registerInfo = TargetMachine->getRegisterInfo();
|
||||
|
||||
if (!registerInfo)
|
||||
if (!MRI)
|
||||
return;
|
||||
|
||||
initMaps(*registerInfo);
|
||||
|
||||
initMaps(*MRI);
|
||||
|
||||
AsmInfo.reset(Tgt->createMCAsmInfo(tripleString));
|
||||
|
||||
if (!AsmInfo)
|
||||
return;
|
||||
|
||||
MRI.reset(Tgt->createMCRegInfo(tripleString));
|
||||
|
||||
if (!MRI)
|
||||
return;
|
||||
|
||||
Disassembler.reset(Tgt->createMCDisassembler());
|
||||
|
||||
if (!Disassembler)
|
||||
@ -208,10 +194,10 @@ EDDisassembler::EDDisassembler(CPUKey &key) :
|
||||
return;
|
||||
|
||||
GenericAsmLexer.reset(new AsmLexer(*AsmInfo));
|
||||
SpecificAsmLexer.reset(Tgt->createAsmLexer(*AsmInfo));
|
||||
SpecificAsmLexer.reset(Tgt->createAsmLexer(*MRI, *AsmInfo));
|
||||
SpecificAsmLexer->InstallLexer(*GenericAsmLexer);
|
||||
|
||||
initMaps(*TargetMachine->getRegisterInfo());
|
||||
initMaps(*MRI);
|
||||
|
||||
Valid = true;
|
||||
}
|
||||
@ -273,7 +259,7 @@ EDInst *EDDisassembler::createInst(EDByteReaderCallback byteReader,
|
||||
}
|
||||
}
|
||||
|
||||
void EDDisassembler::initMaps(const TargetRegisterInfo ®isterInfo) {
|
||||
void EDDisassembler::initMaps(const MCRegisterInfo ®isterInfo) {
|
||||
unsigned numRegisters = registerInfo.getNumRegs();
|
||||
unsigned registerIndex;
|
||||
|
||||
|
@ -46,8 +46,6 @@ class SourceMgr;
|
||||
class Target;
|
||||
class TargetAsmLexer;
|
||||
class TargetAsmParser;
|
||||
class TargetMachine;
|
||||
class TargetRegisterInfo;
|
||||
|
||||
struct EDInstInfo;
|
||||
struct EDInst;
|
||||
@ -137,8 +135,6 @@ struct EDDisassembler {
|
||||
CPUKey Key;
|
||||
/// The LLVM target corresponding to the disassembler
|
||||
const llvm::Target *Tgt;
|
||||
/// The target machine instance.
|
||||
llvm::OwningPtr<llvm::TargetMachine> TargetMachine;
|
||||
/// The assembly information for the target architecture
|
||||
llvm::OwningPtr<const llvm::MCAsmInfo> AsmInfo;
|
||||
// The register information for the target architecture.
|
||||
@ -219,7 +215,7 @@ struct EDDisassembler {
|
||||
/// info
|
||||
///
|
||||
/// @arg registerInfo - the register information to use as a source
|
||||
void initMaps(const llvm::TargetRegisterInfo ®isterInfo);
|
||||
void initMaps(const llvm::MCRegisterInfo ®isterInfo);
|
||||
/// nameWithRegisterID - Returns the name (owned by the EDDisassembler) of a
|
||||
/// register for a given register ID, or NULL on failure
|
||||
///
|
||||
|
@ -8,14 +8,13 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "ARM.h"
|
||||
#include "ARMTargetMachine.h"
|
||||
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/TargetAsmLexer.h"
|
||||
|
||||
#include "llvm/Target/TargetMachine.h" // FIXME
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
@ -43,7 +42,7 @@ protected:
|
||||
|
||||
rmap_ty RegisterMap;
|
||||
|
||||
void InitRegisterMap(const TargetRegisterInfo *info) {
|
||||
void InitRegisterMap(const MCRegisterInfo *info) {
|
||||
unsigned numRegs = info->getNumRegs();
|
||||
|
||||
for (unsigned i = 0; i < numRegs; ++i) {
|
||||
@ -83,27 +82,17 @@ public:
|
||||
|
||||
class ARMAsmLexer : public ARMBaseAsmLexer {
|
||||
public:
|
||||
ARMAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
ARMAsmLexer(const Target &T, const MCRegisterInfo &MRI, const MCAsmInfo &MAI)
|
||||
: ARMBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("arm-unknown-unknown");
|
||||
std::string featureString;
|
||||
std::string CPU;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, CPU, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
InitRegisterMap(&MRI);
|
||||
}
|
||||
};
|
||||
|
||||
class ThumbAsmLexer : public ARMBaseAsmLexer {
|
||||
public:
|
||||
ThumbAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
ThumbAsmLexer(const Target &T, const MCRegisterInfo &MRI,const MCAsmInfo &MAI)
|
||||
: ARMBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("thumb-unknown-unknown");
|
||||
std::string featureString;
|
||||
std::string CPU;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, CPU, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
InitRegisterMap(&MRI);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MBlaze.h"
|
||||
#include "MBlazeTargetMachine.h"
|
||||
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
@ -17,9 +16,9 @@
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/TargetAsmLexer.h"
|
||||
|
||||
#include "llvm/Target/TargetMachine.h" // FIXME
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
|
||||
#include <string>
|
||||
@ -42,7 +41,7 @@ namespace {
|
||||
|
||||
rmap_ty RegisterMap;
|
||||
|
||||
void InitRegisterMap(const TargetRegisterInfo *info) {
|
||||
void InitRegisterMap(const MCRegisterInfo *info) {
|
||||
unsigned numRegs = info->getNumRegs();
|
||||
|
||||
for (unsigned i = 0; i < numRegs; ++i) {
|
||||
@ -82,14 +81,10 @@ namespace {
|
||||
|
||||
class MBlazeAsmLexer : public MBlazeBaseAsmLexer {
|
||||
public:
|
||||
MBlazeAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
MBlazeAsmLexer(const Target &T, const MCRegisterInfo &MRI,
|
||||
const MCAsmInfo &MAI)
|
||||
: MBlazeBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("mblaze-unknown-unknown");
|
||||
std::string featureString;
|
||||
std::string CPU;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, CPU, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
InitRegisterMap(&MRI);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ protected:
|
||||
}
|
||||
}
|
||||
public:
|
||||
X86AsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
X86AsmLexer(const Target &T, const MCRegisterInfo &MRI, const MCAsmInfo &MAI)
|
||||
: TargetAsmLexer(T), AsmInfo(MAI), tentativeIsValid(false) {
|
||||
}
|
||||
};
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "llvm/MC/SubtargetFeature.h"
|
||||
#include "llvm/MC/TargetAsmBackend.h"
|
||||
#include "llvm/MC/TargetAsmParser.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetSelect.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
@ -452,8 +451,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Initialize targets and assembly printers/parsers.
|
||||
llvm::InitializeAllTargetInfos();
|
||||
// FIXME: We shouldn't need to initialize the Target(Machine)s.
|
||||
llvm::InitializeAllTargets();
|
||||
llvm::InitializeAllTargetMCs();
|
||||
llvm::InitializeAllAsmPrinters();
|
||||
llvm::InitializeAllAsmParsers();
|
||||
|
@ -308,8 +308,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Initialize targets and assembly printers/parsers.
|
||||
llvm::InitializeAllTargetInfos();
|
||||
// FIXME: We shouldn't need to initialize the Target(Machine)s.
|
||||
llvm::InitializeAllTargets();
|
||||
llvm::InitializeAllTargetMCs();
|
||||
llvm::InitializeAllAsmPrinters();
|
||||
llvm::InitializeAllAsmParsers();
|
||||
|
Loading…
Reference in New Issue
Block a user