1 //===-- AArch64TargetStreamer.h - AArch64 Target Streamer ------*- 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_AARCH64_MCTARGETDESC_AARCH64TARGETSTREAMER_H
10 #define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64TARGETSTREAMER_H
12 #include "llvm/MC/MCStreamer.h"
15 class AArch64ELFStreamer
;
20 class AArch64TargetStreamer
: public MCTargetStreamer
{
22 AArch64TargetStreamer(MCStreamer
&S
);
23 ~AArch64TargetStreamer() override
;
25 void finish() override
;
26 void emitConstantPools() override
;
28 /// Callback used to implement the ldr= pseudo.
29 /// Add a new entry to the constant pool for the current section and return an
30 /// MCExpr that can be used to refer to the constant pool location.
31 const MCExpr
*addConstantPoolEntry(const MCExpr
*, unsigned Size
, SMLoc Loc
);
33 /// Callback used to implemnt the .ltorg directive.
34 /// Emit contents of constant pool for the current section.
35 void emitCurrentConstantPool();
37 /// Callback used to implement the .note.gnu.property section.
38 void emitNoteSection(unsigned Flags
);
40 /// Callback used to implement the .inst directive.
41 virtual void emitInst(uint32_t Inst
);
43 /// Callback used to implement the .variant_pcs directive.
44 virtual void emitDirectiveVariantPCS(MCSymbol
*Symbol
) {};
46 virtual void emitARM64WinCFIAllocStack(unsigned Size
) {}
47 virtual void emitARM64WinCFISaveR19R20X(int Offset
) {}
48 virtual void emitARM64WinCFISaveFPLR(int Offset
) {}
49 virtual void emitARM64WinCFISaveFPLRX(int Offset
) {}
50 virtual void emitARM64WinCFISaveReg(unsigned Reg
, int Offset
) {}
51 virtual void emitARM64WinCFISaveRegX(unsigned Reg
, int Offset
) {}
52 virtual void emitARM64WinCFISaveRegP(unsigned Reg
, int Offset
) {}
53 virtual void emitARM64WinCFISaveRegPX(unsigned Reg
, int Offset
) {}
54 virtual void emitARM64WinCFISaveLRPair(unsigned Reg
, int Offset
) {}
55 virtual void emitARM64WinCFISaveFReg(unsigned Reg
, int Offset
) {}
56 virtual void emitARM64WinCFISaveFRegX(unsigned Reg
, int Offset
) {}
57 virtual void emitARM64WinCFISaveFRegP(unsigned Reg
, int Offset
) {}
58 virtual void emitARM64WinCFISaveFRegPX(unsigned Reg
, int Offset
) {}
59 virtual void emitARM64WinCFISetFP() {}
60 virtual void emitARM64WinCFIAddFP(unsigned Size
) {}
61 virtual void emitARM64WinCFINop() {}
62 virtual void emitARM64WinCFISaveNext() {}
63 virtual void emitARM64WinCFIPrologEnd() {}
64 virtual void emitARM64WinCFIEpilogStart() {}
65 virtual void emitARM64WinCFIEpilogEnd() {}
66 virtual void emitARM64WinCFITrapFrame() {}
67 virtual void emitARM64WinCFIMachineFrame() {}
68 virtual void emitARM64WinCFIContext() {}
69 virtual void emitARM64WinCFIClearUnwoundToCall() {}
72 std::unique_ptr
<AssemblerConstantPools
> ConstantPools
;
75 class AArch64TargetELFStreamer
: public AArch64TargetStreamer
{
77 AArch64ELFStreamer
&getStreamer();
79 void emitInst(uint32_t Inst
) override
;
80 void emitDirectiveVariantPCS(MCSymbol
*Symbol
) override
;
83 AArch64TargetELFStreamer(MCStreamer
&S
) : AArch64TargetStreamer(S
) {}
86 class AArch64TargetWinCOFFStreamer
: public llvm::AArch64TargetStreamer
{
88 // True if we are processing SEH directives in an epilogue.
89 bool InEpilogCFI
= false;
91 // Symbol of the current epilog for which we are processing SEH directives.
92 MCSymbol
*CurrentEpilog
= nullptr;
94 AArch64TargetWinCOFFStreamer(llvm::MCStreamer
&S
)
95 : AArch64TargetStreamer(S
) {}
97 // The unwind codes on ARM64 Windows are documented at
98 // https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling
99 void emitARM64WinCFIAllocStack(unsigned Size
) override
;
100 void emitARM64WinCFISaveR19R20X(int Offset
) override
;
101 void emitARM64WinCFISaveFPLR(int Offset
) override
;
102 void emitARM64WinCFISaveFPLRX(int Offset
) override
;
103 void emitARM64WinCFISaveReg(unsigned Reg
, int Offset
) override
;
104 void emitARM64WinCFISaveRegX(unsigned Reg
, int Offset
) override
;
105 void emitARM64WinCFISaveRegP(unsigned Reg
, int Offset
) override
;
106 void emitARM64WinCFISaveRegPX(unsigned Reg
, int Offset
) override
;
107 void emitARM64WinCFISaveLRPair(unsigned Reg
, int Offset
) override
;
108 void emitARM64WinCFISaveFReg(unsigned Reg
, int Offset
) override
;
109 void emitARM64WinCFISaveFRegX(unsigned Reg
, int Offset
) override
;
110 void emitARM64WinCFISaveFRegP(unsigned Reg
, int Offset
) override
;
111 void emitARM64WinCFISaveFRegPX(unsigned Reg
, int Offset
) override
;
112 void emitARM64WinCFISetFP() override
;
113 void emitARM64WinCFIAddFP(unsigned Size
) override
;
114 void emitARM64WinCFINop() override
;
115 void emitARM64WinCFISaveNext() override
;
116 void emitARM64WinCFIPrologEnd() override
;
117 void emitARM64WinCFIEpilogStart() override
;
118 void emitARM64WinCFIEpilogEnd() override
;
119 void emitARM64WinCFITrapFrame() override
;
120 void emitARM64WinCFIMachineFrame() override
;
121 void emitARM64WinCFIContext() override
;
122 void emitARM64WinCFIClearUnwoundToCall() override
;
125 void emitARM64WinUnwindCode(unsigned UnwindCode
, int Reg
, int Offset
);
129 createAArch64ObjectTargetStreamer(MCStreamer
&S
, const MCSubtargetInfo
&STI
);
131 } // end namespace llvm