mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Auto-registrate target
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14745 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
98599d098f
commit
d36c970a11
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
#include "llvm/CodeGen/IntrinsicLowering.h"
|
#include "llvm/CodeGen/IntrinsicLowering.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Support/CallSite.h"
|
#include "llvm/Support/CallSite.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
@ -40,6 +41,9 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<CTargetMachine> X("c", "C backend");
|
||||||
|
|
||||||
/// NameAllUsedStructs - This pass inserts names for any unnamed structure
|
/// NameAllUsedStructs - This pass inserts names for any unnamed structure
|
||||||
/// types that are used by the program.
|
/// types that are used by the program.
|
||||||
///
|
///
|
||||||
|
@ -25,6 +25,9 @@ struct CTargetMachine : public TargetMachine {
|
|||||||
|
|
||||||
// This is the only thing that actually does anything here.
|
// This is the only thing that actually does anything here.
|
||||||
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
|
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
|
||||||
|
|
||||||
|
// This class always works, but shouldn't be the default in most cases.
|
||||||
|
static unsigned getModuleMatchQuality(const Module &M) { return 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
#include "llvm/CodeGen/IntrinsicLowering.h"
|
#include "llvm/CodeGen/IntrinsicLowering.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Support/CallSite.h"
|
#include "llvm/Support/CallSite.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
@ -40,6 +41,9 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<CTargetMachine> X("c", "C backend");
|
||||||
|
|
||||||
/// NameAllUsedStructs - This pass inserts names for any unnamed structure
|
/// NameAllUsedStructs - This pass inserts names for any unnamed structure
|
||||||
/// types that are used by the program.
|
/// types that are used by the program.
|
||||||
///
|
///
|
||||||
|
@ -18,9 +18,16 @@
|
|||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Target/TargetMachineImpls.h"
|
#include "llvm/Target/TargetMachineImpls.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
#include <iostream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<PowerPCTargetMachine> X("powerpc", "PowerPC (experimental)");
|
||||||
|
}
|
||||||
|
|
||||||
// allocatePowerPCTargetMachine - Allocate and return a subclass of
|
// allocatePowerPCTargetMachine - Allocate and return a subclass of
|
||||||
// TargetMachine that implements the PowerPC backend.
|
// TargetMachine that implements the PowerPC backend.
|
||||||
//
|
//
|
||||||
|
@ -15,10 +15,16 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Target/TargetMachineImpls.h"
|
#include "llvm/Target/TargetMachineImpls.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<PowerPCTargetMachine> X("powerpc", "PowerPC (experimental)");
|
||||||
|
}
|
||||||
|
|
||||||
// allocatePowerPCTargetMachine - Allocate and return a subclass of
|
// allocatePowerPCTargetMachine - Allocate and return a subclass of
|
||||||
// TargetMachine that implements the PowerPC backend.
|
// TargetMachine that implements the PowerPC backend.
|
||||||
//
|
//
|
||||||
|
@ -17,10 +17,16 @@
|
|||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Target/TargetMachineImpls.h"
|
#include "llvm/Target/TargetMachineImpls.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<SparcV8TargetMachine> X("sparcv8", "SPARC V8 (experimental)");
|
||||||
|
}
|
||||||
|
|
||||||
// allocateSparcV8TargetMachine - Allocate and return a subclass of
|
// allocateSparcV8TargetMachine - Allocate and return a subclass of
|
||||||
// TargetMachine that implements the SparcV8 backend.
|
// TargetMachine that implements the SparcV8 backend.
|
||||||
//
|
//
|
||||||
|
@ -17,10 +17,16 @@
|
|||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Target/TargetMachineImpls.h"
|
#include "llvm/Target/TargetMachineImpls.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<SparcV8TargetMachine> X("sparcv8", "SPARC V8 (experimental)");
|
||||||
|
}
|
||||||
|
|
||||||
// allocateSparcV8TargetMachine - Allocate and return a subclass of
|
// allocateSparcV8TargetMachine - Allocate and return a subclass of
|
||||||
// TargetMachine that implements the SparcV8 backend.
|
// TargetMachine that implements the SparcV8 backend.
|
||||||
//
|
//
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
#include "llvm/CodeGen/MachineCodeForInstruction.h"
|
#include "llvm/CodeGen/MachineCodeForInstruction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Target/TargetMachineImpls.h"
|
#include "llvm/Target/TargetMachineImpls.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "MappingInfo.h"
|
#include "MappingInfo.h"
|
||||||
#include "SparcV9Internals.h"
|
#include "SparcV9Internals.h"
|
||||||
#include "SparcV9TargetMachine.h"
|
#include "SparcV9TargetMachine.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */
|
static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */
|
||||||
@ -59,6 +59,28 @@ namespace {
|
|||||||
|
|
||||||
cl::opt<bool> DisableStrip("disable-strip",
|
cl::opt<bool> DisableStrip("disable-strip",
|
||||||
cl::desc("Do not strip the LLVM bytecode in executable"));
|
cl::desc("Do not strip the LLVM bytecode in executable"));
|
||||||
|
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<SparcV9TargetMachine> X("sparcv9", "SPARC V9");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned SparcV9TargetMachine::getJITMatchQuality() {
|
||||||
|
#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
|
||||||
|
return 10;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned SparcV9TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||||
|
if (M.getEndianness() == Module::BigEndian &&
|
||||||
|
M.getPointerSize() == Module::Pointer64)
|
||||||
|
return 10; // Direct match
|
||||||
|
else if (M.getEndianness() != Module::AnyEndianness ||
|
||||||
|
M.getPointerSize() != Module::AnyPointerSize)
|
||||||
|
return 0; // Match for some other target
|
||||||
|
|
||||||
|
return getJITMatchQuality()/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
@ -111,7 +133,8 @@ FunctionPass *llvm::createSparcV9MachineCodeDestructionPass() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SparcV9TargetMachine::SparcV9TargetMachine(IntrinsicLowering *il)
|
SparcV9TargetMachine::SparcV9TargetMachine(const Module &M,
|
||||||
|
IntrinsicLowering *il)
|
||||||
: TargetMachine("UltraSparcV9-Native", il, false),
|
: TargetMachine("UltraSparcV9-Native", il, false),
|
||||||
schedInfo(*this),
|
schedInfo(*this),
|
||||||
regInfo(*this),
|
regInfo(*this),
|
||||||
@ -264,10 +287,11 @@ void SparcV9JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
|
|||||||
PM.add(createMachineFunctionPrinterPass(&std::cerr, "Final code:\n"));
|
PM.add(createMachineFunctionPrinterPass(&std::cerr, "Final code:\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// allocateSparcV9TargetMachine - Allocate and return a subclass of TargetMachine
|
/// allocateSparcV9TargetMachine - Allocate and return a subclass of
|
||||||
/// that implements the SparcV9 backend. (the llvm/CodeGen/SparcV9.h interface)
|
/// TargetMachine that implements the SparcV9 backend. (the
|
||||||
|
/// llvm/CodeGen/SparcV9.h interface)
|
||||||
///
|
///
|
||||||
TargetMachine *llvm::allocateSparcV9TargetMachine(const Module &M,
|
TargetMachine *llvm::allocateSparcV9TargetMachine(const Module &M,
|
||||||
IntrinsicLowering *IL) {
|
IntrinsicLowering *IL) {
|
||||||
return new SparcV9TargetMachine(IL);
|
return new SparcV9TargetMachine(M, IL);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class SparcV9TargetMachine : public TargetMachine {
|
|||||||
SparcV9FrameInfo frameInfo;
|
SparcV9FrameInfo frameInfo;
|
||||||
SparcV9JITInfo jitInfo;
|
SparcV9JITInfo jitInfo;
|
||||||
public:
|
public:
|
||||||
SparcV9TargetMachine(IntrinsicLowering *IL);
|
SparcV9TargetMachine(const Module &M, IntrinsicLowering *IL);
|
||||||
|
|
||||||
virtual const TargetInstrInfo *getInstrInfo() const { return &instrInfo; }
|
virtual const TargetInstrInfo *getInstrInfo() const { return &instrInfo; }
|
||||||
virtual const TargetSchedInfo *getSchedInfo() const { return &schedInfo; }
|
virtual const TargetSchedInfo *getSchedInfo() const { return &schedInfo; }
|
||||||
@ -46,6 +46,9 @@ public:
|
|||||||
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
|
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
|
||||||
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
|
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
|
||||||
MachineCodeEmitter &MCE);
|
MachineCodeEmitter &MCE);
|
||||||
|
|
||||||
|
static unsigned getModuleMatchQuality(const Module &M);
|
||||||
|
static unsigned getJITMatchQuality();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Target/TargetMachineImpls.h"
|
#include "llvm/Target/TargetMachineImpls.h"
|
||||||
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
#include "Support/Statistic.h"
|
#include "Support/Statistic.h"
|
||||||
@ -35,6 +36,9 @@ namespace {
|
|||||||
"when profiling the code generator."));
|
"when profiling the code generator."));
|
||||||
cl::opt<bool> NoSimpleISel("disable-simple-isel", cl::init(true),
|
cl::opt<bool> NoSimpleISel("disable-simple-isel", cl::init(true),
|
||||||
cl::desc("Use the hand coded 'simple' X86 instruction selector"));
|
cl::desc("Use the hand coded 'simple' X86 instruction selector"));
|
||||||
|
|
||||||
|
// Register the target.
|
||||||
|
RegisterTarget<X86TargetMachine> X("x86", "IA-32 (Pentium and above)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
|
// allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
|
||||||
@ -45,6 +49,24 @@ TargetMachine *llvm::allocateX86TargetMachine(const Module &M,
|
|||||||
return new X86TargetMachine(M, IL);
|
return new X86TargetMachine(M, IL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned X86TargetMachine::getJITMatchQuality() {
|
||||||
|
#if defined(i386) || defined(__i386__) || defined(__x86__)
|
||||||
|
return 10;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned X86TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||||
|
if (M.getEndianness() == Module::LittleEndian &&
|
||||||
|
M.getPointerSize() == Module::Pointer32)
|
||||||
|
return 10; // Direct match
|
||||||
|
else if (M.getEndianness() != Module::AnyEndianness ||
|
||||||
|
M.getPointerSize() != Module::AnyPointerSize)
|
||||||
|
return 0; // Match for some other target
|
||||||
|
|
||||||
|
return getJITMatchQuality()/2;
|
||||||
|
}
|
||||||
|
|
||||||
/// X86TargetMachine ctor - Create an ILP32 architecture model
|
/// X86TargetMachine ctor - Create an ILP32 architecture model
|
||||||
///
|
///
|
||||||
|
@ -47,6 +47,9 @@ public:
|
|||||||
MachineCodeEmitter &MCE);
|
MachineCodeEmitter &MCE);
|
||||||
|
|
||||||
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
|
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
|
||||||
|
|
||||||
|
static unsigned getModuleMatchQuality(const Module &M);
|
||||||
|
static unsigned getJITMatchQuality();
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is implemented in X86CodeEmitter.cpp
|
// this is implemented in X86CodeEmitter.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user