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