blob: bf07b2dbf8a49f1b1144f4615200b42220d3a401 [file] [log] [blame]
Dave Allison65fcc2c2014-04-28 13:45:27 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_UTILS_ARM_ASSEMBLER_THUMB2_H_
18#define ART_COMPILER_UTILS_ARM_ASSEMBLER_THUMB2_H_
19
Vladimir Markocf93a5c2015-06-16 11:33:24 +000020#include <deque>
Andreas Gampe7cffc3b2015-10-19 21:31:53 -070021#include <utility>
Dave Allison65fcc2c2014-04-28 13:45:27 -070022#include <vector>
23
24#include "base/logging.h"
25#include "constants_arm.h"
26#include "utils/arm/managed_register_arm.h"
27#include "utils/arm/assembler_arm.h"
Vladimir Marko6b756b52015-07-14 11:58:38 +010028#include "utils/array_ref.h"
Dave Allison65fcc2c2014-04-28 13:45:27 -070029#include "offsets.h"
Dave Allison65fcc2c2014-04-28 13:45:27 -070030
31namespace art {
32namespace arm {
33
Dave Allison65fcc2c2014-04-28 13:45:27 -070034class Thumb2Assembler FINAL : public ArmAssembler {
35 public:
Nicolas Geoffrayd126ba12015-05-20 11:25:27 +010036 explicit Thumb2Assembler(bool can_relocate_branches = true)
37 : can_relocate_branches_(can_relocate_branches),
Nicolas Geoffray8d486732014-07-16 16:23:40 +010038 force_32bit_(false),
39 it_cond_index_(kNoItCondition),
Vladimir Markocf93a5c2015-06-16 11:33:24 +000040 next_condition_(AL),
41 fixups_(),
Vladimir Marko6b756b52015-07-14 11:58:38 +010042 fixup_dependents_(),
Vladimir Markocf93a5c2015-06-16 11:33:24 +000043 literals_(),
44 last_position_adjustment_(0u),
45 last_old_position_(0u),
46 last_fixup_id_(0u) {
Vladimir Marko10ef6942015-10-22 15:25:54 +010047 cfi().DelayEmittingAdvancePCs();
Dave Allison65fcc2c2014-04-28 13:45:27 -070048 }
49
50 virtual ~Thumb2Assembler() {
Dave Allison65fcc2c2014-04-28 13:45:27 -070051 }
52
53 bool IsThumb() const OVERRIDE {
54 return true;
55 }
56
57 bool IsForced32Bit() const {
58 return force_32bit_;
59 }
60
Nicolas Geoffrayd126ba12015-05-20 11:25:27 +010061 bool CanRelocateBranches() const {
62 return can_relocate_branches_;
Nicolas Geoffray8d486732014-07-16 16:23:40 +010063 }
64
Vladimir Markocf93a5c2015-06-16 11:33:24 +000065 void FinalizeCode() OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070066
67 // Data-processing instructions.
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010068 virtual void and_(Register rd, Register rn, const ShifterOperand& so,
69 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070070
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010071 virtual void eor(Register rd, Register rn, const ShifterOperand& so,
72 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070073
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010074 virtual void sub(Register rd, Register rn, const ShifterOperand& so,
75 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070076
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010077 virtual void rsb(Register rd, Register rn, const ShifterOperand& so,
78 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070079
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010080 virtual void add(Register rd, Register rn, const ShifterOperand& so,
81 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070082
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010083 virtual void adc(Register rd, Register rn, const ShifterOperand& so,
84 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070085
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010086 virtual void sbc(Register rd, Register rn, const ShifterOperand& so,
87 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070088
Vladimir Marko73cf0fb2015-07-30 15:07:22 +010089 virtual void rsc(Register rd, Register rn, const ShifterOperand& so,
90 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -070091
92 void tst(Register rn, const ShifterOperand& so, Condition cond = AL) OVERRIDE;
93
94 void teq(Register rn, const ShifterOperand& so, Condition cond = AL) OVERRIDE;
95
96 void cmp(Register rn, const ShifterOperand& so, Condition cond = AL) OVERRIDE;
97
98 void cmn(Register rn, const ShifterOperand& so, Condition cond = AL) OVERRIDE;
99
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100100 virtual void orr(Register rd, Register rn, const ShifterOperand& so,
101 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700102
Vladimir Markod2b4ca22015-09-14 15:13:26 +0100103 virtual void orn(Register rd, Register rn, const ShifterOperand& so,
104 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
105
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100106 virtual void mov(Register rd, const ShifterOperand& so,
107 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700108
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100109 virtual void bic(Register rd, Register rn, const ShifterOperand& so,
110 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700111
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100112 virtual void mvn(Register rd, const ShifterOperand& so,
113 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700114
115 // Miscellaneous data-processing instructions.
116 void clz(Register rd, Register rm, Condition cond = AL) OVERRIDE;
117 void movw(Register rd, uint16_t imm16, Condition cond = AL) OVERRIDE;
118 void movt(Register rd, uint16_t imm16, Condition cond = AL) OVERRIDE;
Scott Wakeling9ee23f42015-07-23 10:44:35 +0100119 void rbit(Register rd, Register rm, Condition cond = AL) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700120
121 // Multiply instructions.
122 void mul(Register rd, Register rn, Register rm, Condition cond = AL) OVERRIDE;
123 void mla(Register rd, Register rn, Register rm, Register ra,
124 Condition cond = AL) OVERRIDE;
125 void mls(Register rd, Register rn, Register rm, Register ra,
126 Condition cond = AL) OVERRIDE;
Zheng Xuc6667102015-05-15 16:08:45 +0800127 void smull(Register rd_lo, Register rd_hi, Register rn, Register rm,
128 Condition cond = AL) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700129 void umull(Register rd_lo, Register rd_hi, Register rn, Register rm,
130 Condition cond = AL) OVERRIDE;
131
132 void sdiv(Register rd, Register rn, Register rm, Condition cond = AL) OVERRIDE;
133 void udiv(Register rd, Register rn, Register rm, Condition cond = AL) OVERRIDE;
134
Roland Levillain981e4542014-11-14 11:47:14 +0000135 // Bit field extract instructions.
Roland Levillain51d3fc42014-11-13 14:11:42 +0000136 void sbfx(Register rd, Register rn, uint32_t lsb, uint32_t width, Condition cond = AL) OVERRIDE;
Roland Levillain981e4542014-11-14 11:47:14 +0000137 void ubfx(Register rd, Register rn, uint32_t lsb, uint32_t width, Condition cond = AL) OVERRIDE;
Roland Levillain51d3fc42014-11-13 14:11:42 +0000138
Dave Allison65fcc2c2014-04-28 13:45:27 -0700139 // Load/store instructions.
140 void ldr(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
141 void str(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
142
143 void ldrb(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
144 void strb(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
145
146 void ldrh(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
147 void strh(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
148
149 void ldrsb(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
150 void ldrsh(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
151
Roland Levillain4af147e2015-04-07 13:54:49 +0100152 // Load/store register dual instructions using registers `rd` and `rd` + 1.
Dave Allison65fcc2c2014-04-28 13:45:27 -0700153 void ldrd(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
154 void strd(Register rd, const Address& ad, Condition cond = AL) OVERRIDE;
155
Roland Levillain4af147e2015-04-07 13:54:49 +0100156 // Load/store register dual instructions using registers `rd` and `rd2`.
157 // Note that contrary to the ARM A1 encoding, the Thumb-2 T1 encoding
158 // does not require `rd` to be even, nor `rd2' to be equal to `rd` + 1.
159 void ldrd(Register rd, Register rd2, const Address& ad, Condition cond);
160 void strd(Register rd, Register rd2, const Address& ad, Condition cond);
161
162
Dave Allison65fcc2c2014-04-28 13:45:27 -0700163 void ldm(BlockAddressMode am, Register base,
164 RegList regs, Condition cond = AL) OVERRIDE;
165 void stm(BlockAddressMode am, Register base,
166 RegList regs, Condition cond = AL) OVERRIDE;
167
168 void ldrex(Register rd, Register rn, Condition cond = AL) OVERRIDE;
169 void strex(Register rd, Register rt, Register rn, Condition cond = AL) OVERRIDE;
170
171 void ldrex(Register rd, Register rn, uint16_t imm, Condition cond = AL);
172 void strex(Register rd, Register rt, Register rn, uint16_t imm, Condition cond = AL);
173
Calin Juravle52c48962014-12-16 17:02:57 +0000174 void ldrexd(Register rt, Register rt2, Register rn, Condition cond = AL) OVERRIDE;
175 void strexd(Register rd, Register rt, Register rt2, Register rn, Condition cond = AL) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700176
177 // Miscellaneous instructions.
178 void clrex(Condition cond = AL) OVERRIDE;
179 void nop(Condition cond = AL) OVERRIDE;
180
181 void bkpt(uint16_t imm16) OVERRIDE;
182 void svc(uint32_t imm24) OVERRIDE;
183
184 // If-then
185 void it(Condition firstcond, ItState i1 = kItOmitted,
186 ItState i2 = kItOmitted, ItState i3 = kItOmitted) OVERRIDE;
187
188 void cbz(Register rn, Label* target) OVERRIDE;
189 void cbnz(Register rn, Label* target) OVERRIDE;
190
191 // Floating point instructions (VFPv3-D16 and VFPv3-D32 profiles).
192 void vmovsr(SRegister sn, Register rt, Condition cond = AL) OVERRIDE;
193 void vmovrs(Register rt, SRegister sn, Condition cond = AL) OVERRIDE;
194 void vmovsrr(SRegister sm, Register rt, Register rt2, Condition cond = AL) OVERRIDE;
195 void vmovrrs(Register rt, Register rt2, SRegister sm, Condition cond = AL) OVERRIDE;
196 void vmovdrr(DRegister dm, Register rt, Register rt2, Condition cond = AL) OVERRIDE;
197 void vmovrrd(Register rt, Register rt2, DRegister dm, Condition cond = AL) OVERRIDE;
198 void vmovs(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
199 void vmovd(DRegister dd, DRegister dm, Condition cond = AL) OVERRIDE;
200
201 // Returns false if the immediate cannot be encoded.
202 bool vmovs(SRegister sd, float s_imm, Condition cond = AL) OVERRIDE;
203 bool vmovd(DRegister dd, double d_imm, Condition cond = AL) OVERRIDE;
204
205 void vldrs(SRegister sd, const Address& ad, Condition cond = AL) OVERRIDE;
206 void vstrs(SRegister sd, const Address& ad, Condition cond = AL) OVERRIDE;
207 void vldrd(DRegister dd, const Address& ad, Condition cond = AL) OVERRIDE;
208 void vstrd(DRegister dd, const Address& ad, Condition cond = AL) OVERRIDE;
209
210 void vadds(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) OVERRIDE;
211 void vaddd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) OVERRIDE;
212 void vsubs(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) OVERRIDE;
213 void vsubd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) OVERRIDE;
214 void vmuls(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) OVERRIDE;
215 void vmuld(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) OVERRIDE;
216 void vmlas(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) OVERRIDE;
217 void vmlad(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) OVERRIDE;
218 void vmlss(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) OVERRIDE;
219 void vmlsd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) OVERRIDE;
220 void vdivs(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) OVERRIDE;
221 void vdivd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) OVERRIDE;
222
223 void vabss(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
224 void vabsd(DRegister dd, DRegister dm, Condition cond = AL) OVERRIDE;
225 void vnegs(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
226 void vnegd(DRegister dd, DRegister dm, Condition cond = AL) OVERRIDE;
227 void vsqrts(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
228 void vsqrtd(DRegister dd, DRegister dm, Condition cond = AL) OVERRIDE;
229
230 void vcvtsd(SRegister sd, DRegister dm, Condition cond = AL) OVERRIDE;
231 void vcvtds(DRegister dd, SRegister sm, Condition cond = AL) OVERRIDE;
232 void vcvtis(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
233 void vcvtid(SRegister sd, DRegister dm, Condition cond = AL) OVERRIDE;
234 void vcvtsi(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
235 void vcvtdi(DRegister dd, SRegister sm, Condition cond = AL) OVERRIDE;
236 void vcvtus(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
237 void vcvtud(SRegister sd, DRegister dm, Condition cond = AL) OVERRIDE;
238 void vcvtsu(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
239 void vcvtdu(DRegister dd, SRegister sm, Condition cond = AL) OVERRIDE;
240
241 void vcmps(SRegister sd, SRegister sm, Condition cond = AL) OVERRIDE;
242 void vcmpd(DRegister dd, DRegister dm, Condition cond = AL) OVERRIDE;
243 void vcmpsz(SRegister sd, Condition cond = AL) OVERRIDE;
244 void vcmpdz(DRegister dd, Condition cond = AL) OVERRIDE;
245 void vmstat(Condition cond = AL) OVERRIDE; // VMRS APSR_nzcv, FPSCR
246
247 void vpushs(SRegister reg, int nregs, Condition cond = AL) OVERRIDE;
248 void vpushd(DRegister reg, int nregs, Condition cond = AL) OVERRIDE;
249 void vpops(SRegister reg, int nregs, Condition cond = AL) OVERRIDE;
250 void vpopd(DRegister reg, int nregs, Condition cond = AL) OVERRIDE;
251
252 // Branch instructions.
253 void b(Label* label, Condition cond = AL);
254 void bl(Label* label, Condition cond = AL);
255 void blx(Label* label);
256 void blx(Register rm, Condition cond = AL) OVERRIDE;
257 void bx(Register rm, Condition cond = AL) OVERRIDE;
258
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100259 virtual void Lsl(Register rd, Register rm, uint32_t shift_imm,
260 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
261 virtual void Lsr(Register rd, Register rm, uint32_t shift_imm,
262 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
263 virtual void Asr(Register rd, Register rm, uint32_t shift_imm,
264 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
265 virtual void Ror(Register rd, Register rm, uint32_t shift_imm,
266 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
267 virtual void Rrx(Register rd, Register rm,
268 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison45fdb932014-06-25 12:37:10 -0700269
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100270 virtual void Lsl(Register rd, Register rm, Register rn,
271 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
272 virtual void Lsr(Register rd, Register rm, Register rn,
273 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
274 virtual void Asr(Register rd, Register rm, Register rn,
275 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
276 virtual void Ror(Register rd, Register rm, Register rn,
277 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700278
279 void Push(Register rd, Condition cond = AL) OVERRIDE;
280 void Pop(Register rd, Condition cond = AL) OVERRIDE;
281
282 void PushList(RegList regs, Condition cond = AL) OVERRIDE;
283 void PopList(RegList regs, Condition cond = AL) OVERRIDE;
284
285 void Mov(Register rd, Register rm, Condition cond = AL) OVERRIDE;
286
287 void CompareAndBranchIfZero(Register r, Label* label) OVERRIDE;
288 void CompareAndBranchIfNonZero(Register r, Label* label) OVERRIDE;
289
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100290 // Memory barriers.
291 void dmb(DmbOptions flavor) OVERRIDE;
292
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000293 // Get the final position of a label after local fixup based on the old position
294 // recorded before FinalizeCode().
295 uint32_t GetAdjustedPosition(uint32_t old_position) OVERRIDE;
296
297 using ArmAssembler::NewLiteral; // Make the helper template visible.
298
299 Literal* NewLiteral(size_t size, const uint8_t* data) OVERRIDE;
300 void LoadLiteral(Register rt, Literal* literal) OVERRIDE;
301 void LoadLiteral(Register rt, Register rt2, Literal* literal) OVERRIDE;
302 void LoadLiteral(SRegister sd, Literal* literal) OVERRIDE;
303 void LoadLiteral(DRegister dd, Literal* literal) OVERRIDE;
304
Dave Allison65fcc2c2014-04-28 13:45:27 -0700305 // Add signed constant value to rd. May clobber IP.
Dave Allison65fcc2c2014-04-28 13:45:27 -0700306 void AddConstant(Register rd, Register rn, int32_t value,
Vladimir Marko449b1092015-09-08 12:16:45 +0100307 Condition cond = AL, SetCc set_cc = kCcDontCare) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700308
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700309 void CmpConstant(Register rn, int32_t value, Condition cond = AL) OVERRIDE;
310
Dave Allison65fcc2c2014-04-28 13:45:27 -0700311 // Load and Store. May clobber IP.
312 void LoadImmediate(Register rd, int32_t value, Condition cond = AL) OVERRIDE;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700313 void MarkExceptionHandler(Label* label) OVERRIDE;
314 void LoadFromOffset(LoadOperandType type,
315 Register reg,
316 Register base,
317 int32_t offset,
318 Condition cond = AL) OVERRIDE;
319 void StoreToOffset(StoreOperandType type,
320 Register reg,
321 Register base,
322 int32_t offset,
323 Condition cond = AL) OVERRIDE;
324 void LoadSFromOffset(SRegister reg,
325 Register base,
326 int32_t offset,
327 Condition cond = AL) OVERRIDE;
328 void StoreSToOffset(SRegister reg,
329 Register base,
330 int32_t offset,
331 Condition cond = AL) OVERRIDE;
332 void LoadDFromOffset(DRegister reg,
333 Register base,
334 int32_t offset,
335 Condition cond = AL) OVERRIDE;
336 void StoreDToOffset(DRegister reg,
337 Register base,
338 int32_t offset,
339 Condition cond = AL) OVERRIDE;
340
Nicolas Geoffray3bcc8ea2014-11-28 15:00:02 +0000341 bool ShifterOperandCanHold(Register rd,
342 Register rn,
343 Opcode opcode,
344 uint32_t immediate,
Vladimir Markof5c09c32015-12-17 12:08:08 +0000345 SetCc set_cc,
Nicolas Geoffray3bcc8ea2014-11-28 15:00:02 +0000346 ShifterOperand* shifter_op) OVERRIDE;
Vladimir Markof5c09c32015-12-17 12:08:08 +0000347 using ArmAssembler::ShifterOperandCanHold; // Don't hide the non-virtual override.
Nicolas Geoffray3bcc8ea2014-11-28 15:00:02 +0000348
Nicolas Geoffray5bd05a52015-10-13 09:48:30 +0100349 bool ShifterOperandCanAlwaysHold(uint32_t immediate) OVERRIDE;
350
Dave Allison65fcc2c2014-04-28 13:45:27 -0700351
Ian Rogers13735952014-10-08 12:43:28 -0700352 static bool IsInstructionForExceptionHandling(uintptr_t pc);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700353
354 // Emit data (e.g. encoded instruction or immediate) to the.
355 // instruction stream.
356 void Emit32(int32_t value); // Emit a 32 bit instruction in thumb format.
357 void Emit16(int16_t value); // Emit a 16 bit instruction in little endian format.
358 void Bind(Label* label) OVERRIDE;
359
360 void MemoryBarrier(ManagedRegister scratch) OVERRIDE;
361
362 // Force the assembler to generate 32 bit instructions.
363 void Force32Bit() {
364 force_32bit_ = true;
365 }
366
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700367 // Emit an ADR (or a sequence of instructions) to load the jump table address into base_reg. This
368 // will generate a fixup.
369 JumpTable* CreateJumpTable(std::vector<Label*>&& labels, Register base_reg) OVERRIDE;
370 // Emit an ADD PC, X to dispatch a jump-table jump. This will generate a fixup.
371 void EmitJumpTableDispatch(JumpTable* jump_table, Register displacement_reg) OVERRIDE;
372
Dave Allison65fcc2c2014-04-28 13:45:27 -0700373 private:
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000374 typedef uint16_t FixupId;
375
376 // Fixup: branches and literal pool references.
377 //
378 // The thumb2 architecture allows branches to be either 16 or 32 bit instructions. This
379 // depends on both the type of branch and the offset to which it is branching. The 16-bit
380 // cbz and cbnz instructions may also need to be replaced with a separate 16-bit compare
381 // instruction and a 16- or 32-bit branch instruction. Load from a literal pool can also be
382 // 16-bit or 32-bit instruction and, if the method is large, we may need to use a sequence
383 // of instructions to make up for the limited range of load literal instructions (up to
384 // 4KiB for the 32-bit variant). When generating code for these insns we don't know the
385 // size before hand, so we assume it is the smallest available size and determine the final
386 // code offsets and sizes and emit code in FinalizeCode().
387 //
388 // To handle this, we keep a record of every branch and literal pool load in the program.
389 // The actual instruction encoding for these is delayed until we know the final size of
390 // every instruction. When we bind a label to a branch we don't know the final location yet
391 // as some preceding instructions may need to be expanded, so we record a non-final offset.
392 // In FinalizeCode(), we expand the sizes of branches and literal loads that are out of
393 // range. With each expansion, we need to update dependent Fixups, i.e. insntructios with
394 // target on the other side of the expanded insn, as their offsets change and this may
395 // trigger further expansion.
396 //
397 // All Fixups have a 'fixup id' which is a 16 bit unsigned number used to identify the
398 // Fixup. For each unresolved label we keep a singly-linked list of all Fixups pointing
399 // to it, using the fixup ids as links. The first link is stored in the label's position
400 // (the label is linked but not bound), the following links are stored in the code buffer,
401 // in the placeholder where we will eventually emit the actual code.
402
403 class Fixup {
404 public:
405 // Branch type.
406 enum Type : uint8_t {
407 kConditional, // B<cond>.
408 kUnconditional, // B.
409 kUnconditionalLink, // BL.
410 kUnconditionalLinkX, // BLX.
411 kCompareAndBranchXZero, // cbz/cbnz.
412 kLoadLiteralNarrow, // Load narrrow integer literal.
413 kLoadLiteralWide, // Load wide integer literal.
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700414 kLoadLiteralAddr, // Load address of literal (used for jump table).
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000415 kLoadFPLiteralSingle, // Load FP literal single.
416 kLoadFPLiteralDouble, // Load FP literal double.
417 };
418
419 // Calculated size of branch instruction based on type and offset.
420 enum Size : uint8_t {
421 // Branch variants.
422 kBranch16Bit,
423 kBranch32Bit,
424 // NOTE: We don't support branches which would require multiple instructions, i.e.
425 // conditinoal branches beyond +-1MiB and unconditional branches beyond +-16MiB.
426
427 // CBZ/CBNZ variants.
428 kCbxz16Bit, // CBZ/CBNZ rX, label; X < 8; 7-bit positive offset.
429 kCbxz32Bit, // CMP rX, #0 + Bcc label; X < 8; 16-bit Bcc; +-8-bit offset.
430 kCbxz48Bit, // CMP rX, #0 + Bcc label; X < 8; 32-bit Bcc; up to +-1MiB offset.
431
432 // Load integer literal variants.
433 // LDR rX, label; X < 8; 16-bit variant up to 1KiB offset; 2 bytes.
434 kLiteral1KiB,
435 // LDR rX, label; 32-bit variant up to 4KiB offset; 4 bytes.
436 kLiteral4KiB,
437 // MOV rX, imm16 + ADD rX, pc + LDR rX, [rX]; X < 8; up to 64KiB offset; 8 bytes.
438 kLiteral64KiB,
439 // MOV rX, modimm + ADD rX, pc + LDR rX, [rX, #imm12]; up to 1MiB offset; 10 bytes.
440 kLiteral1MiB,
441 // NOTE: We don't provide the 12-byte version of kLiteralFar below where the LDR is 16-bit.
442 // MOV rX, imm16 + MOVT rX, imm16 + ADD rX, pc + LDR rX, [rX]; any offset; 14 bytes.
443 kLiteralFar,
444
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700445 // Load literal base addr.
446 // ADR rX, label; X < 8; 8 bit immediate, shifted to 10 bit. 2 bytes.
447 kLiteralAddr1KiB,
448 // ADR rX, label; 4KiB offset. 4 bytes.
449 kLiteralAddr4KiB,
450 // MOV rX, imm16 + ADD rX, pc; 64KiB offset. 6 bytes.
451 kLiteralAddr64KiB,
452 // MOV rX, imm16 + MOVT rX, imm16 + ADD rX, pc; any offset; 10 bytes.
453 kLiteralAddrFar,
454
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000455 // Load long or FP literal variants.
456 // VLDR s/dX, label; 32-bit insn, up to 1KiB offset; 4 bytes.
457 kLongOrFPLiteral1KiB,
458 // MOV ip, modimm + ADD ip, pc + VLDR s/dX, [IP, #imm8*4]; up to 256KiB offset; 10 bytes.
459 kLongOrFPLiteral256KiB,
460 // MOV ip, imm16 + MOVT ip, imm16 + ADD ip, pc + VLDR s/dX, [IP]; any offset; 14 bytes.
461 kLongOrFPLiteralFar,
462 };
463
464 // Unresolved branch possibly with a condition.
465 static Fixup Branch(uint32_t location, Type type, Size size = kBranch16Bit,
466 Condition cond = AL) {
467 DCHECK(type == kConditional || type == kUnconditional ||
468 type == kUnconditionalLink || type == kUnconditionalLinkX);
469 DCHECK(size == kBranch16Bit || size == kBranch32Bit);
470 DCHECK(size == kBranch32Bit || (type == kConditional || type == kUnconditional));
471 return Fixup(kNoRegister, kNoRegister, kNoSRegister, kNoDRegister,
472 cond, type, size, location);
473 }
474
475 // Unresolved compare-and-branch instruction with a register and condition (EQ or NE).
476 static Fixup CompareAndBranch(uint32_t location, Register rn, Condition cond) {
477 DCHECK(cond == EQ || cond == NE);
478 return Fixup(rn, kNoRegister, kNoSRegister, kNoDRegister,
479 cond, kCompareAndBranchXZero, kCbxz16Bit, location);
480 }
481
482 // Load narrow literal.
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700483 static Fixup LoadNarrowLiteral(uint32_t location, Register rt, Size size) {
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000484 DCHECK(size == kLiteral1KiB || size == kLiteral4KiB || size == kLiteral64KiB ||
485 size == kLiteral1MiB || size == kLiteralFar);
486 DCHECK(!IsHighRegister(rt) || (size != kLiteral1KiB && size != kLiteral64KiB));
487 return Fixup(rt, kNoRegister, kNoSRegister, kNoDRegister,
488 AL, kLoadLiteralNarrow, size, location);
489 }
490
491 // Load wide literal.
492 static Fixup LoadWideLiteral(uint32_t location, Register rt, Register rt2,
493 Size size = kLongOrFPLiteral1KiB) {
494 DCHECK(size == kLongOrFPLiteral1KiB || size == kLongOrFPLiteral256KiB ||
495 size == kLongOrFPLiteralFar);
496 DCHECK(!IsHighRegister(rt) || (size != kLiteral1KiB && size != kLiteral64KiB));
497 return Fixup(rt, rt2, kNoSRegister, kNoDRegister,
498 AL, kLoadLiteralWide, size, location);
499 }
500
501 // Load FP single literal.
502 static Fixup LoadSingleLiteral(uint32_t location, SRegister sd,
503 Size size = kLongOrFPLiteral1KiB) {
504 DCHECK(size == kLongOrFPLiteral1KiB || size == kLongOrFPLiteral256KiB ||
505 size == kLongOrFPLiteralFar);
506 return Fixup(kNoRegister, kNoRegister, sd, kNoDRegister,
507 AL, kLoadFPLiteralSingle, size, location);
508 }
509
510 // Load FP double literal.
511 static Fixup LoadDoubleLiteral(uint32_t location, DRegister dd,
512 Size size = kLongOrFPLiteral1KiB) {
513 DCHECK(size == kLongOrFPLiteral1KiB || size == kLongOrFPLiteral256KiB ||
514 size == kLongOrFPLiteralFar);
515 return Fixup(kNoRegister, kNoRegister, kNoSRegister, dd,
516 AL, kLoadFPLiteralDouble, size, location);
517 }
518
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700519 static Fixup LoadLiteralAddress(uint32_t location, Register rt, Size size) {
520 DCHECK(size == kLiteralAddr1KiB || size == kLiteralAddr4KiB || size == kLiteralAddr64KiB ||
521 size == kLiteralAddrFar);
522 DCHECK(!IsHighRegister(rt) || size != kLiteralAddr1KiB);
523 return Fixup(rt, kNoRegister, kNoSRegister, kNoDRegister,
524 AL, kLoadLiteralAddr, size, location);
525 }
526
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000527 Type GetType() const {
528 return type_;
529 }
530
Vladimir Marko663c9342015-07-22 11:28:14 +0100531 bool IsLoadLiteral() const {
532 return GetType() >= kLoadLiteralNarrow;
533 }
534
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000535 Size GetOriginalSize() const {
536 return original_size_;
537 }
538
539 Size GetSize() const {
540 return size_;
541 }
542
543 uint32_t GetOriginalSizeInBytes() const;
544
545 uint32_t GetSizeInBytes() const;
546
547 uint32_t GetLocation() const {
548 return location_;
549 }
550
551 uint32_t GetAdjustment() const {
552 return adjustment_;
553 }
554
Vladimir Marko6b756b52015-07-14 11:58:38 +0100555 // Prepare the assembler->fixup_dependents_ and each Fixup's dependents_start_/count_.
556 static void PrepareDependents(Thumb2Assembler* assembler);
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000557
Vladimir Marko6b756b52015-07-14 11:58:38 +0100558 ArrayRef<FixupId> Dependents(const Thumb2Assembler& assembler) const {
559 return ArrayRef<FixupId>(assembler.fixup_dependents_.get() + dependents_start_,
560 dependents_count_);
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000561 }
562
563 // Resolve a branch when the target is known.
564 void Resolve(uint32_t target) {
565 DCHECK_EQ(target_, kUnresolved);
566 DCHECK_NE(target, kUnresolved);
567 target_ = target;
568 }
569
570 // Check if the current size is OK for current location_, target_ and adjustment_.
571 // If not, increase the size. Return the size increase, 0 if unchanged.
572 // If the target if after this Fixup, also add the difference to adjustment_,
573 // so that we don't need to consider forward Fixups as their own dependencies.
574 uint32_t AdjustSizeIfNeeded(uint32_t current_code_size);
575
576 // Increase adjustments. This is called for dependents of a Fixup when its size changes.
577 void IncreaseAdjustment(uint32_t increase) {
578 adjustment_ += increase;
579 }
580
581 // Finalize the branch with an adjustment to the location. Both location and target are updated.
582 void Finalize(uint32_t location_adjustment) {
583 DCHECK_NE(target_, kUnresolved);
584 location_ += location_adjustment;
585 target_ += location_adjustment;
586 }
587
588 // Emit the branch instruction into the assembler buffer. This does the
589 // encoding into the thumb instruction.
590 void Emit(AssemblerBuffer* buffer, uint32_t code_size) const;
591
592 private:
593 Fixup(Register rn, Register rt2, SRegister sd, DRegister dd,
594 Condition cond, Type type, Size size, uint32_t location)
595 : rn_(rn),
596 rt2_(rt2),
597 sd_(sd),
598 dd_(dd),
599 cond_(cond),
600 type_(type),
601 original_size_(size), size_(size),
602 location_(location),
603 target_(kUnresolved),
604 adjustment_(0u),
Vladimir Marko6b756b52015-07-14 11:58:38 +0100605 dependents_count_(0u),
606 dependents_start_(0u) {
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000607 }
608 static size_t SizeInBytes(Size size);
609
610 // The size of padding added before the literal pool.
611 static size_t LiteralPoolPaddingSize(uint32_t current_code_size);
612
613 // Returns the offset from the PC-using insn to the target.
614 int32_t GetOffset(uint32_t current_code_size) const;
615
616 size_t IncreaseSize(Size new_size);
617
618 int32_t LoadWideOrFpEncoding(Register rbase, int32_t offset) const;
619
620 static constexpr uint32_t kUnresolved = 0xffffffff; // Value for target_ for unresolved.
621
622 const Register rn_; // Rn for cbnz/cbz, Rt for literal loads.
623 Register rt2_; // For kLoadLiteralWide.
624 SRegister sd_; // For kLoadFPLiteralSingle.
625 DRegister dd_; // For kLoadFPLiteralDouble.
626 const Condition cond_;
627 const Type type_;
628 Size original_size_;
629 Size size_;
630 uint32_t location_; // Offset into assembler buffer in bytes.
631 uint32_t target_; // Offset into assembler buffer in bytes.
632 uint32_t adjustment_; // The number of extra bytes inserted between location_ and target_.
Vladimir Marko6b756b52015-07-14 11:58:38 +0100633 // Fixups that require adjustment when current size changes are stored in a single
634 // array in the assembler and we store only the start index and count here.
635 uint32_t dependents_count_;
636 uint32_t dependents_start_;
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000637 };
638
Dave Allison65fcc2c2014-04-28 13:45:27 -0700639 // Emit a single 32 or 16 bit data processing instruction.
640 void EmitDataProcessing(Condition cond,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700641 Opcode opcode,
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100642 SetCc set_cc,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700643 Register rn,
644 Register rd,
645 const ShifterOperand& so);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700646
647 // Must the instruction be 32 bits or can it possibly be encoded
648 // in 16 bits?
649 bool Is32BitDataProcessing(Condition cond,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700650 Opcode opcode,
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100651 SetCc set_cc,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700652 Register rn,
653 Register rd,
654 const ShifterOperand& so);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700655
656 // Emit a 32 bit data processing instruction.
657 void Emit32BitDataProcessing(Condition cond,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700658 Opcode opcode,
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100659 SetCc set_cc,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700660 Register rn,
661 Register rd,
662 const ShifterOperand& so);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700663
664 // Emit a 16 bit data processing instruction.
665 void Emit16BitDataProcessing(Condition cond,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700666 Opcode opcode,
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100667 SetCc set_cc,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700668 Register rn,
669 Register rd,
670 const ShifterOperand& so);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700671
672 void Emit16BitAddSub(Condition cond,
673 Opcode opcode,
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100674 SetCc set_cc,
Dave Allison65fcc2c2014-04-28 13:45:27 -0700675 Register rn,
676 Register rd,
677 const ShifterOperand& so);
678
679 uint16_t EmitCompareAndBranch(Register rn, uint16_t prev, bool n);
680
681 void EmitLoadStore(Condition cond,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700682 bool load,
683 bool byte,
684 bool half,
685 bool is_signed,
686 Register rd,
687 const Address& ad);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700688
689 void EmitMemOpAddressMode3(Condition cond,
690 int32_t mode,
691 Register rd,
692 const Address& ad);
693
694 void EmitMultiMemOp(Condition cond,
695 BlockAddressMode am,
696 bool load,
697 Register base,
698 RegList regs);
699
700 void EmitMulOp(Condition cond,
701 int32_t opcode,
702 Register rd,
703 Register rn,
704 Register rm,
705 Register rs);
706
707 void EmitVFPsss(Condition cond,
708 int32_t opcode,
709 SRegister sd,
710 SRegister sn,
711 SRegister sm);
712
713 void EmitVFPddd(Condition cond,
714 int32_t opcode,
715 DRegister dd,
716 DRegister dn,
717 DRegister dm);
718
719 void EmitVFPsd(Condition cond,
720 int32_t opcode,
721 SRegister sd,
722 DRegister dm);
723
724 void EmitVFPds(Condition cond,
725 int32_t opcode,
726 DRegister dd,
727 SRegister sm);
728
729 void EmitVPushPop(uint32_t reg, int nregs, bool push, bool dbl, Condition cond);
730
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000731 void EmitBranch(Condition cond, Label* label, bool link, bool x);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700732 static int32_t EncodeBranchOffset(int32_t offset, int32_t inst);
733 static int DecodeBranchOffset(int32_t inst);
Vladimir Marko73cf0fb2015-07-30 15:07:22 +0100734 void EmitShift(Register rd, Register rm, Shift shift, uint8_t amount,
735 Condition cond = AL, SetCc set_cc = kCcDontCare);
736 void EmitShift(Register rd, Register rn, Shift shift, Register rm,
737 Condition cond = AL, SetCc set_cc = kCcDontCare);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700738
Vladimir Marko6fd0ffe2015-11-19 21:13:52 +0000739 static int32_t GetAllowedLoadOffsetBits(LoadOperandType type);
740 static int32_t GetAllowedStoreOffsetBits(StoreOperandType type);
741 bool CanSplitLoadStoreOffset(int32_t allowed_offset_bits,
742 int32_t offset,
743 /*out*/ int32_t* add_to_base,
744 /*out*/ int32_t* offset_for_load_store);
745 int32_t AdjustLoadStoreOffset(int32_t allowed_offset_bits,
746 Register temp,
747 Register base,
748 int32_t offset,
749 Condition cond);
750
Nicolas Geoffrayd126ba12015-05-20 11:25:27 +0100751 // Whether the assembler can relocate branches. If false, unresolved branches will be
752 // emitted on 32bits.
753 bool can_relocate_branches_;
754
755 // Force the assembler to use 32 bit thumb2 instructions.
756 bool force_32bit_;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700757
758 // IfThen conditions. Used to check that conditional instructions match the preceding IT.
759 Condition it_conditions_[4];
760 uint8_t it_cond_index_;
761 Condition next_condition_;
762
763 void SetItCondition(ItState s, Condition cond, uint8_t index);
764
765 void CheckCondition(Condition cond) {
766 CHECK_EQ(cond, next_condition_);
767
768 // Move to the next condition if there is one.
769 if (it_cond_index_ < 3) {
770 ++it_cond_index_;
771 next_condition_ = it_conditions_[it_cond_index_];
772 } else {
773 next_condition_ = AL;
774 }
775 }
776
777 void CheckConditionLastIt(Condition cond) {
778 if (it_cond_index_ < 3) {
779 // Check that the next condition is AL. This means that the
780 // current condition is the last in the IT block.
781 CHECK_EQ(it_conditions_[it_cond_index_ + 1], AL);
782 }
783 CheckCondition(cond);
784 }
785
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000786 FixupId AddFixup(Fixup fixup) {
787 FixupId fixup_id = static_cast<FixupId>(fixups_.size());
788 fixups_.push_back(fixup);
789 // For iterating using FixupId, we need the next id to be representable.
790 DCHECK_EQ(static_cast<size_t>(static_cast<FixupId>(fixups_.size())), fixups_.size());
791 return fixup_id;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700792 }
793
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000794 Fixup* GetFixup(FixupId fixup_id) {
795 DCHECK_LT(fixup_id, fixups_.size());
796 return &fixups_[fixup_id];
Dave Allison65fcc2c2014-04-28 13:45:27 -0700797 }
798
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000799 void BindLabel(Label* label, uint32_t bound_pc);
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700800 uint32_t BindLiterals();
801 void BindJumpTables(uint32_t code_size);
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000802 void AdjustFixupIfNeeded(Fixup* fixup, uint32_t* current_code_size,
803 std::deque<FixupId>* fixups_to_recalculate);
804 uint32_t AdjustFixups();
805 void EmitFixups(uint32_t adjusted_code_size);
806 void EmitLiterals();
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700807 void EmitJumpTables();
Vladimir Marko10ef6942015-10-22 15:25:54 +0100808 void PatchCFI();
Dave Allison65fcc2c2014-04-28 13:45:27 -0700809
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000810 static int16_t BEncoding16(int32_t offset, Condition cond);
811 static int32_t BEncoding32(int32_t offset, Condition cond);
812 static int16_t CbxzEncoding16(Register rn, int32_t offset, Condition cond);
813 static int16_t CmpRnImm8Encoding16(Register rn, int32_t value);
814 static int16_t AddRdnRmEncoding16(Register rdn, Register rm);
815 static int32_t MovwEncoding32(Register rd, int32_t value);
816 static int32_t MovtEncoding32(Register rd, int32_t value);
817 static int32_t MovModImmEncoding32(Register rd, int32_t value);
818 static int16_t LdrLitEncoding16(Register rt, int32_t offset);
819 static int32_t LdrLitEncoding32(Register rt, int32_t offset);
820 static int32_t LdrdEncoding32(Register rt, Register rt2, Register rn, int32_t offset);
821 static int32_t VldrsEncoding32(SRegister sd, Register rn, int32_t offset);
822 static int32_t VldrdEncoding32(DRegister dd, Register rn, int32_t offset);
823 static int16_t LdrRtRnImm5Encoding16(Register rt, Register rn, int32_t offset);
824 static int32_t LdrRtRnImm12Encoding(Register rt, Register rn, int32_t offset);
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700825 static int16_t AdrEncoding16(Register rd, int32_t offset);
826 static int32_t AdrEncoding32(Register rd, int32_t offset);
Dave Allison65fcc2c2014-04-28 13:45:27 -0700827
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000828 std::vector<Fixup> fixups_;
Vladimir Marko6b756b52015-07-14 11:58:38 +0100829 std::unique_ptr<FixupId[]> fixup_dependents_;
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000830
831 // Use std::deque<> for literal labels to allow insertions at the end
832 // without invalidating pointers and references to existing elements.
833 std::deque<Literal> literals_;
834
Andreas Gampe7cffc3b2015-10-19 21:31:53 -0700835 // Jump table list.
836 std::deque<JumpTable> jump_tables_;
837
Vladimir Markocf93a5c2015-06-16 11:33:24 +0000838 // Data for AdjustedPosition(), see the description there.
839 uint32_t last_position_adjustment_;
840 uint32_t last_old_position_;
841 FixupId last_fixup_id_;
Dave Allison65fcc2c2014-04-28 13:45:27 -0700842};
843
844} // namespace arm
845} // namespace art
846
847#endif // ART_COMPILER_UTILS_ARM_ASSEMBLER_THUMB2_H_