40 if (!
isIntN(Width, Value)) {
41 std::string Diagnostic =
"out of range " + Description;
46 Diagnostic +=
" (expected an integer in the range " +
std::to_string(Min) +
50 Ctx->reportFatalError(Fixup.
getLoc(), Diagnostic);
60 std::string Diagnostic =
"out of range " + Description;
64 Diagnostic +=
" (expected an integer in the range 0 to " +
68 Ctx->reportFatalError(Fixup.
getLoc(), Diagnostic);
80 unsigned_width(Size + 1, Value, std::string(
"branch target"), Fixup, Ctx);
91 signed_width(Size + 1, Value, std::string(
"branch target"), Fixup, Ctx);
109 auto top = Value & (0xf00000 << 6);
110 auto middle = Value & (0x1ffff << 5);
111 auto bottom = Value & 0x1f;
113 Value = (top << 6) | (middle << 3) | (bottom << 0);
152 Value = ((Value & 0x30) << 2) | (Value & 0x0f);
176 Value = ((Value & 0x30) << 5) | (Value & 0x0f);
195 uint64_t upper = Value & 0xf0;
196 uint64_t lower = Value & 0x0f;
198 Value = (upper << 4) | lower;
211 Value = (Value & 0xff00) >> 8;
217 Value = (Value & 0xff0000) >> 16;
223 Value = (Value & 0xff000000) >> 24;
248 if (A->getSymbol().isTemporary())
355 std::unique_ptr<MCObjectTargetWriter>
373 auto NumBytes = (NumBits / 8) + ((NumBits % 8) == 0 ? 0 : 1);
379 assert(Offset + NumBytes <= Data.
size() &&
"Invalid fixup offset!");
383 for (
unsigned i = 0; i < NumBytes; ++i) {
384 uint8_t mask = (((Value >> (i * 8)) & 0xff));
385 Data[Offset + i] |= mask;
397 {
"fixup_32", 0, 32, 0},
402 {
"fixup_16", 0, 16, 0},
403 {
"fixup_16_pm", 0, 16, 0},
405 {
"fixup_ldi", 0, 8, 0},
407 {
"fixup_lo8_ldi", 0, 8, 0},
408 {
"fixup_hi8_ldi", 0, 8, 0},
409 {
"fixup_hh8_ldi", 0, 8, 0},
410 {
"fixup_ms8_ldi", 0, 8, 0},
412 {
"fixup_lo8_ldi_neg", 0, 8, 0},
413 {
"fixup_hi8_ldi_neg", 0, 8, 0},
414 {
"fixup_hh8_ldi_neg", 0, 8, 0},
415 {
"fixup_ms8_ldi_neg", 0, 8, 0},
417 {
"fixup_lo8_ldi_pm", 0, 8, 0},
418 {
"fixup_hi8_ldi_pm", 0, 8, 0},
419 {
"fixup_hh8_ldi_pm", 0, 8, 0},
421 {
"fixup_lo8_ldi_pm_neg", 0, 8, 0},
422 {
"fixup_hi8_ldi_pm_neg", 0, 8, 0},
423 {
"fixup_hh8_ldi_pm_neg", 0, 8, 0},
425 {
"fixup_call", 0, 22, 0},
427 {
"fixup_6", 0, 16, 0},
428 {
"fixup_6_adiw", 0, 6, 0},
430 {
"fixup_lo8_ldi_gs", 0, 8, 0},
431 {
"fixup_hi8_ldi_gs", 0, 8, 0},
433 {
"fixup_8", 0, 8, 0},
434 {
"fixup_8_lo8", 0, 8, 0},
435 {
"fixup_8_hi8", 0, 8, 0},
436 {
"fixup_8_hlo8", 0, 8, 0},
438 {
"fixup_diff8", 0, 8, 0},
439 {
"fixup_diff16", 0, 16, 0},
440 {
"fixup_diff32", 0, 32, 0},
442 {
"fixup_lds_sts_16", 0, 16, 0},
444 {
"fixup_port6", 0, 16, 0},
445 {
"fixup_port5", 3, 5, 0},
461 assert((Count % 2) == 0 &&
"NOP instructions must be 2 bytes");
470 switch ((
unsigned) Fixup.
getKind()) {
471 default:
return false;
std::unique_ptr< MCObjectTargetWriter > createAVRELFObjectWriter(uint8_t OSABI)
Creates an ELF object writer for AVR.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 16-bi...
This class represents lattice values for constants.
This represents an "assembler immediate".
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a 16-bit progra...
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 16-bi...
bool writeNopData(raw_ostream &OS, uint64_t Count) const override
Write an (optimal) nop sequence of Count bytes to the given output.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
void unsigned_width(unsigned Width, uint64_t Value, std::string Description, const MCFixup &Fixup, MCContext *Ctx=nullptr)
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target) override
Hook to check if a relocation is needed for some target specific reason.
void hh8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a negated 16-bi...
unsigned TargetOffset
The bit offset to write the relocation into.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
const Triple & getTargetTriple() const
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...
MCContext & getContext() const
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated negat...
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a 16-bit value ...
Represent a reference to a symbol from inside an expression.
void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
Adjusts the value of a relative branch target before fixup application.
Context object for machine code objects.
int64_t maxIntN(int64_t N)
Gets the maximum value for a N-bit signed integer.
A four-byte gp relative fixup.
void signed_width(unsigned Width, uint64_t Value, std::string Description, const MCFixup &Fixup, MCContext *Ctx=nullptr)
Utilities for manipulating generated AVR machine code.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated negat...
int64_t minIntN(int64_t N)
Gets the minimum value for a N-bit signed integer.
Analysis containing CSE Info
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
void fixup_port5(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
5-bit port number fixup on the SBIC family of instructions.
unsigned const MachineRegisterInfo * MRI
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
size_t size() const
size - Get the array size.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)
void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
Adjusts the value of a branch target before fixup application.
void neg(uint64_t &Value)
const MCSymbolRefExpr * getSymA() const
A 16-bit program memory address.
void fixup_7_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
7-bit PC-relative fixup.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 16-bit progra...
uint32_t getOffset() const
void pm(uint64_t &Value)
Adjusts a program memory address.
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
void ms8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void hi8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 24-bi...
void fixup(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
Adjusts a value to fix up the immediate of an LDI Rd, K instruction.
void fixup_6_adiw(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
6-bit fixup for the immediate operand of the ADIW family of instructions.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 16-bit value ...
void adjustBranchTarget(T &val)
Adjusts the value of a branch target.
unsigned TargetSize
The number of bits written by this fixup.
Target - Wrapper for Target specific information.
void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
12-bit PC-relative fixup.
uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a negated 16-bi...
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 32-bit value ...
Generic base class for all target subtargets.
Target independent information on a fixup kind.
const std::string to_string(const T &Value)
void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
22-bit absolute fixup.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Generic interface to target specific assembler backends.
void adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t &Value, MCContext *Ctx=nullptr) const
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 24-bit progra...
This class implements an extremely fast bulk output stream that can only output to a stream...
void lo8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
MCAsmBackend * createAVRAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const llvm::MCTargetOptions &TO)
Creates an assembly backend for AVR.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 24-bit value ...
Replaces the 8-bit immediate with another value.
MCFixupKind getKind() const
void fixup_port6(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
6-bit port number fixup on the IN family of instructions.