LLVM  13.0.0git
PPCELFStreamer.h
Go to the documentation of this file.
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  void emitGOTToPCRelReloc(const MCInst &Inst);
47  void emitGOTToPCRelLabel(const MCInst &Inst);
48 };
49 
50 // Check if the instruction Inst is part of a pair of instructions that make up
51 // a link time GOT PC Rel optimization.
53  const MCSubtargetInfo &STI);
54 
56  std::unique_ptr<MCAsmBackend> MAB,
57  std::unique_ptr<MCObjectWriter> OW,
58  std::unique_ptr<MCCodeEmitter> Emitter);
59 } // end namespace llvm
60 
61 #endif // LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:71
llvm::Optional< bool >
llvm::PPCELFStreamer::emitInstruction
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
Definition: PPCELFStreamer.cpp:88
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::PPCELFStreamer
Definition: PPCELFStreamer.h:28
MCELFStreamer.h
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MCELFStreamer
Definition: MCELFStreamer.h:24
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::PPCELFStreamer::PPCELFStreamer
PPCELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Definition: PPCELFStreamer.cpp:40
llvm::PPCELFStreamer::emitLabel
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
Definition: PPCELFStreamer.cpp:122
llvm::createPPCELFStreamer
MCELFStreamer * createPPCELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Definition: PPCELFStreamer.cpp:224
llvm::isPartOfGOTToPCRelPair
Optional< bool > isPartOfGOTToPCRelPair(const MCInst &Inst, const MCSubtargetInfo &STI)
Definition: PPCELFStreamer.cpp:201
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
SmallVector.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75