1 //=- HexagonMachineFunctionInfo.h - Hexagon machine function info -*- C++ -*-=//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H
10 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H
12 #include "llvm/CodeGen/MachineFunction.h"
19 const unsigned int StartPacket
= 0x1;
20 const unsigned int EndPacket
= 0x2;
22 } // end namespace Hexagon
24 /// Hexagon target-specific information for each MachineFunction.
25 class HexagonMachineFunctionInfo
: public MachineFunctionInfo
{
26 // SRetReturnReg - Some subtargets require that sret lowering includes
27 // returning the value of the returned struct in a register. This field
28 // holds the virtual register into which the sret argument is passed.
29 unsigned SRetReturnReg
= 0;
30 Register StackAlignBaseReg
= 0; // Aligned-stack base register
31 int VarArgsFrameIndex
;
32 int RegSavedAreaStartFrameIndex
;
33 int FirstNamedArgFrameIndex
;
34 int LastNamedArgFrameIndex
;
35 bool HasClobberLR
= false;
36 bool HasEHReturn
= false;
37 std::map
<const MachineInstr
*, unsigned> PacketInfo
;
38 virtual void anchor();
41 HexagonMachineFunctionInfo() = default;
43 HexagonMachineFunctionInfo(const Function
&F
,
44 const TargetSubtargetInfo
*STI
) {}
47 clone(BumpPtrAllocator
&Allocator
, MachineFunction
&DestMF
,
48 const DenseMap
<MachineBasicBlock
*, MachineBasicBlock
*> &Src2DstMBB
)
51 unsigned getSRetReturnReg() const { return SRetReturnReg
; }
52 void setSRetReturnReg(unsigned Reg
) { SRetReturnReg
= Reg
; }
54 void setVarArgsFrameIndex(int v
) { VarArgsFrameIndex
= v
; }
55 int getVarArgsFrameIndex() { return VarArgsFrameIndex
; }
57 void setRegSavedAreaStartFrameIndex(int v
) { RegSavedAreaStartFrameIndex
= v
;}
58 int getRegSavedAreaStartFrameIndex() { return RegSavedAreaStartFrameIndex
; }
60 void setFirstNamedArgFrameIndex(int v
) { FirstNamedArgFrameIndex
= v
; }
61 int getFirstNamedArgFrameIndex() { return FirstNamedArgFrameIndex
; }
63 void setLastNamedArgFrameIndex(int v
) { LastNamedArgFrameIndex
= v
; }
64 int getLastNamedArgFrameIndex() { return LastNamedArgFrameIndex
; }
66 void setStartPacket(MachineInstr
* MI
) {
67 PacketInfo
[MI
] |= Hexagon::StartPacket
;
69 void setEndPacket(MachineInstr
* MI
) {
70 PacketInfo
[MI
] |= Hexagon::EndPacket
;
72 bool isStartPacket(const MachineInstr
* MI
) const {
73 return (PacketInfo
.count(MI
) &&
74 (PacketInfo
.find(MI
)->second
& Hexagon::StartPacket
));
76 bool isEndPacket(const MachineInstr
* MI
) const {
77 return (PacketInfo
.count(MI
) &&
78 (PacketInfo
.find(MI
)->second
& Hexagon::EndPacket
));
80 void setHasClobberLR(bool v
) { HasClobberLR
= v
; }
81 bool hasClobberLR() const { return HasClobberLR
; }
83 bool hasEHReturn() const { return HasEHReturn
; };
84 void setHasEHReturn(bool H
= true) { HasEHReturn
= H
; };
86 void setStackAlignBaseReg(Register R
) { StackAlignBaseReg
= R
; }
87 Register
getStackAlignBaseReg() const { return StackAlignBaseReg
; }
90 } // end namespace llvm
92 #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H