LLVM  4.0.0
MipsELFStreamer.h
Go to the documentation of this file.
1 //===-------- MipsELFStreamer.h - ELF Object Output -----------------------===//
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 class MCAsmBackend;
25 class MCCodeEmitter;
26 class MCContext;
27 class MCSubtargetInfo;
28 
31  MipsRegInfoRecord *RegInfoRecord;
33 
34 
35 public:
37  MCCodeEmitter *Emitter)
38  : MCELFStreamer(Context, MAB, OS, Emitter) {
39 
40  RegInfoRecord = new MipsRegInfoRecord(this, Context);
41  MipsOptionRecords.push_back(
42  std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord));
43  }
44 
45  /// Overriding this function allows us to add arbitrary behaviour before the
46  /// \p Inst is actually emitted. For example, we can inspect the operands and
47  /// gather sufficient information that allows us to reason about the register
48  /// usage for the translation unit.
49  void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
50 
51  /// Overriding this function allows us to record all labels that should be
52  /// marked as microMIPS. Based on this data marking is done in
53  /// EmitInstruction.
54  void EmitLabel(MCSymbol *Symbol) override;
55 
56  /// Overriding this function allows us to dismiss all labels that are
57  /// candidates for marking as microMIPS when .section directive is processed.
59  const MCExpr *Subsection = nullptr) override;
60 
61  /// Overriding this function allows us to dismiss all labels that are
62  /// candidates for marking as microMIPS when .word directive is emitted.
63  void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
64 
65  /// Emits all the option records stored up until the point it's called.
66  void EmitMipsOptionRecords();
67 
68  /// Mark labels as microMIPS, if necessary for the subtarget.
70 };
71 
72 MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
73  raw_pwrite_stream &OS,
74  MCCodeEmitter *Emitter, bool RelaxAll);
75 } // namespace llvm.
76 #endif
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
LLVMContext & Context
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
void createPendingLabelRelocs()
Mark labels as microMIPS, if necessary for the subtarget.
Context object for machine code objects.
Definition: MCContext.h:51
void EmitLabel(MCSymbol *Symbol) override
Overriding this function allows us to record all labels that should be marked as microMIPS.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
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...
MCELFStreamer * createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
void EmitMipsOptionRecords()
Emits all the option records stored up until the point it's called.
void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override
Overriding this function allows us to dismiss all labels that are candidates for marking as microMIPS...
MCSubtargetInfo - Generic base class for all target subtargets.
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
LLVM Value Representation.
Definition: Value.h:71
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Overriding this function allows us to add arbitrary behaviour before the Inst is actually emitted...
Represents a location in source code.
Definition: SMLoc.h:24