mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 18:34:09 +00:00
51b198af83
--- Reverse-merging r75799 into '.': U test/Analysis/PointerTracking U include/llvm/Target/TargetMachineRegistry.h U include/llvm/Target/TargetMachine.h U include/llvm/Target/TargetRegistry.h U include/llvm/Target/TargetSelect.h U tools/lto/LTOCodeGenerator.cpp U tools/lto/LTOModule.cpp U tools/llc/llc.cpp U lib/Target/PowerPC/PPCTargetMachine.h U lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp U lib/Target/PowerPC/PPCTargetMachine.cpp U lib/Target/PowerPC/PPC.h U lib/Target/ARM/ARMTargetMachine.cpp U lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp U lib/Target/ARM/ARMTargetMachine.h U lib/Target/ARM/ARM.h U lib/Target/XCore/XCoreTargetMachine.cpp U lib/Target/XCore/XCoreTargetMachine.h U lib/Target/PIC16/PIC16TargetMachine.cpp U lib/Target/PIC16/PIC16TargetMachine.h U lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp U lib/Target/Alpha/AlphaTargetMachine.cpp U lib/Target/Alpha/AlphaTargetMachine.h U lib/Target/X86/X86TargetMachine.h U lib/Target/X86/X86.h U lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h U lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp U lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h U lib/Target/X86/X86TargetMachine.cpp U lib/Target/MSP430/MSP430TargetMachine.cpp U lib/Target/MSP430/MSP430TargetMachine.h U lib/Target/CppBackend/CPPTargetMachine.h U lib/Target/CppBackend/CPPBackend.cpp U lib/Target/CBackend/CTargetMachine.h U lib/Target/CBackend/CBackend.cpp U lib/Target/TargetMachine.cpp U lib/Target/IA64/IA64TargetMachine.cpp U lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp U lib/Target/IA64/IA64TargetMachine.h U lib/Target/IA64/IA64.h U lib/Target/MSIL/MSILWriter.cpp U lib/Target/CellSPU/SPUTargetMachine.h U lib/Target/CellSPU/SPU.h U lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp U lib/Target/CellSPU/SPUTargetMachine.cpp U lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp U lib/Target/Mips/MipsTargetMachine.cpp U lib/Target/Mips/MipsTargetMachine.h U lib/Target/Mips/Mips.h U lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp U lib/Target/Sparc/SparcTargetMachine.cpp U lib/Target/Sparc/SparcTargetMachine.h U lib/ExecutionEngine/JIT/TargetSelect.cpp U lib/Support/TargetRegistry.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75820 91177308-0d34-0410-b5e6-96231b3b80d8
202 lines
7.9 KiB
C++
202 lines
7.9 KiB
C++
//===-- Target/TargetRegistry.h - Target Registration -----------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file exposes the TargetRegistry interface, which tools can use to access
|
|
// the appropriate target specific classes (TargetMachine, AsmPrinter, etc.)
|
|
// which have been registered.
|
|
//
|
|
// Target specific class implementations should register themselves using the
|
|
// appropriate TargetRegistry interfaces.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TARGET_TARGETREGISTRY_H
|
|
#define LLVM_TARGET_TARGETREGISTRY_H
|
|
|
|
#include <string>
|
|
#include <cassert>
|
|
|
|
namespace llvm {
|
|
class FunctionPass;
|
|
class Module;
|
|
class TargetMachine;
|
|
class formatted_raw_ostream;
|
|
|
|
/// Target - Wrapper for Target specific information.
|
|
///
|
|
/// For registration purposes, this is a POD type so that targets can be
|
|
/// registered without the use of static constructors.
|
|
///
|
|
/// Targets should implement a single global instance of this class (which
|
|
/// will be zero initialized), and pass that instance to the TargetRegistry as
|
|
/// part of their initialization.
|
|
class Target {
|
|
private:
|
|
typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT);
|
|
typedef unsigned (*ModuleMatchQualityFnTy)(const Module &M);
|
|
typedef unsigned (*JITMatchQualityFnTy)();
|
|
|
|
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
|
|
const Module &,
|
|
const std::string &);
|
|
typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
|
|
TargetMachine &,
|
|
bool);
|
|
|
|
friend struct TargetRegistry;
|
|
|
|
/// Next - The next registered target in the linked list, maintained by the
|
|
/// TargetRegistry.
|
|
Target *Next;
|
|
|
|
/// TripleMatchQualityFn - The target function for rating the match quality
|
|
/// of a triple.
|
|
TripleMatchQualityFnTy TripleMatchQualityFn;
|
|
|
|
/// ModuleMatchQualityFn - The target function for rating the match quality
|
|
/// of a module.
|
|
ModuleMatchQualityFnTy ModuleMatchQualityFn;
|
|
|
|
/// JITMatchQualityFn - The target function for rating the match quality
|
|
/// with the host.
|
|
JITMatchQualityFnTy JITMatchQualityFn;
|
|
|
|
/// Name - The target name.
|
|
const char *Name;
|
|
|
|
/// ShortDesc - A short description of the target.
|
|
const char *ShortDesc;
|
|
|
|
/// TargetMachineCtorFn - Construction function for this target's
|
|
/// TargetMachine, if registered.
|
|
TargetMachineCtorTy TargetMachineCtorFn;
|
|
|
|
/// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
|
|
/// if registered.
|
|
AsmPrinterCtorTy AsmPrinterCtorFn;
|
|
|
|
public:
|
|
/// getName - Get the target name.
|
|
const char *getName() const { return Name; }
|
|
|
|
/// getShortDescription - Get a short description of the target.
|
|
const char *getShortDescription() const { return ShortDesc; }
|
|
|
|
/// getJITMatchQuality - Get the quality of this targets match for use as a
|
|
/// JIT.
|
|
unsigned getJITMatchQuality() const { return JITMatchQualityFn(); }
|
|
|
|
/// createTargetMachine - Create a target specific machine implementation.
|
|
TargetMachine *createTargetMachine(const Module &M,
|
|
const std::string &Features) const {
|
|
if (!TargetMachineCtorFn)
|
|
return 0;
|
|
return TargetMachineCtorFn(*this, M, Features);
|
|
}
|
|
|
|
/// createAsmPrinter - Create a target specific assembly printer pass.
|
|
FunctionPass *createAsmPrinter(formatted_raw_ostream &OS,
|
|
TargetMachine &M,
|
|
bool Verbose) const {
|
|
if (!AsmPrinterCtorFn)
|
|
return 0;
|
|
return AsmPrinterCtorFn(OS, M, Verbose);
|
|
}
|
|
};
|
|
|
|
/// TargetRegistry - Generic interface to target specific features.
|
|
//
|
|
// FIXME: Provide Target* iterator.
|
|
struct TargetRegistry {
|
|
/// @name Registry Access
|
|
/// @{
|
|
|
|
/// getClosestStaticTargetForTriple - Given a target triple, pick the most
|
|
/// capable target for that triple.
|
|
static const Target *getClosestStaticTargetForTriple(const std::string &TT,
|
|
std::string &Error);
|
|
|
|
/// 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 Target *getClosestStaticTargetForModule(const Module &M,
|
|
std::string &Error);
|
|
|
|
/// getClosestTargetForJIT - Pick the best target that is compatible with
|
|
/// the current host. If no close target can be found, this returns null
|
|
/// and sets the Error string to a reason.
|
|
//
|
|
// FIXME: Do we still need this interface, clients can always look for the
|
|
// match for the host triple.
|
|
static const Target *getClosestTargetForJIT(std::string &Error);
|
|
|
|
/// @}
|
|
/// @name Target Registration
|
|
/// @{
|
|
|
|
/// RegisterTarget - Register the given target. Attempts to register a
|
|
/// target which has already been registered will be ignored.
|
|
///
|
|
/// Clients are responsible for ensuring that registration doesn't occur
|
|
/// while another thread is attempting to access the registry. Typically
|
|
/// this is done by initializing all targets at program startup.
|
|
///
|
|
/// @param T - The target being registered.
|
|
/// @param Name - The target name. This should be a static string.
|
|
/// @param ShortDesc - A short target description. This should be a static
|
|
/// string.
|
|
/// @param TQualityFn - The triple match quality computation function for
|
|
/// this target.
|
|
/// @param MQualityFn - The module match quality computation function for
|
|
/// this target.
|
|
/// @param JITMatchQualityFn - The JIT match quality computation function
|
|
/// for this target.
|
|
static void RegisterTarget(Target &T,
|
|
const char *Name,
|
|
const char *ShortDesc,
|
|
Target::TripleMatchQualityFnTy TQualityFn,
|
|
Target::ModuleMatchQualityFnTy MQualityFn,
|
|
Target::JITMatchQualityFnTy JITQualityFn);
|
|
|
|
/// RegisterTargetMachine - Register a TargetMachine implementation for the
|
|
/// given target.
|
|
///
|
|
/// Clients are responsible for ensuring that registration doesn't occur
|
|
/// while another thread is attempting to access the registry. Typically
|
|
/// this is done by initializing all targets at program startup.
|
|
///
|
|
/// @param T - The target being registered.
|
|
/// @param Fn - A function to construct a TargetMachine for the target.
|
|
static void RegisterTargetMachine(Target &T,
|
|
Target::TargetMachineCtorTy Fn) {
|
|
assert(!T.TargetMachineCtorFn && "Constructor already registered!");
|
|
T.TargetMachineCtorFn = Fn;
|
|
}
|
|
|
|
/// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
|
|
/// target.
|
|
///
|
|
/// Clients are responsible for ensuring that registration doesn't occur
|
|
/// while another thread is attempting to access the registry. Typically
|
|
/// this is done by initializing all targets at program startup.
|
|
///
|
|
/// @param T - The target being registered.
|
|
/// @param Fn - A function to construct an AsmPrinter for the target.
|
|
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
|
|
assert(!T.AsmPrinterCtorFn && "Constructor already registered!");
|
|
T.AsmPrinterCtorFn = Fn;
|
|
}
|
|
|
|
/// @}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|