LLVM: lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
23
24using namespace llvm;
25
27 "aarch64-mark-bti-property", cl::Hidden,
28 cl::desc("Add .note.gnu.property with BTI to assembly files"),
30
31
32
33
36
38
42 bool HasAddressDiversity) {
44 HasAddressDiversity,
46 8);
47}
48
49
50
56
58 ConstantPools->emitForCurrentSection(Streamer);
59}
60
62 ConstantPools->emitAll(Streamer);
63}
64
65
66
71
76 (PAuthABIVersion == uint64_t(-1)));
78 if (Flags != 0)
79 DescSz += 4 * 4;
80 if (PAuthABIPlatform != uint64_t(-1))
81 DescSz += 4 + 4 + 8 * 2;
82 if (DescSz == 0)
83 return;
84
87
92 Context.reportWarning(
94 "The .note.gnu.property is not emitted because it is already present.");
95 return;
96 }
99
100
102 OutStreamer.emitIntValue(4, 4);
103 OutStreamer.emitIntValue(DescSz, 4);
106
107
108 if (Flags != 0) {
113 }
114
115
116 if (PAuthABIPlatform != uint64_t(-1)) {
118 OutStreamer.emitIntValue(8 * 2, 4);
119 OutStreamer.emitIntValue(PAuthABIPlatform, 8);
120 OutStreamer.emitIntValue(PAuthABIVersion, 8);
121 }
122
125}
126
128 char Buffer[4];
129
130
131
132
133 for (char &C : Buffer) {
135 Inst >>= 8;
136 }
137
139}
140
145 if (TT.isOSBinFormatELF())
147 if (TT.isOSBinFormatCOFF())
149 return nullptr;
150}
151
155
159
160
162 if (VendorName == SubSection.VendorName) {
164 return;
165 }
166 }
167
169 AttSubSection.VendorName = VendorName;
170 AttSubSection.IsOptional = IsOptional;
174}
175
176std::unique_ptrMCELFStreamer::AttributeSubSection
179 if (SubSection.IsActive) {
180 return std::make_uniqueMCELFStreamer::AttributeSubSection(SubSection);
181 }
182 }
183 return nullptr;
184}
185
186std::unique_ptrMCELFStreamer::AttributeSubSection
189 if (Name == SubSection.VendorName) {
190 return std::make_uniqueMCELFStreamer::AttributeSubSection(SubSection);
191 }
192 }
193 return nullptr;
194}
195
198
199 if (unsigned(-1) == Value && "" == String) {
200 assert(0 && "Arguments error");
201 return;
202 }
205 "Can not add AArch64 build attribute: no AArch64 subsection exists");
206 return;
207 }
208
210 if (VendorName == SubSection.VendorName) {
211 if (!SubSection.IsActive) {
213 "Can not add AArch64 build attribute: subsection is not active");
214 return;
215 }
217
224 return;
225 }
226 }
227 if (unsigned(-1) != Value)
234 return;
235 }
236 }
237 assert(0 && "Can not add AArch64 build attribute: required subsection does "
238 "not exist");
239}
240
243 if (VendorName == SubSection.VendorName) {
244 SubSection.IsActive = true;
245 } else {
246 SubSection.IsActive = false;
247 }
248 }
249}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > MarkBTIProperty("aarch64-mark-bti-property", cl::Hidden, cl::desc("Add .note.gnu.property with BTI to assembly files"), cl::init(false))
static const AArch64AuthMCExpr * create(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key, bool HasAddressDiversity, MCContext &Ctx, SMLoc Loc=SMLoc())
AArch64TargetStreamer(MCStreamer &S)
Definition AArch64TargetStreamer.cpp:34
virtual void emitAttributesSubsection(StringRef VendorName, AArch64BuildAttributes::SubsectionOptional IsOptional, AArch64BuildAttributes::SubsectionType ParameterType)
Build attributes implementation.
Definition AArch64TargetStreamer.cpp:156
void activateAttributesSubsection(StringRef VendorName)
Definition AArch64TargetStreamer.cpp:241
void finish() override
Definition AArch64TargetStreamer.cpp:67
std::unique_ptr< MCELFStreamer::AttributeSubSection > getActiveAttributesSubsection()
Definition AArch64TargetStreamer.cpp:177
void emitConstantPools() override
Definition AArch64TargetStreamer.cpp:61
const MCExpr * addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc)
Callback used to implement the ldr= pseudo.
Definition AArch64TargetStreamer.cpp:51
~AArch64TargetStreamer() override
SmallVector< MCELFStreamer::AttributeSubSection, 64 > AttributeSubSections
std::unique_ptr< MCELFStreamer::AttributeSubSection > getAttributesSubsectionByName(StringRef Name)
Definition AArch64TargetStreamer.cpp:187
void emitNoteSection(unsigned Flags, uint64_t PAuthABIPlatform=-1, uint64_t PAuthABIVersion=-1)
Callback used to implement the .note.gnu.property section.
Definition AArch64TargetStreamer.cpp:72
void emitAuthValue(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key, bool HasAddressDiversity)
Callback used to emit AUTH expressions (e.g.
Definition AArch64TargetStreamer.cpp:39
virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, std::string String)
Definition AArch64TargetStreamer.cpp:196
void emitCurrentConstantPool()
Callback used to implement the .ltorg directive.
Definition AArch64TargetStreamer.cpp:57
virtual void emitInst(uint32_t Inst)
Callback used to implement the .inst directive.
Definition AArch64TargetStreamer.cpp:127
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
This represents a section on linux, lots of unix variants and some bare metal systems.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
bool isRegistered() const
Streaming machine code generation interface.
MCContext & getContext() const
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
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.
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
MCSection * getCurrentSectionOnly() const
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
Target specific streamer interface.
MCStreamer & getStreamer()
MCTargetStreamer(MCStreamer &S)
Represents a location in source code.
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
@ GNU_PROPERTY_AARCH64_FEATURE_1_BTI
@ GNU_PROPERTY_AARCH64_FEATURE_PAUTH
@ GNU_PROPERTY_AARCH64_FEATURE_1_AND
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
MCTargetStreamer * createAArch64NullTargetStreamer(MCStreamer &S)
Definition AArch64TargetStreamer.cpp:152
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
MCTargetStreamer * createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition AArch64TargetStreamer.cpp:142
This struct is a compact representation of a valid (non-zero power of two) alignment.
ELF object attributes section emission support.
enum llvm::MCELFStreamer::AttributeItem::Types Type
ELF object attributes subsection support.