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 std::map<const MachineInstr*, unsigned> PacketInfo;
47 virtual void anchor();
48
49public:
51
54
56
60 const override;
61
63
64 unsigned getSRetReturnReg() const { return SRetReturnReg; }
65 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
66
67 void setVarArgsFrameIndex(int v) { VarArgsFrameIndex = v; }
68 int getVarArgsFrameIndex() { return VarArgsFrameIndex; }
69
70 void setRegSavedAreaStartFrameIndex(int v) { RegSavedAreaStartFrameIndex = v;}
71 int getRegSavedAreaStartFrameIndex() { return RegSavedAreaStartFrameIndex; }
72
73 void setFirstNamedArgFrameIndex(int v) { FirstNamedArgFrameIndex = v; }
74 int getFirstNamedArgFrameIndex() { return FirstNamedArgFrameIndex; }
75
76 void setLastNamedArgFrameIndex(int v) { LastNamedArgFrameIndex = v; }
77 int getLastNamedArgFrameIndex() { return LastNamedArgFrameIndex; }
78
80 PacketInfo[MI] |= Hexagon::StartPacket;
81 }
83 PacketInfo[MI] |= Hexagon::EndPacket;
84 }
85 bool isStartPacket(const MachineInstr* MI) const {
86 auto It = PacketInfo.find(MI);
87 return It != PacketInfo.end() && (It->second & Hexagon::StartPacket);
88 }
89 bool isEndPacket(const MachineInstr* MI) const {
90 auto It = PacketInfo.find(MI);
91 return It != PacketInfo.end() && (It->second & Hexagon::EndPacket);
92 }
93 void setHasClobberLR(bool v) { HasClobberLR = v; }
94 bool hasClobberLR() const { return HasClobberLR; }
95
96 bool hasEHReturn() const { return HasEHReturn; };
97 void setHasEHReturn(bool H = true) { HasEHReturn = H; };
98
99 void setStackAlignBaseReg(Register R) { StackAlignBaseReg = R; }
100 Register getStackAlignBaseReg() const { return StackAlignBaseReg; }
101
102 MachineFrameInfo &getVTCMFrameInfo() { return VTCMFrameInfo; }
103 const MachineFrameInfo &getVTCMFrameInfo() const { return VTCMFrameInfo; }
104
105 void moveToVTCMStack(int From, int To) { VTCMMap.insert({From, To}); }
106 bool isVTCMStackIndex(int ObjectIdx) const {
107 return VTCMMap.contains(ObjectIdx);
108 }
109 int getMappedVTCMObjectIndex(int ObjectIdx) const {
110 return VTCMMap.lookup(ObjectIdx);
111 }
112 int64_t getMappedVTCMObjectOffset(int ObjectIdx) const {
113 return VTCMFrameInfo.getObjectOffset(getMappedVTCMObjectIndex(ObjectIdx));
114 }
115};
116
117namespace yaml {
118
119/// Hexagon-specific MachineFunction properties for YAML serialization.
130
132 static void mapping(IO &YamlIO, HexagonFunctionInfo &MFI) {
133 YamlIO.mapOptional("stackAlignBaseReg", MFI.StackAlignBaseReg);
134 }
135};
136
137} // end namespace yaml
138
139} // end namespace llvm
140
141#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.