2013-11-18 23:55:27 +00:00
|
|
|
//===-- MipsTargetStreamer.cpp - Mips Target Streamer Methods -------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides Mips specific target streamer methods.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "MipsTargetStreamer.h"
|
|
|
|
#include "llvm/MC/MCELF.h"
|
|
|
|
#include "llvm/MC/MCSymbol.h"
|
|
|
|
#include "llvm/Support/CommandLine.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "llvm/Support/ELF.h"
|
2013-11-18 23:55:27 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/FormattedStream.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2013-11-19 20:53:28 +00:00
|
|
|
static cl::opt<bool> PrintHackDirectives("print-hack-directives",
|
|
|
|
cl::init(false), cl::Hidden);
|
|
|
|
|
2014-01-06 23:27:31 +00:00
|
|
|
// Pin vtable to this file.
|
2013-11-18 23:55:27 +00:00
|
|
|
void MipsTargetStreamer::anchor() {}
|
|
|
|
|
2013-11-19 20:53:28 +00:00
|
|
|
MipsTargetAsmStreamer::MipsTargetAsmStreamer(formatted_raw_ostream &OS)
|
|
|
|
: OS(OS) {}
|
|
|
|
|
|
|
|
void MipsTargetAsmStreamer::emitMipsHackELFFlags(unsigned Flags) {
|
|
|
|
if (!PrintHackDirectives)
|
|
|
|
return;
|
|
|
|
|
|
|
|
OS << "\t.mips_hack_elf_flags 0x";
|
|
|
|
OS.write_hex(Flags);
|
|
|
|
OS << '\n';
|
|
|
|
}
|
|
|
|
void MipsTargetAsmStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
|
|
|
|
if (!PrintHackDirectives)
|
|
|
|
return;
|
|
|
|
|
|
|
|
OS << "\t.mips_hack_stocg ";
|
|
|
|
OS << Sym->getName();
|
|
|
|
OS << ", ";
|
|
|
|
OS << Val;
|
|
|
|
OS << '\n';
|
|
|
|
}
|
2014-01-06 23:27:31 +00:00
|
|
|
void MipsTargetAsmStreamer::emitDirectiveAbiCalls() { OS << "\t.abicalls\n"; }
|
|
|
|
void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
|
|
|
|
OS << "\t.option\tpic0\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// This part is for ELF object output.
|
|
|
|
MipsTargetELFStreamer::MipsTargetELFStreamer() {}
|
2013-11-18 23:55:27 +00:00
|
|
|
|
|
|
|
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
|
|
|
|
return static_cast<MCELFStreamer &>(*Streamer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MipsTargetELFStreamer::emitMipsHackELFFlags(unsigned Flags) {
|
|
|
|
MCAssembler &MCA = getStreamer().getAssembler();
|
|
|
|
MCA.setELFHeaderEFlags(Flags);
|
|
|
|
}
|
|
|
|
|
2014-01-06 23:27:31 +00:00
|
|
|
// Set a symbol's STO flags.
|
2013-11-19 20:53:28 +00:00
|
|
|
void MipsTargetELFStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
|
2013-11-18 23:55:27 +00:00
|
|
|
MCSymbolData &Data = getStreamer().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);
|
|
|
|
}
|
2014-01-06 23:27:31 +00:00
|
|
|
void MipsTargetELFStreamer::emitDirectiveAbiCalls() {
|
|
|
|
MCAssembler &MCA = getStreamer().getAssembler();
|
|
|
|
unsigned Flags = MCA.getELFHeaderEFlags();
|
|
|
|
Flags |= ELF::EF_MIPS_CPIC;
|
|
|
|
MCA.setELFHeaderEFlags(Flags);
|
|
|
|
}
|
|
|
|
void MipsTargetELFStreamer::emitDirectiveOptionPic0() {
|
|
|
|
MCAssembler &MCA = getStreamer().getAssembler();
|
|
|
|
unsigned Flags = MCA.getELFHeaderEFlags();
|
|
|
|
Flags &= ~ELF::EF_MIPS_PIC;
|
|
|
|
MCA.setELFHeaderEFlags(Flags);
|
|
|
|
}
|