1 //===-------- MipsELFStreamer.h - ELF Object Output -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This is a custom MCELFStreamer which allows us to insert some hooks before
11 // emitting data into an actual object file.
13 //===----------------------------------------------------------------------===//
15 #ifndef MIPSELFSTREAMER_H
16 #define MIPSELFSTREAMER_H
18 #include "MipsOptionRecord.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/MC/MCELFStreamer.h"
27 class MCSubtargetInfo;
29 class MipsELFStreamer : public MCELFStreamer {
30 SmallVector<std::unique_ptr<MipsOptionRecord>, 8> MipsOptionRecords;
31 MipsRegInfoRecord *RegInfoRecord;
34 MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS,
35 MCCodeEmitter *Emitter, const MCSubtargetInfo &STI)
36 : MCELFStreamer(Context, MAB, OS, Emitter) {
38 RegInfoRecord = new MipsRegInfoRecord(this, Context, STI);
39 MipsOptionRecords.push_back(
40 std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord));
43 /// Overriding this function allows us to add arbitrary behaviour before the
44 /// \p Inst is actually emitted. For example, we can inspect the operands and
45 /// gather sufficient information that allows us to reason about the register
46 /// usage for the translation unit.
47 void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
49 /// Emits all the option records stored up until the point it's called.
50 void EmitMipsOptionRecords();
53 MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
54 raw_ostream &OS, MCCodeEmitter *Emitter,
55 const MCSubtargetInfo &STI, bool RelaxAll,