1 //===-- MipsELFStreamer.cpp - MipsELFStreamer ---------------------------===//
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 //===-------------------------------------------------------------------===//
9 #include "MCTargetDesc/MipsELFStreamer.h"
10 #include "MipsSubtarget.h"
11 #include "llvm/MC/MCAssembler.h"
12 #include "llvm/Support/ELF.h"
13 #include "llvm/Support/ErrorHandling.h"
17 MCELFStreamer* createMipsELFStreamer(MCContext &Context, MCAsmBackend &TAB,
18 raw_ostream &OS, MCCodeEmitter *Emitter,
19 bool RelaxAll, bool NoExecStack) {
20 MipsELFStreamer *S = new MipsELFStreamer(Context, TAB, OS, Emitter,
21 RelaxAll, NoExecStack);
25 // For llc. Set a group of ELF header flags
27 MipsELFStreamer::emitELFHeaderFlagsCG(const MipsSubtarget &Subtarget) {
29 if (hasRawTextSupport())
32 // Update e_header flags
33 MCAssembler& MCA = getAssembler();
34 unsigned EFlags = MCA.getELFHeaderEFlags();
36 EFlags |= ELF::EF_MIPS_NOREORDER;
39 if (Subtarget.hasMips64r2())
40 EFlags |= ELF::EF_MIPS_ARCH_64R2;
41 else if (Subtarget.hasMips64())
42 EFlags |= ELF::EF_MIPS_ARCH_64;
43 else if (Subtarget.hasMips32r2())
44 EFlags |= ELF::EF_MIPS_ARCH_32R2;
46 EFlags |= ELF::EF_MIPS_ARCH_32;
49 Reloc::Model RM = Subtarget.getRelocationModel();
50 if (RM == Reloc::PIC_ || RM == Reloc::Default)
51 EFlags |= ELF::EF_MIPS_PIC;
52 else if (RM == Reloc::Static)
53 ; // Do nothing for Reloc::Static
55 llvm_unreachable("Unsupported relocation model for e_flags");
57 MCA.setELFHeaderEFlags(EFlags);