• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "AVRELFStreamer.h"
2 
3 #include "llvm/Support/ELF.h"
4 #include "llvm/Support/FormattedStream.h"
5 
6 #include "AVRMCTargetDesc.h"
7 
8 namespace llvm {
9 
getEFlagsForFeatureSet(const FeatureBitset & Features)10 static unsigned getEFlagsForFeatureSet(const FeatureBitset &Features) {
11   unsigned EFlags = 0;
12 
13   // Set architecture
14   if (Features[AVR::ELFArchAVR1])
15     EFlags |= ELF::EF_AVR_ARCH_AVR1;
16   else if (Features[AVR::ELFArchAVR2])
17     EFlags |= ELF::EF_AVR_ARCH_AVR2;
18   else if (Features[AVR::ELFArchAVR25])
19     EFlags |= ELF::EF_AVR_ARCH_AVR25;
20   else if (Features[AVR::ELFArchAVR3])
21     EFlags |= ELF::EF_AVR_ARCH_AVR3;
22   else if (Features[AVR::ELFArchAVR31])
23     EFlags |= ELF::EF_AVR_ARCH_AVR31;
24   else if (Features[AVR::ELFArchAVR35])
25     EFlags |= ELF::EF_AVR_ARCH_AVR35;
26   else if (Features[AVR::ELFArchAVR4])
27     EFlags |= ELF::EF_AVR_ARCH_AVR4;
28   else if (Features[AVR::ELFArchAVR5])
29     EFlags |= ELF::EF_AVR_ARCH_AVR5;
30   else if (Features[AVR::ELFArchAVR51])
31     EFlags |= ELF::EF_AVR_ARCH_AVR51;
32   else if (Features[AVR::ELFArchAVR6])
33     EFlags |= ELF::EF_AVR_ARCH_AVR6;
34   else if (Features[AVR::ELFArchAVRTiny])
35     EFlags |= ELF::EF_AVR_ARCH_AVRTINY;
36   else if (Features[AVR::ELFArchXMEGA1])
37     EFlags |= ELF::EF_AVR_ARCH_XMEGA1;
38   else if (Features[AVR::ELFArchXMEGA2])
39     EFlags |= ELF::EF_AVR_ARCH_XMEGA2;
40   else if (Features[AVR::ELFArchXMEGA3])
41     EFlags |= ELF::EF_AVR_ARCH_XMEGA3;
42   else if (Features[AVR::ELFArchXMEGA4])
43     EFlags |= ELF::EF_AVR_ARCH_XMEGA4;
44   else if (Features[AVR::ELFArchXMEGA5])
45     EFlags |= ELF::EF_AVR_ARCH_XMEGA5;
46   else if (Features[AVR::ELFArchXMEGA6])
47     EFlags |= ELF::EF_AVR_ARCH_XMEGA6;
48   else if (Features[AVR::ELFArchXMEGA7])
49     EFlags |= ELF::EF_AVR_ARCH_XMEGA7;
50 
51   return EFlags;
52 }
53 
AVRELFStreamer(MCStreamer & S,const MCSubtargetInfo & STI)54 AVRELFStreamer::AVRELFStreamer(MCStreamer &S,
55                                const MCSubtargetInfo &STI)
56     : AVRTargetStreamer(S) {
57 
58   MCAssembler &MCA = getStreamer().getAssembler();
59   unsigned EFlags = MCA.getELFHeaderEFlags();
60 
61   EFlags |= getEFlagsForFeatureSet(STI.getFeatureBits());
62 
63   MCA.setELFHeaderEFlags(EFlags);
64 }
65 
66 } // end namespace llvm
67