[llvm-commits] [llvm] r144385 - in /llvm/trunk: lib/MC/MCDisassembler/Disassembler.cpp lib/MC/MCDisassembler/EDDisassembler.cpp lib/MC/MCDisassembler/EDDisassembler.h lib/MC/MCDisassembler/LLVMBuild.txt tools/edis/EDMain.cpp tools/llvm-mc/Disassembler.cpp
Benjamin Kramer
benny.kra at googlemail.com
Fri Nov 11 05:20:41 PST 2011
Author: d0k
Date: Fri Nov 11 07:20:40 2011
New Revision: 144385
URL: http://llvm.org/viewvc/llvm-project?rev=144385&view=rev
Log:
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.
Modified:
llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp
llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.h
llvm/trunk/lib/MC/MCDisassembler/LLVMBuild.txt
llvm/trunk/tools/edis/EDMain.cpp
llvm/trunk/tools/llvm-mc/Disassembler.cpp
Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=144385&r1=144384&r2=144385&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Fri Nov 11 07:20:40 2011
@@ -18,7 +18,6 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
-#include "llvm/Support/TargetSelect.h"
namespace llvm {
class Target;
@@ -35,12 +34,6 @@
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
int TagType, LLVMOpInfoCallback GetOpInfo,
LLVMSymbolLookupCallback SymbolLookUp) {
- // Initialize targets and assembly printers/parsers.
- llvm::InitializeAllTargetInfos();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllAsmParsers();
- llvm::InitializeAllDisassemblers();
-
// Get the target.
std::string Error;
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
Modified: llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp?rev=144385&r1=144384&r2=144385&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp Fri Nov 11 07:20:40 2011
@@ -34,10 +34,8 @@
#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
-#include "llvm/Support/TargetSelect.h"
using namespace llvm;
-bool EDDisassembler::sInitialized = false;
EDDisassembler::DisassemblerMap_t EDDisassembler::sDisassemblers;
struct TripleMap {
@@ -98,20 +96,6 @@
}
}
-void EDDisassembler::initialize() {
- if (sInitialized)
- return;
-
- sInitialized = true;
-
- InitializeAllTargetInfos();
- InitializeAllTargetMCs();
- InitializeAllAsmParsers();
- InitializeAllDisassemblers();
-}
-
-#undef BRINGUP_TARGET
-
EDDisassembler *EDDisassembler::getDisassembler(Triple::ArchType arch,
AssemblySyntax syntax) {
CPUKey key;
Modified: llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.h?rev=144385&r1=144384&r2=144385&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.h (original)
+++ llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.h Fri Nov 11 07:20:40 2011
@@ -94,8 +94,6 @@
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
/// lazily.
static DisassemblerMap_t sDisassemblers;
@@ -116,9 +114,6 @@
static EDDisassembler *getDisassembler(llvm::StringRef str,
AssemblySyntax syntax);
- /// initialize - Initializes the disassembler registry and the LLVM backend
- static void initialize();
-
////////////////////////
// Per-object members //
////////////////////////
Modified: llvm/trunk/lib/MC/MCDisassembler/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/LLVMBuild.txt?rev=144385&r1=144384&r2=144385&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/LLVMBuild.txt (original)
+++ llvm/trunk/lib/MC/MCDisassembler/LLVMBuild.txt Fri Nov 11 07:20:40 2011
@@ -19,7 +19,4 @@
type = Library
name = MCDisassembler
parent = MC
-; FIXME: This is really horrible, MCDisassembler should not in and of its own
-; accord depending on every target.
-required_libraries = all-targets MC MCParser Support
-
+required_libraries = MC MCParser Support
Modified: llvm/trunk/tools/edis/EDMain.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/edis/EDMain.cpp?rev=144385&r1=144384&r2=144385&view=diff
==============================================================================
--- llvm/trunk/tools/edis/EDMain.cpp (original)
+++ llvm/trunk/tools/edis/EDMain.cpp Fri Nov 11 07:20:40 2011
@@ -17,14 +17,23 @@
#include "../../lib/MC/MCDisassembler/EDInst.h"
#include "../../lib/MC/MCDisassembler/EDOperand.h"
#include "../../lib/MC/MCDisassembler/EDToken.h"
+#include "llvm/Support/TargetSelect.h"
#include "llvm-c/EnhancedDisassembly.h"
using namespace llvm;
int EDGetDisassembler(EDDisassemblerRef *disassembler,
const char *triple,
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;
switch (syntax) {
default: assert(0 && "Unknown assembly syntax!");
Modified: llvm/trunk/tools/llvm-mc/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Disassembler.cpp?rev=144385&r1=144384&r2=144385&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/Disassembler.cpp (original)
+++ llvm/trunk/tools/llvm-mc/Disassembler.cpp Fri Nov 11 07:20:40 2011
@@ -249,7 +249,6 @@
break;
}
- EDDisassembler::initialize();
OwningPtr<EDDisassembler>
disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS));
More information about the llvm-commits
mailing list