PPCELFStreamer.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H
  14. #define LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H
  15. #include "llvm/ADT/SmallVector.h"
  16. #include "llvm/MC/MCELFStreamer.h"
  17. #include <memory>
  18. namespace llvm {
  19. class MCAsmBackend;
  20. class MCCodeEmitter;
  21. class MCContext;
  22. class MCSubtargetInfo;
  23. class PPCELFStreamer : public MCELFStreamer {
  24. // We need to keep track of the last label we emitted (only one) because
  25. // depending on whether the label is on the same line as an aligned
  26. // instruction or not, the label may refer to the instruction or the nop.
  27. MCSymbol *LastLabel;
  28. SMLoc LastLabelLoc;
  29. public:
  30. PPCELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
  31. std::unique_ptr<MCObjectWriter> OW,
  32. std::unique_ptr<MCCodeEmitter> Emitter);
  33. void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
  34. // EmitLabel updates LastLabel and LastLabelLoc when a new label is emitted.
  35. void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
  36. private:
  37. void emitPrefixedInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
  38. void emitGOTToPCRelReloc(const MCInst &Inst);
  39. void emitGOTToPCRelLabel(const MCInst &Inst);
  40. };
  41. // Check if the instruction Inst is part of a pair of instructions that make up
  42. // a link time GOT PC Rel optimization.
  43. Optional<bool> isPartOfGOTToPCRelPair(const MCInst &Inst,
  44. const MCSubtargetInfo &STI);
  45. MCELFStreamer *createPPCELFStreamer(MCContext &Context,
  46. std::unique_ptr<MCAsmBackend> MAB,
  47. std::unique_ptr<MCObjectWriter> OW,
  48. std::unique_ptr<MCCodeEmitter> Emitter);
  49. } // end namespace llvm
  50. #endif // LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H