LLVM  14.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 "llvm/MC/MCStreamer.h"
13 
14 namespace {
15 class AArch64ELFStreamer;
16 }
17 
18 namespace llvm {
19 
21 public:
23  ~AArch64TargetStreamer() override;
24 
25  void finish() override;
26  void emitConstantPools() override;
27 
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);
32 
33  /// Callback used to implemnt the .ltorg directive.
34  /// Emit contents of constant pool for the current section.
36 
37  /// Callback used to implement the .note.gnu.property section.
38  void emitNoteSection(unsigned Flags);
39 
40  /// Callback used to implement the .inst directive.
41  virtual void emitInst(uint32_t Inst);
42 
43  /// Callback used to implement the .variant_pcs directive.
45 
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() {}
70 
71 private:
72  std::unique_ptr<AssemblerConstantPools> ConstantPools;
73 };
74 
76 private:
77  AArch64ELFStreamer &getStreamer();
78 
79  void emitInst(uint32_t Inst) override;
80  void emitDirectiveVariantPCS(MCSymbol *Symbol) override;
81 
82 public:
84 };
85 
87 private:
88  // True if we are processing SEH directives in an epilogue.
89  bool InEpilogCFI = false;
90 
91  // Symbol of the current epilog for which we are processing SEH directives.
92  MCSymbol *CurrentEpilog = nullptr;
93 public:
96 
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;
123 
124 private:
125  void emitARM64WinUnwindCode(unsigned UnwindCode, int Reg, int Offset);
126 };
127 
128 MCTargetStreamer *
129 createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
130 
131 } // end namespace llvm
132 
133 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveReg
void emitARM64WinCFISaveReg(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:103
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIClearUnwoundToCall
void emitARM64WinCFIClearUnwoundToCall() override
Definition: AArch64WinCOFFStreamer.cpp:219
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::AArch64TargetStreamer::emitARM64WinCFISaveNext
virtual void emitARM64WinCFISaveNext()
Definition: AArch64TargetStreamer.h:62
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::AArch64TargetStreamer::emitARM64WinCFISaveRegPX
virtual void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:53
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIAddFP
void emitARM64WinCFIAddFP(unsigned Size) override
Definition: AArch64WinCOFFStreamer.cpp:156
llvm::AArch64TargetStreamer::emitNoteSection
void emitNoteSection(unsigned Flags)
Callback used to implement the .note.gnu.property section.
Definition: AArch64TargetStreamer.cpp:62
llvm::AArch64TargetStreamer::emitARM64WinCFISaveFPLRX
virtual void emitARM64WinCFISaveFPLRX(int Offset)
Definition: AArch64TargetStreamer.h:49
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveFRegP
void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:142
llvm::AArch64TargetStreamer::emitInst
virtual void emitInst(uint32_t Inst)
Callback used to implement the .inst directive.
Definition: AArch64TargetStreamer.cpp:98
llvm::AArch64TargetStreamer::emitARM64WinCFISetFP
virtual void emitARM64WinCFISetFP()
Definition: AArch64TargetStreamer.h:59
llvm::AArch64TargetStreamer::emitARM64WinCFITrapFrame
virtual void emitARM64WinCFITrapFrame()
Definition: AArch64TargetStreamer.h:66
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveFRegX
void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:137
llvm::AArch64TargetStreamer::emitARM64WinCFISaveRegP
virtual void emitARM64WinCFISaveRegP(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:52
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveRegP
void emitARM64WinCFISaveRegP(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:115
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveRegX
void emitARM64WinCFISaveRegX(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:110
llvm::createAArch64ObjectTargetStreamer
MCTargetStreamer * createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition: AArch64TargetStreamer.cpp:113
llvm::AArch64TargetStreamer::emitARM64WinCFISaveReg
virtual void emitARM64WinCFISaveReg(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:50
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::AArch64TargetStreamer::AArch64TargetStreamer
AArch64TargetStreamer(MCStreamer &S)
Definition: AArch64TargetStreamer.cpp:34
llvm::AArch64TargetStreamer::emitARM64WinCFIAddFP
virtual void emitARM64WinCFIAddFP(unsigned Size)
Definition: AArch64TargetStreamer.h:60
llvm::AArch64TargetELFStreamer::AArch64TargetELFStreamer
AArch64TargetELFStreamer(MCStreamer &S)
Definition: AArch64TargetStreamer.h:83
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIMachineFrame
void emitARM64WinCFIMachineFrame() override
Definition: AArch64WinCOFFStreamer.cpp:211
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFITrapFrame
void emitARM64WinCFITrapFrame() override
Definition: AArch64WinCOFFStreamer.cpp:207
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveR19R20X
void emitARM64WinCFISaveR19R20X(int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:91
llvm::AArch64TargetStreamer::emitARM64WinCFISaveFPLR
virtual void emitARM64WinCFISaveFPLR(int Offset)
Definition: AArch64TargetStreamer.h:48
llvm::AArch64TargetStreamer::emitARM64WinCFISaveRegX
virtual void emitARM64WinCFISaveRegX(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:51
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
llvm::AArch64TargetELFStreamer
Definition: AArch64TargetStreamer.h:75
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIEpilogEnd
void emitARM64WinCFIEpilogEnd() override
Definition: AArch64WinCOFFStreamer.cpp:194
llvm::AArch64TargetStreamer::emitDirectiveVariantPCS
virtual void emitDirectiveVariantPCS(MCSymbol *Symbol)
Callback used to implement the .variant_pcs directive.
Definition: AArch64TargetStreamer.h:44
llvm::AArch64TargetStreamer::emitARM64WinCFIEpilogEnd
virtual void emitARM64WinCFIEpilogEnd()
Definition: AArch64TargetStreamer.h:65
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveFPLR
void emitARM64WinCFISaveFPLR(int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:95
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIContext
void emitARM64WinCFIContext() override
Definition: AArch64WinCOFFStreamer.cpp:215
llvm::AArch64TargetWinCOFFStreamer
Definition: AArch64TargetStreamer.h:86
llvm::AArch64TargetStreamer::emitARM64WinCFISaveFReg
virtual void emitARM64WinCFISaveFReg(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:55
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIAllocStack
void emitARM64WinCFIAllocStack(unsigned Size) override
Definition: AArch64WinCOFFStreamer.cpp:82
llvm::AArch64TargetStreamer::emitARM64WinCFINop
virtual void emitARM64WinCFINop()
Definition: AArch64TargetStreamer.h:61
llvm::AArch64TargetStreamer::emitARM64WinCFISaveFRegPX
virtual void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:58
llvm::AArch64TargetStreamer
Definition: AArch64TargetStreamer.h:20
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIEpilogStart
void emitARM64WinCFIEpilogStart() override
Definition: AArch64WinCOFFStreamer.cpp:184
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFINop
void emitARM64WinCFINop() override
Definition: AArch64WinCOFFStreamer.cpp:161
llvm::AArch64TargetStreamer::emitARM64WinCFISaveLRPair
virtual void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:54
llvm::AArch64TargetStreamer::~AArch64TargetStreamer
~AArch64TargetStreamer() override
llvm::AArch64TargetStreamer::emitARM64WinCFISaveR19R20X
virtual void emitARM64WinCFISaveR19R20X(int Offset)
Definition: AArch64TargetStreamer.h:47
llvm::AArch64TargetStreamer::emitARM64WinCFIAllocStack
virtual void emitARM64WinCFIAllocStack(unsigned Size)
Definition: AArch64TargetStreamer.h:46
uint32_t
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::AArch64TargetStreamer::finish
void finish() override
Definition: AArch64TargetStreamer.cpp:57
llvm::AArch64TargetStreamer::emitARM64WinCFISaveFRegP
virtual void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:57
llvm::AArch64TargetStreamer::emitARM64WinCFIPrologEnd
virtual void emitARM64WinCFIPrologEnd()
Definition: AArch64TargetStreamer.h:63
llvm::AArch64TargetStreamer::emitConstantPools
void emitConstantPools() override
Definition: AArch64TargetStreamer.cpp:51
llvm::AArch64TargetStreamer::emitARM64WinCFIClearUnwoundToCall
virtual void emitARM64WinCFIClearUnwoundToCall()
Definition: AArch64TargetStreamer.h:69
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveNext
void emitARM64WinCFISaveNext() override
Definition: AArch64WinCOFFStreamer.cpp:165
llvm::AArch64TargetStreamer::emitARM64WinCFISaveFRegX
virtual void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset)
Definition: AArch64TargetStreamer.h:56
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveFPLRX
void emitARM64WinCFISaveFPLRX(int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:99
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
llvm::AArch64TargetStreamer::addConstantPoolEntry
const MCExpr * addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc)
Callback used to implement the ldr= pseudo.
Definition: AArch64TargetStreamer.cpp:41
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveRegPX
void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:120
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveFReg
void emitARM64WinCFISaveFReg(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:130
llvm::AArch64TargetWinCOFFStreamer::AArch64TargetWinCOFFStreamer
AArch64TargetWinCOFFStreamer(llvm::MCStreamer &S)
Definition: AArch64TargetStreamer.h:94
MCStreamer.h
llvm::AArch64TargetStreamer::emitARM64WinCFIContext
virtual void emitARM64WinCFIContext()
Definition: AArch64TargetStreamer.h:68
llvm::AArch64TargetStreamer::emitARM64WinCFIMachineFrame
virtual void emitARM64WinCFIMachineFrame()
Definition: AArch64TargetStreamer.h:67
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveLRPair
void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:125
llvm::AArch64TargetStreamer::emitARM64WinCFIEpilogStart
virtual void emitARM64WinCFIEpilogStart()
Definition: AArch64TargetStreamer.h:64
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFIPrologEnd
void emitARM64WinCFIPrologEnd() override
Definition: AArch64WinCOFFStreamer.cpp:171
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISetFP
void emitARM64WinCFISetFP() override
Definition: AArch64WinCOFFStreamer.cpp:152
llvm::AArch64TargetWinCOFFStreamer::emitARM64WinCFISaveFRegPX
void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset) override
Definition: AArch64WinCOFFStreamer.cpp:147
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::AArch64TargetStreamer::emitCurrentConstantPool
void emitCurrentConstantPool()
Callback used to implemnt the .ltorg directive.
Definition: AArch64TargetStreamer.cpp:47