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 slot holding the caller's VSP, or -1.
49 int VSPFrameIndex = -1;
50 std::map<const MachineInstr*, unsigned> PacketInfo;
51 virtual void anchor();
52
53public:
55
58
60
64 const override;
65
67
68 unsigned getSRetReturnReg() const { return SRetReturnReg; }
69 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
70
71 void setVarArgsFrameIndex(int v) { VarArgsFrameIndex = v; }
72 int getVarArgsFrameIndex() { return VarArgsFrameIndex; }
73
74 void setRegSavedAreaStartFrameIndex(int v) { RegSavedAreaStartFrameIndex = v;}
75 int getRegSavedAreaStartFrameIndex() { return RegSavedAreaStartFrameIndex; }
76
77 void setFirstNamedArgFrameIndex(int v) { FirstNamedArgFrameIndex = v; }
78 int getFirstNamedArgFrameIndex() { return FirstNamedArgFrameIndex; }
79
80 void setLastNamedArgFrameIndex(int v) { LastNamedArgFrameIndex = v; }
81 int getLastNamedArgFrameIndex() { return LastNamedArgFrameIndex; }
82
84 PacketInfo[MI] |= Hexagon::StartPacket;
85 }
87 PacketInfo[MI] |= Hexagon::EndPacket;
88 }
89 bool isStartPacket(const MachineInstr* MI) const {
90 auto It = PacketInfo.find(MI);
91 return It != PacketInfo.end() && (It->second & Hexagon::StartPacket);
92 }
93 bool isEndPacket(const MachineInstr* MI) const {
94 auto It = PacketInfo.find(MI);
95 return It != PacketInfo.end() && (It->second & Hexagon::EndPacket);
96 }
97 void setHasClobberLR(bool v) { HasClobberLR = v; }
98 bool hasClobberLR() const { return HasClobberLR; }
99
100 bool hasEHReturn() const { return HasEHReturn; };
101 void setHasEHReturn(bool H = true) { HasEHReturn = H; };
102
103 void setStackAlignBaseReg(Register R) { StackAlignBaseReg = R; }
104 Register getStackAlignBaseReg() const { return StackAlignBaseReg; }
105
106 void setVSPFrameIndex(int FI) { VSPFrameIndex = FI; }
107 int getVSPFrameIndex() const { return VSPFrameIndex; }
108
109 MachineFrameInfo &getVTCMFrameInfo() { return VTCMFrameInfo; }
110 const MachineFrameInfo &getVTCMFrameInfo() const { return VTCMFrameInfo; }
111
112 void moveToVTCMStack(int From, int To) { VTCMMap.insert({From, To}); }
113 bool isVTCMStackIndex(int ObjectIdx) const {
114 return VTCMMap.contains(ObjectIdx);
115 }
116 int getMappedVTCMObjectIndex(int ObjectIdx) const {
117 return VTCMMap.lookup(ObjectIdx);
118 }
119 int64_t getMappedVTCMObjectOffset(int ObjectIdx) const {
120 return VTCMFrameInfo.getObjectOffset(getMappedVTCMObjectIndex(ObjectIdx));
121 }
122
123 unsigned getMaxVTCMCallFrameSize() const { return MaxVTCMCallFrameSize; }
124 void reserveVTCMCallFrame(unsigned Size) {
125 MaxVTCMCallFrameSize = std::max(MaxVTCMCallFrameSize, Size);
126 }
127};
128
129namespace yaml {
130
131/// Hexagon-specific MachineFunction properties for YAML serialization.
143
145 static void mapping(IO &YamlIO, HexagonFunctionInfo &MFI) {
146 YamlIO.mapOptional("stackAlignBaseReg", MFI.StackAlignBaseReg);
147 YamlIO.mapOptional("maxVTCMCallFrameSize", MFI.MaxVTCMCallFrameSize, 0u);
148 }
149};
150
151} // end namespace yaml
152
153} // end namespace llvm
154
155#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONMACHINEFUNCTIONINFO_H
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.