blob: 83d33b6013d2c6200cb385ea82eb416b38827236 [file] [log] [blame]
Matheus Almeidadac77fb2014-03-27 11:39:03 +00001//===-------- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
16#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
Matheus Almeidadac77fb2014-03-27 11:39:03 +000017
Daniel Sanders68c37472014-07-21 13:30:55 +000018#include "MipsOptionRecord.h"
19#include "llvm/ADT/SmallVector.h"
Matheus Almeidadac77fb2014-03-27 11:39:03 +000020#include "llvm/MC/MCELFStreamer.h"
Daniel Sanders68c37472014-07-21 13:30:55 +000021#include <memory>
Matheus Almeidadac77fb2014-03-27 11:39:03 +000022
23namespace llvm {
24class MCAsmBackend;
25class MCCodeEmitter;
26class MCContext;
27class MCSubtargetInfo;
28
29class MipsELFStreamer : public MCELFStreamer {
Daniel Sanders68c37472014-07-21 13:30:55 +000030 SmallVector<std::unique_ptr<MipsOptionRecord>, 8> MipsOptionRecords;
31 MipsRegInfoRecord *RegInfoRecord;
Matheus Almeidadac77fb2014-03-27 11:39:03 +000032
33public:
34 MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS,
35 MCCodeEmitter *Emitter, const MCSubtargetInfo &STI)
Daniel Sanders68c37472014-07-21 13:30:55 +000036 : MCELFStreamer(Context, MAB, OS, Emitter) {
Matheus Almeidadac77fb2014-03-27 11:39:03 +000037
Daniel Sanders68c37472014-07-21 13:30:55 +000038 RegInfoRecord = new MipsRegInfoRecord(this, Context, STI);
39 MipsOptionRecords.push_back(
40 std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord));
41 }
42
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;
48
49 /// Emits all the option records stored up until the point it's called.
50 void EmitMipsOptionRecords();
Matheus Almeidadac77fb2014-03-27 11:39:03 +000051};
52
53MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
54 raw_ostream &OS, MCCodeEmitter *Emitter,
55 const MCSubtargetInfo &STI, bool RelaxAll,
56 bool NoExecStack);
57} // namespace llvm.
58#endif