Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/llvm/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp
35294 views
1
#include "AVRELFStreamer.h"
2
3
#include "llvm/BinaryFormat/ELF.h"
4
#include "llvm/MC/MCAssembler.h"
5
#include "llvm/MC/MCSubtargetInfo.h"
6
#include "llvm/Support/FormattedStream.h"
7
#include "llvm/TargetParser/SubtargetFeature.h"
8
9
#include "AVRMCTargetDesc.h"
10
11
namespace llvm {
12
13
static unsigned getEFlagsForFeatureSet(const FeatureBitset &Features) {
14
unsigned EFlags = 0;
15
16
// Set architecture
17
if (Features[AVR::ELFArchAVR1])
18
EFlags |= ELF::EF_AVR_ARCH_AVR1;
19
else if (Features[AVR::ELFArchAVR2])
20
EFlags |= ELF::EF_AVR_ARCH_AVR2;
21
else if (Features[AVR::ELFArchAVR25])
22
EFlags |= ELF::EF_AVR_ARCH_AVR25;
23
else if (Features[AVR::ELFArchAVR3])
24
EFlags |= ELF::EF_AVR_ARCH_AVR3;
25
else if (Features[AVR::ELFArchAVR31])
26
EFlags |= ELF::EF_AVR_ARCH_AVR31;
27
else if (Features[AVR::ELFArchAVR35])
28
EFlags |= ELF::EF_AVR_ARCH_AVR35;
29
else if (Features[AVR::ELFArchAVR4])
30
EFlags |= ELF::EF_AVR_ARCH_AVR4;
31
else if (Features[AVR::ELFArchAVR5])
32
EFlags |= ELF::EF_AVR_ARCH_AVR5;
33
else if (Features[AVR::ELFArchAVR51])
34
EFlags |= ELF::EF_AVR_ARCH_AVR51;
35
else if (Features[AVR::ELFArchAVR6])
36
EFlags |= ELF::EF_AVR_ARCH_AVR6;
37
else if (Features[AVR::ELFArchTiny])
38
EFlags |= ELF::EF_AVR_ARCH_AVRTINY;
39
else if (Features[AVR::ELFArchXMEGA1])
40
EFlags |= ELF::EF_AVR_ARCH_XMEGA1;
41
else if (Features[AVR::ELFArchXMEGA2])
42
EFlags |= ELF::EF_AVR_ARCH_XMEGA2;
43
else if (Features[AVR::ELFArchXMEGA3])
44
EFlags |= ELF::EF_AVR_ARCH_XMEGA3;
45
else if (Features[AVR::ELFArchXMEGA4])
46
EFlags |= ELF::EF_AVR_ARCH_XMEGA4;
47
else if (Features[AVR::ELFArchXMEGA5])
48
EFlags |= ELF::EF_AVR_ARCH_XMEGA5;
49
else if (Features[AVR::ELFArchXMEGA6])
50
EFlags |= ELF::EF_AVR_ARCH_XMEGA6;
51
else if (Features[AVR::ELFArchXMEGA7])
52
EFlags |= ELF::EF_AVR_ARCH_XMEGA7;
53
54
return EFlags;
55
}
56
57
AVRELFStreamer::AVRELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
58
: AVRTargetStreamer(S) {
59
ELFObjectWriter &W = getStreamer().getWriter();
60
unsigned EFlags = W.getELFHeaderEFlags();
61
62
EFlags |= getEFlagsForFeatureSet(STI.getFeatureBits());
63
EFlags |= ELF::EF_AVR_LINKRELAX_PREPARED;
64
65
W.setELFHeaderEFlags(EFlags);
66
}
67
68
} // end namespace llvm
69
70