Path: blob/main/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.h
35294 views
//===- PPCELFStreamer.h - ELF Object Output --------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This is a custom MCELFStreamer for PowerPC.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H13#define LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H1415#include "llvm/MC/MCELFStreamer.h"16#include <memory>1718namespace llvm {1920class MCAsmBackend;21class MCCodeEmitter;22class MCContext;23class MCSubtargetInfo;2425class PPCELFStreamer : public MCELFStreamer {26// We need to keep track of the last label we emitted (only one) because27// depending on whether the label is on the same line as an aligned28// instruction or not, the label may refer to the instruction or the nop.29MCSymbol *LastLabel;30SMLoc LastLabelLoc;3132public:33PPCELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,34std::unique_ptr<MCObjectWriter> OW,35std::unique_ptr<MCCodeEmitter> Emitter);3637void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;3839// EmitLabel updates LastLabel and LastLabelLoc when a new label is emitted.40void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;41private:42void emitPrefixedInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);43void emitGOTToPCRelReloc(const MCInst &Inst);44void emitGOTToPCRelLabel(const MCInst &Inst);45};4647// Check if the instruction Inst is part of a pair of instructions that make up48// a link time GOT PC Rel optimization.49std::optional<bool> isPartOfGOTToPCRelPair(const MCInst &Inst,50const MCSubtargetInfo &STI);5152MCELFStreamer *createPPCELFStreamer(MCContext &Context,53std::unique_ptr<MCAsmBackend> MAB,54std::unique_ptr<MCObjectWriter> OW,55std::unique_ptr<MCCodeEmitter> Emitter);56} // end namespace llvm5758#endif // LLVM_LIB_TARGET_PPC_MCELFSTREAMER_PPCELFSTREAMER_H596061