mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
Add registered target list to --version output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
494d663175
commit
603bea3274
@ -92,6 +92,12 @@ namespace llvm {
|
|||||||
/// JIT.
|
/// JIT.
|
||||||
unsigned getJITMatchQuality() const { return JITMatchQualityFn(); }
|
unsigned getJITMatchQuality() const { return JITMatchQualityFn(); }
|
||||||
|
|
||||||
|
/// hasTargetMachine - Check if this target supports code generation.
|
||||||
|
bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
|
||||||
|
|
||||||
|
/// hasAsmPrinter - Check if this target supports .s printing.
|
||||||
|
bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; }
|
||||||
|
|
||||||
/// createTargetMachine - Create a target specific machine implementation.
|
/// createTargetMachine - Create a target specific machine implementation.
|
||||||
TargetMachine *createTargetMachine(const Module &M,
|
TargetMachine *createTargetMachine(const Module &M,
|
||||||
const std::string &Features) const {
|
const std::string &Features) const {
|
||||||
@ -114,9 +120,50 @@ namespace llvm {
|
|||||||
//
|
//
|
||||||
// FIXME: Provide Target* iterator.
|
// FIXME: Provide Target* iterator.
|
||||||
struct TargetRegistry {
|
struct TargetRegistry {
|
||||||
|
class iterator {
|
||||||
|
const Target *Current;
|
||||||
|
explicit iterator(Target *T) : Current(T) {}
|
||||||
|
friend class TargetRegistry;
|
||||||
|
public:
|
||||||
|
iterator(const iterator &I) : Current(I.Current) {}
|
||||||
|
iterator() : Current(0) {}
|
||||||
|
|
||||||
|
bool operator==(const iterator &x) const {
|
||||||
|
return Current == x.Current;
|
||||||
|
}
|
||||||
|
bool operator!=(const iterator &x) const {
|
||||||
|
return !operator==(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterator traversal: forward iteration only
|
||||||
|
iterator &operator++() { // Preincrement
|
||||||
|
assert(Current && "Cannot increment end iterator!");
|
||||||
|
Current = Current->Next;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
iterator operator++(int) { // Postincrement
|
||||||
|
iterator tmp = *this;
|
||||||
|
++*this;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Target &operator*() const {
|
||||||
|
assert(Current && "Cannot dereference end iterator!");
|
||||||
|
return *Current;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Target *operator->() const {
|
||||||
|
return &operator*();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// @name Registry Access
|
/// @name Registry Access
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
static iterator begin();
|
||||||
|
|
||||||
|
static iterator end() { return iterator(); }
|
||||||
|
|
||||||
/// getClosestStaticTargetForTriple - Given a target triple, pick the most
|
/// getClosestStaticTargetForTriple - Given a target triple, pick the most
|
||||||
/// capable target for that triple.
|
/// capable target for that triple.
|
||||||
static const Target *getClosestStaticTargetForTriple(const std::string &TT,
|
static const Target *getClosestStaticTargetForTriple(const std::string &TT,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
#include "llvm/System/Path.h"
|
#include "llvm/System/Path.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -823,8 +824,8 @@ size_t alias::getOptionWidth() const {
|
|||||||
// Print out the option for the alias.
|
// Print out the option for the alias.
|
||||||
void alias::printOptionInfo(size_t GlobalWidth) const {
|
void alias::printOptionInfo(size_t GlobalWidth) const {
|
||||||
size_t L = std::strlen(ArgStr);
|
size_t L = std::strlen(ArgStr);
|
||||||
cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
|
cerr << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
|
||||||
<< HelpStr << "\n";
|
<< HelpStr << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1140,6 +1141,23 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
cout << ".\n";
|
cout << ".\n";
|
||||||
cout << " Built " << __DATE__ << "(" << __TIME__ << ").\n";
|
cout << " Built " << __DATE__ << "(" << __TIME__ << ").\n";
|
||||||
|
cout << "\n";
|
||||||
|
cout << " Registered Targets:\n";
|
||||||
|
|
||||||
|
size_t Width = 0;
|
||||||
|
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||||
|
ie = TargetRegistry::end(); it != ie; ++it)
|
||||||
|
Width = std::max(Width, ::strlen(it->getName()));
|
||||||
|
|
||||||
|
unsigned NumTargets = 0;
|
||||||
|
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||||
|
ie = TargetRegistry::end(); it != ie; ++it, ++NumTargets) {
|
||||||
|
cout << " " << it->getName()
|
||||||
|
<< std::string(Width - ::strlen(it->getName()), ' ') << " - "
|
||||||
|
<< it->getShortDescription() << "\n";
|
||||||
|
}
|
||||||
|
if (!NumTargets)
|
||||||
|
cout << " (none)\n";
|
||||||
}
|
}
|
||||||
void operator=(bool OptionWasSpecified) {
|
void operator=(bool OptionWasSpecified) {
|
||||||
if (OptionWasSpecified) {
|
if (OptionWasSpecified) {
|
||||||
|
@ -14,20 +14,23 @@ using namespace llvm;
|
|||||||
// Clients are responsible for avoid race conditions in registration.
|
// Clients are responsible for avoid race conditions in registration.
|
||||||
static Target *FirstTarget = 0;
|
static Target *FirstTarget = 0;
|
||||||
|
|
||||||
|
TargetRegistry::iterator TargetRegistry::begin() {
|
||||||
|
return iterator(FirstTarget);
|
||||||
|
}
|
||||||
|
|
||||||
const Target *
|
const Target *
|
||||||
TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT,
|
TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT,
|
||||||
std::string &Error) {
|
std::string &Error) {
|
||||||
Target *Best = 0, *EquallyBest = 0;
|
const Target *Best = 0, *EquallyBest = 0;
|
||||||
unsigned BestQuality = 0;
|
unsigned BestQuality = 0;
|
||||||
// FIXME: Use iterator.
|
for (iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||||
for (Target *i = FirstTarget; i; i = i->Next) {
|
if (unsigned Qual = it->TripleMatchQualityFn(TT)) {
|
||||||
if (unsigned Qual = i->TripleMatchQualityFn(TT)) {
|
|
||||||
if (!Best || Qual > BestQuality) {
|
if (!Best || Qual > BestQuality) {
|
||||||
Best = i;
|
Best = &*it;
|
||||||
EquallyBest = 0;
|
EquallyBest = 0;
|
||||||
BestQuality = Qual;
|
BestQuality = Qual;
|
||||||
} else if (Qual == BestQuality)
|
} else if (Qual == BestQuality)
|
||||||
EquallyBest = i;
|
EquallyBest = &*it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,17 +53,16 @@ TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT,
|
|||||||
const Target *
|
const Target *
|
||||||
TargetRegistry::getClosestStaticTargetForModule(const Module &M,
|
TargetRegistry::getClosestStaticTargetForModule(const Module &M,
|
||||||
std::string &Error) {
|
std::string &Error) {
|
||||||
Target *Best = 0, *EquallyBest = 0;
|
const Target *Best = 0, *EquallyBest = 0;
|
||||||
unsigned BestQuality = 0;
|
unsigned BestQuality = 0;
|
||||||
// FIXME: Use iterator.
|
for (iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||||
for (Target *i = FirstTarget; i; i = i->Next) {
|
if (unsigned Qual = it->ModuleMatchQualityFn(M)) {
|
||||||
if (unsigned Qual = i->ModuleMatchQualityFn(M)) {
|
|
||||||
if (!Best || Qual > BestQuality) {
|
if (!Best || Qual > BestQuality) {
|
||||||
Best = i;
|
Best = &*it;
|
||||||
EquallyBest = 0;
|
EquallyBest = 0;
|
||||||
BestQuality = Qual;
|
BestQuality = Qual;
|
||||||
} else if (Qual == BestQuality)
|
} else if (Qual == BestQuality)
|
||||||
EquallyBest = i;
|
EquallyBest = &*it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,17 +84,16 @@ TargetRegistry::getClosestStaticTargetForModule(const Module &M,
|
|||||||
|
|
||||||
const Target *
|
const Target *
|
||||||
TargetRegistry::getClosestTargetForJIT(std::string &Error) {
|
TargetRegistry::getClosestTargetForJIT(std::string &Error) {
|
||||||
Target *Best = 0, *EquallyBest = 0;
|
const Target *Best = 0, *EquallyBest = 0;
|
||||||
unsigned BestQuality = 0;
|
unsigned BestQuality = 0;
|
||||||
// FIXME: Use iterator.
|
for (iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||||
for (Target *i = FirstTarget; i; i = i->Next) {
|
if (unsigned Qual = it->JITMatchQualityFn()) {
|
||||||
if (unsigned Qual = i->JITMatchQualityFn()) {
|
|
||||||
if (!Best || Qual > BestQuality) {
|
if (!Best || Qual > BestQuality) {
|
||||||
Best = i;
|
Best = &*it;
|
||||||
EquallyBest = 0;
|
EquallyBest = 0;
|
||||||
BestQuality = Qual;
|
BestQuality = Qual;
|
||||||
} else if (Qual == BestQuality)
|
} else if (Qual == BestQuality)
|
||||||
EquallyBest = i;
|
EquallyBest = &*it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user