LLVM
8.0.1
lib
Target
MSP430
MCTargetDesc
MSP430ELFStreamer.cpp
Go to the documentation of this file.
1
//===-- MSP430ELFStreamer.cpp - MSP430 ELF Target Streamer Methods --------===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file provides MSP430 specific target streamer methods.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
MSP430MCTargetDesc.h
"
15
#include "
llvm/BinaryFormat/ELF.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
22
using namespace
llvm
;
23
24
namespace
llvm
{
25
26
class
MSP430TargetELFStreamer
:
public
MCTargetStreamer
{
27
public
:
28
MCELFStreamer
&
getStreamer
();
29
MSP430TargetELFStreamer
(
MCStreamer
&S,
const
MCSubtargetInfo
&STI);
30
};
31
32
// This part is for ELF object output.
33
MSP430TargetELFStreamer::MSP430TargetELFStreamer
(
MCStreamer
&S,
34
const
MCSubtargetInfo
&STI)
35
:
MCTargetStreamer
(S) {
36
MCAssembler
&MCA =
getStreamer
().
getAssembler
();
37
unsigned
EFlags = MCA.
getELFHeaderEFlags
();
38
MCA.
setELFHeaderEFlags
(EFlags);
39
40
// Emit build attributes section according to
41
// MSP430 EABI (slaa534.pdf, part 13).
42
MCSection
*AttributeSection =
getStreamer
().
getContext
().
getELFSection
(
43
".MSP430.attributes"
,
ELF::SHT_MSP430_ATTRIBUTES
, 0);
44
Streamer
.
SwitchSection
(AttributeSection);
45
46
// Format version.
47
Streamer
.
EmitIntValue
(0x41, 1);
48
// Subsection length.
49
Streamer
.
EmitIntValue
(22, 4);
50
// Vendor name string, zero-terminated.
51
Streamer
.
EmitBytes
(
"mspabi"
);
52
Streamer
.
EmitIntValue
(0, 1);
53
54
// Attribute vector scope tag. 1 stands for the entire file.
55
Streamer
.
EmitIntValue
(1, 1);
56
// Attribute vector length.
57
Streamer
.
EmitIntValue
(11, 4);
58
// OFBA_MSPABI_Tag_ISA(4) = 1, MSP430
59
Streamer
.
EmitIntValue
(4, 1);
60
Streamer
.
EmitIntValue
(1, 1);
61
// OFBA_MSPABI_Tag_Code_Model(6) = 1, Small
62
Streamer
.
EmitIntValue
(6, 1);
63
Streamer
.
EmitIntValue
(1, 1);
64
// OFBA_MSPABI_Tag_Data_Model(8) = 1, Small
65
Streamer
.
EmitIntValue
(8, 1);
66
Streamer
.
EmitIntValue
(1, 1);
67
}
68
69
MCELFStreamer
&
MSP430TargetELFStreamer::getStreamer
() {
70
return
static_cast<
MCELFStreamer
&
>
(
Streamer
);
71
}
72
73
MCTargetStreamer
*
74
createMSP430ObjectTargetStreamer
(
MCStreamer
&S,
const
MCSubtargetInfo
&STI) {
75
const
Triple
&TT = STI.
getTargetTriple
();
76
if
(TT.
isOSBinFormatELF
())
77
return
new
MSP430TargetELFStreamer
(S, STI);
78
return
nullptr
;
79
}
80
81
}
// namespace llvm
llvm::MCAssembler::setELFHeaderEFlags
void setELFHeaderEFlags(unsigned Flags)
Definition:
MCAssembler.h:256
llvm::ELF::SHT_MSP430_ATTRIBUTES
Definition:
ELF.h:870
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:24
llvm::Triple::isOSBinFormatELF
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition:
Triple.h:604
llvm::MCStreamer::EmitBytes
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition:
MCStreamer.cpp:1018
llvm::MCTargetStreamer
Target specific streamer interface.
Definition:
MCStreamer.h:84
MCELFStreamer.h
ELF.h
llvm::MCAssembler
Definition:
MCAssembler.h:61
MCStreamer.h
llvm::MCSubtargetInfo::getTargetTriple
const Triple & getTargetTriple() const
Definition:
MCSubtargetInfo.h:68
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition:
MCStreamer.h:251
MCSectionELF.h
llvm::MSP430TargetELFStreamer::getStreamer
MCELFStreamer & getStreamer()
Definition:
MSP430ELFStreamer.cpp:69
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:124
llvm::MCStreamer
Streaming machine code generation interface.
Definition:
MCStreamer.h:189
llvm::MCELFStreamer
Definition:
MCELFStreamer.h:24
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:1040
llvm::MCObjectStreamer::getAssembler
MCAssembler & getAssembler()
Definition:
MCObjectStreamer.h:105
llvm::MCAssembler::getELFHeaderEFlags
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Definition:
MCAssembler.h:255
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:
Triple.h:44
llvm::MCTargetStreamer::Streamer
MCStreamer & Streamer
Definition:
MCStreamer.h:86
MSP430MCTargetDesc.h
llvm::MSP430TargetELFStreamer::MSP430TargetELFStreamer
MSP430TargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition:
MSP430ELFStreamer.cpp:33
llvm::createMSP430ObjectTargetStreamer
MCTargetStreamer * createMSP430ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition:
MSP430ELFStreamer.cpp:74
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition:
MCSubtargetInfo.h:36
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition:
MCContext.h:389
llvm::MSP430TargetELFStreamer
Definition:
MSP430ELFStreamer.cpp:26
Generated on Sun Dec 20 2020 13:57:23 for LLVM by
1.8.13