LLVM API Documentation

MipsELFStreamer.h
Go to the documentation of this file.
00001 //===-------- MipsELFStreamer.h - ELF Object Output -----------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This is a custom MCELFStreamer which allows us to insert some hooks before
00011 // emitting data into an actual object file.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
00016 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSELFSTREAMER_H
00017 
00018 #include "MipsOptionRecord.h"
00019 #include "llvm/ADT/SmallVector.h"
00020 #include "llvm/MC/MCELFStreamer.h"
00021 #include <memory>
00022 
00023 namespace llvm {
00024 class MCAsmBackend;
00025 class MCCodeEmitter;
00026 class MCContext;
00027 class MCSubtargetInfo;
00028 
00029 class MipsELFStreamer : public MCELFStreamer {
00030   SmallVector<std::unique_ptr<MipsOptionRecord>, 8> MipsOptionRecords;
00031   MipsRegInfoRecord *RegInfoRecord;
00032 
00033 public:
00034   MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS,
00035                   MCCodeEmitter *Emitter, const MCSubtargetInfo &STI)
00036       : MCELFStreamer(Context, MAB, OS, Emitter) {
00037 
00038     RegInfoRecord = new MipsRegInfoRecord(this, Context, STI);
00039     MipsOptionRecords.push_back(
00040         std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord));
00041   }
00042 
00043   /// Overriding this function allows us to add arbitrary behaviour before the
00044   /// \p Inst is actually emitted. For example, we can inspect the operands and
00045   /// gather sufficient information that allows us to reason about the register
00046   /// usage for the translation unit.
00047   void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
00048 
00049   /// Emits all the option records stored up until the point it's called.
00050   void EmitMipsOptionRecords();
00051 };
00052 
00053 MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
00054                                      raw_ostream &OS, MCCodeEmitter *Emitter,
00055                                      const MCSubtargetInfo &STI, bool RelaxAll,
00056                                      bool NoExecStack);
00057 } // namespace llvm.
00058 #endif