diff options
author | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-07-21 13:30:55 +0000 |
---|---|---|
committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-07-21 13:30:55 +0000 |
commit | 68c3747efb97be3a751bb12ed89af9c7539bc401 (patch) | |
tree | 970963753dd42b10090d36b94e5280bb2db2502f /llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h | |
parent | edf1570d4e300bb51f852da199a6fa8df141ad66 (diff) | |
download | bcm5719-llvm-68c3747efb97be3a751bb12ed89af9c7539bc401.tar.gz bcm5719-llvm-68c3747efb97be3a751bb12ed89af9c7539bc401.zip |
[mips] Add MipsOptionRecord abstraction and use it to implement .reginfo/.MIPS.options
This abstraction allows us to support the various records that can be placed in
the .MIPS.options section in the future. We currently use it to record register
usage information (the ODK_REGINFO record in our ELF64 spec).
Each .MIPS.options record should subclass MipsOptionRecord and provide an
implementation of EmitMipsOptionRecord.
Patch by Matheus Almeida and Toma Tabacu
llvm-svn: 213522
Diffstat (limited to 'llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h')
-rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h index 641f8cf7af2..58863be9cc2 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h @@ -15,8 +15,10 @@ #ifndef MIPSELFSTREAMER_H #define MIPSELFSTREAMER_H +#include "MipsOptionRecord.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/MC/MCELFStreamer.h" -#include "llvm/Support/raw_ostream.h" +#include <memory> namespace llvm { class MCAsmBackend; @@ -25,13 +27,27 @@ class MCContext; class MCSubtargetInfo; class MipsELFStreamer : public MCELFStreamer { + SmallVector<std::unique_ptr<MipsOptionRecord>, 8> MipsOptionRecords; + MipsRegInfoRecord *RegInfoRecord; public: MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS, MCCodeEmitter *Emitter, const MCSubtargetInfo &STI) - : MCELFStreamer(Context, MAB, OS, Emitter) {} + : MCELFStreamer(Context, MAB, OS, Emitter) { - virtual ~MipsELFStreamer() {} + RegInfoRecord = new MipsRegInfoRecord(this, Context, STI); + MipsOptionRecords.push_back( + std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord)); + } + + /// Overriding this function allows us to add arbitrary behaviour before the + /// \p Inst is actually emitted. For example, we can inspect the operands and + /// gather sufficient information that allows us to reason about the register + /// usage for the translation unit. + void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override; + + /// Emits all the option records stored up until the point it's called. + void EmitMipsOptionRecords(); }; MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, |