Index: lib/Target/NDS32/CMakeLists.txt =================================================================== --- lib/Target/NDS32/CMakeLists.txt +++ lib/Target/NDS32/CMakeLists.txt @@ -14,6 +14,7 @@ NDS32ISelLowering.cpp NDS32MachineFunctionInfo.cpp NDS32InstrInfo.cpp + NDS32Subtarget.cpp NDS32RegisterInfo.cpp NDS32FrameLowering.cpp NDS32SelectionDAGInfo.cpp Index: lib/Target/NDS32/NDS32Subtarget.h =================================================================== --- /dev/null +++ lib/Target/NDS32/NDS32Subtarget.h @@ -0,0 +1,76 @@ +//===-- NDS32Subtarget.h - Define Subtarget for the NDS32 ----*- 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 NDS32 specific subclass of TargetSubtargetInfo. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_NDS32_NDS32SUBTARGET_H +#define LLVM_LIB_TARGET_NDS32_NDS32SUBTARGET_H + +#include "NDS32FrameLowering.h" +#include "NDS32ISelLowering.h" +#include "NDS32SelectionDAGInfo.h" +#include "NDS32InstrInfo.h" +#include "NDS32RegisterInfo.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/Target/TargetSubtargetInfo.h" +#include + +#define GET_SUBTARGETINFO_HEADER +#include "NDS32GenSubtargetInfo.inc" + +namespace llvm { +class StringRef; + +class NDS32Subtarget : public NDS32GenSubtargetInfo { + virtual void anchor(); + bool ExtendedInsts; + NDS32FrameLowering FrameLowering; + std::unique_ptr InstrInfo; + NDS32TargetLowering TLInfo; + NDS32SelectionDAGInfo TSInfo; + +public: + /// This constructor initializes the data members to match that + /// of the specified triple. + /// + NDS32Subtarget(const Triple &TT, const std::string &CPU, + const std::string &FS, const TargetMachine &TM); + + NDS32Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); + + /// ParseSubtargetFeatures - Parses features string setting specified + /// subtarget options. Definition of function is auto generated by tblgen. + void ParseSubtargetFeatures(StringRef CPU, StringRef FS); + + const TargetFrameLowering *getFrameLowering() const override { + return &FrameLowering; + } + const NDS32InstrInfo *getInstrInfo() const override { return InstrInfo.get(); } + const NDS32RegisterInfo *getRegisterInfo() const override { + return &InstrInfo->getRegisterInfo(); + } + const NDS32TargetLowering *getTargetLowering() const override { + return &TLInfo; + } + const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { + return &TSInfo; + } + +protected: + /// No16Bit - Not generate 16-Bit ISA + bool No16Bit = false; + +public: + bool has16Bit() const { return !No16Bit; } +}; +} // End llvm namespace + +#endif // LLVM_TARGET_NDS32_SUBTARGET_H Index: lib/Target/NDS32/NDS32Subtarget.cpp =================================================================== --- /dev/null +++ lib/Target/NDS32/NDS32Subtarget.cpp @@ -0,0 +1,40 @@ +//===-- NDS32Subtarget.cpp - NDS32 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 NDS32 specific subclass of TargetSubtargetInfo. +// +//===----------------------------------------------------------------------===// + +#include "NDS32Subtarget.h" +#include "NDS32.h" +#include "llvm/Support/TargetRegistry.h" + +using namespace llvm; + +#define DEBUG_TYPE "NDS32-subtarget" + +#define GET_SUBTARGETINFO_TARGET_DESC +#define GET_SUBTARGETINFO_CTOR +#include "NDS32GenSubtargetInfo.inc" + +void NDS32Subtarget::anchor() { } + +NDS32Subtarget & +NDS32Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { + ParseSubtargetFeatures(CPU, FS); + return *this; +} + +NDS32Subtarget::NDS32Subtarget(const Triple &TT, const std::string &CPU, + const std::string &FS, const TargetMachine &TM) + : NDS32GenSubtargetInfo(TT, CPU, FS), FrameLowering(), + InstrInfo(NDS32InstrInfo::create(initializeSubtargetDependencies(CPU, FS))), + TLInfo(TM, *this) { + ParseSubtargetFeatures(CPU, FS); +}