Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h
35294 views
//===- MipsELFStreamer.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 which allows us to insert some hooks before9// emitting data into an actual object file.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H14#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H1516#include "MipsOptionRecord.h"17#include "llvm/ADT/SmallVector.h"18#include "llvm/MC/MCELFStreamer.h"19#include <memory>2021namespace llvm {2223class MCAsmBackend;24class MCCodeEmitter;25class MCContext;26class MCSubtargetInfo;27struct MCDwarfFrameInfo;2829class MipsELFStreamer : public MCELFStreamer {30SmallVector<std::unique_ptr<MipsOptionRecord>, 8> MipsOptionRecords;31MipsRegInfoRecord *RegInfoRecord;32SmallVector<MCSymbol*, 4> Labels;3334public:35MipsELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,36std::unique_ptr<MCObjectWriter> OW,37std::unique_ptr<MCCodeEmitter> Emitter);3839/// Overriding this function allows us to add arbitrary behaviour before the40/// \p Inst is actually emitted. For example, we can inspect the operands and41/// gather sufficient information that allows us to reason about the register42/// usage for the translation unit.43void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;4445/// Overriding this function allows us to record all labels that should be46/// marked as microMIPS. Based on this data marking is done in47/// EmitInstruction.48void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;4950/// Overriding this function allows us to dismiss all labels that are51/// candidates for marking as microMIPS when .section directive is processed.52void switchSection(MCSection *Section, uint32_t Subsection = 0) override;5354/// Overriding these functions allows us to dismiss all labels that are55/// candidates for marking as microMIPS when .word/.long/.4byte etc56/// directives are emitted.57void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;58void emitIntValue(uint64_t Value, unsigned Size) override;5960// Overriding these functions allows us to avoid recording of these labels61// in EmitLabel and later marking them as microMIPS.62void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;63void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;64MCSymbol *emitCFILabel() override;6566/// Emits all the option records stored up until the point it's called.67void EmitMipsOptionRecords();6869/// Mark labels as microMIPS, if necessary for the subtarget.70void createPendingLabelRelocs();71};7273MCELFStreamer *createMipsELFStreamer(MCContext &Context,74std::unique_ptr<MCAsmBackend> MAB,75std::unique_ptr<MCObjectWriter> OW,76std::unique_ptr<MCCodeEmitter> Emitter);77} // end namespace llvm7879#endif // LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H808182