mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-11 10:25:41 +00:00
[mips] Implement custom MCELFStreamer.
This allows us to insert some hooks before emitting data into an actual object file. For example, we can capture the register usage for a translation unit by overriding the EmitInstruction method. The register usage information is needed to generate .reginfo and .Mips.options ELF sections. No functional changes. Differential Revision: http://llvm-reviews.chandlerc.com/D3129 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204917 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
add_llvm_library(LLVMMipsDesc
|
add_llvm_library(LLVMMipsDesc
|
||||||
MipsAsmBackend.cpp
|
MipsAsmBackend.cpp
|
||||||
MipsELFObjectWriter.cpp
|
MipsELFObjectWriter.cpp
|
||||||
|
MipsELFStreamer.cpp
|
||||||
MipsMCAsmInfo.cpp
|
MipsMCAsmInfo.cpp
|
||||||
MipsMCCodeEmitter.cpp
|
MipsMCCodeEmitter.cpp
|
||||||
MipsMCExpr.cpp
|
MipsMCExpr.cpp
|
||||||
|
19
lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
Normal file
19
lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
43
lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h
Normal file
43
lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
//===-------- 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"
|
||||||
|
|
||||||
|
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() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
|
||||||
|
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||||
|
const MCSubtargetInfo &STI, bool RelaxAll,
|
||||||
|
bool NoExecStack);
|
||||||
|
} // namespace llvm.
|
||||||
|
#endif
|
@@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "InstPrinter/MipsInstPrinter.h"
|
#include "InstPrinter/MipsInstPrinter.h"
|
||||||
|
#include "MipsELFStreamer.h"
|
||||||
#include "MipsMCAsmInfo.h"
|
#include "MipsMCAsmInfo.h"
|
||||||
#include "MipsMCNaCl.h"
|
#include "MipsMCNaCl.h"
|
||||||
#include "MipsMCTargetDesc.h"
|
#include "MipsMCTargetDesc.h"
|
||||||
@@ -112,7 +113,8 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
|
|||||||
bool RelaxAll, bool NoExecStack) {
|
bool RelaxAll, bool NoExecStack) {
|
||||||
MCStreamer *S;
|
MCStreamer *S;
|
||||||
if (!Triple(TT).isOSNaCl())
|
if (!Triple(TT).isOSNaCl())
|
||||||
S = createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);
|
S = createMipsELFStreamer(Context, MAB, OS, Emitter, STI, RelaxAll,
|
||||||
|
NoExecStack);
|
||||||
else
|
else
|
||||||
S = createMipsNaClELFStreamer(Context, MAB, OS, Emitter, RelaxAll,
|
S = createMipsNaClELFStreamer(Context, MAB, OS, Emitter, RelaxAll,
|
||||||
NoExecStack);
|
NoExecStack);
|
||||||
|
Reference in New Issue
Block a user