LLVM  14.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"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/MC/MCELFStreamer.h"
20 #include <memory>
21 
22 namespace llvm {
23 
24 class MCAsmBackend;
25 class MCCodeEmitter;
26 class MCContext;
27 class MCSubtargetInfo;
28 struct MCDwarfFrameInfo;
29 
32  MipsRegInfoRecord *RegInfoRecord;
34 
35 public:
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.
54  const MCExpr *Subsection = nullptr) override;
55 
56  /// Overriding these functions allows us to dismiss all labels that are
57  /// candidates for marking as microMIPS when .word/.long/.4byte etc
58  /// directives are emitted.
59  void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
60  void emitIntValue(uint64_t Value, unsigned Size) override;
61 
62  // Overriding these functions allows us to avoid recording of these labels
63  // in EmitLabel and later marking them as microMIPS.
64  void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
65  void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
66  MCSymbol *emitCFILabel() override;
67 
68  /// Emits all the option records stored up until the point it's called.
69  void EmitMipsOptionRecords();
70 
71  /// Mark labels as microMIPS, if necessary for the subtarget.
73 };
74 
76  std::unique_ptr<MCAsmBackend> MAB,
77  std::unique_ptr<MCObjectWriter> OW,
78  std::unique_ptr<MCCodeEmitter> Emitter,
79  bool RelaxAll);
80 } // end namespace llvm
81 
82 #endif // LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::MipsELFStreamer::emitCFIEndProcImpl
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override
Definition: MipsELFStreamer.cpp:67
llvm
This is an optimization pass for GlobalISel generic memory operations.
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:72
llvm::MipsELFStreamer::emitIntValue
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.
Definition: MipsELFStreamer.cpp:105
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::MipsELFStreamer::SwitchSection
void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr) override
Overriding this function allows us to dismiss all labels that are candidates for marking as microMIPS...
Definition: MipsELFStreamer.cpp:93
llvm::createMipsELFStreamer
MCELFStreamer * createMipsELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, bool RelaxAll)
Definition: MipsELFStreamer.cpp:115
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::MipsRegInfoRecord
Definition: MipsOptionRecord.h:38
MCELFStreamer.h
Context
ManagedStatic< detail::RecordContext > Context
Definition: Record.cpp:96
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::MipsELFStreamer::MipsELFStreamer
MipsELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Definition: MipsELFStreamer.cpp:25
llvm::MCELFStreamer
Definition: MCELFStreamer.h:24
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::MipsELFStreamer::emitCFILabel
MCSymbol * emitCFILabel() override
When emitting an object file, create and emit a real label.
Definition: MipsELFStreamer.cpp:61
MipsOptionRecord.h
llvm::MipsELFStreamer::emitCFIStartProcImpl
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override
Definition: MipsELFStreamer.cpp:56
uint64_t
llvm::MipsELFStreamer::createPendingLabelRelocs
void createPendingLabelRelocs()
Mark labels as microMIPS, if necessary for the subtarget.
Definition: MipsELFStreamer.cpp:72
llvm::MipsELFStreamer::emitValueImpl
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...
Definition: MipsELFStreamer.cpp:99
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
llvm::MipsELFStreamer::emitInstruction
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Overriding this function allows us to add arbitrary behaviour before the Inst is actually emitted.
Definition: MipsELFStreamer.cpp:36
llvm::MipsELFStreamer
Definition: MipsELFStreamer.h:30
llvm::MipsELFStreamer::EmitMipsOptionRecords
void EmitMipsOptionRecords()
Emits all the option records stored up until the point it's called.
Definition: MipsELFStreamer.cpp:110
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
SmallVector.h
llvm::MipsELFStreamer::emitLabel
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Overriding this function allows us to record all labels that should be marked as microMIPS.
Definition: MipsELFStreamer.cpp:88
llvm::MCDwarfFrameInfo
Definition: MCDwarf.h:673
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35