LLVM
10.0.0
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/MCContext.h
"
16
#include "
llvm/MC/MCELFStreamer.h
"
17
#include "
llvm/MC/MCSectionELF.h
"
18
#include "
llvm/MC/MCStreamer.h
"
19
#include "
llvm/MC/MCSubtargetInfo.h
"
20
21
using namespace
llvm
;
22
23
namespace
llvm
{
24
25
class
MSP430TargetELFStreamer
:
public
MCTargetStreamer
{
26
public
:
27
MCELFStreamer
&
getStreamer
();
28
MSP430TargetELFStreamer
(
MCStreamer
&S,
const
MCSubtargetInfo
&STI);
29
};
30
31
// This part is for ELF object output.
32
MSP430TargetELFStreamer::MSP430TargetELFStreamer
(
MCStreamer
&S,
33
const
MCSubtargetInfo
&STI)
34
:
MCTargetStreamer
(S) {
35
MCAssembler
&MCA =
getStreamer
().
getAssembler
();
36
unsigned
EFlags = MCA.
getELFHeaderEFlags
();
37
MCA.
setELFHeaderEFlags
(EFlags);
38
39
// Emit build attributes section according to
40
// MSP430 EABI (slaa534.pdf, part 13).
41
MCSection
*AttributeSection =
getStreamer
().
getContext
().
getELFSection
(
42
".MSP430.attributes"
,
ELF::SHT_MSP430_ATTRIBUTES
, 0);
43
Streamer
.
SwitchSection
(AttributeSection);
44
45
// Format version.
46
Streamer
.
EmitIntValue
(0x41, 1);
47
// Subsection length.
48
Streamer
.
EmitIntValue
(22, 4);
49
// Vendor name string, zero-terminated.
50
Streamer
.
EmitBytes
(
"mspabi"
);
51
Streamer
.
EmitIntValue
(0, 1);
52
53
// Attribute vector scope tag. 1 stands for the entire file.
54
Streamer
.
EmitIntValue
(1, 1);
55
// Attribute vector length.
56
Streamer
.
EmitIntValue
(11, 4);
57
// OFBA_MSPABI_Tag_ISA(4) = 1, MSP430
58
Streamer
.
EmitIntValue
(4, 1);
59
Streamer
.
EmitIntValue
(1, 1);
60
// OFBA_MSPABI_Tag_Code_Model(6) = 1, Small
61
Streamer
.
EmitIntValue
(6, 1);
62
Streamer
.
EmitIntValue
(1, 1);
63
// OFBA_MSPABI_Tag_Data_Model(8) = 1, Small
64
Streamer
.
EmitIntValue
(8, 1);
65
Streamer
.
EmitIntValue
(1, 1);
66
}
67
68
MCELFStreamer
&
MSP430TargetELFStreamer::getStreamer
() {
69
return
static_cast<
MCELFStreamer
&
>
(
Streamer
);
70
}
71
72
MCTargetStreamer
*
73
createMSP430ObjectTargetStreamer
(
MCStreamer
&S,
const
MCSubtargetInfo
&STI) {
74
const
Triple
&
TT
= STI.
getTargetTriple
();
75
if
(TT.
isOSBinFormatELF
())
76
return
new
MSP430TargetELFStreamer
(S, STI);
77
return
nullptr
;
78
}
79
80
}
// namespace llvm
llvm::MCAssembler::setELFHeaderEFlags
void setELFHeaderEFlags(unsigned Flags)
Definition:
MCAssembler.h:252
llvm::ELF::SHT_MSP430_ATTRIBUTES
Definition:
ELF.h:878
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition:
MCSection.h:39
MCSubtargetInfo.h
MCContext.h
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:23
llvm::Triple::isOSBinFormatELF
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition:
Triple.h:624
llvm::MCStreamer::EmitBytes
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition:
MCStreamer.cpp:1081
llvm::MCTargetStreamer
Target specific streamer interface.
Definition:
MCStreamer.h:91
MCELFStreamer.h
ELF.h
llvm::MCAssembler
Definition:
MCAssembler.h:60
MCStreamer.h
llvm::MCSubtargetInfo::getTargetTriple
const Triple & getTargetTriple() const
Definition:
MCSubtargetInfo.h:104
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition:
MCStreamer.h:266
MCSectionELF.h
llvm::MSP430TargetELFStreamer::getStreamer
MCELFStreamer & getStreamer()
Definition:
MSP430ELFStreamer.cpp:68
llvm::MCStreamer::EmitIntValue
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
Definition:
MCStreamer.cpp:131
llvm::MCStreamer
Streaming machine code generation interface.
Definition:
MCStreamer.h:197
llvm::MCELFStreamer
Definition:
MCELFStreamer.h:23
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:1103
llvm::MCObjectStreamer::getAssembler
MCAssembler & getAssembler()
Definition:
MCObjectStreamer.h:111
llvm::MCAssembler::getELFHeaderEFlags
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Definition:
MCAssembler.h:251
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:
Triple.h:43
llvm::MCTargetStreamer::Streamer
MCStreamer & Streamer
Definition:
MCStreamer.h:93
MSP430MCTargetDesc.h
llvm::MSP430TargetELFStreamer::MSP430TargetELFStreamer
MSP430TargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition:
MSP430ELFStreamer.cpp:32
llvm::createMSP430ObjectTargetStreamer
MCTargetStreamer * createMSP430ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition:
MSP430ELFStreamer.cpp:73
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition:
MCSubtargetInfo.h:74
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition:
MCContext.h:424
llvm::TT
Definition:
ARMBaseInstrInfo.h:496
llvm::MSP430TargetELFStreamer
Definition:
MSP430ELFStreamer.cpp:25
Generated on Tue Mar 24 2020 13:12:31 for LLVM by
1.8.13