37 ~AArch64AsmBackend() {
81 class ELFAArch64AsmBackend :
public AArch64AsmBackend {
84 ELFAArch64AsmBackend(
const Target &
T,
const StringRef TT,
86 : AArch64AsmBackend(T, TT), OSABI(_OSABI) { }
88 bool fixupNeedsRelaxation(
const MCFixup &Fixup,
93 unsigned int getNumFixupKinds()
const {
106 {
"fixup_a64_add_lo12", 0, 32, 0 },
107 {
"fixup_a64_ldst8_lo12", 0, 32, 0 },
108 {
"fixup_a64_ldst16_lo12", 0, 32, 0 },
109 {
"fixup_a64_ldst32_lo12", 0, 32, 0 },
110 {
"fixup_a64_ldst64_lo12", 0, 32, 0 },
111 {
"fixup_a64_ldst128_lo12", 0, 32, 0 },
116 {
"fixup_a64_movw_uabs_g0", 0, 32, 0 },
117 {
"fixup_a64_movw_uabs_g0_nc", 0, 32, 0 },
118 {
"fixup_a64_movw_uabs_g1", 0, 32, 0 },
119 {
"fixup_a64_movw_uabs_g1_nc", 0, 32, 0 },
120 {
"fixup_a64_movw_uabs_g2", 0, 32, 0 },
121 {
"fixup_a64_movw_uabs_g2_nc", 0, 32, 0 },
122 {
"fixup_a64_movw_uabs_g3", 0, 32, 0 },
123 {
"fixup_a64_movw_sabs_g0", 0, 32, 0 },
124 {
"fixup_a64_movw_sabs_g1", 0, 32, 0 },
125 {
"fixup_a64_movw_sabs_g2", 0, 32, 0 },
127 {
"fixup_a64_ld64_got_lo12_nc", 0, 32, 0 },
128 {
"fixup_a64_movw_dtprel_g2", 0, 32, 0 },
129 {
"fixup_a64_movw_dtprel_g1", 0, 32, 0 },
130 {
"fixup_a64_movw_dtprel_g1_nc", 0, 32, 0 },
131 {
"fixup_a64_movw_dtprel_g0", 0, 32, 0 },
132 {
"fixup_a64_movw_dtprel_g0_nc", 0, 32, 0 },
133 {
"fixup_a64_add_dtprel_hi12", 0, 32, 0 },
134 {
"fixup_a64_add_dtprel_lo12", 0, 32, 0 },
135 {
"fixup_a64_add_dtprel_lo12_nc", 0, 32, 0 },
136 {
"fixup_a64_ldst8_dtprel_lo12", 0, 32, 0 },
137 {
"fixup_a64_ldst8_dtprel_lo12_nc", 0, 32, 0 },
138 {
"fixup_a64_ldst16_dtprel_lo12", 0, 32, 0 },
139 {
"fixup_a64_ldst16_dtprel_lo12_nc", 0, 32, 0 },
140 {
"fixup_a64_ldst32_dtprel_lo12", 0, 32, 0 },
141 {
"fixup_a64_ldst32_dtprel_lo12_nc", 0, 32, 0 },
142 {
"fixup_a64_ldst64_dtprel_lo12", 0, 32, 0 },
143 {
"fixup_a64_ldst64_dtprel_lo12_nc", 0, 32, 0 },
144 {
"fixup_a64_movw_gottprel_g1", 0, 32, 0 },
145 {
"fixup_a64_movw_gottprel_g0_nc", 0, 32, 0 },
147 {
"fixup_a64_ld64_gottprel_lo12_nc", 0, 32, 0 },
149 {
"fixup_a64_movw_tprel_g2", 0, 32, 0 },
150 {
"fixup_a64_movw_tprel_g1", 0, 32, 0 },
151 {
"fixup_a64_movw_tprel_g1_nc", 0, 32, 0 },
152 {
"fixup_a64_movw_tprel_g0", 0, 32, 0 },
153 {
"fixup_a64_movw_tprel_g0_nc", 0, 32, 0 },
154 {
"fixup_a64_add_tprel_hi12", 0, 32, 0 },
155 {
"fixup_a64_add_tprel_lo12", 0, 32, 0 },
156 {
"fixup_a64_add_tprel_lo12_nc", 0, 32, 0 },
157 {
"fixup_a64_ldst8_tprel_lo12", 0, 32, 0 },
158 {
"fixup_a64_ldst8_tprel_lo12_nc", 0, 32, 0 },
159 {
"fixup_a64_ldst16_tprel_lo12", 0, 32, 0 },
160 {
"fixup_a64_ldst16_tprel_lo12_nc", 0, 32, 0 },
161 {
"fixup_a64_ldst32_tprel_lo12", 0, 32, 0 },
162 {
"fixup_a64_ldst32_tprel_lo12_nc", 0, 32, 0 },
163 {
"fixup_a64_ldst64_tprel_lo12", 0, 32, 0 },
164 {
"fixup_a64_ldst64_tprel_lo12_nc", 0, 32, 0 },
166 {
"fixup_a64_tlsdesc_ld64_lo12_nc", 0, 32, 0 },
167 {
"fixup_a64_tlsdesc_add_lo12_nc", 0, 32, 0 },
168 {
"fixup_a64_tlsdesc_call", 0, 0, 0 }
178 void applyFixup(
const MCFixup &Fixup,
char *Data,
unsigned DataSize,
179 uint64_t Value)
const {
180 unsigned NumBytes = getFixupKindInfo(Fixup.
getKind()).TargetSize / 8;
185 assert(Offset + NumBytes <= DataSize &&
"Invalid fixup offset!");
189 for (
unsigned i = 0; i != NumBytes; ++i) {
190 Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
194 bool mayNeedRelaxation(
const MCInst&)
const {
210 ELFAArch64AsmBackend::fixupNeedsRelaxation(
const MCFixup &Fixup,
220 bool AArch64AsmBackend::writeNopData(uint64_t Count,
MCObjectWriter *OW)
const {
225 uint64_t NumNops = Count / 4;
226 for (uint64_t i = 0; i != NumNops; ++i)
233 unsigned lo2 = Value & 0x3;
234 unsigned hi19 = (Value & 0x1fffff) >> 2;
236 return (hi19 << 5) | (lo2 << 29);
244 assert((int64_t)Value >= -32768 &&
245 (int64_t)Value <= 65536 &&
246 "Out of range ABS16 fixup");
249 assert((int64_t)Value >= -(1LL << 31) &&
250 (int64_t)Value <= (1LL << 32) - 1 &&
251 "Out of range ABS32 fixup");
262 assert((int64_t)Value >= -(1LL << 20) &&
263 (int64_t)Value < (1LL << 20) &&
"Out of range LDR (lit) fixup");
264 return (Value & 0x1ffffc) << 3;
269 assert((int64_t)Value >= -(1LL << 20) &&
270 (int64_t)Value < (1LL << 20) &&
"Out of range ADR fixup");
277 assert((int64_t)Value >= -(1LL << 32) &&
278 (int64_t)Value < (1LL << 32) &&
"Out of range ADRP fixup");
279 return ADRImmBits((Value & 0x1fffff000ULL) >> 12);
287 assert((int64_t)Value >= 0 &&
288 (int64_t)Value < (1LL << 24) &&
"Out of range ADD fixup");
289 return (Value & 0xfff000) >> 2;
297 assert((int64_t)Value >= 0 &&
298 (int64_t)Value < (1LL << 12) &&
"Out of range ADD fixup");
312 return (Value & 0xfff) << 10;
320 assert((int64_t) Value >= 0 &&
321 (int64_t) Value < (1LL << 12) &&
"Out of range LD/ST fixup");
332 return (Value & 0xfff) << 10;
340 assert((int64_t) Value >= 0 &&
341 (int64_t) Value < (1LL << 12) &&
"Out of range LD/ST fixup");
352 return (Value & 0xffe) << 9;
360 assert((int64_t) Value >= 0 &&
361 (int64_t) Value < (1LL << 12) &&
"Out of range LD/ST fixup");
372 return (Value & 0xffc) << 8;
380 assert((int64_t) Value >= 0 &&
381 (int64_t) Value < (1LL << 12) &&
"Out of range LD/ST fixup");
392 return (Value & 0xff8) << 7;
397 return (Value & 0xff0) << 6;
402 assert(Value <= 0xffff &&
"Out of range move wide fixup");
403 return (Value & 0xffff) << 5;
417 return (Value & 0xffff) << 5;
422 assert(Value <= 0xffffffffull &&
"Out of range move wide fixup");
423 return ((Value >> 16) & 0xffff) << 5;
434 return ((Value >> 16) & 0xffff) << 5;
439 assert(Value <= 0xffffffffffffull &&
"Out of range move wide fixup");
440 return ((Value >> 32) & 0xffff) << 5;
445 return ((Value >> 32) & 0xffff) << 5;
450 return ((Value >> 48) & 0xffff) << 5;
463 assert(Signed >= -(1LL << 16) && Signed < (1LL << 16)
464 &&
"Out of range move wide fixup");
466 Value = (Value & 0xffff) << 5;
471 Value = (~Value & 0xffff) << 5;
490 assert(Signed >= -(1LL << 32) && Signed < (1LL << 32)
491 &&
"Out of range move wide fixup");
493 Value = ((Value >> 16) & 0xffff) << 5;
497 Value = ((~Value >> 16) & 0xffff) << 5;
513 assert(Signed >= -(1LL << 48) && Signed < (1LL << 48)
514 &&
"Out of range move wide fixup");
516 Value = ((Value >> 32) & 0xffff) << 5;
520 Value = ((~Value >> 32) & 0xffff) << 5;
528 assert((int64_t)Value >= -(1LL << 15) &&
529 (int64_t)Value < (1LL << 15) &&
"Out of range TBZ/TBNZ fixup");
530 return (Value & 0xfffc) << (5 - 2);
535 assert((int64_t)Value >= -(1LL << 20) &&
536 (int64_t)Value < (1LL << 20) &&
"Out of range B.cond fixup");
537 return (Value & 0x1ffffc) << (5 - 2);
544 assert((int64_t)Value >= -(1LL << 27) &&
545 (int64_t)Value < (1LL << 27) &&
"Out of range branch fixup");
546 return (Value & 0xffffffc) >> 2;
558 assert((int64_t)Value >= -(1LL << 32) &&
559 (int64_t)Value < (1LL << 32) &&
"Out of range ADRP fixup");
560 return ADRImmBits((Value & 0x1fffff000ULL) >> 12);
571 assert(((int64_t)Value & 7) == 0 &&
"Misaligned fixup");
572 return (Value & 0xff8) << 7;
584 return new ELFAArch64AsmBackend(T, TT, TheTriple.
getOS());
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
MCObjectWriter * createAArch64ELFObjectWriter(raw_ostream &OS, uint8_t OSABI)
void Write32(uint32_t Value)
MCSubtargetInfo * createAArch64MCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS)
MCAsmBackend * createAArch64AsmBackend(const Target &T, const MCRegisterInfo &MRI, StringRef TT, StringRef CPU)
#define llvm_unreachable(msg)
uint32_t getOffset() const
MCFixupKind
MCFixupKind - Extensible enumeration to represent the type of a fixup.
static unsigned ADRImmBits(unsigned Value)
MCFixupKind getKind() const
static uint64_t adjustFixupValue(unsigned Kind, uint64_t Value)
MCFixupKindInfo - Target independent information on a fixup kind.
LLVM Value Representation.
MCAsmBackend - Generic interface to target specific assembler backends.
const MCRegisterInfo & MRI
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
getFixupKindInfo - Get information on a fixup kind.