2013-01-30 02:16:36 +00:00
|
|
|
//===-- MipsELFStreamer.cpp - MipsELFStreamer ---------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===-------------------------------------------------------------------===//
|
|
|
|
#include "MipsSubtarget.h"
|
|
|
|
#include "llvm/MC/MCAssembler.h"
|
2013-02-19 22:04:37 +00:00
|
|
|
#include "llvm/MC/MCELF.h"
|
2013-10-05 16:42:21 +00:00
|
|
|
#include "llvm/MC/MCELFStreamer.h"
|
2013-02-19 22:04:37 +00:00
|
|
|
#include "llvm/MC/MCELFSymbolFlags.h"
|
|
|
|
#include "llvm/MC/MCSymbol.h"
|
2013-01-30 02:16:36 +00:00
|
|
|
#include "llvm/Support/ELF.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2013-10-05 16:42:21 +00:00
|
|
|
using namespace llvm;
|
2013-01-30 02:16:36 +00:00
|
|
|
|
2013-10-05 16:42:21 +00:00
|
|
|
namespace {
|
|
|
|
class MipsELFStreamer : public MCELFStreamer {
|
|
|
|
public:
|
|
|
|
MipsELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
|
|
|
|
MCCodeEmitter *Emitter, bool RelaxAll, bool NoExecStack)
|
|
|
|
: MCELFStreamer(Context, TAB, OS, Emitter) {}
|
2013-01-30 02:16:36 +00:00
|
|
|
|
2013-10-05 16:42:21 +00:00
|
|
|
~MipsELFStreamer() {}
|
|
|
|
void emitMipsHackELFFlags(unsigned Flags);
|
|
|
|
void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val);
|
|
|
|
};
|
|
|
|
}
|
2013-01-30 02:16:36 +00:00
|
|
|
|
2013-10-05 16:42:21 +00:00
|
|
|
namespace llvm {
|
|
|
|
MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
|
|
|
raw_ostream &OS, MCCodeEmitter *Emitter,
|
|
|
|
bool RelaxAll, bool NoExecStack) {
|
|
|
|
MipsELFStreamer *S =
|
|
|
|
new MipsELFStreamer(Context, TAB, OS, Emitter, RelaxAll, NoExecStack);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
} // namespace llvm
|
2013-01-30 02:16:36 +00:00
|
|
|
|
2013-10-05 16:42:21 +00:00
|
|
|
void MipsELFStreamer::emitMipsHackELFFlags(unsigned Flags) {
|
|
|
|
MCAssembler &MCA = getAssembler();
|
2013-01-30 02:16:36 +00:00
|
|
|
|
2013-10-05 16:42:21 +00:00
|
|
|
MCA.setELFHeaderEFlags(Flags);
|
|
|
|
}
|
2013-02-19 22:04:37 +00:00
|
|
|
|
2013-10-05 16:42:21 +00:00
|
|
|
// Set a symbol's STO flags
|
|
|
|
void MipsELFStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
|
|
|
|
MCSymbolData &Data = getOrCreateSymbolData(Sym);
|
|
|
|
// The "other" values are stored in the last 6 bits of the second byte
|
|
|
|
// The traditional defines for STO values assume the full byte and thus
|
|
|
|
// the shift to pack it.
|
|
|
|
MCELF::setOther(Data, Val >> 2);
|
|
|
|
}
|