38 unsigned Kind =
Fixup.getKind();
65 Ctx.reportError(
Fixup.getLoc(),
66 "fixup value out of range [-32768, 65535]");
84 Ctx.reportError(
Fixup.getLoc(),
"out of range PC16 fixup");
94 Ctx.reportError(
Fixup.getLoc(),
"out of range PC19 fixup");
117 Value = ((
Value + 0x80008000LL) >> 32) & 0xffff;
122 Value = ((
Value + 0x800080008000LL) >> 48) & 0xffff;
133 Ctx.reportError(
Fixup.getLoc(),
"out of range PC7 fixup");
143 Ctx.reportError(
Fixup.getLoc(),
"out of range PC10 fixup");
153 Ctx.reportError(
Fixup.getLoc(),
"out of range PC16 fixup");
162 Ctx.reportError(
Fixup.getLoc(),
"out of range PC18 fixup");
169 Ctx.reportError(
Fixup.getLoc(),
"out of range PC18 fixup");
175 Ctx.reportError(
Fixup.getLoc(),
"out of range PC18 fixup");
184 Ctx.reportError(
Fixup.getLoc(),
"out of range PC21 fixup");
193 Ctx.reportError(
Fixup.getLoc(),
"out of range PC26 fixup");
202 Ctx.reportError(
Fixup.getLoc(),
"out of range PC26 fixup");
211 Ctx.reportError(
Fixup.getLoc(),
"out of range PC21 fixup");
220std::unique_ptr<MCObjectTargetWriter>
237 assert(i <= 3 &&
"Index out of range!");
239 return (1 - i / 2) * 2 + i % 2;
288 uint64_t
Value,
bool IsResolved) {
305 switch ((
unsigned)Kind) {
326 for (
unsigned i = 0; i != NumBytes; ++i) {
329 : (FullSize - 1 - i);
330 CurVal |= (uint64_t)((
uint8_t)
Data[Idx]) << (i * 8);
333 uint64_t Mask = ((uint64_t)(-1) >>
335 CurVal |=
Value & Mask;
338 for (
unsigned i = 0; i != NumBytes; ++i) {
341 : (FullSize - 1 - i);
348 .
Case(
"BFD_RELOC_NONE", ELF::R_MIPS_NONE)
349 .
Case(
"BFD_RELOC_16", ELF::R_MIPS_16)
350 .
Case(
"BFD_RELOC_32", ELF::R_MIPS_32)
351 .
Case(
"BFD_RELOC_64", ELF::R_MIPS_64)
381 .
Case(
"R_MICROMIPS_TLS_DTPREL_HI16",
383 .
Case(
"R_MICROMIPS_TLS_DTPREL_LO16",
401 {
"fixup_Mips_16", 0, 16, 0 },
402 {
"fixup_Mips_32", 0, 32, 0 },
403 {
"fixup_Mips_REL32", 0, 32, 0 },
404 {
"fixup_Mips_GPREL32", 0, 32, 0 },
405 {
"fixup_Mips_DTPREL32", 0, 32, 0 },
406 {
"fixup_Mips_DTPREL64", 0, 64, 0 },
407 {
"fixup_Mips_TPREL32", 0, 32, 0 },
408 {
"fixup_Mips_TPREL64", 0, 64, 0 },
409 {
"fixup_Mips_26", 0, 26, 0 },
410 {
"fixup_Mips_HI16", 0, 16, 0 },
411 {
"fixup_Mips_LO16", 0, 16, 0 },
412 {
"fixup_Mips_AnyImm16", 0, 16, 0 },
413 {
"fixup_Mips_GPREL16", 0, 16, 0 },
414 {
"fixup_Mips_LITERAL", 0, 16, 0 },
415 {
"fixup_Mips_GOT", 0, 16, 0 },
416 {
"fixup_Mips_PC16", 0, 16, 0 },
417 {
"fixup_Mips_CALL16", 0, 16, 0 },
418 {
"fixup_Mips_SHIFT5", 6, 5, 0 },
419 {
"fixup_Mips_SHIFT6", 6, 5, 0 },
420 {
"fixup_Mips_64", 0, 64, 0 },
421 {
"fixup_Mips_TLSGD", 0, 16, 0 },
422 {
"fixup_Mips_GOTTPREL", 0, 16, 0 },
423 {
"fixup_Mips_TPREL_HI", 0, 16, 0 },
424 {
"fixup_Mips_TPREL_LO", 0, 16, 0 },
425 {
"fixup_Mips_TLSLDM", 0, 16, 0 },
426 {
"fixup_Mips_DTPREL_HI", 0, 16, 0 },
427 {
"fixup_Mips_DTPREL_LO", 0, 16, 0 },
428 {
"fixup_Mips_Branch_PCRel", 0, 16, 0 },
429 {
"fixup_Mips_GPOFF_HI", 0, 16, 0 },
430 {
"fixup_MICROMIPS_GPOFF_HI",0, 16, 0 },
431 {
"fixup_Mips_GPOFF_LO", 0, 16, 0 },
432 {
"fixup_MICROMIPS_GPOFF_LO",0, 16, 0 },
433 {
"fixup_Mips_GOT_PAGE", 0, 16, 0 },
434 {
"fixup_Mips_GOT_OFST", 0, 16, 0 },
435 {
"fixup_Mips_GOT_DISP", 0, 16, 0 },
436 {
"fixup_Mips_HIGHER", 0, 16, 0 },
437 {
"fixup_MICROMIPS_HIGHER", 0, 16, 0 },
438 {
"fixup_Mips_HIGHEST", 0, 16, 0 },
439 {
"fixup_MICROMIPS_HIGHEST", 0, 16, 0 },
440 {
"fixup_Mips_GOT_HI16", 0, 16, 0 },
441 {
"fixup_Mips_GOT_LO16", 0, 16, 0 },
442 {
"fixup_Mips_CALL_HI16", 0, 16, 0 },
443 {
"fixup_Mips_CALL_LO16", 0, 16, 0 },
444 {
"fixup_Mips_PC18_S3", 0, 18, 0 },
445 {
"fixup_MIPS_PC19_S2", 0, 19, 0 },
446 {
"fixup_MIPS_PC21_S2", 0, 21, 0 },
447 {
"fixup_MIPS_PC26_S2", 0, 26, 0 },
448 {
"fixup_MIPS_PCHI16", 0, 16, 0 },
449 {
"fixup_MIPS_PCLO16", 0, 16, 0 },
450 {
"fixup_MICROMIPS_26_S1", 0, 26, 0 },
451 {
"fixup_MICROMIPS_HI16", 0, 16, 0 },
452 {
"fixup_MICROMIPS_LO16", 0, 16, 0 },
453 {
"fixup_MICROMIPS_GOT16", 0, 16, 0 },
454 {
"fixup_MICROMIPS_PC7_S1", 0, 7, 0 },
455 {
"fixup_MICROMIPS_PC10_S1", 0, 10, 0 },
456 {
"fixup_MICROMIPS_PC16_S1", 0, 16, 0 },
457 {
"fixup_MICROMIPS_PC26_S1", 0, 26, 0 },
458 {
"fixup_MICROMIPS_PC19_S2", 0, 19, 0 },
459 {
"fixup_MICROMIPS_PC18_S3", 0, 18, 0 },
460 {
"fixup_MICROMIPS_PC21_S1", 0, 21, 0 },
461 {
"fixup_MICROMIPS_CALL16", 0, 16, 0 },
462 {
"fixup_MICROMIPS_GOT_DISP", 0, 16, 0 },
463 {
"fixup_MICROMIPS_GOT_PAGE", 0, 16, 0 },
464 {
"fixup_MICROMIPS_GOT_OFST", 0, 16, 0 },
465 {
"fixup_MICROMIPS_TLS_GD", 0, 16, 0 },
466 {
"fixup_MICROMIPS_TLS_LDM", 0, 16, 0 },
467 {
"fixup_MICROMIPS_TLS_DTPREL_HI16", 0, 16, 0 },
468 {
"fixup_MICROMIPS_TLS_DTPREL_LO16", 0, 16, 0 },
469 {
"fixup_MICROMIPS_GOTTPREL", 0, 16, 0 },
470 {
"fixup_MICROMIPS_TLS_TPREL_HI16", 0, 16, 0 },
471 {
"fixup_MICROMIPS_TLS_TPREL_LO16", 0, 16, 0 },
472 {
"fixup_Mips_SUB", 0, 64, 0 },
473 {
"fixup_MICROMIPS_SUB", 0, 64, 0 },
474 {
"fixup_Mips_JALR", 0, 32, 0 },
475 {
"fixup_MICROMIPS_JALR", 0, 32, 0 },
479 "Not all MIPS little endian fixup kinds added!");
487 {
"fixup_Mips_16", 16, 16, 0 },
488 {
"fixup_Mips_32", 0, 32, 0 },
489 {
"fixup_Mips_REL32", 0, 32, 0 },
490 {
"fixup_Mips_GPREL32", 0, 32, 0 },
491 {
"fixup_Mips_DTPREL32", 0, 32, 0 },
492 {
"fixup_Mips_DTPREL64", 0, 64, 0 },
493 {
"fixup_Mips_TPREL32", 0, 32, 0 },
494 {
"fixup_Mips_TPREL64", 0, 64, 0 },
495 {
"fixup_Mips_26", 6, 26, 0 },
496 {
"fixup_Mips_HI16", 16, 16, 0 },
497 {
"fixup_Mips_LO16", 16, 16, 0 },
498 {
"fixup_Mips_AnyImm16", 16, 16, 0 },
499 {
"fixup_Mips_GPREL16", 16, 16, 0 },
500 {
"fixup_Mips_LITERAL", 16, 16, 0 },
501 {
"fixup_Mips_GOT", 16, 16, 0 },
502 {
"fixup_Mips_PC16", 16, 16, 0 },
503 {
"fixup_Mips_CALL16", 16, 16, 0 },
504 {
"fixup_Mips_SHIFT5", 21, 5, 0 },
505 {
"fixup_Mips_SHIFT6", 21, 5, 0 },
506 {
"fixup_Mips_64", 0, 64, 0 },
507 {
"fixup_Mips_TLSGD", 16, 16, 0 },
508 {
"fixup_Mips_GOTTPREL", 16, 16, 0 },
509 {
"fixup_Mips_TPREL_HI", 16, 16, 0 },
510 {
"fixup_Mips_TPREL_LO", 16, 16, 0 },
511 {
"fixup_Mips_TLSLDM", 16, 16, 0 },
512 {
"fixup_Mips_DTPREL_HI", 16, 16, 0 },
513 {
"fixup_Mips_DTPREL_LO", 16, 16, 0 },
514 {
"fixup_Mips_Branch_PCRel",16, 16, 0 },
515 {
"fixup_Mips_GPOFF_HI", 16, 16, 0 },
516 {
"fixup_MICROMIPS_GPOFF_HI", 16, 16, 0 },
517 {
"fixup_Mips_GPOFF_LO", 16, 16, 0 },
518 {
"fixup_MICROMIPS_GPOFF_LO", 16, 16, 0 },
519 {
"fixup_Mips_GOT_PAGE", 16, 16, 0 },
520 {
"fixup_Mips_GOT_OFST", 16, 16, 0 },
521 {
"fixup_Mips_GOT_DISP", 16, 16, 0 },
522 {
"fixup_Mips_HIGHER", 16, 16, 0 },
523 {
"fixup_MICROMIPS_HIGHER", 16, 16, 0 },
524 {
"fixup_Mips_HIGHEST", 16, 16, 0 },
525 {
"fixup_MICROMIPS_HIGHEST",16, 16, 0 },
526 {
"fixup_Mips_GOT_HI16", 16, 16, 0 },
527 {
"fixup_Mips_GOT_LO16", 16, 16, 0 },
528 {
"fixup_Mips_CALL_HI16", 16, 16, 0 },
529 {
"fixup_Mips_CALL_LO16", 16, 16, 0 },
530 {
"fixup_Mips_PC18_S3", 14, 18, 0 },
531 {
"fixup_MIPS_PC19_S2", 13, 19, 0 },
532 {
"fixup_MIPS_PC21_S2", 11, 21, 0 },
533 {
"fixup_MIPS_PC26_S2", 6, 26, 0 },
534 {
"fixup_MIPS_PCHI16", 16, 16, 0 },
535 {
"fixup_MIPS_PCLO16", 16, 16, 0 },
536 {
"fixup_MICROMIPS_26_S1", 6, 26, 0 },
537 {
"fixup_MICROMIPS_HI16", 16, 16, 0 },
538 {
"fixup_MICROMIPS_LO16", 16, 16, 0 },
539 {
"fixup_MICROMIPS_GOT16", 16, 16, 0 },
540 {
"fixup_MICROMIPS_PC7_S1", 9, 7, 0 },
541 {
"fixup_MICROMIPS_PC10_S1", 6, 10, 0 },
542 {
"fixup_MICROMIPS_PC16_S1",16, 16, 0 },
543 {
"fixup_MICROMIPS_PC26_S1", 6, 26, 0 },
544 {
"fixup_MICROMIPS_PC19_S2",13, 19, 0 },
545 {
"fixup_MICROMIPS_PC18_S3",14, 18, 0 },
546 {
"fixup_MICROMIPS_PC21_S1",11, 21, 0 },
547 {
"fixup_MICROMIPS_CALL16", 16, 16, 0 },
548 {
"fixup_MICROMIPS_GOT_DISP", 16, 16, 0 },
549 {
"fixup_MICROMIPS_GOT_PAGE", 16, 16, 0 },
550 {
"fixup_MICROMIPS_GOT_OFST", 16, 16, 0 },
551 {
"fixup_MICROMIPS_TLS_GD", 16, 16, 0 },
552 {
"fixup_MICROMIPS_TLS_LDM", 16, 16, 0 },
553 {
"fixup_MICROMIPS_TLS_DTPREL_HI16", 16, 16, 0 },
554 {
"fixup_MICROMIPS_TLS_DTPREL_LO16", 16, 16, 0 },
555 {
"fixup_MICROMIPS_GOTTPREL", 16, 16, 0 },
556 {
"fixup_MICROMIPS_TLS_TPREL_HI16", 16, 16, 0 },
557 {
"fixup_MICROMIPS_TLS_TPREL_LO16", 16, 16, 0 },
558 {
"fixup_Mips_SUB", 0, 64, 0 },
559 {
"fixup_MICROMIPS_SUB", 0, 64, 0 },
560 {
"fixup_Mips_JALR", 0, 32, 0 },
561 {
"fixup_MICROMIPS_JALR", 0, 32, 0 },
565 "Not all MIPS big endian fixup kinds added!");
598 if (
Count % 4 == 2) {
601 uint16_t Nop = STI && STI->
hasFeature(Mips::FeatureMicroMips) ? 0x0c00 : 0;
619 std::unique_ptr<MCObjectTargetWriter>
620 createObjectTargetWriter()
const override {
633 return new WindowsMipsAsmBackend(
T, MRI, STI);
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)
static bool shouldForceRelocation(const MCFixup &Fixup)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value, MCContext &Ctx)
static unsigned calculateMMLEIndex(unsigned i)
static bool needsMMLEByteOrder(unsigned Kind)
PowerPC TLS Dynamic Call Fixup
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Generic interface to target specific assembler backends.
const llvm::endianness Endian
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
MCContext & getContext() const
virtual std::optional< MCFixupKind > getFixupKind(StringRef Name) const
Map a relocation name used in .reloc to a fixup kind.
void maybeAddReloc(const MCFragment &, const MCFixup &, const MCValue &, uint64_t &Value, bool IsResolved)
Context object for machine code objects.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
static MipsABIInfo computeTargetABI(const Triple &TT, StringRef ABIName)
bool writeNopData(raw_ostream &OS, uint64_t Count, const MCSubtargetInfo *STI) const override
WriteNopData - Write an (optimal) nop sequence of Count bytes to the given output.
MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
std::optional< MCFixupKind > getFixupKind(StringRef Name) const override
Map a relocation name used in .reloc to a fixup kind.
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, uint8_t *Data, uint64_t Value, bool IsResolved) override
ApplyFixup - Apply the Value for given Fixup into the provided data fragment, at the offset specified...
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
bool isOSWindows() const
Tests whether the OS is Windows.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
@ fixup_MICROMIPS_TLS_TPREL_LO16
@ fixup_MICROMIPS_GOT_PAGE
@ fixup_MICROMIPS_PC16_S1
@ fixup_MICROMIPS_TLS_TPREL_HI16
@ fixup_MICROMIPS_PC21_S1
@ fixup_MICROMIPS_GPOFF_LO
@ fixup_MICROMIPS_PC19_S2
@ fixup_MICROMIPS_TLS_LDM
@ fixup_MICROMIPS_GOT_OFST
@ fixup_MICROMIPS_TLS_DTPREL_HI16
@ fixup_MICROMIPS_PC10_S1
@ fixup_MICROMIPS_HIGHEST
@ fixup_MICROMIPS_GOT_DISP
@ fixup_MICROMIPS_PC18_S3
@ fixup_MICROMIPS_PC26_S1
@ fixup_MICROMIPS_GOTTPREL
@ fixup_MICROMIPS_TLS_DTPREL_LO16
@ fixup_MICROMIPS_GPOFF_HI
bool isRelocation(MCFixupKind FixupKind)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< MCObjectTargetWriter > createMipsELFObjectWriter(const Triple &TT, bool IsN32)
Construct a Mips ELF object writer.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
static StringRef getCPU(StringRef CPU)
Processes a CPU name.
constexpr MCFixupKind FirstTargetFixupKind
std::unique_ptr< MCObjectTargetWriter > createMipsWinCOFFObjectWriter()
Construct a Mips Win COFF object writer.
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
static Lanai::Fixups FixupKind(const MCExpr *Expr)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_2
A two-byte fixup.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
constexpr MCFixupKind FirstLiteralRelocationKind
MCAsmBackend * createMipsAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Target independent information on a fixup kind.
uint8_t TargetSize
The number of bits written by this fixup.