mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 02:29:18 +00:00
Move the various Subtarget dependent members down to the subtarget
for the Sparc port. Use the same initializeSubtargetDependencies function to handle initialization similar to the other ports to handle dependencies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211811 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9e50640808
commit
eca517deaa
@ -26,20 +26,44 @@ using namespace llvm;
|
||||
|
||||
void SparcSubtarget::anchor() { }
|
||||
|
||||
SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, bool is64Bit) :
|
||||
SparcGenSubtargetInfo(TT, CPU, FS),
|
||||
IsV9(false),
|
||||
V8DeprecatedInsts(false),
|
||||
IsVIS(false),
|
||||
Is64Bit(is64Bit),
|
||||
HasHardQuad(false),
|
||||
UsePopc(false) {
|
||||
static std::string computeDataLayout(const SparcSubtarget &ST) {
|
||||
// Sparc is big endian.
|
||||
std::string Ret = "E-m:e";
|
||||
|
||||
// Some ABIs have 32bit pointers.
|
||||
if (!ST.is64Bit())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Alignments for 64 bit integers.
|
||||
Ret += "-i64:64";
|
||||
|
||||
// On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
|
||||
// On SparcV9 registers can hold 64 or 32 bits, on others only 32.
|
||||
if (ST.is64Bit())
|
||||
Ret += "-n32:64";
|
||||
else
|
||||
Ret += "-f128:64-n32";
|
||||
|
||||
if (ST.is64Bit())
|
||||
Ret += "-S128";
|
||||
else
|
||||
Ret += "-S64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
||||
StringRef FS) {
|
||||
IsV9 = false;
|
||||
V8DeprecatedInsts = false;
|
||||
IsVIS = false;
|
||||
HasHardQuad = false;
|
||||
UsePopc = false;
|
||||
|
||||
// Determine default and user specified characteristics
|
||||
std::string CPUName = CPU;
|
||||
if (CPUName.empty())
|
||||
CPUName = (is64Bit) ? "v9" : "v8";
|
||||
CPUName = (Is64Bit) ? "v9" : "v8";
|
||||
|
||||
// Parse features string.
|
||||
ParseSubtargetFeatures(CPUName, FS);
|
||||
@ -47,8 +71,16 @@ SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
|
||||
// Popc is a v9-only instruction.
|
||||
if (!IsV9)
|
||||
UsePopc = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, TargetMachine &TM,
|
||||
bool is64Bit)
|
||||
: SparcGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit),
|
||||
DL(computeDataLayout(initializeSubtargetDependencies(CPU, FS))),
|
||||
InstrInfo(*this), TLInfo(TM), TSInfo(DL), FrameLowering(*this) {}
|
||||
|
||||
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
|
||||
|
||||
|
@ -14,6 +14,13 @@
|
||||
#ifndef SPARC_SUBTARGET_H
|
||||
#define SPARC_SUBTARGET_H
|
||||
|
||||
#include "SparcFrameLowering.h"
|
||||
#include "SparcInstrInfo.h"
|
||||
#include "SparcISelLowering.h"
|
||||
#include "SparcJITInfo.h"
|
||||
#include "SparcSelectionDAGInfo.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/Target/TargetFrameLowering.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#include <string>
|
||||
|
||||
@ -31,10 +38,26 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
|
||||
bool Is64Bit;
|
||||
bool HasHardQuad;
|
||||
bool UsePopc;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
SparcInstrInfo InstrInfo;
|
||||
SparcTargetLowering TLInfo;
|
||||
SparcSelectionDAGInfo TSInfo;
|
||||
SparcFrameLowering FrameLowering;
|
||||
SparcJITInfo JITInfo;
|
||||
|
||||
public:
|
||||
SparcSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, bool is64bit);
|
||||
const std::string &FS, TargetMachine &TM, bool is64bit);
|
||||
|
||||
const SparcInstrInfo *getInstrInfo() const { return &InstrInfo; }
|
||||
const TargetFrameLowering *getFrameLowering() const { return &FrameLowering; }
|
||||
const SparcRegisterInfo *getRegisterInfo() const {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
const SparcTargetLowering *getTargetLowering() const { return &TLInfo; }
|
||||
const SparcSelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
|
||||
SparcJITInfo *getJITInfo() { return &JITInfo; }
|
||||
const DataLayout *getDataLayout() const { return &DL; }
|
||||
|
||||
bool isV9() const { return IsV9; }
|
||||
bool isVIS() const { return IsVIS; }
|
||||
@ -47,6 +70,7 @@ public:
|
||||
/// ParseSubtargetFeatures - Parses features string setting specified
|
||||
/// subtarget options. Definition of function is auto generated by tblgen.
|
||||
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
||||
SparcSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
|
||||
|
||||
bool is64Bit() const { return Is64Bit; }
|
||||
|
||||
|
@ -23,32 +23,6 @@ extern "C" void LLVMInitializeSparcTarget() {
|
||||
RegisterTargetMachine<SparcV9TargetMachine> Y(TheSparcV9Target);
|
||||
}
|
||||
|
||||
static std::string computeDataLayout(const SparcSubtarget &ST) {
|
||||
// Sparc is big endian.
|
||||
std::string Ret = "E-m:e";
|
||||
|
||||
// Some ABIs have 32bit pointers.
|
||||
if (!ST.is64Bit())
|
||||
Ret += "-p:32:32";
|
||||
|
||||
// Alignments for 64 bit integers.
|
||||
Ret += "-i64:64";
|
||||
|
||||
// On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
|
||||
// On SparcV9 registers can hold 64 or 32 bits, on others only 32.
|
||||
if (ST.is64Bit())
|
||||
Ret += "-n32:64";
|
||||
else
|
||||
Ret += "-f128:64-n32";
|
||||
|
||||
if (ST.is64Bit())
|
||||
Ret += "-S128";
|
||||
else
|
||||
Ret += "-S64";
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/// SparcTargetMachine ctor - Create an ILP32 architecture model
|
||||
///
|
||||
SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
|
||||
@ -58,11 +32,7 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
|
||||
CodeGenOpt::Level OL,
|
||||
bool is64bit)
|
||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||
Subtarget(TT, CPU, FS, is64bit),
|
||||
DL(computeDataLayout(Subtarget)),
|
||||
InstrInfo(Subtarget),
|
||||
TLInfo(*this), TSInfo(DL),
|
||||
FrameLowering(Subtarget) {
|
||||
Subtarget(TT, CPU, FS, *this, is64bit) {
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
|
@ -14,50 +14,40 @@
|
||||
#ifndef SPARCTARGETMACHINE_H
|
||||
#define SPARCTARGETMACHINE_H
|
||||
|
||||
#include "SparcFrameLowering.h"
|
||||
#include "SparcISelLowering.h"
|
||||
#include "SparcInstrInfo.h"
|
||||
#include "SparcJITInfo.h"
|
||||
#include "SparcSelectionDAGInfo.h"
|
||||
#include "SparcSubtarget.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/Target/TargetFrameLowering.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class SparcTargetMachine : public LLVMTargetMachine {
|
||||
SparcSubtarget Subtarget;
|
||||
const DataLayout DL; // Calculates type size & alignment
|
||||
SparcInstrInfo InstrInfo;
|
||||
SparcTargetLowering TLInfo;
|
||||
SparcSelectionDAGInfo TSInfo;
|
||||
SparcFrameLowering FrameLowering;
|
||||
SparcJITInfo JITInfo;
|
||||
public:
|
||||
SparcTargetMachine(const Target &T, StringRef TT,
|
||||
StringRef CPU, StringRef FS, const TargetOptions &Options,
|
||||
Reloc::Model RM, CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL, bool is64bit);
|
||||
|
||||
const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
const TargetFrameLowering *getFrameLowering() const override {
|
||||
return &FrameLowering;
|
||||
const SparcInstrInfo *getInstrInfo() const override {
|
||||
return getSubtargetImpl()->getInstrInfo();
|
||||
}
|
||||
const TargetFrameLowering *getFrameLowering() const override {
|
||||
return getSubtargetImpl()->getFrameLowering();
|
||||
}
|
||||
const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; }
|
||||
const SparcRegisterInfo *getRegisterInfo() const override {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
return getSubtargetImpl()->getRegisterInfo();
|
||||
}
|
||||
const SparcTargetLowering* getTargetLowering() const override {
|
||||
return &TLInfo;
|
||||
const SparcTargetLowering *getTargetLowering() const override {
|
||||
return getSubtargetImpl()->getTargetLowering();
|
||||
}
|
||||
const SparcSelectionDAGInfo* getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
const SparcSelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return getSubtargetImpl()->getSelectionDAGInfo();
|
||||
}
|
||||
SparcJITInfo *getJITInfo() override {
|
||||
return &JITInfo;
|
||||
SparcJITInfo *getJITInfo() override { return Subtarget.getJITInfo(); }
|
||||
const DataLayout *getDataLayout() const override {
|
||||
return getSubtargetImpl()->getDataLayout();
|
||||
}
|
||||
const DataLayout *getDataLayout() const override { return &DL; }
|
||||
|
||||
// Pass Pipeline Configuration
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
Loading…
Reference in New Issue
Block a user