LLVM  7.0.0
MipsELFStreamer.h
Go to the documentation of this file.
1 //===- MipsELFStreamer.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 which allows us to insert some hooks before
11 // emitting data into an actual object file.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
16 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
17 
18 #include "MipsOptionRecord.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/MC/MCELFStreamer.h"
21 #include <memory>
22 
23 namespace llvm {
24 
25 class MCAsmBackend;
26 class MCCodeEmitter;
27 class MCContext;
28 class MCSubtargetInfo;
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,
45  bool = false) override;
46 
47  /// Overriding this function allows us to record all labels that should be
48  /// marked as microMIPS. Based on this data marking is done in
49  /// EmitInstruction.
50  void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
51 
52  /// Overriding this function allows us to dismiss all labels that are
53  /// candidates for marking as microMIPS when .section directive is processed.
55  const MCExpr *Subsection = nullptr) override;
56 
57  /// Overriding these functions allows us to dismiss all labels that are
58  /// candidates for marking as microMIPS when .word/.long/.4byte etc
59  /// directives are emitted.
60  void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
61  void EmitIntValue(uint64_t Value, unsigned Size) override;
62 
63  /// Emits all the option records stored up until the point it's called.
64  void EmitMipsOptionRecords();
65 
66  /// Mark labels as microMIPS, if necessary for the subtarget.
68 };
69 
71  std::unique_ptr<MCAsmBackend> MAB,
72  std::unique_ptr<MCObjectWriter> OW,
73  std::unique_ptr<MCCodeEmitter> Emitter,
74  bool RelaxAll);
75 } // end namespace llvm
76 
77 #endif // LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
LLVMContext & Context
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
MipsELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, 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:36
void createPendingLabelRelocs()
Mark labels as microMIPS, if necessary for the subtarget.
Context object for machine code objects.
Definition: MCContext.h:63
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
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...
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...
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
void EmitMipsOptionRecords()
Emits all the option records stored up until the point it&#39;s called.
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...
Generic base class for all target subtargets.
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Overriding this function allows us to record all labels that should be marked as microMIPS.
MCELFStreamer * createMipsELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, bool RelaxAll)
LLVM Value Representation.
Definition: Value.h:73
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Represents a location in source code.
Definition: SMLoc.h:24
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool=false) override
Overriding this function allows us to add arbitrary behaviour before the Inst is actually emitted...