mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Add a new TargetNameParser class, which is useful for parsing options.
Add two methods which are useful for autoselecting targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14748 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
71d24aab2d
commit
cbc74123d8
@ -17,12 +17,33 @@
|
|||||||
#ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
|
#ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
|
||||||
#define LLVM_TARGET_TARGETMACHINEREGISTRY_H
|
#define LLVM_TARGET_TARGETMACHINEREGISTRY_H
|
||||||
|
|
||||||
|
#include "Support/CommandLine.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Module;
|
class Module;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class IntrinsicLowering;
|
class IntrinsicLowering;
|
||||||
|
|
||||||
struct TargetMachineRegistry {
|
struct TargetMachineRegistry {
|
||||||
|
struct Entry;
|
||||||
|
|
||||||
|
/// TargetMachineRegistry::getList - This static method returns the list of
|
||||||
|
/// target machines that are registered with the system.
|
||||||
|
static const Entry *getList() { return List; }
|
||||||
|
|
||||||
|
/// getClosestStaticTargetForModule - Given an LLVM module, pick the best
|
||||||
|
/// target that is compatible with the module. If no close target can be
|
||||||
|
/// found, this returns null and sets the Error string to a reason.
|
||||||
|
static const Entry *getClosestStaticTargetForModule(const Module &M,
|
||||||
|
std::string &Error);
|
||||||
|
|
||||||
|
/// getClosestTargetForJIT - Given an LLVM module, pick the best target that
|
||||||
|
/// is compatible with the current host and the specified module. If no
|
||||||
|
/// close target can be found, this returns null and sets the Error string
|
||||||
|
/// to a reason.
|
||||||
|
static const Entry *getClosestTargetForJIT(std::string &Error);
|
||||||
|
|
||||||
|
|
||||||
/// Entry - One instance of this struct is created for each target that is
|
/// Entry - One instance of this struct is created for each target that is
|
||||||
/// registered.
|
/// registered.
|
||||||
struct Entry {
|
struct Entry {
|
||||||
@ -46,10 +67,6 @@ namespace llvm {
|
|||||||
const Entry *Next; // Next entry in the linked list.
|
const Entry *Next; // Next entry in the linked list.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// TargetMachineRegistry::getList - This static method returns the list of
|
|
||||||
/// target machines that are registered with the system.
|
|
||||||
static const Entry *getList() { return List; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const Entry *List;
|
static const Entry *List;
|
||||||
};
|
};
|
||||||
@ -71,6 +88,21 @@ namespace llvm {
|
|||||||
return new TargetMachineImpl(M, IL);
|
return new TargetMachineImpl(M, IL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
/// TargetNameParser - This option can be used to provide a command line
|
||||||
|
/// option to choose among the various registered targets (commonly -march).
|
||||||
|
class TargetNameParser :
|
||||||
|
public cl::parser<const TargetMachineRegistry::Entry*> {
|
||||||
|
public:
|
||||||
|
void initialize(cl::Option &O) {
|
||||||
|
for (const TargetMachineRegistry::Entry *E =
|
||||||
|
TargetMachineRegistry::getList(); E; E = E->getNext())
|
||||||
|
Values.push_back(std::make_pair(E->Name,
|
||||||
|
std::make_pair(E, E->ShortDesc)));
|
||||||
|
cl::parser<const TargetMachineRegistry::Entry*>::initialize(O);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user