LLVM  8.0.1
AVRFixupKinds.h
Go to the documentation of this file.
1 //===-- AVRFixupKinds.h - AVR Specific Fixup Entries ------------*- C++ -*-===//
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 #ifndef LLVM_AVR_FIXUP_KINDS_H
11 #define LLVM_AVR_FIXUP_KINDS_H
12 
13 #include "llvm/MC/MCFixup.h"
14 
15 namespace llvm {
16 namespace AVR {
17 
18 /// The set of supported fixups.
19 ///
20 /// Although most of the current fixup types reflect a unique relocation
21 /// one can have multiple fixup types for a given relocation and thus need
22 /// to be uniquely named.
23 ///
24 /// \note This table *must* be in the same order of
25 /// MCFixupKindInfo Infos[AVR::NumTargetFixupKinds]
26 /// in `AVRAsmBackend.cpp`.
27 enum Fixups {
28  /// A 32-bit AVR fixup.
30 
31  /// A 7-bit PC-relative fixup for the family of conditional
32  /// branches which take 7-bit targets (BRNE,BRGT,etc).
34  /// A 12-bit PC-relative fixup for the family of branches
35  /// which take 12-bit targets (RJMP,RCALL,etc).
36  /// \note Although the fixup is labelled as 13 bits, it
37  /// is actually only encoded in 12. The reason for
38  /// The nonmenclature is that AVR branch targets are
39  /// rightshifted by 1, because instructions are always
40  /// aligned to 2 bytes, so the 0'th bit is always 0.
41  /// This way there is 13-bits of precision.
43 
44  /// A 16-bit address.
46  /// A 16-bit program memory address.
48 
49  /// Replaces the 8-bit immediate with another value.
51 
52  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
53  /// with the lower 8 bits of a 16-bit value (bits 0-7).
55  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
56  /// with the upper 8 bits of a 16-bit value (bits 8-15).
58  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
59  /// with the upper 8 bits of a 24-bit value (bits 16-23).
61  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
62  /// with the upper 8 bits of a 32-bit value (bits 24-31).
64 
65  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
66  /// with the lower 8 bits of a negated 16-bit value (bits 0-7).
68  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
69  /// with the upper 8 bits of a negated 16-bit value (bits 8-15).
71  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
72  /// with the upper 8 bits of a negated negated 24-bit value (bits 16-23).
74  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
75  /// with the upper 8 bits of a negated negated 32-bit value (bits 24-31).
77 
78  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
79  /// with the lower 8 bits of a 16-bit program memory address value (bits 0-7).
81  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
82  /// with the upper 8 bits of a 16-bit program memory address value (bits
83  /// 8-15).
85  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
86  /// with the upper 8 bits of a 24-bit program memory address value (bits
87  /// 16-23).
89 
90  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
91  /// with the lower 8 bits of a negated 16-bit program memory address value
92  /// (bits 0-7).
94  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
95  /// with the upper 8 bits of a negated 16-bit program memory address value
96  /// (bits 8-15).
98  /// Replaces the immediate operand of a 16-bit `Rd, K` instruction
99  /// with the upper 8 bits of a negated 24-bit program memory address value
100  /// (bits 16-23).
102 
103  /// A 22-bit fixup for the target of a `CALL k` or `JMP k` instruction.
105 
107  /// A symbol+addr fixup for the `LDD <x>+<n>, <r>" family of instructions.
109 
112 
117 
121 
123 
124  /// A 6-bit port address.
126  /// A 5-bit port address.
128 
129  // Marker
132 };
133 
134 namespace fixups {
135 
136 /// Adjusts the value of a branch target.
137 /// All branch targets in AVR are rightshifted by 1 to take advantage
138 /// of the fact that all instructions are aligned to addresses of size
139 /// 2, so bit 0 of an address is always 0. This gives us another bit
140 /// of precision.
141 /// \param[in,out] The target to adjust.
142 template <typename T> inline void adjustBranchTarget(T &val) { val >>= 1; }
143 
144 } // end of namespace fixups
145 }
146 } // end of namespace llvm::AVR
147 
148 #endif // LLVM_AVR_FIXUP_KINDS_H
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
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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
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
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
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
A 12-bit PC-relative fixup for the family of branches which take 12-bit targets (RJMP,RCALL,etc).
Definition: AVRFixupKinds.h:42
A 7-bit PC-relative fixup for the family of conditional branches which take 7-bit targets (BRNE...
Definition: AVRFixupKinds.h:33
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated negat...
Definition: AVRFixupKinds.h:73
A 5-bit port address.
A 16-bit address.
Definition: AVRFixupKinds.h:45
A symbol+addr fixup for the `LDD <x>+<n>, <r>" family of instructions.
A 16-bit program memory address.
Definition: AVRFixupKinds.h:47
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
A 6-bit port address.
Replaces the immediate operand of a 16-bit Rd, K instruction with the upper 8 bits of a negated 24-bi...
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
Fixups
The set of supported fixups.
Definition: AVRFixupKinds.h:27
void adjustBranchTarget(T &val)
Adjusts the value of a branch target.
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
A 22-bit fixup for the target of a CALL k or JMP k instruction.
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
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
A 32-bit AVR fixup.
Definition: AVRFixupKinds.h:29