LLVM 24.0.0git
RuntimeDyldCOFFAArch64.h
Go to the documentation of this file.
1//===-- RuntimeDyldCOFFAArch64.h --- COFF/AArch64 specific code ---*- C++*-===//
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// COFF AArch64 support for MC-JIT runtime dynamic linker.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFAARCH64_H
14#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFAARCH64_H
15
16#include "../RuntimeDyldCOFF.h"
19#include "llvm/Object/COFF.h"
20#include "llvm/Support/Endian.h"
21
22#define DEBUG_TYPE "dyld"
23
24namespace llvm {
25
26// This relocation type is used for handling long branch instruction
27// through the Stub.
31
32static void add16(uint8_t *p, int16_t v) {
33 using namespace llvm::support::endian;
34 write16le(p, read16le(p) + v);
35}
36
37static void or32le(void *P, int32_t V) {
38 using namespace llvm::support::endian;
39
40 write32le(P, read32le(P) | V);
41}
42
43static void write32AArch64Imm(uint8_t *T, uint64_t imm, uint32_t rangeLimit) {
44 using namespace llvm::support::endian;
45
46 uint32_t orig = read32le(T);
47 orig &= ~(0xFFF << 10);
48 write32le(T, orig | ((imm & (0xFFF >> rangeLimit)) << 10));
49}
50
51/// Byte addend held in an LDR/STR (unsigned immediate) instruction. Its imm12
52/// field counts access-size units, so reading it back has to undo that scaling
53/// the way write32AArch64Ldr applies it.
54static uint64_t read32AArch64LdrAddend(uint32_t Inst) {
55 uint32_t Size = Inst >> 30;
56 // 0x04000000 indicates SIMD/FP registers, 0x00800000 indicates 128 bit.
57 if ((Inst & 0x04800000) == 0x04800000)
58 Size += 4;
59 return static_cast<uint64_t>((Inst >> 10) & 0xFFF) << Size;
60}
61
62static void write32AArch64Ldr(uint8_t *T, uint64_t imm) {
63 using namespace llvm::support::endian;
64
65 uint32_t orig = read32le(T);
66 uint32_t size = orig >> 30;
67 // 0x04000000 indicates SIMD/FP registers
68 // 0x00800000 indicates 128 bit
69 if ((orig & 0x04800000) == 0x04800000)
70 size += 4;
71 if ((imm & ((1 << size) - 1)) != 0)
72 assert(0 && "misaligned ldr/str offset");
73 write32AArch64Imm(T, imm >> size, size);
74}
75
76static void write32AArch64Addr(void *T, uint64_t s, uint64_t p, int shift) {
77 using namespace llvm::support::endian;
78
79 uint64_t Imm = (s >> shift) - (p >> shift);
80 // ADRP's page offset is 21 bits signed (+/-4 GiB); fail loudly rather than
81 // truncate into a wild pointer.
82 if (!isInt<21>(static_cast<int64_t>(Imm))) {
83 report_fatal_error(Twine("ADRP target out of range: target=") + Twine(s) +
84 " pc=" + Twine(p) +
85 " delta=" + Twine(s > p ? s - p : p - s) +
86 (s > p ? " (target above pc)" : " (target below pc)") +
87 " -- needs a 21-bit signed page offset (+/-4 GiB)");
88 }
89 uint32_t ImmLo = (Imm & 0x3) << 29;
90 uint32_t ImmHi = (Imm & 0x1FFFFC) << 3;
91 uint64_t Mask = (0x3 << 29) | (0x1FFFFC << 3);
92 write32le(T, (read32le(T) & ~Mask) | ImmLo | ImmHi);
93}
94
96
97private:
98 uint64_t ImageBase;
99
100 // Fake an __ImageBase pointer by returning the section with the lowest adress
101 uint64_t getImageBase() {
102 if (!ImageBase) {
103 ImageBase = std::numeric_limits<uint64_t>::max();
104 for (const SectionEntry &Section : Sections)
105 // The Sections list may contain sections that weren't loaded for
106 // whatever reason: they may be debug sections, and ProcessAllSections
107 // is false, or they may be sections that contain 0 bytes. If the
108 // section isn't loaded, the load address will be 0, and it should not
109 // be included in the ImageBase calculation.
110 if (Section.getLoadAddress() != 0)
111 ImageBase = std::min(ImageBase, Section.getLoadAddress());
112 }
113 return ImageBase;
114 }
115
116public:
119 : RuntimeDyldCOFF(MM, Resolver, 8, COFF::IMAGE_REL_ARM64_ADDR64),
120 ImageBase(0) {}
121
122 Align getStubAlignment() override { return Align(8); }
123
124 unsigned getMaxStubSize() const override { return 20; }
125
126 /// GOT slot in this section's stub area holding the address of \p Name, so
127 /// an ADRP can reach external symbols (e.g. DLL exports) beyond +/-4 GiB.
128 /// computeSectionStubBufSize reserves getMaxStubSize() per relocation, which
129 /// covers the 8 bytes.
130 uint64_t getGOTEntryOffset(unsigned SectionID, StubMap &Stubs, StringRef Name,
131 bool CreateIfMissing) {
132 // Key on the symbol alone; ~0 cannot collide with a branch stub's offset.
134 Key.SectionID = SectionID;
135 Key.Offset = ~uint64_t(0);
136 Key.SymbolName = Name.data();
137
138 // RelocationValueRef compares symbol-name pointers rather than their
139 // contents, but paired COFF relocations need not carry the same pointer.
140 for (const auto &[StubKey, StubOffset] : Stubs)
141 if (StubKey.SectionID == SectionID && StubKey.Offset == ~uint64_t(0) &&
142 StubKey.SymbolName && StringRef(StubKey.SymbolName) == Name)
143 return StubOffset;
144 if (!CreateIfMissing)
145 return ~uint64_t(0);
146
147 SectionEntry &Sec = Sections[SectionID];
148 uint64_t EntryOffset = alignTo(Sec.getStubOffset(), 8);
149 Sec.advanceStubOffset(EntryOffset + 8 - Sec.getStubOffset());
150 Stubs[Key] = EntryOffset;
151
152 // Have the resolver write the symbol's absolute address into the slot.
153 RelocationEntry RE(SectionID, EntryOffset, COFF::IMAGE_REL_ARM64_ADDR64, 0,
154 /*IsPCRel=*/false, Log2_64(8));
155 addRelocationForSymbol(RE, Name);
156
157 LLVM_DEBUG(dbgs() << " Created GOT entry for " << Name << " at offset "
158 << EntryOffset << "\n");
159 return EntryOffset;
160 }
161
162 /// ADD (immediate, no shift): the second half of the ADRP+ADD idiom.
163 static bool isAddImmediate(uint32_t Inst) {
164 // sf 0 0 100010 sh imm12 Rn Rd with sh == 0; excludes ADDS (bit 29).
165 return (Inst & 0x7FC00000) == 0x11000000;
166 }
167
168 std::tuple<uint64_t, uint64_t, uint64_t>
169 generateRelocationStub(unsigned SectionID, StringRef TargetName,
170 uint64_t Offset, uint64_t RelType, uint64_t Addend,
171 StubMap &Stubs) {
172 uintptr_t StubOffset;
173 SectionEntry &Section = Sections[SectionID];
174
175 RelocationValueRef OriginalRelValueRef;
176 OriginalRelValueRef.SectionID = SectionID;
177 OriginalRelValueRef.Offset = Offset;
178 OriginalRelValueRef.Addend = Addend;
179 OriginalRelValueRef.SymbolName = TargetName.data();
180
181 auto [Stub, Inserted] = Stubs.try_emplace(OriginalRelValueRef);
182 if (Inserted) {
183 LLVM_DEBUG(dbgs() << " Create a new stub function for "
184 << TargetName.data() << "\n");
185
186 StubOffset = Section.getStubOffset();
187 Stub->second = StubOffset;
188 createStubFunction(Section.getAddressWithOffset(StubOffset));
189 Section.advanceStubOffset(getMaxStubSize());
190 } else {
191 LLVM_DEBUG(dbgs() << " Stub function found for " << TargetName.data()
192 << "\n");
193 StubOffset = Stub->second;
194 }
195
196 // Resolve original relocation to stub function.
197 const RelocationEntry RE(SectionID, Offset, RelType, Addend);
198 resolveRelocation(RE, Section.getLoadAddressWithOffset(StubOffset));
199
200 // adjust relocation info so resolution writes to the stub function
201 // Here an internal relocation type is used for resolving long branch via
202 // stub instruction.
203 Addend = 0;
204 Offset = StubOffset;
206
207 return std::make_tuple(Offset, RelType, Addend);
208 }
209
212 const object::ObjectFile &Obj,
213 ObjSectionToIDMap &ObjSectionToID,
214 StubMap &Stubs) override {
215 using namespace llvm::support::endian;
216
217 auto Symbol = RelI->getSymbol();
218 if (Symbol == Obj.symbol_end())
219 report_fatal_error("Unknown symbol in relocation");
220
221 Expected<StringRef> TargetNameOrErr = Symbol->getName();
222 if (!TargetNameOrErr)
223 return TargetNameOrErr.takeError();
224 StringRef TargetName = *TargetNameOrErr;
225
226 auto SectionOrErr = Symbol->getSection();
227 if (!SectionOrErr)
228 return SectionOrErr.takeError();
229 auto Section = *SectionOrErr;
230
231 uint64_t RelType = RelI->getType();
232 uint64_t Offset = RelI->getOffset();
233
234 // If there is no section, this must be an external reference.
235 bool IsExtern = Section == Obj.section_end();
236
237 // Determine the Addend used to adjust the relocation value.
238 uint64_t Addend = 0;
239 SectionEntry &AddendSection = Sections[SectionID];
240 uintptr_t ObjTarget = AddendSection.getObjAddress() + Offset;
241 uint8_t *Displacement = (uint8_t *)ObjTarget;
242
243 unsigned TargetSectionID = -1;
244 uint64_t TargetOffset = -1;
245
246 if (TargetName.starts_with(getImportSymbolPrefix())) {
247 TargetSectionID = SectionID;
248 TargetOffset = getDLLImportOffset(SectionID, Stubs, TargetName);
249 TargetName = StringRef();
250 IsExtern = false;
251 } else if (!IsExtern) {
252 if (auto TargetSectionIDOrErr = findOrEmitSection(
253 Obj, *Section, Section->isText(), ObjSectionToID))
254 TargetSectionID = *TargetSectionIDOrErr;
255 else
256 return TargetSectionIDOrErr.takeError();
257
258 TargetOffset = getSymbolOffset(*Symbol);
259 }
260
261 switch (RelType) {
266 Addend = read32le(Displacement);
267 break;
269 uint32_t orig = read32le(Displacement);
270 Addend = (orig & 0x03FFFFFF) << 2;
271
272 if (IsExtern)
273 std::tie(Offset, RelType, Addend) = generateRelocationStub(
274 SectionID, TargetName, Offset, RelType, Addend, Stubs);
275 break;
276 }
278 uint32_t orig = read32le(Displacement);
279 Addend = (orig & 0x00FFFFE0) >> 3;
280 break;
281 }
283 uint32_t orig = read32le(Displacement);
284 Addend = (orig & 0x000FFFE0) >> 3;
285 break;
286 }
289 uint32_t orig = read32le(Displacement);
290 Addend = ((orig >> 29) & 0x3) | ((orig >> 3) & 0x1FFFFC);
291
292 // External symbols are routinely beyond ADRP's +/-4 GiB on Windows and
293 // there is no veneer, so route ADRP+ADD through a GOT slot. Only that
294 // idiom qualifies: ADRP+LDR reads the symbol's contents, and a non-zero
295 // addend cannot be expressed by a slot holding plain `sym`. LLVM codegen
296 // emits direct addresses as a MOVaddr pseudo and expands it after
297 // scheduling into this adjacent ADRP+ADD pair.
298 if (IsExtern && Addend == 0 &&
300 uint32_t NextInst = read32le(Displacement + 4);
301 if (isAddImmediate(NextInst) && ((NextInst >> 10) & 0xFFF) == 0) {
302 TargetOffset = getGOTEntryOffset(SectionID, Stubs, TargetName,
303 /*CreateIfMissing=*/true);
304 TargetSectionID = SectionID;
305 TargetName = StringRef();
306 IsExtern = false;
307 Addend = 0;
308 }
309 }
310 break;
311 }
313 Addend = read32AArch64LdrAddend(read32le(Displacement));
314 break;
315 }
317 uint32_t orig = read32le(Displacement);
318 Addend = ((orig >> 10) & 0xFFF);
319
320 // Partner of the ADRP above; no slot means that ADRP was left alone.
321 if (IsExtern && Addend == 0 &&
323 uint64_t GOTOffset = getGOTEntryOffset(SectionID, Stubs, TargetName,
324 /*CreateIfMissing=*/false);
325 if (GOTOffset != ~uint64_t(0) && isAddImmediate(orig)) {
326 // ADD Xd, Xn, #imm -> LDR Xd, [Xn, #imm]: load the slot instead.
327 uint32_t Rd = orig & 0x1F;
328 uint32_t Rn = (orig >> 5) & 0x1F;
330 0xF9400000u | (Rn << 5) | Rd);
331
332 // 12L so the resolver scales the immediate for a 64-bit load.
334 TargetOffset = GOTOffset;
335 TargetSectionID = SectionID;
336 TargetName = StringRef();
337 IsExtern = false;
338 Addend = 0;
339 }
340 }
341 break;
342 }
343
345 Addend = read64le(Displacement);
346 break;
347 }
348 default:
349 break;
350 }
351
352#if !defined(NDEBUG)
353 SmallString<32> RelTypeName;
354 RelI->getTypeName(RelTypeName);
355
356 LLVM_DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset
357 << " RelType: " << RelTypeName << " TargetName: "
358 << TargetName << " Addend " << Addend << "\n");
359#endif
360
361 if (IsExtern) {
362 RelocationEntry RE(SectionID, Offset, RelType, Addend);
363 addRelocationForSymbol(RE, TargetName);
364 } else {
365 RelocationEntry RE(SectionID, Offset, RelType, TargetOffset + Addend);
366 addRelocationForSection(RE, TargetSectionID);
367 }
368 return ++RelI;
369 }
370
371 void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override {
372 using namespace llvm::support::endian;
373
374 const auto Section = Sections[RE.SectionID];
375 uint8_t *Target = Section.getAddressWithOffset(RE.Offset);
376 uint64_t FinalAddress = Section.getLoadAddressWithOffset(RE.Offset);
377
378 switch (RE.RelType) {
379 default:
380 llvm_unreachable("unsupported relocation type");
382 // This relocation is ignored.
383 break;
384 }
386 // The page base of the target, for ADRP instruction.
387 Value += RE.Addend;
388 write32AArch64Addr(Target, Value, FinalAddress, 12);
389 break;
390 }
392 // The 12-bit relative displacement to the target, for instruction ADR
393 Value += RE.Addend;
394 write32AArch64Addr(Target, Value, FinalAddress, 0);
395 break;
396 }
398 // The 12-bit page offset of the target,
399 // for instructions ADD/ADDS (immediate) with zero shift.
400 Value += RE.Addend;
401 write32AArch64Imm(Target, Value & 0xFFF, 0);
402 break;
403 }
405 // The 12-bit page offset of the target,
406 // for instruction LDR (indexed, unsigned immediate).
407 Value += RE.Addend;
409 break;
410 }
412 // The 32-bit VA of the target.
413 uint32_t VA = Value + RE.Addend;
414 write32le(Target, VA);
415 break;
416 }
418 // The target's 32-bit RVA.
419 uint64_t RVA = Value + RE.Addend - getImageBase();
420 write32le(Target, RVA);
421 break;
422 }
424 // Encode the immadiate value for generated Stub instruction (MOVZ)
425 or32le(Target + 12, ((Value + RE.Addend) & 0xFFFF) << 5);
426 or32le(Target + 8, ((Value + RE.Addend) & 0xFFFF0000) >> 11);
427 or32le(Target + 4, ((Value + RE.Addend) & 0xFFFF00000000) >> 27);
428 or32le(Target + 0, ((Value + RE.Addend) & 0xFFFF000000000000) >> 43);
429 break;
430 }
432 // The 26-bit relative displacement to the target, for B and BL
433 // instructions.
434 uint64_t PCRelVal = Value + RE.Addend - FinalAddress;
435 assert(isInt<28>(PCRelVal) && "Branch target is out of range.");
436 write32le(Target, (read32le(Target) & ~(0x03FFFFFF)) |
437 (PCRelVal & 0x0FFFFFFC) >> 2);
438 break;
439 }
441 // The 19-bit offset to the relocation target,
442 // for conditional B instruction.
443 uint64_t PCRelVal = Value + RE.Addend - FinalAddress;
444 assert(isInt<21>(PCRelVal) && "Branch target is out of range.");
445 write32le(Target, (read32le(Target) & ~(0x00FFFFE0)) |
446 (PCRelVal & 0x001FFFFC) << 3);
447 break;
448 }
450 // The 14-bit offset to the relocation target,
451 // for instructions TBZ and TBNZ.
452 uint64_t PCRelVal = Value + RE.Addend - FinalAddress;
453 assert(isInt<16>(PCRelVal) && "Branch target is out of range.");
454 write32le(Target, (read32le(Target) & ~(0x000FFFE0)) |
455 (PCRelVal & 0x0000FFFC) << 3);
456 break;
457 }
459 // The 64-bit VA of the relocation target.
461 break;
462 }
464 // 16-bit section index of the section that contains the target.
465 assert(static_cast<uint32_t>(RE.SectionID) <= UINT16_MAX &&
466 "relocation overflow");
468 break;
469 }
471 // 32-bit offset of the target from the beginning of its section.
472 assert(static_cast<int64_t>(RE.Addend) <= INT32_MAX &&
473 "Relocation overflow");
474 assert(static_cast<int64_t>(RE.Addend) >= INT32_MIN &&
475 "Relocation underflow");
477 break;
478 }
480 // The 32-bit relative address from the byte following the relocation.
481 uint64_t Result = Value - FinalAddress - 4;
482 write32le(Target, Result + RE.Addend);
483 break;
484 }
485 }
486 }
487
488 void registerEHFrames() override {}
489};
490
491} // End namespace llvm
492
493#undef DEBUG_TYPE
494
495#endif // LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFAARCH64_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
#define T
#define P(N)
This file defines the SmallString class.
#define LLVM_DEBUG(...)
Definition Debug.h:119
void write32le(void *P, uint32_t V)
Definition Endian.h:455
Tagged union holding either a T or a Error.
Definition Error.h:485
Error takeError()
Take ownership of the stored error.
Definition Error.h:612
Symbol resolution interface.
Definition JITSymbol.h:373
RelocationEntry - used to represent relocations internally in the dynamic linker.
uint32_t RelType
RelType - relocation type.
uint64_t Offset
Offset - offset into the section.
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
unsigned SectionID
SectionID - the section this relocation points to.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition Record.h:2295
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
unsigned getMaxStubSize() const override
RuntimeDyldCOFFAArch64(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
std::tuple< uint64_t, uint64_t, uint64_t > generateRelocationStub(unsigned SectionID, StringRef TargetName, uint64_t Offset, uint64_t RelType, uint64_t Addend, StubMap &Stubs)
Expected< object::relocation_iterator > processRelocationRef(unsigned SectionID, object::relocation_iterator RelI, const object::ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs) override
Parses one or more object file relocations (some object files use relocation pairs) and stores it to ...
uint64_t getGOTEntryOffset(unsigned SectionID, StubMap &Stubs, StringRef Name, bool CreateIfMissing)
GOT slot in this section's stub area holding the address of Name, so an ADRP can reach external symbo...
static bool isAddImmediate(uint32_t Inst)
ADD (immediate, no shift): the second half of the ADRP+ADD idiom.
uint64_t getSymbolOffset(const SymbolRef &Sym)
static constexpr StringRef getImportSymbolPrefix()
RuntimeDyldCOFF(RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver, unsigned PointerSize, uint32_t PointerReloc)
uint64_t getDLLImportOffset(unsigned SectionID, StubMap &Stubs, StringRef Name, bool SetSectionIDMinus1=false)
std::map< SectionRef, unsigned > ObjSectionToIDMap
std::map< RelocationValueRef, uintptr_t > StubMap
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
void addRelocationForSection(const RelocationEntry &RE, unsigned SectionID)
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
uint8_t * createStubFunction(uint8_t *Addr, unsigned AbiVariant=0)
Emits long jump instruction to Addr.
SectionEntry - represents a section emitted into memory by the dynamic linker.
uint8_t * getAddressWithOffset(unsigned OffsetBytes) const
Return the address of this section with an offset.
void advanceStubOffset(unsigned StubSize)
uintptr_t getStubOffset() const
uintptr_t getObjAddress() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:138
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM Value Representation.
Definition Value.h:75
This class is the base class for all object file types.
Definition ObjectFile.h:231
uint64_t getType() const
Definition ObjectFile.h:633
uint64_t getOffset() const
Definition ObjectFile.h:625
symbol_iterator getSymbol() const
Definition ObjectFile.h:629
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
Definition ObjectFile.h:637
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_REL_ARM64_SECREL
Definition COFF.h:409
@ IMAGE_REL_ARM64_BRANCH19
Definition COFF.h:416
@ IMAGE_REL_ARM64_REL32
Definition COFF.h:418
@ IMAGE_REL_ARM64_ADDR32
Definition COFF.h:402
@ IMAGE_REL_ARM64_SECTION
Definition COFF.h:414
@ IMAGE_REL_ARM64_ABSOLUTE
Definition COFF.h:401
@ IMAGE_REL_ARM64_PAGEOFFSET_12A
Definition COFF.h:407
@ IMAGE_REL_ARM64_BRANCH14
Definition COFF.h:417
@ IMAGE_REL_ARM64_BRANCH26
Definition COFF.h:404
@ IMAGE_REL_ARM64_PAGEOFFSET_12L
Definition COFF.h:408
@ IMAGE_REL_ARM64_ADDR32NB
Definition COFF.h:403
@ IMAGE_REL_ARM64_PAGEBASE_REL21
Definition COFF.h:405
@ IMAGE_REL_ARM64_REL21
Definition COFF.h:406
@ IMAGE_REL_ARM64_ADDR64
Definition COFF.h:415
content_iterator< RelocationRef > relocation_iterator
Definition ObjectFile.h:79
uint64_t read64le(const void *P)
Definition Endian.h:415
uint16_t read16le(const void *P)
Definition Endian.h:409
void write64le(void *P, uint64_t V)
Definition Endian.h:458
void write16le(void *P, uint16_t V)
Definition Endian.h:452
uint32_t read32le(const void *P)
Definition Endian.h:412
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1685
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:166
@ INTERNAL_REL_ARM64_LONG_BRANCH26
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition MathExtras.h:332
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
static uint64_t read32AArch64LdrAddend(uint32_t Inst)
Byte addend held in an LDR/STR (unsigned immediate) instruction.
static void write32AArch64Ldr(uint8_t *T, uint64_t imm)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:149
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
static void or32le(void *P, int32_t V)
static void add16(uint8_t *p, int16_t v)
static void write32AArch64Imm(uint8_t *T, uint64_t imm, uint32_t rangeLimit)
static void write32AArch64Addr(void *T, uint64_t s, uint64_t p, int shift)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39