1*fe6060f1SDimitry Andric //===-- M68kRegisterInfo.h - M68k Register Information Impl --*- C++ --===// 2*fe6060f1SDimitry Andric // 3*fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*fe6060f1SDimitry Andric // 7*fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 8*fe6060f1SDimitry Andric /// 9*fe6060f1SDimitry Andric /// \file 10*fe6060f1SDimitry Andric /// This file contains the M68k implementation of the TargetRegisterInfo 11*fe6060f1SDimitry Andric /// class. 12*fe6060f1SDimitry Andric /// 13*fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 14*fe6060f1SDimitry Andric 15*fe6060f1SDimitry Andric #ifndef LLVM_LIB_TARGET_M68K_M68KREGISTERINFO_H 16*fe6060f1SDimitry Andric #define LLVM_LIB_TARGET_M68K_M68KREGISTERINFO_H 17*fe6060f1SDimitry Andric 18*fe6060f1SDimitry Andric #include "M68k.h" 19*fe6060f1SDimitry Andric 20*fe6060f1SDimitry Andric #include "llvm/CodeGen/TargetRegisterInfo.h" 21*fe6060f1SDimitry Andric 22*fe6060f1SDimitry Andric #define GET_REGINFO_HEADER 23*fe6060f1SDimitry Andric #include "M68kGenRegisterInfo.inc" 24*fe6060f1SDimitry Andric 25*fe6060f1SDimitry Andric namespace llvm { 26*fe6060f1SDimitry Andric class M68kSubtarget; 27*fe6060f1SDimitry Andric class TargetInstrInfo; 28*fe6060f1SDimitry Andric class Type; 29*fe6060f1SDimitry Andric 30*fe6060f1SDimitry Andric class M68kRegisterInfo : public M68kGenRegisterInfo { 31*fe6060f1SDimitry Andric virtual void anchor(); 32*fe6060f1SDimitry Andric 33*fe6060f1SDimitry Andric /// Physical register used as stack ptr. 34*fe6060f1SDimitry Andric unsigned StackPtr; 35*fe6060f1SDimitry Andric 36*fe6060f1SDimitry Andric /// Physical register used as frame ptr. 37*fe6060f1SDimitry Andric unsigned FramePtr; 38*fe6060f1SDimitry Andric 39*fe6060f1SDimitry Andric /// Physical register used as a base ptr in complex stack frames. I.e., when 40*fe6060f1SDimitry Andric /// we need a 3rd base, not just SP and FP, due to variable size stack 41*fe6060f1SDimitry Andric /// objects. 42*fe6060f1SDimitry Andric unsigned BasePtr; 43*fe6060f1SDimitry Andric 44*fe6060f1SDimitry Andric /// Physical register used to store GOT address if needed. 45*fe6060f1SDimitry Andric unsigned GlobalBasePtr; 46*fe6060f1SDimitry Andric 47*fe6060f1SDimitry Andric protected: 48*fe6060f1SDimitry Andric const M68kSubtarget &Subtarget; 49*fe6060f1SDimitry Andric 50*fe6060f1SDimitry Andric public: 51*fe6060f1SDimitry Andric M68kRegisterInfo(const M68kSubtarget &Subtarget); 52*fe6060f1SDimitry Andric 53*fe6060f1SDimitry Andric const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override; 54*fe6060f1SDimitry Andric 55*fe6060f1SDimitry Andric const uint32_t *getCallPreservedMask(const MachineFunction &MF, 56*fe6060f1SDimitry Andric CallingConv::ID) const override; 57*fe6060f1SDimitry Andric 58*fe6060f1SDimitry Andric /// Returns a register class with registers that can be used in forming tail 59*fe6060f1SDimitry Andric /// calls. 60*fe6060f1SDimitry Andric const TargetRegisterClass * 61*fe6060f1SDimitry Andric getRegsForTailCall(const MachineFunction &MF) const; 62*fe6060f1SDimitry Andric 63*fe6060f1SDimitry Andric /// Return a mega-register of the specified register Reg so its sub-register 64*fe6060f1SDimitry Andric /// of index SubIdx is Reg, its super(or mega) Reg. In other words it will 65*fe6060f1SDimitry Andric /// return a register that is not direct super register but still shares 66*fe6060f1SDimitry Andric /// physical register with Reg. 67*fe6060f1SDimitry Andric /// NOTE not sure about the term though. 68*fe6060f1SDimitry Andric unsigned getMatchingMegaReg(unsigned Reg, 69*fe6060f1SDimitry Andric const TargetRegisterClass *RC) const; 70*fe6060f1SDimitry Andric 71*fe6060f1SDimitry Andric /// Returns the Register Class of a physical register of the given type, 72*fe6060f1SDimitry Andric /// picking the biggest register class of the right type that contains this 73*fe6060f1SDimitry Andric /// physreg. 74*fe6060f1SDimitry Andric const TargetRegisterClass *getMaximalPhysRegClass(unsigned reg, MVT VT) const; 75*fe6060f1SDimitry Andric 76*fe6060f1SDimitry Andric /// Return index of a register within a register class, otherwise return -1 77*fe6060f1SDimitry Andric int getRegisterOrder(unsigned Reg, const TargetRegisterClass &TRC) const; 78*fe6060f1SDimitry Andric 79*fe6060f1SDimitry Andric /// Return spill order index of a register, if there is none then trap 80*fe6060f1SDimitry Andric int getSpillRegisterOrder(unsigned Reg) const; 81*fe6060f1SDimitry Andric 82*fe6060f1SDimitry Andric BitVector getReservedRegs(const MachineFunction &MF) const override; 83*fe6060f1SDimitry Andric 84*fe6060f1SDimitry Andric bool requiresRegisterScavenging(const MachineFunction &MF) const override; 85*fe6060f1SDimitry Andric 86*fe6060f1SDimitry Andric bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override; 87*fe6060f1SDimitry Andric 88*fe6060f1SDimitry Andric /// FrameIndex represent objects inside a abstract stack. We must replace 89*fe6060f1SDimitry Andric /// FrameIndex with an stack/frame pointer direct reference. 90*fe6060f1SDimitry Andric void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, 91*fe6060f1SDimitry Andric unsigned FIOperandNum, 92*fe6060f1SDimitry Andric RegScavenger *RS = nullptr) const override; 93*fe6060f1SDimitry Andric 94*fe6060f1SDimitry Andric bool hasBasePointer(const MachineFunction &MF) const; 95*fe6060f1SDimitry Andric 96*fe6060f1SDimitry Andric /// True if the stack can be realigned for the target. 97*fe6060f1SDimitry Andric bool canRealignStack(const MachineFunction &MF) const override; 98*fe6060f1SDimitry Andric 99*fe6060f1SDimitry Andric Register getFrameRegister(const MachineFunction &MF) const override; 100*fe6060f1SDimitry Andric unsigned getStackRegister() const { return StackPtr; } 101*fe6060f1SDimitry Andric unsigned getBaseRegister() const { return BasePtr; } 102*fe6060f1SDimitry Andric unsigned getGlobalBaseRegister() const { return GlobalBasePtr; } 103*fe6060f1SDimitry Andric 104*fe6060f1SDimitry Andric const TargetRegisterClass *intRegClass(unsigned Size) const; 105*fe6060f1SDimitry Andric }; 106*fe6060f1SDimitry Andric 107*fe6060f1SDimitry Andric } // end namespace llvm 108*fe6060f1SDimitry Andric 109*fe6060f1SDimitry Andric #endif 110