LLVM 24.0.0git
HexagonMachineFunctionInfo.h
Go to the documentation of this file.
1//=- HexagonMachineFunctionInfo.h - Hexagon machine function info -*- 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#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H
10#define LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H
11
12#include "llvm/ADT/DenseMap.h"
16#include <map>
17
18namespace llvm {
19
20namespace yaml {
22} // end namespace yaml
23
24namespace Hexagon {
25
26 const unsigned int StartPacket = 0x1;
27 const unsigned int EndPacket = 0x2;
28
29} // end namespace Hexagon
30
31/// Hexagon target-specific information for each MachineFunction.
33 // SRetReturnReg - Some subtargets require that sret lowering includes
34 // returning the value of the returned struct in a register. This field
35 // holds the virtual register into which the sret argument is passed.
36 unsigned SRetReturnReg = 0;
37 Register StackAlignBaseReg = 0; // Aligned-stack base register
38 int VarArgsFrameIndex;
39 int RegSavedAreaStartFrameIndex;
40 int FirstNamedArgFrameIndex;
41 int LastNamedArgFrameIndex;
42 bool HasClobberLR = false;
43 bool HasEHReturn = false;
44 MachineFrameInfo VTCMFrameInfo{Align(2048), false, false};
45 DenseMap<int, int> VTCMMap;
46 // Size of the largest outgoing HLX argument area on the VTCM stack.
47 unsigned MaxVTCMCallFrameSize = 0;
48 // Scalar stack alignment required by outgoing stack arguments. These
49 // requests are not tied to a frame object; see
50 // HexagonFrameLowering::getMaxStackAlign.
51 Align OutgoingArgAlign;
52 // Scalar stack slot holding the caller's VSP, or -1.
53 int VSPFrameIndex = -1;
54 std::map<const MachineInstr*, unsigned> PacketInfo;
55 virtual void anchor();
56
57public:
59
62
64
68 const override;
69
71
72 unsigned getSRetReturnReg() const { return SRetReturnReg; }
73 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
74
75 void setVarArgsFrameIndex(int v) { VarArgsFrameIndex = v; }
76 int getVarArgsFrameIndex() { return VarArgsFrameIndex; }
77
78 void setRegSavedAreaStartFrameIndex(int v) { RegSavedAreaStartFrameIndex = v;}
79 int getRegSavedAreaStartFrameIndex() { return RegSavedAreaStartFrameIndex; }
80
81 void setFirstNamedArgFrameIndex(int v) { FirstNamedArgFrameIndex = v; }
82 int getFirstNamedArgFrameIndex() { return FirstNamedArgFrameIndex; }
83
84 void setLastNamedArgFrameIndex(int v) { LastNamedArgFrameIndex = v; }
85 int getLastNamedArgFrameIndex() { return LastNamedArgFrameIndex; }
86
88 PacketInfo[MI] |= Hexagon::StartPacket;
89 }
91 PacketInfo[MI] |= Hexagon::EndPacket;
92 }
93 bool isStartPacket(const MachineInstr* MI) const {
94 auto It = PacketInfo.find(MI);
95 return It != PacketInfo.end() && (It->second & Hexagon::StartPacket);
96 }
97 bool isEndPacket(const MachineInstr* MI) const {
98 auto It = PacketInfo.find(MI);
99 return It != PacketInfo.end() && (It->second & Hexagon::EndPacket);
100 }
101 void setHasClobberLR(bool v) { HasClobberLR = v; }
102 bool hasClobberLR() const { return HasClobberLR; }
103
104 bool hasEHReturn() const { return HasEHReturn; };
105 void setHasEHReturn(bool H = true) { HasEHReturn = H; };
106
107 void setStackAlignBaseReg(Register R) { StackAlignBaseReg = R; }
108 Register getStackAlignBaseReg() const { return StackAlignBaseReg; }
109
110 void setVSPFrameIndex(int FI) { VSPFrameIndex = FI; }
111 int getVSPFrameIndex() const { return VSPFrameIndex; }
112
113 MachineFrameInfo &getVTCMFrameInfo() { return VTCMFrameInfo; }
114 const MachineFrameInfo &getVTCMFrameInfo() const { return VTCMFrameInfo; }
115
116 void moveToVTCMStack(int From, int To) { VTCMMap.insert({From, To}); }
117 bool isVTCMStackIndex(int ObjectIdx) const {
118 return VTCMMap.contains(ObjectIdx);
119 }
120 int getMappedVTCMObjectIndex(int ObjectIdx) const {
121 return VTCMMap.lookup(ObjectIdx);
122 }
123 int64_t getMappedVTCMObjectOffset(int ObjectIdx) const {
124 return VTCMFrameInfo.getObjectOffset(getMappedVTCMObjectIndex(ObjectIdx));
125 }
126
127 unsigned getMaxVTCMCallFrameSize() const { return MaxVTCMCallFrameSize; }
128 void reserveVTCMCallFrame(unsigned Size) {
129 MaxVTCMCallFrameSize = std::max(MaxVTCMCallFrameSize, Size);
130 }
131
132 Align getOutgoingArgAlign() const { return OutgoingArgAlign; }
134 OutgoingArgAlign = std::max(OutgoingArgAlign, A);
135 }
136};
137
138namespace yaml {
139
140/// Hexagon-specific MachineFunction properties for YAML serialization.
153
155 static void mapping(IO &YamlIO, HexagonFunctionInfo &MFI) {
156 YamlIO.mapOptional("stackAlignBaseReg", MFI.StackAlignBaseReg);
157 YamlIO.mapOptional("maxVTCMCallFrameSize", MFI.MaxVTCMCallFrameSize, 0u);
158 YamlIO.mapOptional("outgoingArgAlign", MFI.OutgoingArgAlign, Align());
159 }
160};
161
162} // end namespace yaml
163
164} // end namespace llvm
165
166#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines the DenseMap class.
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
#define H(x, y, z)
Definition MD5.cpp:56
Register Reg
Register const TargetRegisterInfo * TRI
Basic Register Allocator
Hexagon target-specific information for each MachineFunction.
bool isStartPacket(const MachineInstr *MI) const
bool isEndPacket(const MachineInstr *MI) const
int64_t getMappedVTCMObjectOffset(int ObjectIdx) const
const MachineFrameInfo & getVTCMFrameInfo() const
int getMappedVTCMObjectIndex(int ObjectIdx) const
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
void initializeBaseYamlFields(const yaml::HexagonFunctionInfo &YamlMFI)
HexagonMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
void mapOptional(StringRef Key, T &Val)
Definition YAMLTraits.h:800
const unsigned int EndPacket
const unsigned int StartPacket
This is an optimization pass for GlobalISel generic memory operations.
@ Other
Any other memory.
Definition ModRef.h:68
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Hexagon-specific MachineFunction properties for YAML serialization.
void mappingImpl(yaml::IO &YamlIO) override
~HexagonFunctionInfo() override=default
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
static void mapping(IO &YamlIO, HexagonFunctionInfo &MFI)
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:63
A wrapper around std::string which contains a source range that's being set during parsing.