Index: lib/Target/Mips/MCTargetDesc/CMakeLists.txt =================================================================== --- lib/Target/Mips/MCTargetDesc/CMakeLists.txt +++ lib/Target/Mips/MCTargetDesc/CMakeLists.txt @@ -1,6 +1,7 @@ add_llvm_library(LLVMMipsDesc MipsAsmBackend.cpp MipsELFObjectWriter.cpp + MipsELFStreamer.cpp MipsMCAsmInfo.cpp MipsMCCodeEmitter.cpp MipsMCExpr.cpp Index: lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h =================================================================== --- /dev/null +++ lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h @@ -0,0 +1,47 @@ +//===-------- MipsELFStreamer.h - ELF Object Output -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is a custom MCELFStreamer which allows us to insert some hooks before +// emitting data into an actual object file. +// +//===----------------------------------------------------------------------===// + +#ifndef MIPSELFSTREAMER_H +#define MIPSELFSTREAMER_H + +#include "llvm/MC/MCELFStreamer.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +namespace llvm { +class MCAsmBackend; +class MCCodeEmitter; +class MCContext; +class MCSubtargetInfo; +} + +class MipsELFStreamer : public MCELFStreamer { + const MCSubtargetInfo &STI; + +public: + MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS, + MCCodeEmitter *Emitter, const MCSubtargetInfo &STI) + : MCELFStreamer(Context, MAB, OS, Emitter), STI(STI) {} + + virtual ~MipsELFStreamer() {} +}; + +namespace llvm { +MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, + raw_ostream &OS, MCCodeEmitter *Emitter, + const MCSubtargetInfo &STI, bool RelaxAll, + bool NoExecStack); +} +#endif Index: lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp =================================================================== --- /dev/null +++ lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp @@ -0,0 +1,19 @@ +//===-------- MipsELFStreamer.cpp - ELF Object Output ---------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "MipsELFStreamer.h" + +namespace llvm { +MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, + raw_ostream &OS, MCCodeEmitter *Emitter, + const MCSubtargetInfo &STI, bool RelaxAll, + bool NoExecStack) { + return new MipsELFStreamer(Context, MAB, OS, Emitter, STI); +} +} Index: lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "InstPrinter/MipsInstPrinter.h" +#include "MipsELFStreamer.h" #include "MipsMCAsmInfo.h" #include "MipsMCNaCl.h" #include "MipsMCTargetDesc.h" @@ -112,7 +113,8 @@ bool RelaxAll, bool NoExecStack) { MCStreamer *S; if (!Triple(TT).isOSNaCl()) - S = createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack); + S = createMipsELFStreamer(Context, MAB, OS, Emitter, STI, RelaxAll, + NoExecStack); else S = createMipsNaClELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);