Lines Matching +full:loc +full:- +full:code
1 //===- AVR.cpp ------------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // AVR is a Harvard-architecture 8-bit microcontroller designed for small
10 // baremetal programs. All AVR-family processors have 32 8-bit registers.
12 // one supports up to 2^24 data address space and 2^22 code address space.
17 // can write the linked code to on-chip flush memory. You can do that with
20 // ld.lld -Ttext=0 -o foo foo.o
21 // objcopy -O binary --only-section=.text foo output.bin
26 //===----------------------------------------------------------------------===//
49 const uint8_t *loc) const override;
53 void relocate(uint8_t *loc, const Relocation &rel,
59 const uint8_t *loc) const { in getRelExpr()
96 error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + in getRelExpr()
102 static void writeLDI(uint8_t *loc, uint64_t val) { in writeLDI() argument
103 write16le(loc, (read16le(loc) & 0xf0f0) | (val & 0xf0) << 4 | (val & 0x0f)); in writeLDI()
119 void AVR::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { in relocate() argument
122 checkUInt(loc, val, 8, rel); in relocate()
123 *loc = val; in relocate()
126 checkUInt(loc, val, 32, rel); in relocate()
127 *loc = val & 0xff; in relocate()
130 checkUInt(loc, val, 32, rel); in relocate()
131 *loc = (val >> 8) & 0xff; in relocate()
134 checkUInt(loc, val, 32, rel); in relocate()
135 *loc = (val >> 16) & 0xff; in relocate()
138 // Note: this relocation is often used between code and data space, which in relocate()
141 write16le(loc, val & 0xffff); in relocate()
144 checkAlignment(loc, val, 2, rel); in relocate()
145 checkUInt(loc, val >> 1, 16, rel); in relocate()
146 write16le(loc, val >> 1); in relocate()
149 checkUInt(loc, val, 32, rel); in relocate()
150 write32le(loc, val); in relocate()
154 checkUInt(loc, val, 8, rel); in relocate()
155 writeLDI(loc, val & 0xff); in relocate()
159 writeLDI(loc, -val & 0xff); in relocate()
162 writeLDI(loc, val & 0xff); in relocate()
165 writeLDI(loc, (-val >> 8) & 0xff); in relocate()
168 writeLDI(loc, (val >> 8) & 0xff); in relocate()
171 writeLDI(loc, (-val >> 16) & 0xff); in relocate()
174 writeLDI(loc, (val >> 16) & 0xff); in relocate()
177 writeLDI(loc, (-val >> 24) & 0xff); in relocate()
180 writeLDI(loc, (val >> 24) & 0xff); in relocate()
184 checkUInt(loc, val, 17, rel); in relocate()
187 checkAlignment(loc, val, 2, rel); in relocate()
188 writeLDI(loc, (val >> 1) & 0xff); in relocate()
191 checkUInt(loc, val, 17, rel); in relocate()
194 checkAlignment(loc, val, 2, rel); in relocate()
195 writeLDI(loc, (val >> 9) & 0xff); in relocate()
198 checkAlignment(loc, val, 2, rel); in relocate()
199 writeLDI(loc, (val >> 17) & 0xff); in relocate()
203 checkAlignment(loc, val, 2, rel); in relocate()
204 writeLDI(loc, (-val >> 1) & 0xff); in relocate()
207 checkAlignment(loc, val, 2, rel); in relocate()
208 writeLDI(loc, (-val >> 9) & 0xff); in relocate()
211 checkAlignment(loc, val, 2, rel); in relocate()
212 writeLDI(loc, (-val >> 17) & 0xff); in relocate()
216 checkUInt(loc, val, 7, rel); in relocate()
219 write16le(loc, (read16le(loc) & 0xf8f0) | ((hi << 8) | lo)); in relocate()
224 checkUInt(loc, val, 5, rel); in relocate()
225 write16le(loc, (read16le(loc) & 0xff07) | (val << 3)); in relocate()
228 checkUInt(loc, val, 6, rel); in relocate()
229 write16le(loc, (read16le(loc) & 0xf9f0) | (val & 0x30) << 5 | (val & 0x0f)); in relocate()
234 checkInt(loc, val - 2, 8, rel); in relocate()
235 checkAlignment(loc, val, 2, rel); in relocate()
236 const uint16_t target = (val - 2) >> 1; in relocate()
237 write16le(loc, (read16le(loc) & 0xfc07) | ((target & 0x7f) << 3)); in relocate()
241 checkAlignment(loc, val, 2, rel); in relocate()
242 const uint16_t target = (val - 2) >> 1; in relocate()
243 write16le(loc, (read16le(loc) & 0xf000) | (target & 0xfff)); in relocate()
248 checkInt(loc, val, 6, rel); in relocate()
249 write16le(loc, (read16le(loc) & 0xd3f8) | (val & 0x20) << 8 | in relocate()
253 checkInt(loc, val, 6, rel); in relocate()
254 write16le(loc, (read16le(loc) & 0xff30) | (val & 0x30) << 2 | (val & 0x0F)); in relocate()
258 checkAlignment(loc, val, 2, rel); in relocate()
261 write16le(loc, read16le(loc) | ((hi >> 1) << 4) | (hi & 1)); in relocate()
262 write16le(loc + 2, lo); in relocate()
276 return cast<ObjFile<ELF32LE>>(file)->getObj().getHeader().e_flags; in getEFlags()