LLVM  7.0.0svn
AVRAsmBackend.cpp
Go to the documentation of this file.
1 //===-- AVRAsmBackend.cpp - AVR Asm Backend ------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the AVRAsmBackend class.
11 //
12 //===----------------------------------------------------------------------===//
13 
17 
18 #include "llvm/MC/MCAsmBackend.h"
19 #include "llvm/MC/MCAssembler.h"
20 #include "llvm/MC/MCContext.h"
21 #include "llvm/MC/MCDirectives.h"
24 #include "llvm/MC/MCObjectWriter.h"
26 #include "llvm/MC/MCValue.h"
30 
31 // FIXME: we should be doing checks to make sure asm operands
32 // are not out of bounds.
33 
34 namespace adjust {
35 
36 using namespace llvm;
37 
38 void signed_width(unsigned Width, uint64_t Value, std::string Description,
39  const MCFixup &Fixup, MCContext *Ctx = nullptr) {
40  if (!isIntN(Width, Value)) {
41  std::string Diagnostic = "out of range " + Description;
42 
43  int64_t Min = minIntN(Width);
44  int64_t Max = maxIntN(Width);
45 
46  Diagnostic += " (expected an integer in the range " + std::to_string(Min) +
47  " to " + std::to_string(Max) + ")";
48 
49  if (Ctx) {
50  Ctx->reportFatalError(Fixup.getLoc(), Diagnostic);
51  } else {
52  llvm_unreachable(Diagnostic.c_str());
53  }
54  }
55 }
56 
57 void unsigned_width(unsigned Width, uint64_t Value, std::string Description,
58  const MCFixup &Fixup, MCContext *Ctx = nullptr) {
59  if (!isUIntN(Width, Value)) {
60  std::string Diagnostic = "out of range " + Description;
61 
62  int64_t Max = maxUIntN(Width);
63 
64  Diagnostic += " (expected an integer in the range 0 to " +
65  std::to_string(Max) + ")";
66 
67  if (Ctx) {
68  Ctx->reportFatalError(Fixup.getLoc(), Diagnostic);
69  } else {
70  llvm_unreachable(Diagnostic.c_str());
71  }
72  }
73 }
74 
75 /// Adjusts the value of a branch target before fixup application.
76 void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
77  MCContext *Ctx = nullptr) {
78  // We have one extra bit of precision because the value is rightshifted by
79  // one.
80  unsigned_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
81 
82  // Rightshifts the value by one.
84 }
85 
86 /// Adjusts the value of a relative branch target before fixup application.
87 void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
88  MCContext *Ctx = nullptr) {
89  // We have one extra bit of precision because the value is rightshifted by
90  // one.
91  signed_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
92 
93  Value -= 2;
94 
95  // Rightshifts the value by one.
97 }
98 
99 /// 22-bit absolute fixup.
100 ///
101 /// Resolves to:
102 /// 1001 kkkk 010k kkkk kkkk kkkk 111k kkkk
103 ///
104 /// Offset of 0 (so the result is left shifted by 3 bits before application).
105 void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
106  MCContext *Ctx = nullptr) {
107  adjustBranch(Size, Fixup, Value, Ctx);
108 
109  auto top = Value & (0xf00000 << 6); // the top four bits
110  auto middle = Value & (0x1ffff << 5); // the middle 13 bits
111  auto bottom = Value & 0x1f; // end bottom 5 bits
112 
113  Value = (top << 6) | (middle << 3) | (bottom << 0);
114 }
115 
116 /// 7-bit PC-relative fixup.
117 ///
118 /// Resolves to:
119 /// 0000 00kk kkkk k000
120 /// Offset of 0 (so the result is left shifted by 3 bits before application).
121 void fixup_7_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
122  MCContext *Ctx = nullptr) {
123  adjustRelativeBranch(Size, Fixup, Value, Ctx);
124 
125  // Because the value may be negative, we must mask out the sign bits
126  Value &= 0x7f;
127 }
128 
129 /// 12-bit PC-relative fixup.
130 /// Yes, the fixup is 12 bits even though the name says otherwise.
131 ///
132 /// Resolves to:
133 /// 0000 kkkk kkkk kkkk
134 /// Offset of 0 (so the result isn't left-shifted before application).
135 void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
136  MCContext *Ctx = nullptr) {
137  adjustRelativeBranch(Size, Fixup, Value, Ctx);
138 
139  // Because the value may be negative, we must mask out the sign bits
140  Value &= 0xfff;
141 }
142 
143 /// 6-bit fixup for the immediate operand of the ADIW family of
144 /// instructions.
145 ///
146 /// Resolves to:
147 /// 0000 0000 kk00 kkkk
148 void fixup_6_adiw(const MCFixup &Fixup, uint64_t &Value,
149  MCContext *Ctx = nullptr) {
150  unsigned_width(6, Value, std::string("immediate"), Fixup, Ctx);
151 
152  Value = ((Value & 0x30) << 2) | (Value & 0x0f);
153 }
154 
155 /// 5-bit port number fixup on the SBIC family of instructions.
156 ///
157 /// Resolves to:
158 /// 0000 0000 AAAA A000
159 void fixup_port5(const MCFixup &Fixup, uint64_t &Value,
160  MCContext *Ctx = nullptr) {
161  unsigned_width(5, Value, std::string("port number"), Fixup, Ctx);
162 
163  Value &= 0x1f;
164 
165  Value <<= 3;
166 }
167 
168 /// 6-bit port number fixup on the `IN` family of instructions.
169 ///
170 /// Resolves to:
171 /// 1011 0AAd dddd AAAA
172 void fixup_port6(const MCFixup &Fixup, uint64_t &Value,
173  MCContext *Ctx = nullptr) {
174  unsigned_width(6, Value, std::string("port number"), Fixup, Ctx);
175 
176  Value = ((Value & 0x30) << 5) | (Value & 0x0f);
177 }
178 
179 /// Adjusts a program memory address.
180 /// This is a simple right-shift.
181 void pm(uint64_t &Value) {
182  Value >>= 1;
183 }
184 
185 /// Fixups relating to the LDI instruction.
186 namespace ldi {
187 
188 /// Adjusts a value to fix up the immediate of an `LDI Rd, K` instruction.
189 ///
190 /// Resolves to:
191 /// 0000 KKKK 0000 KKKK
192 /// Offset of 0 (so the result isn't left-shifted before application).
193 void fixup(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
194  MCContext *Ctx = nullptr) {
195  uint64_t upper = Value & 0xf0;
196  uint64_t lower = Value & 0x0f;
197 
198  Value = (upper << 4) | lower;
199 }
200 
201 void neg(uint64_t &Value) { Value *= -1; }
202 
203 void lo8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
204  MCContext *Ctx = nullptr) {
205  Value &= 0xff;
206  ldi::fixup(Size, Fixup, Value, Ctx);
207 }
208 
209 void hi8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
210  MCContext *Ctx = nullptr) {
211  Value = (Value & 0xff00) >> 8;
212  ldi::fixup(Size, Fixup, Value, Ctx);
213 }
214 
215 void hh8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
216  MCContext *Ctx = nullptr) {
217  Value = (Value & 0xff0000) >> 16;
218  ldi::fixup(Size, Fixup, Value, Ctx);
219 }
220 
221 void ms8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
222  MCContext *Ctx = nullptr) {
223  Value = (Value & 0xff000000) >> 24;
224  ldi::fixup(Size, Fixup, Value, Ctx);
225 }
226 
227 } // end of ldi namespace
228 } // end of adjust namespace
229 
230 namespace llvm {
231 
232 // Prepare value for the target space for it
234  const MCValue &Target,
235  uint64_t &Value,
236  MCContext *Ctx) const {
237  // The size of the fixup in bits.
238  uint64_t Size = AVRAsmBackend::getFixupKindInfo(Fixup.getKind()).TargetSize;
239 
240  unsigned Kind = Fixup.getKind();
241 
242  // Parsed LLVM-generated temporary labels are already
243  // adjusted for instruction size, but normal labels aren't.
244  //
245  // To handle both cases, we simply un-adjust the temporary label
246  // case so it acts like all other labels.
247  if (const MCSymbolRefExpr *A = Target.getSymA()) {
248  if (A->getSymbol().isTemporary())
249  Value += 2;
250  }
251 
252  switch (Kind) {
253  default:
254  llvm_unreachable("unhandled fixup");
255  case AVR::fixup_7_pcrel:
256  adjust::fixup_7_pcrel(Size, Fixup, Value, Ctx);
257  break;
258  case AVR::fixup_13_pcrel:
259  adjust::fixup_13_pcrel(Size, Fixup, Value, Ctx);
260  break;
261  case AVR::fixup_call:
262  adjust::fixup_call(Size, Fixup, Value, Ctx);
263  break;
264  case AVR::fixup_ldi:
265  adjust::ldi::fixup(Size, Fixup, Value, Ctx);
266  break;
267  case AVR::fixup_lo8_ldi:
268  adjust::ldi::lo8(Size, Fixup, Value, Ctx);
269  break;
272  adjust::pm(Value);
273  adjust::ldi::lo8(Size, Fixup, Value, Ctx);
274  break;
275  case AVR::fixup_hi8_ldi:
276  adjust::ldi::hi8(Size, Fixup, Value, Ctx);
277  break;
280  adjust::pm(Value);
281  adjust::ldi::hi8(Size, Fixup, Value, Ctx);
282  break;
283  case AVR::fixup_hh8_ldi:
285  if (Kind == AVR::fixup_hh8_ldi_pm) adjust::pm(Value);
286 
287  adjust::ldi::hh8(Size, Fixup, Value, Ctx);
288  break;
289  case AVR::fixup_ms8_ldi:
290  adjust::ldi::ms8(Size, Fixup, Value, Ctx);
291  break;
292 
295  if (Kind == AVR::fixup_lo8_ldi_pm_neg) adjust::pm(Value);
296 
297  adjust::ldi::neg(Value);
298  adjust::ldi::lo8(Size, Fixup, Value, Ctx);
299  break;
302  if (Kind == AVR::fixup_hi8_ldi_pm_neg) adjust::pm(Value);
303 
304  adjust::ldi::neg(Value);
305  adjust::ldi::hi8(Size, Fixup, Value, Ctx);
306  break;
309  if (Kind == AVR::fixup_hh8_ldi_pm_neg) adjust::pm(Value);
310 
311  adjust::ldi::neg(Value);
312  adjust::ldi::hh8(Size, Fixup, Value, Ctx);
313  break;
315  adjust::ldi::neg(Value);
316  adjust::ldi::ms8(Size, Fixup, Value, Ctx);
317  break;
318  case AVR::fixup_16:
319  adjust::unsigned_width(16, Value, std::string("port number"), Fixup, Ctx);
320 
321  Value &= 0xffff;
322  break;
323  case AVR::fixup_16_pm:
324  Value >>= 1; // Flash addresses are always shifted.
325  adjust::unsigned_width(16, Value, std::string("port number"), Fixup, Ctx);
326 
327  Value &= 0xffff;
328  break;
329 
330  case AVR::fixup_6_adiw:
331  adjust::fixup_6_adiw(Fixup, Value, Ctx);
332  break;
333 
334  case AVR::fixup_port5:
335  adjust::fixup_port5(Fixup, Value, Ctx);
336  break;
337 
338  case AVR::fixup_port6:
339  adjust::fixup_port6(Fixup, Value, Ctx);
340  break;
341 
342  // Fixups which do not require adjustments.
343  case FK_Data_1:
344  case FK_Data_2:
345  case FK_Data_4:
346  case FK_Data_8:
347  break;
348 
349  case FK_GPRel_4:
350  llvm_unreachable("don't know how to adjust this fixup");
351  break;
352  }
353 }
354 
355 std::unique_ptr<MCObjectWriter>
357  return createAVRELFObjectWriter(OS,
359 }
360 
362  const MCValue &Target, MutableArrayRef<char> Data,
363  uint64_t Value, bool IsPCRel) const {
364  adjustFixupValue(Fixup, Target, Value, &Asm.getContext());
365  if (Value == 0)
366  return; // Doesn't change encoding.
367 
368  MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
369 
370  // The number of bits in the fixup mask
371  auto NumBits = Info.TargetSize + Info.TargetOffset;
372  auto NumBytes = (NumBits / 8) + ((NumBits % 8) == 0 ? 0 : 1);
373 
374  // Shift the value into position.
375  Value <<= Info.TargetOffset;
376 
377  unsigned Offset = Fixup.getOffset();
378  assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
379 
380  // For each byte of the fragment that the fixup touches, mask in the
381  // bits from the fixup value.
382  for (unsigned i = 0; i < NumBytes; ++i) {
383  uint8_t mask = (((Value >> (i * 8)) & 0xff));
384  Data[Offset + i] |= mask;
385  }
386 }
387 
389  // NOTE: Many AVR fixups work on sets of non-contignous bits. We work around
390  // this by saying that the fixup is the size of the entire instruction.
391  const static MCFixupKindInfo Infos[AVR::NumTargetFixupKinds] = {
392  // This table *must* be in same the order of fixup_* kinds in
393  // AVRFixupKinds.h.
394  //
395  // name offset bits flags
396  {"fixup_32", 0, 32, 0},
397 
398  {"fixup_7_pcrel", 3, 7, MCFixupKindInfo::FKF_IsPCRel},
399  {"fixup_13_pcrel", 0, 12, MCFixupKindInfo::FKF_IsPCRel},
400 
401  {"fixup_16", 0, 16, 0},
402  {"fixup_16_pm", 0, 16, 0},
403 
404  {"fixup_ldi", 0, 8, 0},
405 
406  {"fixup_lo8_ldi", 0, 8, 0},
407  {"fixup_hi8_ldi", 0, 8, 0},
408  {"fixup_hh8_ldi", 0, 8, 0},
409  {"fixup_ms8_ldi", 0, 8, 0},
410 
411  {"fixup_lo8_ldi_neg", 0, 8, 0},
412  {"fixup_hi8_ldi_neg", 0, 8, 0},
413  {"fixup_hh8_ldi_neg", 0, 8, 0},
414  {"fixup_ms8_ldi_neg", 0, 8, 0},
415 
416  {"fixup_lo8_ldi_pm", 0, 8, 0},
417  {"fixup_hi8_ldi_pm", 0, 8, 0},
418  {"fixup_hh8_ldi_pm", 0, 8, 0},
419 
420  {"fixup_lo8_ldi_pm_neg", 0, 8, 0},
421  {"fixup_hi8_ldi_pm_neg", 0, 8, 0},
422  {"fixup_hh8_ldi_pm_neg", 0, 8, 0},
423 
424  {"fixup_call", 0, 22, 0},
425 
426  {"fixup_6", 0, 16, 0}, // non-contiguous
427  {"fixup_6_adiw", 0, 6, 0},
428 
429  {"fixup_lo8_ldi_gs", 0, 8, 0},
430  {"fixup_hi8_ldi_gs", 0, 8, 0},
431 
432  {"fixup_8", 0, 8, 0},
433  {"fixup_8_lo8", 0, 8, 0},
434  {"fixup_8_hi8", 0, 8, 0},
435  {"fixup_8_hlo8", 0, 8, 0},
436 
437  {"fixup_diff8", 0, 8, 0},
438  {"fixup_diff16", 0, 16, 0},
439  {"fixup_diff32", 0, 32, 0},
440 
441  {"fixup_lds_sts_16", 0, 16, 0},
442 
443  {"fixup_port6", 0, 16, 0}, // non-contiguous
444  {"fixup_port5", 3, 5, 0},
445  };
446 
447  if (Kind < FirstTargetFixupKind)
448  return MCAsmBackend::getFixupKindInfo(Kind);
449 
450  assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
451  "Invalid kind!");
452 
453  return Infos[Kind - FirstTargetFixupKind];
454 }
455 
456 bool AVRAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
457  // If the count is not 2-byte aligned, we must be writing data into the text
458  // section (otherwise we have unaligned instructions, and thus have far
459  // bigger problems), so just write zeros instead.
460  assert((Count % 2) == 0 && "NOP instructions must be 2 bytes");
461 
462  OW->WriteZeros(Count);
463  return true;
464 }
465 
467  const MCFixup &Fixup,
468  const MCValue &Target) {
469  switch ((unsigned) Fixup.getKind()) {
470  default: return false;
471  // Fixups which should always be recorded as relocations.
472  case AVR::fixup_7_pcrel:
473  case AVR::fixup_13_pcrel:
474  case AVR::fixup_call:
475  return true;
476  }
477 }
478 
480  const MCRegisterInfo &MRI,
481  const llvm::MCTargetOptions &TO) {
482  return new AVRAsmBackend(STI.getTargetTriple().getOS());
483 }
484 
485 } // end of namespace llvm
486 
void WriteZeros(unsigned N)
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 16-bi...
Definition: AVRFixupKinds.h:70
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a 16-bit progra...
Definition: AVRFixupKinds.h:80
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:294
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 16-bi...
Definition: AVRFixupKinds.h:97
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.
Defines the object file and target independent interfaces used by the assembler backend to write nati...
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...
Definition: AVRFixupKinds.h:67
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)...
Definition: MCFixup.h:66
const Triple & getTargetTriple() const
getTargetTriple - Return the target triple string.
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...
MCContext & getContext() const
Definition: MCAssembler.h:273
std::unique_ptr< MCObjectWriter > createAVRELFObjectWriter(raw_pwrite_stream &OS, 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 negat...
Definition: AVRFixupKinds.h:76
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a 16-bit value ...
Definition: AVRFixupKinds.h:54
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:165
A four-byte fixup.
Definition: MCFixup.h:26
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.
Definition: MCContext.h:63
int64_t maxIntN(int64_t N)
Gets the maximum value for a N-bit signed integer.
Definition: MathExtras.h:376
A four-byte gp relative fixup.
Definition: MCFixup.h:34
void signed_width(unsigned Width, uint64_t Value, std::string Description, const MCFixup &Fixup, MCContext *Ctx=nullptr)
Utilities for manipulating generated AVR machine code.
Definition: AVRAsmBackend.h:32
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated negat...
Definition: AVRFixupKinds.h:73
int64_t minIntN(int64_t N)
Gets the minimum value for a N-bit signed integer.
Definition: MathExtras.h:369
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
A 16-bit address.
Definition: AVRFixupKinds.h:45
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...
Definition: ArrayRef.h:291
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:23
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
Definition: MCValue.h:48
A 16-bit program memory address.
Definition: AVRFixupKinds.h:47
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...
Definition: AVRFixupKinds.h:84
uint32_t getOffset() const
Definition: MCFixup.h:95
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.
Definition: MathExtras.h:390
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.
A one-byte fixup.
Definition: MCFixup.h:24
void hi8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
SMLoc getLoc() const
Definition: MCFixup.h:112
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 ...
Definition: AVRFixupKinds.h:57
std::unique_ptr< MCObjectWriter > createObjectWriter(raw_pwrite_stream &OS) const override
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file...
void adjustBranchTarget(T &val)
Adjusts the value of a branch target.
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override
Write an (optimal) nop sequence of Count bytes to the given output.
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.
Definition: MathExtras.h:358
Replaces the immediate operand of a 16-bit Rd, K instruction with the lower 8 bits of a negated 16-bi...
Definition: AVRFixupKinds.h:93
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 32-bit value ...
Definition: AVRFixupKinds.h:63
MCSubtargetInfo - Generic base class for all target subtargets.
A eight-byte fixup.
Definition: MCFixup.h:27
static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)
Target independent information on a fixup kind.
const std::string to_string(const T &Value)
Definition: ScopedPrinter.h:62
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:337
const unsigned Kind
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.
Definition: Value.h:73
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:40
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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...
Definition: AVRFixupKinds.h:88
void lo8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
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.
Definition: MathExtras.h:385
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a 24-bit value ...
Definition: AVRFixupKinds.h:60
Replaces the 8-bit immediate with another value.
Definition: AVRFixupKinds.h:50
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsPCRel) const override
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
A two-byte fixup.
Definition: MCFixup.h:25
MCFixupKind getKind() const
Definition: MCFixup.h:93
void fixup_port6(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx=nullptr)
6-bit port number fixup on the IN family of instructions.