1//==- HexagonRegisterInfo.h - Hexagon Register Information Impl --*- 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-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the Hexagon implementation of the TargetRegisterInfo
10// class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONREGISTERINFO_H
15#define LLVM_LIB_TARGET_HEXAGON_HEXAGONREGISTERINFO_H
16
17#include "llvm/CodeGen/TargetRegisterInfo.h"
18
19#define GET_REGINFO_HEADER
20#include "HexagonGenRegisterInfo.inc"
21
22namespace llvm {
23
24namespace Hexagon {
25 // Generic (pseudo) subreg indices for use with getHexagonSubRegIndex.
26 enum { ps_sub_lo = 0, ps_sub_hi = 1 };
27}
28
29class HexagonRegisterInfo : public HexagonGenRegisterInfo {
30public:
31 HexagonRegisterInfo(unsigned HwMode);
32
33 /// Code Generation virtual methods...
34 const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF)
35 const override;
36 const uint32_t *getCallPreservedMask(const MachineFunction &MF,
37 CallingConv::ID) const override;
38 /// Mask for calls that pass or return values in HLX registers.
39 const uint32_t *getHLXCallPreservedMask() const;
40
41 BitVector getReservedRegs(const MachineFunction &MF) const override;
42
43 /// Compute the first available callee-saved register to use as the
44 /// aligned-stack base register when this function needs dynamic stack
45 /// realignment. This does not update the machine function info.
46 Register computeStackAlignBaseRegister(const MachineFunction &MF) const;
47
48 bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
49 unsigned FIOperandNum, RegScavenger *RS = nullptr) const override;
50
51 /// Returns true since we may need scavenging for a temporary register
52 /// when generating hardware loop instructions.
53 bool requiresRegisterScavenging(const MachineFunction &MF) const override {
54 return true;
55 }
56
57 /// Returns true. Spill code for predicate registers might need an extra
58 /// register.
59 bool requiresFrameIndexScavenging(const MachineFunction &MF) const override {
60 return true;
61 }
62
63 /// Returns true if the frame pointer is valid.
64 bool useFPForScavengingIndex(const MachineFunction &MF) const override;
65
66 bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC,
67 unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg,
68 const TargetRegisterClass *NewRC, LiveIntervals &LIS) const override;
69
70 // Debug information queries.
71 Register getFrameRegister(const MachineFunction &MF) const override;
72 Register getFrameRegister() const;
73 Register getStackRegister() const;
74 Register getVTCMStackRegister() const;
75
76 unsigned getHexagonSubRegIndex(const TargetRegisterClass &RC,
77 unsigned GenIdx) const;
78
79 const MCPhysReg *getCallerSavedRegs(const MachineFunction *MF,
80 const TargetRegisterClass *RC) const;
81
82 /// Returns true if the given reserved physical register is live across
83 /// function calls/returns.
84 bool isGlobalReg(MCPhysReg Reg) const;
85
86 /// Returns true if the given reserved physical register Reg is live
87 /// across function calls/returns. This function should not be used for
88 /// non-reserved registers, instead register liveness information should be
89 /// checked
90 bool isFakeReg(MCPhysReg Reg) const;
91
92 bool isEHReturnCalleeSaveReg(Register Reg) const;
93
94private:
95 BitVector getBaseReservedRegs(const MachineFunction &MF) const;
96 Register
97 computeStackAlignBaseRegister(const MachineFunction &MF,
98 const BitVector &BaseReservedRegs) const;
99};
100
101} // end namespace llvm
102
103#endif
104