mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Clients are responsible for initializing the targets, remove it from the disassembler API.
This will break users of the LLVMCreateDisasm API (not that I know of any). They have to call the LLVMInitializeAll* functions from llvm-c/Target.h themselves now. edis' C API in all its horribleness should be unaffected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eea66f63d9
commit
178051fbae
@ -18,7 +18,6 @@
|
|||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/Support/MemoryObject.h"
|
#include "llvm/Support/MemoryObject.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/TargetSelect.h"
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Target;
|
class Target;
|
||||||
@ -35,12 +34,6 @@ using namespace llvm;
|
|||||||
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||||
int TagType, LLVMOpInfoCallback GetOpInfo,
|
int TagType, LLVMOpInfoCallback GetOpInfo,
|
||||||
LLVMSymbolLookupCallback SymbolLookUp) {
|
LLVMSymbolLookupCallback SymbolLookUp) {
|
||||||
// Initialize targets and assembly printers/parsers.
|
|
||||||
llvm::InitializeAllTargetInfos();
|
|
||||||
llvm::InitializeAllTargetMCs();
|
|
||||||
llvm::InitializeAllAsmParsers();
|
|
||||||
llvm::InitializeAllDisassemblers();
|
|
||||||
|
|
||||||
// Get the target.
|
// Get the target.
|
||||||
std::string Error;
|
std::string Error;
|
||||||
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
|
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
|
||||||
|
@ -34,10 +34,8 @@
|
|||||||
#include "llvm/Support/MemoryObject.h"
|
#include "llvm/Support/MemoryObject.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/TargetSelect.h"
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
bool EDDisassembler::sInitialized = false;
|
|
||||||
EDDisassembler::DisassemblerMap_t EDDisassembler::sDisassemblers;
|
EDDisassembler::DisassemblerMap_t EDDisassembler::sDisassemblers;
|
||||||
|
|
||||||
struct TripleMap {
|
struct TripleMap {
|
||||||
@ -98,20 +96,6 @@ static int getLLVMSyntaxVariant(Triple::ArchType arch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDDisassembler::initialize() {
|
|
||||||
if (sInitialized)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sInitialized = true;
|
|
||||||
|
|
||||||
InitializeAllTargetInfos();
|
|
||||||
InitializeAllTargetMCs();
|
|
||||||
InitializeAllAsmParsers();
|
|
||||||
InitializeAllDisassemblers();
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef BRINGUP_TARGET
|
|
||||||
|
|
||||||
EDDisassembler *EDDisassembler::getDisassembler(Triple::ArchType arch,
|
EDDisassembler *EDDisassembler::getDisassembler(Triple::ArchType arch,
|
||||||
AssemblySyntax syntax) {
|
AssemblySyntax syntax) {
|
||||||
CPUKey key;
|
CPUKey key;
|
||||||
|
@ -94,8 +94,6 @@ struct EDDisassembler {
|
|||||||
|
|
||||||
typedef std::map<CPUKey, EDDisassembler*> DisassemblerMap_t;
|
typedef std::map<CPUKey, EDDisassembler*> DisassemblerMap_t;
|
||||||
|
|
||||||
/// True if the disassembler registry has been initialized; false if not
|
|
||||||
static bool sInitialized;
|
|
||||||
/// A map from disassembler specifications to disassemblers. Populated
|
/// A map from disassembler specifications to disassemblers. Populated
|
||||||
/// lazily.
|
/// lazily.
|
||||||
static DisassemblerMap_t sDisassemblers;
|
static DisassemblerMap_t sDisassemblers;
|
||||||
@ -116,9 +114,6 @@ struct EDDisassembler {
|
|||||||
static EDDisassembler *getDisassembler(llvm::StringRef str,
|
static EDDisassembler *getDisassembler(llvm::StringRef str,
|
||||||
AssemblySyntax syntax);
|
AssemblySyntax syntax);
|
||||||
|
|
||||||
/// initialize - Initializes the disassembler registry and the LLVM backend
|
|
||||||
static void initialize();
|
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Per-object members //
|
// Per-object members //
|
||||||
////////////////////////
|
////////////////////////
|
||||||
|
@ -19,7 +19,4 @@
|
|||||||
type = Library
|
type = Library
|
||||||
name = MCDisassembler
|
name = MCDisassembler
|
||||||
parent = MC
|
parent = MC
|
||||||
; FIXME: This is really horrible, MCDisassembler should not in and of its own
|
required_libraries = MC MCParser Support
|
||||||
; accord depending on every target.
|
|
||||||
required_libraries = all-targets MC MCParser Support
|
|
||||||
|
|
||||||
|
@ -17,13 +17,22 @@
|
|||||||
#include "../../lib/MC/MCDisassembler/EDInst.h"
|
#include "../../lib/MC/MCDisassembler/EDInst.h"
|
||||||
#include "../../lib/MC/MCDisassembler/EDOperand.h"
|
#include "../../lib/MC/MCDisassembler/EDOperand.h"
|
||||||
#include "../../lib/MC/MCDisassembler/EDToken.h"
|
#include "../../lib/MC/MCDisassembler/EDToken.h"
|
||||||
|
#include "llvm/Support/TargetSelect.h"
|
||||||
#include "llvm-c/EnhancedDisassembly.h"
|
#include "llvm-c/EnhancedDisassembly.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
int EDGetDisassembler(EDDisassemblerRef *disassembler,
|
int EDGetDisassembler(EDDisassemblerRef *disassembler,
|
||||||
const char *triple,
|
const char *triple,
|
||||||
EDAssemblySyntax_t syntax) {
|
EDAssemblySyntax_t syntax) {
|
||||||
EDDisassembler::initialize();
|
static bool initialized;
|
||||||
|
if (!initialized) {
|
||||||
|
// Initialize targets and assembly printers/parsers.
|
||||||
|
llvm::InitializeAllTargetInfos();
|
||||||
|
llvm::InitializeAllTargetMCs();
|
||||||
|
llvm::InitializeAllAsmParsers();
|
||||||
|
llvm::InitializeAllDisassemblers();
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
EDDisassembler::AssemblySyntax Syntax;
|
EDDisassembler::AssemblySyntax Syntax;
|
||||||
switch (syntax) {
|
switch (syntax) {
|
||||||
|
@ -249,7 +249,6 @@ int Disassembler::disassembleEnhanced(const std::string &TS,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
EDDisassembler::initialize();
|
|
||||||
OwningPtr<EDDisassembler>
|
OwningPtr<EDDisassembler>
|
||||||
disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS));
|
disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user