MipsELFStreamer.cpp revision 7304702ef99f98897d15baae0eede55f294bc602
1//===-- MipsELFStreamer.cpp - MipsELFStreamer ---------------------------===// 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#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" 14 15namespace llvm { 16 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); 22 return S; 23 } 24 25 // For llc. Set a group of ELF header flags 26 void 27 MipsELFStreamer::emitELFHeaderFlagsCG(const MipsSubtarget &Subtarget) { 28 29 if (hasRawTextSupport()) 30 return; 31 32 // Update e_header flags 33 MCAssembler& MCA = getAssembler(); 34 unsigned EFlags = MCA.getELFHeaderEFlags(); 35 36 EFlags |= ELF::EF_MIPS_NOREORDER; 37 38 // Architecture 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; 45 else 46 EFlags |= ELF::EF_MIPS_ARCH_32; 47 48 if (Subtarget.inMicroMipsMode()) 49 EFlags |= ELF::EF_MIPS_MICROMIPS; 50 51 // Relocation Model 52 Reloc::Model RM = Subtarget.getRelocationModel(); 53 if (RM == Reloc::PIC_ || RM == Reloc::Default) 54 EFlags |= ELF::EF_MIPS_PIC; 55 else if (RM == Reloc::Static) 56 ; // Do nothing for Reloc::Static 57 else 58 llvm_unreachable("Unsupported relocation model for e_flags"); 59 60 MCA.setELFHeaderEFlags(EFlags); 61 62 63 } 64} 65