I have no idea why I thought I did't need a subtarget. I do need one so I have added it.

This commit is contained in:
Jeremy Rand 2015-07-17 23:57:48 -05:00
parent 9bb9bf24c8
commit 26846cab41
13 changed files with 156 additions and 14 deletions

View File

@ -16,6 +16,7 @@ add_llvm_target(WDC65816CodeGen
WDC65816FrameLowering.cpp
WDC65816MachineFunctionInfo.cpp
WDC65816RegisterInfo.cpp
WDC65816Subtarget.cpp
WDC65816TargetMachine.cpp
WDC65816SelectionDAGInfo.cpp
)

View File

@ -99,6 +99,7 @@ void WDC65816AsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
bool WDC65816AsmPrinter::printGetPCX(const MachineInstr *MI, unsigned opNum,
raw_ostream &O) {
// WDC_TODO - print whatever this is here...
return true;
}
#if 0 // WDC_TODO - How much of this do we need?

View File

@ -15,14 +15,18 @@
#define WDC65816_FRAMEINFO_H
#include "WDC65816.h"
#include "WDC65816Subtarget.h"
#include "llvm/Target/TargetFrameLowering.h"
namespace llvm {
class WDC65816Subtarget;
class WDC65816FrameLowering : public TargetFrameLowering {
const WDC65816Subtarget &SubTarget;
public:
explicit WDC65816FrameLowering(void)
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown, 1, 0) {}
explicit WDC65816FrameLowering(const WDC65816Subtarget &ST)
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown, 1, 0),
SubTarget(ST) {}
bool hasFP(const MachineFunction &MF) const;

View File

