1 //===-------- MipsELFStreamer.cpp - ELF Object Output ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "MipsELFStreamer.h"
11 #include "MipsTargetStreamer.h"
12 #include "llvm/MC/MCELF.h"
13 #include "llvm/MC/MCInst.h"
14 #include "llvm/Support/ELF.h"
18 void MipsELFStreamer::EmitInstruction(const MCInst &Inst,
19 const MCSubtargetInfo &STI) {
20 MCELFStreamer::EmitInstruction(Inst, STI);
22 MCContext &Context = getContext();
23 const MCRegisterInfo *MCRegInfo = Context.getRegisterInfo();
24 MipsTargetELFStreamer *ELFTargetStreamer =
25 static_cast<MipsTargetELFStreamer *>(getTargetStreamer());
27 for (unsigned OpIndex = 0; OpIndex < Inst.getNumOperands(); ++OpIndex) {
28 const MCOperand &Op = Inst.getOperand(OpIndex);
33 unsigned Reg = Op.getReg();
34 RegInfoRecord->SetPhysRegUsed(Reg, MCRegInfo);
37 if (ELFTargetStreamer->isMicroMipsEnabled()) {
38 for (auto Label : Labels) {
39 MCSymbolData &Data = getOrCreateSymbolData(Label);
40 // The "other" values are stored in the last 6 bits of the second byte.
41 // The traditional defines for STO values assume the full byte and thus
42 // the shift to pack it.
43 MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
50 void MipsELFStreamer::EmitLabel(MCSymbol *Symbol) {
51 MCELFStreamer::EmitLabel(Symbol);
52 Labels.push_back(Symbol);
55 void MipsELFStreamer::SwitchSection(const MCSection * Section,
56 const MCExpr *Subsection) {
57 MCELFStreamer::SwitchSection(Section, Subsection);
61 void MipsELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
63 MCELFStreamer::EmitValueImpl(Value, Size, Loc);
67 void MipsELFStreamer::EmitMipsOptionRecords() {
68 for (const auto &I : MipsOptionRecords)
69 I->EmitMipsOptionRecord();
72 MCELFStreamer *llvm::createMipsELFStreamer(MCContext &Context,
73 MCAsmBackend &MAB, raw_ostream &OS,
74 MCCodeEmitter *Emitter,
76 return new MipsELFStreamer(Context, MAB, OS, Emitter);