LLVM 22.0.0git
AArch64TargetStreamer.h
Go to the documentation of this file.
1//===-- AArch64TargetStreamer.h - AArch64 Target Streamer ------*- 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_AARCH64_MCTARGETDESC_AARCH64TARGETSTREAMER_H
10#define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64TARGETSTREAMER_H
11
12#include "AArch64MCAsmInfo.h"
13#include "llvm/ADT/StringRef.h"
16#include "llvm/MC/MCStreamer.h"
18#include <cstdint>
19
20namespace {
21class AArch64ELFStreamer;
22}
23
24namespace llvm {
25
27public:
30
31 void finish() override;
32 void emitConstantPools() override;
33
34 /// Callback used to implement the ldr= pseudo.
35 /// Add a new entry to the constant pool for the current section and return an
36 /// MCExpr that can be used to refer to the constant pool location.
37 const MCExpr *addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc);
38
39 /// Callback used to implement the .ltorg directive.
40 /// Emit contents of constant pool for the current section.
42
43 /// Callback used to implement the .note.gnu.property section.
44 void emitNoteSection(unsigned Flags, uint64_t PAuthABIPlatform = -1,
45 uint64_t PAuthABIVersion = -1);
46
47 /// Callback used to emit AUTH expressions (e.g. signed
48 /// personality function pointer).
49 void emitAuthValue(const MCExpr *Expr, uint16_t Discriminator,
50 AArch64PACKey::ID Key, bool HasAddressDiversity);
51
52 /// Callback used to implement the .inst directive.
53 virtual void emitInst(uint32_t Inst);
54
55 /// Callback used to implement the .variant_pcs directive.
56 virtual void emitDirectiveVariantPCS(MCSymbol *Symbol) {};
57
60
61 virtual void emitARM64WinCFIAllocStack(unsigned Size) {}
63 virtual void emitARM64WinCFISaveFPLR(int Offset) {}
64 virtual void emitARM64WinCFISaveFPLRX(int Offset) {}
65 virtual void emitARM64WinCFISaveReg(unsigned Reg, int Offset) {}
66 virtual void emitARM64WinCFISaveRegX(unsigned Reg, int Offset) {}
67 virtual void emitARM64WinCFISaveRegP(unsigned Reg, int Offset) {}
68 virtual void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset) {}
69 virtual void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset) {}
70 virtual void emitARM64WinCFISaveFReg(unsigned Reg, int Offset) {}
71 virtual void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset) {}
72 virtual void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset) {}
73 virtual void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset) {}
74 virtual void emitARM64WinCFISetFP() {}
75 virtual void emitARM64WinCFIAddFP(unsigned Size) {}
76 virtual void emitARM64WinCFINop() {}
77 virtual void emitARM64WinCFISaveNext() {}
78 virtual void emitARM64WinCFIPrologEnd() {}
80 virtual void emitARM64WinCFIEpilogEnd() {}
81 virtual void emitARM64WinCFITrapFrame() {}
83 virtual void emitARM64WinCFIContext() {}
84 virtual void emitARM64WinCFIECContext() {}
86 virtual void emitARM64WinCFIPACSignLR() {}
87 virtual void emitARM64WinCFISaveAnyRegI(unsigned Reg, int Offset) {}
88 virtual void emitARM64WinCFISaveAnyRegIP(unsigned Reg, int Offset) {}
89 virtual void emitARM64WinCFISaveAnyRegD(unsigned Reg, int Offset) {}
90 virtual void emitARM64WinCFISaveAnyRegDP(unsigned Reg, int Offset) {}
91 virtual void emitARM64WinCFISaveAnyRegQ(unsigned Reg, int Offset) {}
92 virtual void emitARM64WinCFISaveAnyRegQP(unsigned Reg, int Offset) {}
93 virtual void emitARM64WinCFISaveAnyRegIX(unsigned Reg, int Offset) {}
94 virtual void emitARM64WinCFISaveAnyRegIPX(unsigned Reg, int Offset) {}
95 virtual void emitARM64WinCFISaveAnyRegDX(unsigned Reg, int Offset) {}
96 virtual void emitARM64WinCFISaveAnyRegDPX(unsigned Reg, int Offset) {}
97 virtual void emitARM64WinCFISaveAnyRegQX(unsigned Reg, int Offset) {}
98 virtual void emitARM64WinCFISaveAnyRegQPX(unsigned Reg, int Offset) {}
99 virtual void emitARM64WinCFIAllocZ(int Offset) {}
100 virtual void emitARM64WinCFISaveZReg(unsigned Reg, int Offset) {}
101 virtual void emitARM64WinCFISavePReg(unsigned Reg, int Offset) {}
102
103 /// Build attributes implementation
104 virtual void
108 virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
109 std::string String);
111 std::unique_ptr<MCELFStreamer::AttributeSubSection>
113 std::unique_ptr<MCELFStreamer::AttributeSubSection>
115 void
118
120
121private:
122 std::unique_ptr<AssemblerConstantPools> ConstantPools;
123};
124
126private:
127 AArch64ELFStreamer &getStreamer();
128
129 MCSection *AttributeSection = nullptr;
130
131 /// Build attributes implementation
132 void emitAttributesSubsection(
133 StringRef VendorName,
135 AArch64BuildAttributes::SubsectionType ParameterType) override;
136 void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
137 std::string String) override;
138 void emitInst(uint32_t Inst) override;
139 void emitDirectiveVariantPCS(MCSymbol *Symbol) override;
140 void finish() override;
141
142public:
144};
145
147public:
150
151 // The unwind codes on ARM64 Windows are documented at
152 // https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling
153 void emitARM64WinCFIAllocStack(unsigned Size) override;
154 void emitARM64WinCFISaveR19R20X(int Offset) override;
155 void emitARM64WinCFISaveFPLR(int Offset) override;
156 void emitARM64WinCFISaveFPLRX(int Offset) override;
157 void emitARM64WinCFISaveReg(unsigned Reg, int Offset) override;
158 void emitARM64WinCFISaveRegX(unsigned Reg, int Offset) override;
159 void emitARM64WinCFISaveRegP(unsigned Reg, int Offset) override;
160 void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset) override;
161 void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset) override;
162 void emitARM64WinCFISaveFReg(unsigned Reg, int Offset) override;
163 void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset) override;
164 void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset) override;
165 void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset) override;
166 void emitARM64WinCFISetFP() override;
167 void emitARM64WinCFIAddFP(unsigned Size) override;
168 void emitARM64WinCFINop() override;
169 void emitARM64WinCFISaveNext() override;
170 void emitARM64WinCFIPrologEnd() override;
171 void emitARM64WinCFIEpilogStart() override;
172 void emitARM64WinCFIEpilogEnd() override;
173 void emitARM64WinCFITrapFrame() override;
174 void emitARM64WinCFIMachineFrame() override;
175 void emitARM64WinCFIContext() override;
176 void emitARM64WinCFIECContext() override;
177 void emitARM64WinCFIClearUnwoundToCall() override;
178 void emitARM64WinCFIPACSignLR() override;
179 void emitARM64WinCFISaveAnyRegI(unsigned Reg, int Offset) override;
180 void emitARM64WinCFISaveAnyRegIP(unsigned Reg, int Offset) override;
181 void emitARM64WinCFISaveAnyRegD(unsigned Reg, int Offset) override;
182 void emitARM64WinCFISaveAnyRegDP(unsigned Reg, int Offset) override;
183 void emitARM64WinCFISaveAnyRegQ(unsigned Reg, int Offset) override;
184 void emitARM64WinCFISaveAnyRegQP(unsigned Reg, int Offset) override;
185 void emitARM64WinCFISaveAnyRegIX(unsigned Reg, int Offset) override;
186 void emitARM64WinCFISaveAnyRegIPX(unsigned Reg, int Offset) override;
187 void emitARM64WinCFISaveAnyRegDX(unsigned Reg, int Offset) override;
188 void emitARM64WinCFISaveAnyRegDPX(unsigned Reg, int Offset) override;
189 void emitARM64WinCFISaveAnyRegQX(unsigned Reg, int Offset) override;
190 void emitARM64WinCFISaveAnyRegQPX(unsigned Reg, int Offset) override;
191 void emitARM64WinCFIAllocZ(int Offset) override;
192 void emitARM64WinCFISaveZReg(unsigned Reg, int Offset) override;
193 void emitARM64WinCFISavePReg(unsigned Reg, int Offset) override;
194
195private:
196 void emitARM64WinUnwindCode(unsigned UnwindCode, int Reg, int Offset);
197};
198
199MCTargetStreamer *
200createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
201
202MCTargetStreamer *createAArch64NullTargetStreamer(MCStreamer &S);
203
204} // end namespace llvm
205
206#endif
std::string Name
uint64_t Size
Register Reg
virtual void emitARM64WinCFISaveAnyRegIX(unsigned Reg, int Offset)
void insertAttributeInPlace(const MCELFStreamer::AttributeItem &Attr, MCELFStreamer::AttributeSubSection &AttSubSection)
virtual void emitARM64WinCFISaveRegP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegQX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegDPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegDX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegQ(unsigned Reg, int Offset)
virtual void emitDirectiveArch(StringRef Name)
virtual void emitARM64WinCFISaveAnyRegQP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegD(unsigned Reg, int Offset)
virtual void emitAttributesSubsection(StringRef VendorName, AArch64BuildAttributes::SubsectionOptional IsOptional, AArch64BuildAttributes::SubsectionType ParameterType)
Build attributes implementation.
virtual void emitARM64WinCFISavePReg(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveFReg(unsigned Reg, int Offset)
virtual void emitDirectiveArchExtension(StringRef Name)
void activateAttributesSubsection(StringRef VendorName)
virtual void emitARM64WinCFISaveAnyRegI(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveRegX(unsigned Reg, int Offset)
virtual void emitARM64WinCFIAllocStack(unsigned Size)
std::unique_ptr< MCELFStreamer::AttributeSubSection > getActiveAttributesSubsection()
virtual void emitARM64WinCFISaveFPLRX(int Offset)
virtual void emitARM64WinCFIAllocZ(int Offset)
const MCExpr * addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc)
Callback used to implement the ldr= pseudo.
virtual void emitDirectiveVariantPCS(MCSymbol *Symbol)
Callback used to implement the .variant_pcs directive.
virtual void emitARM64WinCFISaveR19R20X(int Offset)
virtual void emitARM64WinCFIAddFP(unsigned Size)
virtual void emitARM64WinCFISaveFPLR(int Offset)
virtual void emitARM64WinCFIClearUnwoundToCall()
virtual void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegQPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset)
SmallVector< MCELFStreamer::AttributeSubSection, 64 > AttributeSubSections
std::unique_ptr< MCELFStreamer::AttributeSubSection > getAttributesSubsectionByName(StringRef Name)
virtual void emitARM64WinCFISaveAnyRegDP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegIPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveZReg(unsigned Reg, int Offset)
void emitNoteSection(unsigned Flags, uint64_t PAuthABIPlatform=-1, uint64_t PAuthABIVersion=-1)
Callback used to implement the .note.gnu.property section.
virtual void emitARM64WinCFISaveReg(unsigned Reg, int Offset)
void emitAuthValue(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key, bool HasAddressDiversity)
Callback used to emit AUTH expressions (e.g.
virtual void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset)
virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, std::string String)
void emitCurrentConstantPool()
Callback used to implement the .ltorg directive.
virtual void emitInst(uint32_t Inst)
Callback used to implement the .inst directive.
virtual void emitARM64WinCFISaveAnyRegIP(unsigned Reg, int Offset)
void emitARM64WinCFISaveAnyRegQX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegDX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegIP(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegQ(unsigned Reg, int Offset) override
void emitARM64WinCFIAllocZ(int Offset) override
void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset) override
void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveRegP(unsigned Reg, int Offset) override
void emitARM64WinCFISaveR19R20X(int Offset) override
void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveRegX(unsigned Reg, int Offset) override
void emitARM64WinCFISavePReg(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegQPX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegIPX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveFPLR(int Offset) override
void emitARM64WinCFISaveZReg(unsigned Reg, int Offset) override
void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset) override
AArch64TargetWinCOFFStreamer(llvm::MCStreamer &S)
void emitARM64WinCFISaveAnyRegDPX(unsigned Reg, int Offset) override
void emitARM64WinCFIAllocStack(unsigned Size) override
void emitARM64WinCFISaveAnyRegD(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegI(unsigned Reg, int Offset) override
void emitARM64WinCFISaveFReg(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegIX(unsigned Reg, int Offset) override
void emitARM64WinCFISaveFPLRX(int Offset) override
void emitARM64WinCFISaveReg(unsigned Reg, int Offset) override
void emitARM64WinCFIAddFP(unsigned Size) override
void emitARM64WinCFISaveAnyRegDP(unsigned Reg, int Offset) override
void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset) override
void emitARM64WinCFISaveAnyRegQP(unsigned Reg, int Offset) override
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:496
Streaming machine code generation interface.
Definition: MCStreamer.h:220
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
Target specific streamer interface.
Definition: MCStreamer.h:93
Represents a location in source code.
Definition: SMLoc.h:23
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
LLVM Value Representation.
Definition: Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
MCTargetStreamer * createAArch64NullTargetStreamer(MCStreamer &S)
MCTargetStreamer * createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
ELF object attributes section emission support.
Definition: MCELFStreamer.h:77
ELF object attributes subsection support.
Definition: MCELFStreamer.h:95