@ -30,10 +30,11 @@ using namespace llvm;
///
namespace {
class WDC65816DAGToDAGISel : public SelectionDAGISel {
const WDC65816Subtarget &Subtarget;
WDC65816TargetMachine &TM;
public:
explicit WDC65816DAGToDAGISel(WDC65816TargetMachine &tm)
: SelectionDAGISel(tm),
: SelectionDAGISel(tm), Subtarget(tm.getSubtarget<WDC65816Subtarget>()),
TM(tm) {
}

View File

@ -19,6 +19,7 @@
#include "llvm/Target/TargetLowering.h"
namespace llvm {
class WDC65816Subtarget;
#if 0 // WDC_TODO - Do I need any of this?
namespace SPISD {
enum {
@ -52,6 +53,7 @@ namespace llvm {
#endif
class WDC65816TargetLowering : public TargetLowering {
const WDC65816Subtarget *Subtarget;
public:
WDC65816TargetLowering(TargetMachine &TM);

View File

@ -14,6 +14,7 @@
#include "WDC65816InstrInfo.h"
#include "WDC65816.h"
#include "WDC65816MachineFunctionInfo.h"
#include "WDC65816Subtarget.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
@ -32,9 +33,9 @@ using namespace llvm;
// Pin the vtable to this file.
void WDC65816InstrInfo::anchor() {}
WDC65816InstrInfo::WDC65816InstrInfo(void)
WDC65816InstrInfo::WDC65816InstrInfo(WDC65816Subtarget &ST)
: WDC65816GenInstrInfo(WDC::ADJCALLSTACKDOWN, WDC::ADJCALLSTACKUP),
RI() {
RI(ST), Subtarget(ST) {
}

View File

@ -24,9 +24,10 @@ namespace llvm {
class WDC65816InstrInfo : public WDC65816GenInstrInfo {
const WDC65816RegisterInfo RI;
const WDC65816Subtarget& Subtarget;
virtual void anchor();
public:
explicit WDC65816InstrInfo(void);
explicit WDC65816InstrInfo(WDC65816Subtarget &ST);
/// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
/// such, whenever a client has an instance of instruction info, it should

View File

@ -13,6 +13,8 @@
#include "WDC65816RegisterInfo.h"
#include "WDC65816.h"
#include "WDC65816MachineFunctionInfo.h"
#include "WDC65816Subtarget.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
@ -34,8 +36,8 @@ ReserveAppRegisters("sparc-reserve-app-registers", cl::Hidden, cl::init(false),
cl::desc("Reserve application registers (%g2-%g4)"));
#endif
WDC65816RegisterInfo::WDC65816RegisterInfo(void)
: WDC65816GenRegisterInfo(WDC::P) {
WDC65816RegisterInfo::WDC65816RegisterInfo(WDC65816Subtarget &st)
: WDC65816GenRegisterInfo(WDC::P), Subtarget(st) {
}
const uint16_t* WDC65816RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF)

View File

@ -21,12 +21,14 @@
namespace llvm {
class WDC65816Subtarget;
class TargetInstrInfo;
class Type;
struct WDC65816RegisterInfo : public WDC65816GenRegisterInfo {
WDC65816Subtarget &Subtarget;
WDC65816RegisterInfo(void);
WDC65816RegisterInfo(WDC65816Subtarget &st);
/// Code Generation virtual methods...
const uint16_t *getCalleeSavedRegs(const MachineFunction *MF = 0) const;

View File

@ -0,0 +1,64 @@
//===-- WDC65816Subtarget.cpp - WDC65816 Subtarget Information ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the WDC65816 specific subclass of TargetSubtargetInfo.
//
//===----------------------------------------------------------------------===//
#include "WDC65816Subtarget.h"
#include "WDC65816.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/TargetRegistry.h"
#define GET_SUBTARGETINFO_TARGET_DESC
#define GET_SUBTARGETINFO_CTOR
#include "WDC65816GenSubtargetInfo.inc"
using namespace llvm;
void WDC65816Subtarget::anchor() { }
WDC65816Subtarget::WDC65816Subtarget(const std::string &TT, const std::string &CPU,
const std::string &FS) :
WDC65816GenSubtargetInfo(TT, CPU, FS) {
// Determine default and user specified characteristics
std::string CPUName = CPU;
// Parse features string.
ParseSubtargetFeatures(CPUName, FS);
}
#if 0 // WDC_TODO - Do I need this?
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
if (is64Bit()) {
// All 64-bit stack frames must be 16-byte aligned, and must reserve space
// for spilling the 16 window registers at %sp+BIAS..%sp+BIAS+128.
frameSize += 128;
// Frames with calls must also reserve space for 6 outgoing arguments
// whether they are used or not. LowerCall_64 takes care of that.
assert(frameSize % 16 == 0 && "Stack size not 16-byte aligned");
} else {
// Emit the correct save instruction based on the number of bytes in
// the frame. Minimum stack frame size according to V8 ABI is:
// 16 words for register window spill
// 1 word for address of returned aggregate-value
// + 6 words for passing parameters on the stack
// ----------
// 23 words * 4 bytes per word = 92 bytes
frameSize += 92;
// Round up to next doubleword boundary -- a double-word boundary
// is required by the ABI.
frameSize = RoundUpToAlignment(frameSize, 8);
}
return frameSize;
}
#endif

View File

@ -0,0 +1,60 @@
//===-- WDC65816Subtarget.h - Define Subtarget for the WDC65816 -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the WDC65816 specific subclass of TargetSubtargetInfo.
//
//===----------------------------------------------------------------------===//
#ifndef WDC65816_SUBTARGET_H
#define WDC65816_SUBTARGET_H
#include "llvm/Target/TargetSubtargetInfo.h"
#include <string>
#define GET_SUBTARGETINFO_HEADER
#include "WDC65816GenSubtargetInfo.inc"
namespace llvm {
class StringRef;
class WDC65816Subtarget : public WDC65816GenSubtargetInfo {
virtual void anchor();
public:
WDC65816Subtarget(const std::string &TT, const std::string &CPU,
const std::string &FS);
/// ParseSubtargetFeatures - Parses features string setting specified
/// subtarget options. Definition of function is auto generated by tblgen.
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
bool is64Bit() const { return false; }
std::string getDataLayout() const {
return std::string("e-p:32:8:8-i16:8:8-f32:8:8-f68:8:8-n16");
}
#if 0 // WDC_TODO - do I need any of this?
/// The 64-bit ABI uses biased stack and frame pointers, so the stack frame
/// of the current function is the area from [%sp+BIAS] to [%fp+BIAS].
int64_t getStackPointerBias() const {
return is64Bit() ? 2047 : 0;
}
/// Given a actual stack size as determined by FrameInfo, this function
/// returns adjusted framesize which includes space for register window
/// spills and arguments.
int getAdjustedFrameSize(int stackSize) const;
#endif
};
} // end namespace llvm
#endif

View File

@ -31,10 +31,11 @@ WDC65816TargetMachine::WDC65816TargetMachine(const Target &T, StringRef TT,
Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL)
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
DL("e-p:32:8:8-i16:8:8-f32:8:8-f68:8:8-n16"),
InstrInfo(),
Subtarget(TT, CPU, FS),
DL(Subtarget.getDataLayout()),
InstrInfo(Subtarget),
TLInfo(*this), TSInfo(*this),
FrameLowering() {
FrameLowering(Subtarget) {
initAsmInfo();
}
@ -67,5 +68,5 @@ bool WDC65816PassConfig::addInstSelector() {
/// passes immediately before machine code is emitted. This should return
/// true if -print-machineinstrs should print out the code after the passes.
bool WDC65816PassConfig::addPreEmitPass(){
return true;
return false;
}

View File

@ -18,6 +18,7 @@
#include "WDC65816ISelLowering.h"
#include "WDC65816InstrInfo.h"
#include "WDC65816SelectionDAGInfo.h"
#include "WDC65816Subtarget.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Target/TargetFrameLowering.h"
#include "llvm/Target/TargetMachine.h"
@ -25,7 +26,7 @@
namespace llvm {
class WDC65816TargetMachine : public LLVMTargetMachine {
// SparcSubtarget Subtarget; WDC_TODO - Do I need this?
WDC65816Subtarget Subtarget;
const DataLayout DL; // Calculates type size & alignment
WDC65816InstrInfo InstrInfo;
WDC65816TargetLowering TLInfo;
@ -41,6 +42,7 @@ namespace llvm {
virtual const TargetFrameLowering *getFrameLowering() const {
return &FrameLowering;
}
virtual const WDC65816Subtarget *getSubtargetImpl() const{ return &Subtarget; }
virtual const WDC65816RegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}