LLVM 19.0.0git
MSP430ELFStreamer.cpp
Go to the documentation of this file.
1//===-- MSP430ELFStreamer.cpp - MSP430 ELF Target Streamer Methods --------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides MSP430 specific target streamer methods.
10//
11//===----------------------------------------------------------------------===//
12
13#include "MSP430MCTargetDesc.h"
15#include "llvm/MC/MCAssembler.h"
16#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCStreamer.h"
22
23using namespace llvm;
24using namespace llvm::MSP430Attrs;
25
26namespace llvm {
27
29public:
32};
33
34// This part is for ELF object output.
36 const MCSubtargetInfo &STI)
37 : MCTargetStreamer(S) {
39 unsigned EFlags = MCA.getELFHeaderEFlags();
40 MCA.setELFHeaderEFlags(EFlags);
41
42 // Emit build attributes section according to
43 // MSP430 EABI (slaa534.pdf, part 13).
44 MCSection *AttributeSection = getStreamer().getContext().getELFSection(
45 ".MSP430.attributes", ELF::SHT_MSP430_ATTRIBUTES, 0);
46 Streamer.switchSection(AttributeSection);
47
48 // Format version.
49 Streamer.emitInt8(0x41);
50 // Subsection length.
52 // Vendor name string, zero-terminated.
53 Streamer.emitBytes("mspabi");
55
56 // Attribute vector scope tag. 1 stands for the entire file.
58 // Attribute vector length.
60
62 Streamer.emitInt8(STI.hasFeature(MSP430::FeatureX) ? ISAMSP430X : ISAMSP430);
67 // Don't emit TagEnumSize, for full GCC compatibility.
68}
69
71 return static_cast<MCELFStreamer &>(Streamer);
72}
73
76 const Triple &TT = STI.getTargetTriple();
77 if (TT.isOSBinFormatELF())
78 return new MSP430TargetELFStreamer(S, STI);
79 return nullptr;
80}
81
82} // namespace llvm
This file contains enumerations for MSP430 ELF build attributes as defined in the MSP430 ELF psABI sp...
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Definition: MCAssembler.h:281
void setELFHeaderEFlags(unsigned Flags)
Definition: MCAssembler.h:282
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:562
MCAssembler & getAssembler()
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
Streaming machine code generation interface.
Definition: MCStreamer.h:212
MCContext & getContext() const
Definition: MCStreamer.h:297
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
void emitInt32(uint64_t Value)
Definition: MCStreamer.h:756
void emitInt8(uint64_t Value)
Definition: MCStreamer.h:754
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
Target specific streamer interface.
Definition: MCStreamer.h:93
MCStreamer & Streamer
Definition: MCStreamer.h:95
MSP430TargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ SHT_MSP430_ATTRIBUTES
Definition: ELF.h:1140
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCTargetStreamer * createMSP430ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)