LLVM 24.0.0git
MipsELFStreamer.h
Go to the documentation of this file.
1//===- MipsELFStreamer.h - ELF Object Output --------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This is a custom MCELFStreamer which allows us to insert some hooks before
10// emitting data into an actual object file.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
15#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
16
17#include "MipsOptionRecord.h"
20#include <memory>
21
22namespace llvm {
23
24class MCAsmBackend;
25class MCCodeEmitter;
26class MCContext;
27class MCSubtargetInfo;
28struct MCDwarfFrameInfo;
29
32 MipsRegInfoRecord *RegInfoRecord;
34
35public:
36 MipsELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
37 std::unique_ptr<MCObjectWriter> OW,
38 std::unique_ptr<MCCodeEmitter> Emitter);
39
40 /// Overriding this function allows us to add arbitrary behaviour before the
41 /// \p Inst is actually emitted. For example, we can inspect the operands and
42 /// gather sufficient information that allows us to reason about the register
43 /// usage for the translation unit.
44 void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
45
46 /// Overriding this function allows us to record all labels that should be
47 /// marked as microMIPS. Based on this data marking is done in
48 /// EmitInstruction.
49 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
50
51 /// Overriding this function allows us to dismiss all labels that are
52 /// candidates for marking as microMIPS when .section directive is processed.
53 void switchSection(MCSection *Section, uint32_t Subsection = 0) override;
54
55 /// Overriding these functions allows us to dismiss all labels that are
56 /// candidates for marking as microMIPS when .word/.long/.4byte etc
57 /// directives are emitted.
58 void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
59 void emitIntValue(uint64_t Value, unsigned Size) override;
60 void emitBytes(StringRef Data) override;
62 void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
63 SMLoc Loc = SMLoc()) override;
64 void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
65 SMLoc Loc = SMLoc()) override;
66
67 // Overriding these functions allows us to avoid recording of these labels
68 // in EmitLabel and later marking them as microMIPS.
69 void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
70 void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
71 MCSymbol *emitCFILabel() override;
72
73 /// Emits all the option records stored up until the point it's called.
75
76 /// Mark labels as microMIPS, if necessary for the subtarget.
78};
79
81 std::unique_ptr<MCAsmBackend> MAB,
82 std::unique_ptr<MCObjectWriter> OW,
83 std::unique_ptr<MCCodeEmitter> Emitter);
84} // end namespace llvm
85
86#endif // LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
unsigned uint64_t
dxil DXContainer Global Emitter
This file defines the SmallVector class.
Generic interface to target specific assembler backends.
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
MCELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override
void EmitMipsOptionRecords()
Emits all the option records stored up until the point it's called.
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Overriding this function allows us to add arbitrary behaviour before the Inst is actually emitted.
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Overriding this function allows us to record all labels that should be marked as microMIPS.
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
MipsELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
MCSymbol * emitCFILabel() override
When emitting an object file, create and emit a real label.
void createPendingLabelRelocs()
Mark labels as microMIPS, if necessary for the subtarget.
void switchSection(MCSection *Section, uint32_t Subsection=0) override
Overriding this function allows us to dismiss all labels that are candidates for marking as microMIPS...
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void emitIntValue(uint64_t Value, unsigned Size) override
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override
Overriding these functions allows us to dismiss all labels that are candidates for marking as microMI...
Represents a location in source code.
Definition SMLoc.h:22
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
MCELFStreamer * createMipsELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)