100 lines · c
1//===-- SparcSubtarget.h - Define Subtarget for the SPARC -------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file declares the SPARC specific subclass of TargetSubtargetInfo.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H14#define LLVM_LIB_TARGET_SPARC_SPARCSUBTARGET_H15 16#include "MCTargetDesc/SparcMCTargetDesc.h"17#include "SparcFrameLowering.h"18#include "SparcISelLowering.h"19#include "SparcInstrInfo.h"20#include "llvm/CodeGen/TargetSubtargetInfo.h"21#include "llvm/IR/DataLayout.h"22#include "llvm/Support/ErrorHandling.h"23#include "llvm/TargetParser/Triple.h"24 25#define GET_SUBTARGETINFO_HEADER26#include "SparcGenSubtargetInfo.inc"27 28namespace llvm {29class StringRef;30 31class SparcSubtarget : public SparcGenSubtargetInfo {32 // ReserveRegister[i] - Register #i is not available as a general purpose33 // register.34 BitVector ReserveRegister;35 36 virtual void anchor();37 38#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \39 bool ATTRIBUTE = DEFAULT;40#include "SparcGenSubtargetInfo.inc"41 42 SparcInstrInfo InstrInfo;43 SparcTargetLowering TLInfo;44 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;45 SparcFrameLowering FrameLowering;46 47public:48 SparcSubtarget(const StringRef &CPU, const StringRef &TuneCPU,49 const StringRef &FS, const TargetMachine &TM);50 51 ~SparcSubtarget() override;52 53 const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }54 const TargetFrameLowering *getFrameLowering() const override {55 return &FrameLowering;56 }57 const SparcRegisterInfo *getRegisterInfo() const override {58 return &InstrInfo.getRegisterInfo();59 }60 const SparcTargetLowering *getTargetLowering() const override {61 return &TLInfo;62 }63 64 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;65 66 void initLibcallLoweringInfo(LibcallLoweringInfo &Info) const override;67 68 bool enableMachineScheduler() const override;69 70#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \71 bool GETTER() const { return ATTRIBUTE; }72#include "SparcGenSubtargetInfo.inc"73 74 /// ParseSubtargetFeatures - Parses features string setting specified75 /// subtarget options. Definition of function is auto generated by tblgen.76 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);77 SparcSubtarget &initializeSubtargetDependencies(StringRef CPU,78 StringRef TuneCPU,79 StringRef FS);80 81 /// The 64-bit ABI uses biased stack and frame pointers, so the stack frame82 /// of the current function is the area from [%sp+BIAS] to [%fp+BIAS].83 int64_t getStackPointerBias() const {84 return is64Bit() ? 2047 : 0;85 }86 87 bool isRegisterReserved(MCPhysReg PhysReg) const {88 return ReserveRegister[PhysReg];89 }90 91 /// Given a actual stack size as determined by FrameInfo, this function92 /// returns adjusted framesize which includes space for register window93 /// spills and arguments.94 int getAdjustedFrameSize(int stackSize) const;95};96 97} // end namespace llvm98 99#endif100