xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.h (revision a0409676120c1e558d0ade943019934e0f15118d)
1 //===- PPCELFStreamer.h - ELF Object Output --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This is a custom MCELFStreamer for PowerPC.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H
15 #define LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H
16 
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/MC/MCELFStreamer.h"
19 #include <memory>
20 
21 namespace llvm {
22 
23 class MCAsmBackend;
24 class MCCodeEmitter;
25 class MCContext;
26 class MCSubtargetInfo;
27 
28 class PPCELFStreamer : public MCELFStreamer {
29   // We need to keep track of the last label we emitted (only one) because
30   // depending on whether the label is on the same line as an aligned
31   // instruction or not, the label may refer to the instruction or the nop.
32   MCSymbol *LastLabel;
33   SMLoc LastLabelLoc;
34 
35 public:
36   PPCELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
37                  std::unique_ptr<MCObjectWriter> OW,
38                  std::unique_ptr<MCCodeEmitter> Emitter);
39 
40   void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
41 
42   // EmitLabel updates LastLabel and LastLabelLoc when a new label is emitted.
43   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
44 private:
45   void emitPrefixedInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
46 };
47 
48 MCELFStreamer *createPPCELFStreamer(MCContext &Context,
49                                     std::unique_ptr<MCAsmBackend> MAB,
50                                     std::unique_ptr<MCObjectWriter> OW,
51                                     std::unique_ptr<MCCodeEmitter> Emitter);
52 } // end namespace llvm
53 
54 #endif // LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H
55