reverts 195057 per request
[oota-llvm.git] / lib / Target / Mips / MCTargetDesc / MipsTargetStreamer.cpp
1 //===-- MipsTargetStreamer.cpp - Mips Target Streamer Methods -------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides Mips specific target streamer methods.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MipsTargetStreamer.h"
15 #include "llvm/MC/MCELF.h"
16 #include "llvm/MC/MCSymbol.h"
17 #include "llvm/Support/CommandLine.h"
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Support/FormattedStream.h"
20
21 using namespace llvm;
22
23 static cl::opt<bool> PrintHackDirectives("print-hack-directives",
24                                          cl::init(false), cl::Hidden);
25
26 // pin vtable to this file
27 void MipsTargetStreamer::anchor() {}
28
29 MipsTargetAsmStreamer::MipsTargetAsmStreamer(formatted_raw_ostream &OS)
30     : OS(OS) {}
31
32 void MipsTargetAsmStreamer::emitMipsHackELFFlags(unsigned Flags) {
33   if (!PrintHackDirectives)
34     return;
35
36   OS << "\t.mips_hack_elf_flags 0x";
37   OS.write_hex(Flags);
38   OS << '\n';
39 }
40 void MipsTargetAsmStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
41   if (!PrintHackDirectives)
42     return;
43
44   OS << "\t.mips_hack_stocg ";
45   OS << Sym->getName();
46   OS << ", ";
47   OS << Val;
48   OS << '\n';
49 }
50
51 MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
52   return static_cast<MCELFStreamer &>(*Streamer);
53 }
54
55 void MipsTargetELFStreamer::emitMipsHackELFFlags(unsigned Flags) {
56   MCAssembler &MCA = getStreamer().getAssembler();
57   MCA.setELFHeaderEFlags(Flags);
58 }
59
60 // Set a symbol's STO flags
61 void MipsTargetELFStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
62   MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Sym);
63   // The "other" values are stored in the last 6 bits of the second byte
64   // The traditional defines for STO values assume the full byte and thus
65   // the shift to pack it.
66   MCELF::setOther(Data, Val >> 2);
67 }