1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[GC] Remove a bunch of unused complexity from Registry and RegistryParser [NFCI]

The only two Registries we have in the system are the GCStrategy and GCMetadataPrinter ones.  Registry has a bunch of problems - for instance, order of initialization is undefined - and the code was overly general for what was actually used.  I hope to completely kill Registry in the near future, but for now, just delete all the unused listener and parsing support.

llvm-svn: 257727
This commit is contained in:
Philip Reames 2016-01-14 00:45:15 +00:00
parent 4b1f1aa597
commit d8d6ceb6fa
2 changed files with 0 additions and 129 deletions

View File

@ -62,23 +62,14 @@ namespace llvm {
typedef typename U::entry entry;
class node;
class listener;
class iterator;
private:
Registry() = delete;
static void Announce(const entry &E) {
for (listener *Cur = ListenerHead; Cur; Cur = Cur->Next)
Cur->registered(E);
}
friend class node;
static node *Head, *Tail;
friend class listener;
static listener *ListenerHead, *ListenerTail;
public:
/// Node in linked list of entries.
///
@ -95,8 +86,6 @@ namespace llvm {
else
Head = this;
Tail = this;
Announce(V);
}
};
@ -122,60 +111,6 @@ namespace llvm {
return make_range(begin(), end());
}
/// Abstract base class for registry listeners, which are informed when new
/// entries are added to the registry. Simply subclass and instantiate:
///
/// \code
/// class CollectorPrinter : public Registry<Collector>::listener {
/// protected:
/// void registered(const Registry<Collector>::entry &e) {
/// cerr << "collector now available: " << e->getName() << "\n";
/// }
///
/// public:
/// CollectorPrinter() { init(); } // Print those already registered.
/// };
///
/// CollectorPrinter Printer;
/// \endcode
class listener {
listener *Prev, *Next;
friend void Registry::Announce(const entry &E);
protected:
/// Called when an entry is added to the registry.
///
virtual void registered(const entry &) = 0;
/// Calls 'registered' for each pre-existing entry.
///
void init() {
for (iterator I = begin(), E = end(); I != E; ++I)
registered(*I);
}
public:
listener() : Prev(ListenerTail), Next(nullptr) {
if (Prev)
Prev->Next = this;
else
ListenerHead = this;
ListenerTail = this;
}
virtual ~listener() {
if (Next)
Next->Prev = Prev;
else
ListenerTail = Prev;
if (Prev)
Prev->Next = Next;
else
ListenerHead = Next;
}
};
/// A static registration template. Use like such:
///
/// Registry<Collector>::Add<FancyGC>
@ -203,8 +138,6 @@ namespace llvm {
Add(const char *Name, const char *Desc)
: Entry(Name, Desc, CtorFn), Node(Entry) {}
};
/// Registry::Parser now lives in llvm/Support/RegistryParser.h.
};
// Since these are defined in a header file, plugins must be sure to export
@ -215,13 +148,6 @@ namespace llvm {
template <typename T, typename U>
typename Registry<T,U>::node *Registry<T,U>::Tail;
template <typename T, typename U>
typename Registry<T,U>::listener *Registry<T,U>::ListenerHead;
template <typename T, typename U>
typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
} // end namespace llvm
#endif // LLVM_SUPPORT_REGISTRY_H

View File

@ -1,55 +0,0 @@
//=== RegistryParser.h - Linker-supported plugin registries -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Defines a command-line parser for a registry.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_REGISTRYPARSER_H
#define LLVM_SUPPORT_REGISTRYPARSER_H
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Registry.h"
namespace llvm {
/// A command-line parser for a registry. Use like such:
///
/// static cl::opt<Registry<Collector>::entry, false,
/// RegistryParser<Collector> >
/// GCOpt("gc", cl::desc("Garbage collector to use."),
/// cl::value_desc());
///
/// To make use of the value:
///
/// Collector *TheCollector = GCOpt->instantiate();
///
template <typename T, typename U = RegistryTraits<T> >
class RegistryParser :
public cl::parser<const typename U::entry*>,
public Registry<T, U>::listener {
typedef U traits;
typedef typename U::entry entry;
typedef typename Registry<T, U>::listener listener;
protected:
void registered(const entry &E) {
addLiteralOption(traits::nameof(E), &E, traits::descof(E));
}
public:
void initialize(cl::Option &O) {
listener::init();
cl::parser<const typename U::entry*>::initialize(O);
}
};
}
#endif // LLVM_SUPPORT_REGISTRYPARSER_H