LLVM
17.0.0git
lib
Target
MSP430
MCTargetDesc
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
"
14
#include "
llvm/BinaryFormat/ELF.h
"
15
#include "
llvm/MC/MCAssembler.h
"
16
#include "
llvm/MC/MCContext.h
"
17
#include "
llvm/MC/MCELFStreamer.h
"
18
#include "
llvm/MC/MCSectionELF.h
"
19
#include "
llvm/MC/MCStreamer.h
"
20
#include "
llvm/MC/MCSubtargetInfo.h
"
21
#include "
llvm/Support/MSP430Attributes.h
"
22
23
using namespace
llvm
;
24
using namespace
llvm::MSP430Attrs
;
25
26
namespace
llvm
{
27
28
class
MSP430TargetELFStreamer
:
public
MCTargetStreamer
{
29
public
:
30
MCELFStreamer
&
getStreamer
();
31
MSP430TargetELFStreamer
(
MCStreamer
&S,
const
MCSubtargetInfo
&STI);
32
};
33
34
// This part is for ELF object output.
35
MSP430TargetELFStreamer::MSP430TargetELFStreamer
(
MCStreamer
&S,
36
const
MCSubtargetInfo
&STI)
37
:
MCTargetStreamer
(S) {
38
MCAssembler
&MCA =
getStreamer
().
getAssembler
();
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.
51
Streamer
.
emitInt32
(22);
52
// Vendor name string, zero-terminated.
53
Streamer
.
emitBytes
(
"mspabi"
);
54
Streamer
.
emitInt8
(0);
55
56
// Attribute vector scope tag. 1 stands for the entire file.
57
Streamer
.
emitInt8
(1);
58
// Attribute vector length.
59
Streamer
.
emitInt32
(11);
60
61
Streamer
.
emitInt8
(
TagISA
);
62
Streamer
.
emitInt8
(STI.
hasFeature
(MSP430::FeatureX) ?
ISAMSP430X
:
ISAMSP430
);
63
Streamer
.
emitInt8
(
TagCodeModel
);
64
Streamer
.
emitInt8
(
CMSmall
);
65
Streamer
.
emitInt8
(
TagDataModel
);
66
Streamer
.
emitInt8
(
DMSmall
);
67
// Don't emit TagEnumSize, for full GCC compatibility.
68
}
69
70
MCELFStreamer
&
MSP430TargetELFStreamer::getStreamer
() {
71
return
static_cast<
MCELFStreamer
&
>
(
Streamer
);
72
}
73
74
MCTargetStreamer
*
75
createMSP430ObjectTargetStreamer
(
MCStreamer
&S,
const
MCSubtargetInfo
&STI) {
76
const
Triple
&TT = STI.
getTargetTriple
();
77
if
(TT.isOSBinFormatELF())
78
return
new
MSP430TargetELFStreamer
(S, STI);
79
return
nullptr
;
80
}
81
82
}
// namespace llvm
ELF.h
MCAssembler.h
MCContext.h
MCELFStreamer.h
MCSectionELF.h
MCStreamer.h
MCSubtargetInfo.h
MSP430Attributes.h
This file contains enumerations for MSP430 ELF build attributes as defined in the MSP430 ELF psABI sp...
MSP430MCTargetDesc.h
llvm::MCAssembler
Definition:
MCAssembler.h:73
llvm::MCAssembler::getELFHeaderEFlags
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Definition:
MCAssembler.h:276
llvm::MCAssembler::setELFHeaderEFlags
void setELFHeaderEFlags(unsigned Flags)
Definition:
MCAssembler.h:277
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition:
MCContext.h:563
llvm::MCELFStreamer
Definition:
MCELFStreamer.h:31
llvm::MCObjectStreamer::getAssembler
MCAssembler & getAssembler()
Definition:
MCObjectStreamer.h:128
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition:
MCSection.h:39
llvm::MCStreamer
Streaming machine code generation interface.
Definition:
MCStreamer.h:212
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition:
MCStreamer.h:297
llvm::MCStreamer::switchSection
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition:
MCStreamer.cpp:1238
llvm::MCStreamer::emitInt32
void emitInt32(uint64_t Value)
Definition:
MCStreamer.h:748
llvm::MCStreamer::emitInt8
void emitInt8(uint64_t Value)
Definition:
MCStreamer.h:746
llvm::MCStreamer::emitBytes
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition:
MCStreamer.cpp:1216
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition:
MCSubtargetInfo.h:76
llvm::MCSubtargetInfo::hasFeature
bool hasFeature(unsigned Feature) const
Definition:
MCSubtargetInfo.h:119
llvm::MCSubtargetInfo::getTargetTriple
const Triple & getTargetTriple() const
Definition:
MCSubtargetInfo.h:108
llvm::MCTargetStreamer
Target specific streamer interface.
Definition:
MCStreamer.h:93
llvm::MCTargetStreamer::Streamer
MCStreamer & Streamer
Definition:
MCStreamer.h:95
llvm::MSP430TargetELFStreamer
Definition:
MSP430ELFStreamer.cpp:28
llvm::MSP430TargetELFStreamer::MSP430TargetELFStreamer
MSP430TargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition:
MSP430ELFStreamer.cpp:35
llvm::MSP430TargetELFStreamer::getStreamer
MCELFStreamer & getStreamer()
Definition:
MSP430ELFStreamer.cpp:70
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:
Triple.h:44
llvm::ELF::SHT_MSP430_ATTRIBUTES
@ SHT_MSP430_ATTRIBUTES
Definition:
ELF.h:1071
llvm::MSP430Attrs
Definition:
MSP430Attributes.h:24
llvm::MSP430Attrs::TagDataModel
@ TagDataModel
Definition:
MSP430Attributes.h:32
llvm::MSP430Attrs::TagISA
@ TagISA
Definition:
MSP430Attributes.h:30
llvm::MSP430Attrs::TagCodeModel
@ TagCodeModel
Definition:
MSP430Attributes.h:31
llvm::MSP430Attrs::CMSmall
@ CMSmall
Definition:
MSP430Attributes.h:37
llvm::MSP430Attrs::ISAMSP430
@ ISAMSP430
Definition:
MSP430Attributes.h:36
llvm::MSP430Attrs::ISAMSP430X
@ ISAMSP430X
Definition:
MSP430Attributes.h:36
llvm::MSP430Attrs::DMSmall
@ DMSmall
Definition:
MSP430Attributes.h:38
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::createMSP430ObjectTargetStreamer
MCTargetStreamer * createMSP430ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition:
MSP430ELFStreamer.cpp:75
Generated on Sat Jun 3 2023 16:30:10 for LLVM by
1.9.6