blob: 6a07e360227cc14583576d6de4cdf68409651fc1 [file] [log] [blame]
Scott Wakelingfe885462016-09-22 10:24:38 +01001/*
2 * Copyright (C) 2016 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_OPTIMIZING_CODE_GENERATOR_ARM_VIXL_H_
18#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_VIXL_H_
19
Artem Serovd4cc5b22016-11-04 11:19:09 +000020#include "base/enums.h"
21#include "code_generator.h"
Artem Serovcfbe9132016-10-14 15:58:56 +010022#include "common_arm.h"
David Sehr312f3b22018-03-19 08:39:26 -070023#include "dex/string_reference.h"
24#include "dex/type_reference.h"
Artem Serovd4cc5b22016-11-04 11:19:09 +000025#include "driver/compiler_options.h"
26#include "nodes.h"
Artem Serovd4cc5b22016-11-04 11:19:09 +000027#include "parallel_move_resolver.h"
Scott Wakelingfe885462016-09-22 10:24:38 +010028#include "utils/arm/assembler_arm_vixl.h"
29
30// TODO(VIXL): make vixl clean wrt -Wshadow.
31#pragma GCC diagnostic push
32#pragma GCC diagnostic ignored "-Wshadow"
33#include "aarch32/constants-aarch32.h"
34#include "aarch32/instructions-aarch32.h"
35#include "aarch32/macro-assembler-aarch32.h"
36#pragma GCC diagnostic pop
37
Scott Wakelingfe885462016-09-22 10:24:38 +010038namespace art {
39namespace arm {
40
Roland Levillainba650a42017-03-06 13:52:32 +000041// This constant is used as an approximate margin when emission of veneer and literal pools
42// must be blocked.
43static constexpr int kMaxMacroInstructionSizeInBytes =
44 15 * vixl::aarch32::kMaxInstructionSizeInBytes;
45
Scott Wakelinga7812ae2016-10-17 10:03:36 +010046static const vixl::aarch32::Register kParameterCoreRegistersVIXL[] = {
47 vixl::aarch32::r1,
48 vixl::aarch32::r2,
49 vixl::aarch32::r3
50};
Artem Serovd4cc5b22016-11-04 11:19:09 +000051static const size_t kParameterCoreRegistersLengthVIXL = arraysize(kParameterCoreRegistersVIXL);
Scott Wakelinga7812ae2016-10-17 10:03:36 +010052static const vixl::aarch32::SRegister kParameterFpuRegistersVIXL[] = {
53 vixl::aarch32::s0,
54 vixl::aarch32::s1,
55 vixl::aarch32::s2,
56 vixl::aarch32::s3,
57 vixl::aarch32::s4,
58 vixl::aarch32::s5,
59 vixl::aarch32::s6,
60 vixl::aarch32::s7,
61 vixl::aarch32::s8,
62 vixl::aarch32::s9,
63 vixl::aarch32::s10,
64 vixl::aarch32::s11,
65 vixl::aarch32::s12,
66 vixl::aarch32::s13,
67 vixl::aarch32::s14,
68 vixl::aarch32::s15
69};
Artem Serovd4cc5b22016-11-04 11:19:09 +000070static const size_t kParameterFpuRegistersLengthVIXL = arraysize(kParameterFpuRegistersVIXL);
Scott Wakelinga7812ae2016-10-17 10:03:36 +010071
Scott Wakelingfe885462016-09-22 10:24:38 +010072static const vixl::aarch32::Register kMethodRegister = vixl::aarch32::r0;
Scott Wakelinga7812ae2016-10-17 10:03:36 +010073
Scott Wakelingfe885462016-09-22 10:24:38 +010074static const vixl::aarch32::Register kCoreAlwaysSpillRegister = vixl::aarch32::r5;
Scott Wakelinga7812ae2016-10-17 10:03:36 +010075
Roland Levillain6d729a72017-06-30 18:34:01 +010076// Callee saves core registers r5, r6, r7, r8 (except when emitting Baker
77// read barriers, where it is used as Marking Register), r10, r11, and lr.
Scott Wakelinga7812ae2016-10-17 10:03:36 +010078static const vixl::aarch32::RegisterList kCoreCalleeSaves = vixl::aarch32::RegisterList::Union(
79 vixl::aarch32::RegisterList(vixl::aarch32::r5,
80 vixl::aarch32::r6,
Roland Levillain6d729a72017-06-30 18:34:01 +010081 vixl::aarch32::r7),
82 // Do not consider r8 as a callee-save register with Baker read barriers.
83 ((kEmitCompilerReadBarrier && kUseBakerReadBarrier)
84 ? vixl::aarch32::RegisterList()
85 : vixl::aarch32::RegisterList(vixl::aarch32::r8)),
Scott Wakelinga7812ae2016-10-17 10:03:36 +010086 vixl::aarch32::RegisterList(vixl::aarch32::r10,
87 vixl::aarch32::r11,
88 vixl::aarch32::lr));
89
90// Callee saves FP registers s16 to s31 inclusive.
Scott Wakelingfe885462016-09-22 10:24:38 +010091static const vixl::aarch32::SRegisterList kFpuCalleeSaves =
92 vixl::aarch32::SRegisterList(vixl::aarch32::s16, 16);
93
Scott Wakelinga7812ae2016-10-17 10:03:36 +010094static const vixl::aarch32::Register kRuntimeParameterCoreRegistersVIXL[] = {
95 vixl::aarch32::r0,
96 vixl::aarch32::r1,
97 vixl::aarch32::r2,
98 vixl::aarch32::r3
99};
100static const size_t kRuntimeParameterCoreRegistersLengthVIXL =
Artem Serovd4cc5b22016-11-04 11:19:09 +0000101 arraysize(kRuntimeParameterCoreRegistersVIXL);
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100102static const vixl::aarch32::SRegister kRuntimeParameterFpuRegistersVIXL[] = {
103 vixl::aarch32::s0,
104 vixl::aarch32::s1,
105 vixl::aarch32::s2,
106 vixl::aarch32::s3
107};
108static const size_t kRuntimeParameterFpuRegistersLengthVIXL =
Artem Serovd4cc5b22016-11-04 11:19:09 +0000109 arraysize(kRuntimeParameterFpuRegistersVIXL);
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100110
111class LoadClassSlowPathARMVIXL;
Scott Wakelingfe885462016-09-22 10:24:38 +0100112class CodeGeneratorARMVIXL;
113
Artem Serovc5fcb442016-12-02 19:19:58 +0000114using VIXLInt32Literal = vixl::aarch32::Literal<int32_t>;
115using VIXLUInt32Literal = vixl::aarch32::Literal<uint32_t>;
116
Artem Serov551b28f2016-10-18 19:11:30 +0100117class JumpTableARMVIXL : public DeletableArenaObject<kArenaAllocSwitchTable> {
118 public:
119 explicit JumpTableARMVIXL(HPackedSwitch* switch_instr)
Artem Serov09a940d2016-11-11 16:15:11 +0000120 : switch_instr_(switch_instr),
121 table_start_(),
Vladimir Markoca6fff82017-10-03 14:49:14 +0100122 bb_addresses_(switch_instr->GetAllocator()->Adapter(kArenaAllocCodeGenerator)) {
Artem Serov09a940d2016-11-11 16:15:11 +0000123 uint32_t num_entries = switch_instr_->GetNumEntries();
124 for (uint32_t i = 0; i < num_entries; i++) {
Artem Serovc5fcb442016-12-02 19:19:58 +0000125 VIXLInt32Literal *lit = new VIXLInt32Literal(0, vixl32::RawLiteral::kManuallyPlaced);
Artem Serov09a940d2016-11-11 16:15:11 +0000126 bb_addresses_.emplace_back(lit);
127 }
128 }
Artem Serov551b28f2016-10-18 19:11:30 +0100129
130 vixl::aarch32::Label* GetTableStartLabel() { return &table_start_; }
131
132 void EmitTable(CodeGeneratorARMVIXL* codegen);
Artem Serov09a940d2016-11-11 16:15:11 +0000133 void FixTable(CodeGeneratorARMVIXL* codegen);
Artem Serov551b28f2016-10-18 19:11:30 +0100134
135 private:
136 HPackedSwitch* const switch_instr_;
137 vixl::aarch32::Label table_start_;
Artem Serovc5fcb442016-12-02 19:19:58 +0000138 ArenaVector<std::unique_ptr<VIXLInt32Literal>> bb_addresses_;
Artem Serov551b28f2016-10-18 19:11:30 +0100139
140 DISALLOW_COPY_AND_ASSIGN(JumpTableARMVIXL);
141};
142
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100143class InvokeRuntimeCallingConventionARMVIXL
144 : public CallingConvention<vixl::aarch32::Register, vixl::aarch32::SRegister> {
145 public:
146 InvokeRuntimeCallingConventionARMVIXL()
147 : CallingConvention(kRuntimeParameterCoreRegistersVIXL,
148 kRuntimeParameterCoreRegistersLengthVIXL,
149 kRuntimeParameterFpuRegistersVIXL,
150 kRuntimeParameterFpuRegistersLengthVIXL,
151 kArmPointerSize) {}
152
153 private:
154 DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConventionARMVIXL);
155};
156
157class InvokeDexCallingConventionARMVIXL
158 : public CallingConvention<vixl::aarch32::Register, vixl::aarch32::SRegister> {
159 public:
160 InvokeDexCallingConventionARMVIXL()
161 : CallingConvention(kParameterCoreRegistersVIXL,
162 kParameterCoreRegistersLengthVIXL,
163 kParameterFpuRegistersVIXL,
164 kParameterFpuRegistersLengthVIXL,
165 kArmPointerSize) {}
166
167 private:
168 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionARMVIXL);
169};
170
Artem Serovd4cc5b22016-11-04 11:19:09 +0000171class InvokeDexCallingConventionVisitorARMVIXL : public InvokeDexCallingConventionVisitor {
172 public:
173 InvokeDexCallingConventionVisitorARMVIXL() {}
174 virtual ~InvokeDexCallingConventionVisitorARMVIXL() {}
175
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100176 Location GetNextLocation(DataType::Type type) OVERRIDE;
177 Location GetReturnLocation(DataType::Type type) const OVERRIDE;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000178 Location GetMethodLocation() const OVERRIDE;
179
180 private:
181 InvokeDexCallingConventionARMVIXL calling_convention;
182 uint32_t double_index_ = 0;
183
184 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorARMVIXL);
185};
186
Artem Serovcfbe9132016-10-14 15:58:56 +0100187class FieldAccessCallingConventionARMVIXL : public FieldAccessCallingConvention {
188 public:
189 FieldAccessCallingConventionARMVIXL() {}
190
191 Location GetObjectLocation() const OVERRIDE {
192 return helpers::LocationFrom(vixl::aarch32::r1);
193 }
194 Location GetFieldIndexLocation() const OVERRIDE {
195 return helpers::LocationFrom(vixl::aarch32::r0);
196 }
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100197 Location GetReturnLocation(DataType::Type type) const OVERRIDE {
198 return DataType::Is64BitType(type)
Artem Serovcfbe9132016-10-14 15:58:56 +0100199 ? helpers::LocationFrom(vixl::aarch32::r0, vixl::aarch32::r1)
200 : helpers::LocationFrom(vixl::aarch32::r0);
201 }
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100202 Location GetSetValueLocation(DataType::Type type, bool is_instance) const OVERRIDE {
203 return DataType::Is64BitType(type)
Nicolas Geoffraya72859d2017-01-26 22:47:27 +0000204 ? helpers::LocationFrom(vixl::aarch32::r2, vixl::aarch32::r3)
Artem Serovcfbe9132016-10-14 15:58:56 +0100205 : (is_instance
206 ? helpers::LocationFrom(vixl::aarch32::r2)
207 : helpers::LocationFrom(vixl::aarch32::r1));
208 }
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100209 Location GetFpuLocation(DataType::Type type) const OVERRIDE {
210 return DataType::Is64BitType(type)
Artem Serovcfbe9132016-10-14 15:58:56 +0100211 ? helpers::LocationFrom(vixl::aarch32::s0, vixl::aarch32::s1)
212 : helpers::LocationFrom(vixl::aarch32::s0);
213 }
214
215 private:
216 DISALLOW_COPY_AND_ASSIGN(FieldAccessCallingConventionARMVIXL);
217};
218
Scott Wakelingfe885462016-09-22 10:24:38 +0100219class SlowPathCodeARMVIXL : public SlowPathCode {
220 public:
221 explicit SlowPathCodeARMVIXL(HInstruction* instruction)
222 : SlowPathCode(instruction), entry_label_(), exit_label_() {}
223
224 vixl::aarch32::Label* GetEntryLabel() { return &entry_label_; }
225 vixl::aarch32::Label* GetExitLabel() { return &exit_label_; }
226
227 void SaveLiveRegisters(CodeGenerator* codegen, LocationSummary* locations) OVERRIDE;
228 void RestoreLiveRegisters(CodeGenerator* codegen, LocationSummary* locations) OVERRIDE;
229
230 private:
231 vixl::aarch32::Label entry_label_;
232 vixl::aarch32::Label exit_label_;
233
234 DISALLOW_COPY_AND_ASSIGN(SlowPathCodeARMVIXL);
235};
236
237class ParallelMoveResolverARMVIXL : public ParallelMoveResolverWithSwap {
238 public:
239 ParallelMoveResolverARMVIXL(ArenaAllocator* allocator, CodeGeneratorARMVIXL* codegen)
240 : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {}
241
242 void EmitMove(size_t index) OVERRIDE;
243 void EmitSwap(size_t index) OVERRIDE;
244 void SpillScratch(int reg) OVERRIDE;
245 void RestoreScratch(int reg) OVERRIDE;
246
247 ArmVIXLAssembler* GetAssembler() const;
248
249 private:
Alexandre Rames9c19bd62016-10-24 11:50:32 +0100250 void Exchange(vixl32::Register reg, int mem);
Scott Wakelingfe885462016-09-22 10:24:38 +0100251 void Exchange(int mem1, int mem2);
252
253 CodeGeneratorARMVIXL* const codegen_;
254
255 DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverARMVIXL);
256};
257
Scott Wakelingfe885462016-09-22 10:24:38 +0100258class LocationsBuilderARMVIXL : public HGraphVisitor {
259 public:
260 LocationsBuilderARMVIXL(HGraph* graph, CodeGeneratorARMVIXL* codegen)
261 : HGraphVisitor(graph), codegen_(codegen) {}
262
Artem Serovd4cc5b22016-11-04 11:19:09 +0000263#define DECLARE_VISIT_INSTRUCTION(name, super) \
264 void Visit##name(H##name* instr) OVERRIDE;
Scott Wakelingfe885462016-09-22 10:24:38 +0100265
Artem Serovd4cc5b22016-11-04 11:19:09 +0000266 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
267 FOR_EACH_CONCRETE_INSTRUCTION_ARM(DECLARE_VISIT_INSTRUCTION)
268 FOR_EACH_CONCRETE_INSTRUCTION_SHARED(DECLARE_VISIT_INSTRUCTION)
Scott Wakelingfe885462016-09-22 10:24:38 +0100269
Artem Serovd4cc5b22016-11-04 11:19:09 +0000270#undef DECLARE_VISIT_INSTRUCTION
271
272 void VisitInstruction(HInstruction* instruction) OVERRIDE {
273 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
274 << " (id " << instruction->GetId() << ")";
Scott Wakelingfe885462016-09-22 10:24:38 +0100275 }
276
Artem Serovd4cc5b22016-11-04 11:19:09 +0000277 private:
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100278 void HandleInvoke(HInvoke* invoke);
Artem Serov02109dd2016-09-23 17:17:54 +0100279 void HandleBitwiseOperation(HBinaryOperation* operation, Opcode opcode);
Scott Wakelingfe885462016-09-22 10:24:38 +0100280 void HandleCondition(HCondition* condition);
Artem Serov02109dd2016-09-23 17:17:54 +0100281 void HandleIntegerRotate(LocationSummary* locations);
282 void HandleLongRotate(LocationSummary* locations);
283 void HandleShift(HBinaryOperation* operation);
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100284 void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info);
285 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
Scott Wakelingfe885462016-09-22 10:24:38 +0100286
Alexandre Rames9c19bd62016-10-24 11:50:32 +0100287 Location ArithmeticZeroOrFpuRegister(HInstruction* input);
Artem Serov02109dd2016-09-23 17:17:54 +0100288 Location ArmEncodableConstantOrRegister(HInstruction* constant, Opcode opcode);
289 bool CanEncodeConstantAsImmediate(HConstant* input_cst, Opcode opcode);
Alexandre Rames9c19bd62016-10-24 11:50:32 +0100290
Scott Wakelingfe885462016-09-22 10:24:38 +0100291 CodeGeneratorARMVIXL* const codegen_;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000292 InvokeDexCallingConventionVisitorARMVIXL parameter_visitor_;
Scott Wakelingfe885462016-09-22 10:24:38 +0100293
294 DISALLOW_COPY_AND_ASSIGN(LocationsBuilderARMVIXL);
295};
296
297class InstructionCodeGeneratorARMVIXL : public InstructionCodeGenerator {
298 public:
299 InstructionCodeGeneratorARMVIXL(HGraph* graph, CodeGeneratorARMVIXL* codegen);
300
Artem Serovd4cc5b22016-11-04 11:19:09 +0000301#define DECLARE_VISIT_INSTRUCTION(name, super) \
302 void Visit##name(H##name* instr) OVERRIDE;
Scott Wakelingfe885462016-09-22 10:24:38 +0100303
Artem Serovd4cc5b22016-11-04 11:19:09 +0000304 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
305 FOR_EACH_CONCRETE_INSTRUCTION_ARM(DECLARE_VISIT_INSTRUCTION)
306 FOR_EACH_CONCRETE_INSTRUCTION_SHARED(DECLARE_VISIT_INSTRUCTION)
307
308#undef DECLARE_VISIT_INSTRUCTION
309
310 void VisitInstruction(HInstruction* instruction) OVERRIDE {
311 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
312 << " (id " << instruction->GetId() << ")";
313 }
Scott Wakelingfe885462016-09-22 10:24:38 +0100314
315 ArmVIXLAssembler* GetAssembler() const { return assembler_; }
xueliang.zhongf51bc622016-11-04 09:23:32 +0000316 ArmVIXLMacroAssembler* GetVIXLAssembler() { return GetAssembler()->GetVIXLAssembler(); }
Scott Wakelingfe885462016-09-22 10:24:38 +0100317
318 private:
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100319 // Generate code for the given suspend check. If not null, `successor`
320 // is the block to branch to if the suspend check is not needed, and after
321 // the suspend call.
Scott Wakelingfe885462016-09-22 10:24:38 +0100322 void GenerateSuspendCheck(HSuspendCheck* instruction, HBasicBlock* successor);
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100323 void GenerateClassInitializationCheck(LoadClassSlowPathARMVIXL* slow_path,
324 vixl32::Register class_reg);
Artem Serov02109dd2016-09-23 17:17:54 +0100325 void GenerateAndConst(vixl::aarch32::Register out, vixl::aarch32::Register first, uint32_t value);
326 void GenerateOrrConst(vixl::aarch32::Register out, vixl::aarch32::Register first, uint32_t value);
327 void GenerateEorConst(vixl::aarch32::Register out, vixl::aarch32::Register first, uint32_t value);
Anton Kirilovdda43962016-11-21 19:55:20 +0000328 void GenerateAddLongConst(Location out, Location first, uint64_t value);
Artem Serov02109dd2016-09-23 17:17:54 +0100329 void HandleBitwiseOperation(HBinaryOperation* operation);
Scott Wakelingfe885462016-09-22 10:24:38 +0100330 void HandleCondition(HCondition* condition);
Artem Serov02109dd2016-09-23 17:17:54 +0100331 void HandleIntegerRotate(HRor* ror);
332 void HandleLongRotate(HRor* ror);
333 void HandleShift(HBinaryOperation* operation);
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100334
335 void GenerateWideAtomicStore(vixl::aarch32::Register addr,
336 uint32_t offset,
337 vixl::aarch32::Register value_lo,
338 vixl::aarch32::Register value_hi,
339 vixl::aarch32::Register temp1,
340 vixl::aarch32::Register temp2,
341 HInstruction* instruction);
342 void GenerateWideAtomicLoad(vixl::aarch32::Register addr,
343 uint32_t offset,
344 vixl::aarch32::Register out_lo,
345 vixl::aarch32::Register out_hi);
346
347 void HandleFieldSet(HInstruction* instruction,
348 const FieldInfo& field_info,
349 bool value_can_be_null);
350 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
351
Aart Bik351df3e2018-03-07 11:54:57 -0800352 void GenerateMinMaxInt(LocationSummary* locations, bool is_min);
Aart Bik1f8d51b2018-02-15 10:42:37 -0800353 void GenerateMinMaxLong(LocationSummary* locations, bool is_min);
Aart Bik351df3e2018-03-07 11:54:57 -0800354 void GenerateMinMaxFloat(HInstruction* minmax, bool is_min);
355 void GenerateMinMaxDouble(HInstruction* minmax, bool is_min);
356 void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
Aart Bik1f8d51b2018-02-15 10:42:37 -0800357
Artem Serovcfbe9132016-10-14 15:58:56 +0100358 // Generate a heap reference load using one register `out`:
359 //
360 // out <- *(out + offset)
361 //
362 // while honoring heap poisoning and/or read barriers (if any).
363 //
364 // Location `maybe_temp` is used when generating a read barrier and
365 // shall be a register in that case; it may be an invalid location
366 // otherwise.
367 void GenerateReferenceLoadOneRegister(HInstruction* instruction,
368 Location out,
369 uint32_t offset,
Artem Serov657022c2016-11-23 14:19:38 +0000370 Location maybe_temp,
371 ReadBarrierOption read_barrier_option);
Anton Kirilove28d9ae2016-10-25 18:17:23 +0100372 // Generate a heap reference load using two different registers
373 // `out` and `obj`:
374 //
375 // out <- *(obj + offset)
376 //
377 // while honoring heap poisoning and/or read barriers (if any).
378 //
379 // Location `maybe_temp` is used when generating a Baker's (fast
380 // path) read barrier and shall be a register in that case; it may
381 // be an invalid location otherwise.
382 void GenerateReferenceLoadTwoRegisters(HInstruction* instruction,
383 Location out,
384 Location obj,
385 uint32_t offset,
Artem Serov657022c2016-11-23 14:19:38 +0000386 Location maybe_temp,
387 ReadBarrierOption read_barrier_option);
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100388 // Generate a GC root reference load:
389 //
390 // root <- *(obj + offset)
391 //
Artem Serovd4cc5b22016-11-04 11:19:09 +0000392 // while honoring read barriers based on read_barrier_option.
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100393 void GenerateGcRootFieldLoad(HInstruction* instruction,
394 Location root,
395 vixl::aarch32::Register obj,
396 uint32_t offset,
Artem Serovd4cc5b22016-11-04 11:19:09 +0000397 ReadBarrierOption read_barrier_option);
Scott Wakelingfe885462016-09-22 10:24:38 +0100398 void GenerateTestAndBranch(HInstruction* instruction,
399 size_t condition_input_index,
400 vixl::aarch32::Label* true_target,
xueliang.zhongf51bc622016-11-04 09:23:32 +0000401 vixl::aarch32::Label* false_target,
402 bool far_target = true);
Scott Wakelingfe885462016-09-22 10:24:38 +0100403 void GenerateCompareTestAndBranch(HCondition* condition,
404 vixl::aarch32::Label* true_target,
Anton Kirilovfd522532017-05-10 12:46:57 +0100405 vixl::aarch32::Label* false_target,
406 bool is_far_target = true);
Scott Wakelingfe885462016-09-22 10:24:38 +0100407 void DivRemOneOrMinusOne(HBinaryOperation* instruction);
408 void DivRemByPowerOfTwo(HBinaryOperation* instruction);
409 void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction);
410 void GenerateDivRemConstantIntegral(HBinaryOperation* instruction);
Artem Serovd4cc5b22016-11-04 11:19:09 +0000411 void HandleGoto(HInstruction* got, HBasicBlock* successor);
Scott Wakelingfe885462016-09-22 10:24:38 +0100412
Artem Serov8f7c4102017-06-21 11:21:37 +0100413 vixl::aarch32::MemOperand VecAddress(
414 HVecMemoryOperation* instruction,
415 // This function may acquire a scratch register.
416 vixl::aarch32::UseScratchRegisterScope* temps_scope,
417 /*out*/ vixl32::Register* scratch);
418 vixl::aarch32::AlignedMemOperand VecAddressUnaligned(
419 HVecMemoryOperation* instruction,
420 // This function may acquire a scratch register.
421 vixl::aarch32::UseScratchRegisterScope* temps_scope,
422 /*out*/ vixl32::Register* scratch);
423
Scott Wakelingfe885462016-09-22 10:24:38 +0100424 ArmVIXLAssembler* const assembler_;
425 CodeGeneratorARMVIXL* const codegen_;
426
427 DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorARMVIXL);
428};
429
430class CodeGeneratorARMVIXL : public CodeGenerator {
431 public:
432 CodeGeneratorARMVIXL(HGraph* graph,
433 const ArmInstructionSetFeatures& isa_features,
434 const CompilerOptions& compiler_options,
435 OptimizingCompilerStats* stats = nullptr);
Scott Wakelingfe885462016-09-22 10:24:38 +0100436 virtual ~CodeGeneratorARMVIXL() {}
437
Scott Wakelingfe885462016-09-22 10:24:38 +0100438 void GenerateFrameEntry() OVERRIDE;
439 void GenerateFrameExit() OVERRIDE;
440 void Bind(HBasicBlock* block) OVERRIDE;
441 void MoveConstant(Location destination, int32_t value) OVERRIDE;
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100442 void MoveLocation(Location dst, Location src, DataType::Type dst_type) OVERRIDE;
Scott Wakelingfe885462016-09-22 10:24:38 +0100443 void AddLocationAsTemp(Location location, LocationSummary* locations) OVERRIDE;
444
Artem Serovd4cc5b22016-11-04 11:19:09 +0000445 size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE;
446 size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE;
447 size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) OVERRIDE;
448 size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) OVERRIDE;
449
450 size_t GetWordSize() const OVERRIDE {
451 return static_cast<size_t>(kArmPointerSize);
452 }
453
454 size_t GetFloatingPointSpillSlotSize() const OVERRIDE { return vixl::aarch32::kRegSizeInBytes; }
455
456 HGraphVisitor* GetLocationBuilder() OVERRIDE { return &location_builder_; }
457
458 HGraphVisitor* GetInstructionVisitor() OVERRIDE { return &instruction_visitor_; }
459
Scott Wakelingfe885462016-09-22 10:24:38 +0100460 ArmVIXLAssembler* GetAssembler() OVERRIDE { return &assembler_; }
461
462 const ArmVIXLAssembler& GetAssembler() const OVERRIDE { return assembler_; }
463
xueliang.zhongf51bc622016-11-04 09:23:32 +0000464 ArmVIXLMacroAssembler* GetVIXLAssembler() { return GetAssembler()->GetVIXLAssembler(); }
Scott Wakelingfe885462016-09-22 10:24:38 +0100465
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100466 uintptr_t GetAddressOf(HBasicBlock* block) OVERRIDE {
467 vixl::aarch32::Label* block_entry_label = GetLabelOf(block);
468 DCHECK(block_entry_label->IsBound());
469 return block_entry_label->GetLocation();
470 }
471
Artem Serov09a940d2016-11-11 16:15:11 +0000472 void FixJumpTables();
Scott Wakelingfe885462016-09-22 10:24:38 +0100473 void SetupBlockedRegisters() const OVERRIDE;
474
Scott Wakelingfe885462016-09-22 10:24:38 +0100475 void DumpCoreRegister(std::ostream& stream, int reg) const OVERRIDE;
476 void DumpFloatingPointRegister(std::ostream& stream, int reg) const OVERRIDE;
477
Artem Serovd4cc5b22016-11-04 11:19:09 +0000478 ParallelMoveResolver* GetMoveResolver() OVERRIDE { return &move_resolver_; }
Scott Wakelingfe885462016-09-22 10:24:38 +0100479 InstructionSet GetInstructionSet() const OVERRIDE { return InstructionSet::kThumb2; }
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100480 // Helper method to move a 32-bit value between two locations.
481 void Move32(Location destination, Location source);
482
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100483 void LoadFromShiftedRegOffset(DataType::Type type,
Scott Wakelingc34dba72016-10-03 10:14:44 +0100484 Location out_loc,
485 vixl::aarch32::Register base,
486 vixl::aarch32::Register reg_index,
487 vixl::aarch32::Condition cond = vixl::aarch32::al);
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100488 void StoreToShiftedRegOffset(DataType::Type type,
Scott Wakelingc34dba72016-10-03 10:14:44 +0100489 Location out_loc,
490 vixl::aarch32::Register base,
491 vixl::aarch32::Register reg_index,
492 vixl::aarch32::Condition cond = vixl::aarch32::al);
493
Scott Wakelingfe885462016-09-22 10:24:38 +0100494 // Generate code to invoke a runtime entry point.
495 void InvokeRuntime(QuickEntrypointEnum entrypoint,
496 HInstruction* instruction,
497 uint32_t dex_pc,
498 SlowPathCode* slow_path = nullptr) OVERRIDE;
499
500 // Generate code to invoke a runtime entry point, but do not record
501 // PC-related information in a stack map.
502 void InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset,
503 HInstruction* instruction,
504 SlowPathCode* slow_path);
505
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100506 // Emit a write barrier.
507 void MarkGCCard(vixl::aarch32::Register temp,
508 vixl::aarch32::Register card,
509 vixl::aarch32::Register object,
510 vixl::aarch32::Register value,
511 bool can_be_null);
512
Artem Serovd4cc5b22016-11-04 11:19:09 +0000513 void GenerateMemoryBarrier(MemBarrierKind kind);
514
515 vixl::aarch32::Label* GetLabelOf(HBasicBlock* block) {
516 block = FirstNonEmptyBlock(block);
517 return &(block_labels_[block->GetBlockId()]);
518 }
519
Donghui Bai426b49c2016-11-08 14:55:38 +0800520 vixl32::Label* GetFinalLabel(HInstruction* instruction, vixl32::Label* final_label);
521
Artem Serovd4cc5b22016-11-04 11:19:09 +0000522 void Initialize() OVERRIDE {
523 block_labels_.resize(GetGraph()->GetBlocks().size());
524 }
525
526 void Finalize(CodeAllocator* allocator) OVERRIDE;
527
528 const ArmInstructionSetFeatures& GetInstructionSetFeatures() const { return isa_features_; }
529
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100530 bool NeedsTwoRegisters(DataType::Type type) const OVERRIDE {
531 return type == DataType::Type::kFloat64 || type == DataType::Type::kInt64;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000532 }
533
534 void ComputeSpillMask() OVERRIDE;
535
536 vixl::aarch32::Label* GetFrameEntryLabel() { return &frame_entry_label_; }
537
538 // Check if the desired_string_load_kind is supported. If it is, return it,
539 // otherwise return a fall-back kind that should be used instead.
540 HLoadString::LoadKind GetSupportedLoadStringKind(
541 HLoadString::LoadKind desired_string_load_kind) OVERRIDE;
542
543 // Check if the desired_class_load_kind is supported. If it is, return it,
544 // otherwise return a fall-back kind that should be used instead.
545 HLoadClass::LoadKind GetSupportedLoadClassKind(
546 HLoadClass::LoadKind desired_class_load_kind) OVERRIDE;
547
548 // Check if the desired_dispatch_info is supported. If it is, return it,
549 // otherwise return a fall-back info that should be used instead.
550 HInvokeStaticOrDirect::DispatchInfo GetSupportedInvokeStaticOrDirectDispatch(
551 const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info,
552 HInvokeStaticOrDirect* invoke) OVERRIDE;
553
Vladimir Markoe7197bf2017-06-02 17:00:23 +0100554 void GenerateStaticOrDirectCall(
555 HInvokeStaticOrDirect* invoke, Location temp, SlowPathCode* slow_path = nullptr) OVERRIDE;
556 void GenerateVirtualCall(
557 HInvokeVirtual* invoke, Location temp, SlowPathCode* slow_path = nullptr) OVERRIDE;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000558
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100559 void MoveFromReturnRegister(Location trg, DataType::Type type) OVERRIDE;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000560
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000561 // The PcRelativePatchInfo is used for PC-relative addressing of methods/strings/types,
562 // whether through .data.bimg.rel.ro, .bss, or directly in the boot image.
563 //
564 // The PC-relative address is loaded with three instructions,
Artem Serovd4cc5b22016-11-04 11:19:09 +0000565 // MOVW+MOVT to load the offset to base_reg and then ADD base_reg, PC. The offset
566 // is calculated from the ADD's effective PC, i.e. PC+4 on Thumb2. Though we
567 // currently emit these 3 instructions together, instruction scheduling could
568 // split this sequence apart, so we keep separate labels for each of them.
569 struct PcRelativePatchInfo {
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000570 PcRelativePatchInfo(const DexFile* dex_file, uint32_t off_or_idx)
Artem Serovd4cc5b22016-11-04 11:19:09 +0000571 : target_dex_file(dex_file), offset_or_index(off_or_idx) { }
572 PcRelativePatchInfo(PcRelativePatchInfo&& other) = default;
573
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000574 // Target dex file or null for .data.bmig.rel.ro patches.
575 const DexFile* target_dex_file;
576 // Either the boot image offset (to write to .data.bmig.rel.ro) or string/type/method index.
Artem Serovd4cc5b22016-11-04 11:19:09 +0000577 uint32_t offset_or_index;
578 vixl::aarch32::Label movw_label;
579 vixl::aarch32::Label movt_label;
580 vixl::aarch32::Label add_pc_label;
581 };
582
Vladimir Markob066d432018-01-03 13:14:37 +0000583 PcRelativePatchInfo* NewBootImageRelRoPatch(uint32_t boot_image_offset);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000584 PcRelativePatchInfo* NewBootImageMethodPatch(MethodReference target_method);
Vladimir Marko0eb882b2017-05-15 13:39:18 +0100585 PcRelativePatchInfo* NewMethodBssEntryPatch(MethodReference target_method);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000586 PcRelativePatchInfo* NewBootImageTypePatch(const DexFile& dex_file, dex::TypeIndex type_index);
Vladimir Marko1998cd02017-01-13 13:02:58 +0000587 PcRelativePatchInfo* NewTypeBssEntryPatch(const DexFile& dex_file, dex::TypeIndex type_index);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000588 PcRelativePatchInfo* NewBootImageStringPatch(const DexFile& dex_file,
589 dex::StringIndex string_index);
Vladimir Marko6cfbdbc2017-07-25 13:26:39 +0100590 PcRelativePatchInfo* NewStringBssEntryPatch(const DexFile& dex_file,
591 dex::StringIndex string_index);
Vladimir Markoeee1c0e2017-04-21 17:58:41 +0100592
593 // Add a new baker read barrier patch and return the label to be bound
594 // before the BNE instruction.
595 vixl::aarch32::Label* NewBakerReadBarrierPatch(uint32_t custom_data);
596
Artem Serovc5fcb442016-12-02 19:19:58 +0000597 VIXLUInt32Literal* DeduplicateBootImageAddressLiteral(uint32_t address);
Artem Serovc5fcb442016-12-02 19:19:58 +0000598 VIXLUInt32Literal* DeduplicateJitStringLiteral(const DexFile& dex_file,
Nicolas Geoffrayf0acfe72017-01-09 20:54:52 +0000599 dex::StringIndex string_index,
600 Handle<mirror::String> handle);
Artem Serovc5fcb442016-12-02 19:19:58 +0000601 VIXLUInt32Literal* DeduplicateJitClassLiteral(const DexFile& dex_file,
602 dex::TypeIndex type_index,
Nicolas Geoffray5247c082017-01-13 14:17:29 +0000603 Handle<mirror::Class> handle);
Artem Serovc5fcb442016-12-02 19:19:58 +0000604
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100605 void EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linker_patches) OVERRIDE;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000606
Artem Serovc5fcb442016-12-02 19:19:58 +0000607 void EmitJitRootPatches(uint8_t* code, const uint8_t* roots_data) OVERRIDE;
608
Vladimir Markoeee1c0e2017-04-21 17:58:41 +0100609 // Maybe add the reserved entrypoint register as a temporary for field load. This temp
610 // is added only for AOT compilation if link-time generated thunks for fields are enabled.
611 void MaybeAddBakerCcEntrypointTempForFields(LocationSummary* locations);
612
Anton Kirilove28d9ae2016-10-25 18:17:23 +0100613 // Fast path implementation of ReadBarrier::Barrier for a heap
614 // reference field load when Baker's read barriers are used.
615 void GenerateFieldLoadWithBakerReadBarrier(HInstruction* instruction,
616 Location ref,
617 vixl::aarch32::Register obj,
618 uint32_t offset,
619 Location temp,
620 bool needs_null_check);
Anton Kirilovedb2ac32016-11-30 15:14:10 +0000621 // Fast path implementation of ReadBarrier::Barrier for a heap
622 // reference array load when Baker's read barriers are used.
623 void GenerateArrayLoadWithBakerReadBarrier(HInstruction* instruction,
624 Location ref,
625 vixl::aarch32::Register obj,
626 uint32_t data_offset,
627 Location index,
628 Location temp,
629 bool needs_null_check);
Anton Kirilove28d9ae2016-10-25 18:17:23 +0100630 // Factored implementation, used by GenerateFieldLoadWithBakerReadBarrier,
631 // GenerateArrayLoadWithBakerReadBarrier and some intrinsics.
632 //
633 // Load the object reference located at the address
634 // `obj + offset + (index << scale_factor)`, held by object `obj`, into
635 // `ref`, and mark it if needed.
Anton Kirilove28d9ae2016-10-25 18:17:23 +0100636 void GenerateReferenceLoadWithBakerReadBarrier(HInstruction* instruction,
637 Location ref,
638 vixl::aarch32::Register obj,
639 uint32_t offset,
640 Location index,
641 ScaleFactor scale_factor,
642 Location temp,
Roland Levillainff487002017-03-07 16:50:01 +0000643 bool needs_null_check);
644
645 // Generate code checking whether the the reference field at the
646 // address `obj + field_offset`, held by object `obj`, needs to be
647 // marked, and if so, marking it and updating the field within `obj`
648 // with the marked value.
649 //
650 // This routine is used for the implementation of the
651 // UnsafeCASObject intrinsic with Baker read barriers.
652 //
653 // This method has a structure similar to
654 // GenerateReferenceLoadWithBakerReadBarrier, but note that argument
655 // `ref` is only as a temporary here, and thus its value should not
656 // be used afterwards.
657 void UpdateReferenceFieldWithBakerReadBarrier(HInstruction* instruction,
658 Location ref,
659 vixl::aarch32::Register obj,
660 Location field_offset,
661 Location temp,
662 bool needs_null_check,
663 vixl::aarch32::Register temp2);
Anton Kirilove28d9ae2016-10-25 18:17:23 +0100664
Roland Levillainba650a42017-03-06 13:52:32 +0000665 // Generate a heap reference load (with no read barrier).
666 void GenerateRawReferenceLoad(HInstruction* instruction,
667 Location ref,
668 vixl::aarch32::Register obj,
669 uint32_t offset,
670 Location index,
671 ScaleFactor scale_factor,
672 bool needs_null_check);
673
Roland Levillain5daa4952017-07-03 17:23:56 +0100674 // Emit code checking the status of the Marking Register, and
675 // aborting the program if MR does not match the value stored in the
676 // art::Thread object. Code is only emitted in debug mode and if
677 // CompilerOptions::EmitRunTimeChecksInDebugMode returns true.
678 //
679 // Argument `code` is used to identify the different occurrences of
680 // MaybeGenerateMarkingRegisterCheck in the code generator, and is
681 // used together with kMarkingRegisterCheckBreakCodeBaseCode to
682 // create the value passed to the BKPT instruction. Note that unlike
683 // in the ARM64 code generator, where `__LINE__` is passed as `code`
684 // argument to
685 // CodeGeneratorARM64::MaybeGenerateMarkingRegisterCheck, we cannot
686 // realistically do that here, as Encoding T1 for the BKPT
687 // instruction only accepts 8-bit immediate values.
688 //
689 // If `temp_loc` is a valid location, it is expected to be a
690 // register and will be used as a temporary to generate code;
691 // otherwise, a temporary will be fetched from the core register
692 // scratch pool.
693 virtual void MaybeGenerateMarkingRegisterCheck(int code,
694 Location temp_loc = Location::NoLocation());
695
Anton Kirilove28d9ae2016-10-25 18:17:23 +0100696 // Generate a read barrier for a heap reference within `instruction`
697 // using a slow path.
698 //
699 // A read barrier for an object reference read from the heap is
700 // implemented as a call to the artReadBarrierSlow runtime entry
701 // point, which is passed the values in locations `ref`, `obj`, and
702 // `offset`:
703 //
704 // mirror::Object* artReadBarrierSlow(mirror::Object* ref,
705 // mirror::Object* obj,
706 // uint32_t offset);
707 //
708 // The `out` location contains the value returned by
709 // artReadBarrierSlow.
710 //
711 // When `index` is provided (i.e. for array accesses), the offset
712 // value passed to artReadBarrierSlow is adjusted to take `index`
713 // into account.
714 void GenerateReadBarrierSlow(HInstruction* instruction,
715 Location out,
716 Location ref,
717 Location obj,
718 uint32_t offset,
719 Location index = Location::NoLocation());
720
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100721 // If read barriers are enabled, generate a read barrier for a heap
722 // reference using a slow path. If heap poisoning is enabled, also
723 // unpoison the reference in `out`.
724 void MaybeGenerateReadBarrierSlow(HInstruction* instruction,
725 Location out,
726 Location ref,
727 Location obj,
728 uint32_t offset,
729 Location index = Location::NoLocation());
730
Anton Kirilovedb2ac32016-11-30 15:14:10 +0000731 // Generate a read barrier for a GC root within `instruction` using
732 // a slow path.
733 //
734 // A read barrier for an object reference GC root is implemented as
735 // a call to the artReadBarrierForRootSlow runtime entry point,
736 // which is passed the value in location `root`:
737 //
738 // mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root);
739 //
740 // The `out` location contains the value returned by
741 // artReadBarrierForRootSlow.
742 void GenerateReadBarrierForRootSlow(HInstruction* instruction, Location out, Location root);
743
Scott Wakelingfe885462016-09-22 10:24:38 +0100744 void GenerateNop() OVERRIDE;
745
Artem Serovd4cc5b22016-11-04 11:19:09 +0000746 void GenerateImplicitNullCheck(HNullCheck* instruction) OVERRIDE;
747 void GenerateExplicitNullCheck(HNullCheck* instruction) OVERRIDE;
748
749 JumpTableARMVIXL* CreateJumpTable(HPackedSwitch* switch_instr) {
Vladimir Markoca6fff82017-10-03 14:49:14 +0100750 jump_tables_.emplace_back(new (GetGraph()->GetAllocator()) JumpTableARMVIXL(switch_instr));
Artem Serovd4cc5b22016-11-04 11:19:09 +0000751 return jump_tables_.back().get();
752 }
753 void EmitJumpTables();
754
755 void EmitMovwMovtPlaceholder(CodeGeneratorARMVIXL::PcRelativePatchInfo* labels,
756 vixl::aarch32::Register out);
757
Anton Kirilov5601d4e2017-05-11 19:33:50 +0100758 // `temp` is an extra temporary register that is used for some conditions;
759 // callers may not specify it, in which case the method will use a scratch
760 // register instead.
761 void GenerateConditionWithZero(IfCondition condition,
762 vixl::aarch32::Register out,
763 vixl::aarch32::Register in,
764 vixl::aarch32::Register temp = vixl32::Register());
765
Scott Wakelingfe885462016-09-22 10:24:38 +0100766 private:
Scott Wakelinga7812ae2016-10-17 10:03:36 +0100767 vixl::aarch32::Register GetInvokeStaticOrDirectExtraParameter(HInvokeStaticOrDirect* invoke,
768 vixl::aarch32::Register temp);
769
Artem Serovc5fcb442016-12-02 19:19:58 +0000770 using Uint32ToLiteralMap = ArenaSafeMap<uint32_t, VIXLUInt32Literal*>;
Artem Serovc5fcb442016-12-02 19:19:58 +0000771 using StringToLiteralMap = ArenaSafeMap<StringReference,
772 VIXLUInt32Literal*,
773 StringReferenceValueComparator>;
774 using TypeToLiteralMap = ArenaSafeMap<TypeReference,
775 VIXLUInt32Literal*,
776 TypeReferenceValueComparator>;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000777
Vladimir Markoeee1c0e2017-04-21 17:58:41 +0100778 struct BakerReadBarrierPatchInfo {
779 explicit BakerReadBarrierPatchInfo(uint32_t data) : label(), custom_data(data) { }
780
781 vixl::aarch32::Label label;
782 uint32_t custom_data;
783 };
784
Artem Serovc5fcb442016-12-02 19:19:58 +0000785 VIXLUInt32Literal* DeduplicateUint32Literal(uint32_t value, Uint32ToLiteralMap* map);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000786 PcRelativePatchInfo* NewPcRelativePatch(const DexFile* dex_file,
Artem Serovd4cc5b22016-11-04 11:19:09 +0000787 uint32_t offset_or_index,
788 ArenaDeque<PcRelativePatchInfo>* patches);
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100789 template <linker::LinkerPatch (*Factory)(size_t, const DexFile*, uint32_t, uint32_t)>
Artem Serovd4cc5b22016-11-04 11:19:09 +0000790 static void EmitPcRelativeLinkerPatches(const ArenaDeque<PcRelativePatchInfo>& infos,
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100791 ArenaVector<linker::LinkerPatch>* linker_patches);
Artem Serovd4cc5b22016-11-04 11:19:09 +0000792
Scott Wakelingfe885462016-09-22 10:24:38 +0100793 // Labels for each block that will be compiled.
794 // We use a deque so that the `vixl::aarch32::Label` objects do not move in memory.
795 ArenaDeque<vixl::aarch32::Label> block_labels_; // Indexed by block id.
796 vixl::aarch32::Label frame_entry_label_;
797
Artem Serov551b28f2016-10-18 19:11:30 +0100798 ArenaVector<std::unique_ptr<JumpTableARMVIXL>> jump_tables_;
Scott Wakelingfe885462016-09-22 10:24:38 +0100799 LocationsBuilderARMVIXL location_builder_;
800 InstructionCodeGeneratorARMVIXL instruction_visitor_;
801 ParallelMoveResolverARMVIXL move_resolver_;
802
803 ArmVIXLAssembler assembler_;
804 const ArmInstructionSetFeatures& isa_features_;
805
Artem Serovc5fcb442016-12-02 19:19:58 +0000806 // Deduplication map for 32-bit literals, used for non-patchable boot image addresses.
807 Uint32ToLiteralMap uint32_literals_;
Vladimir Markob066d432018-01-03 13:14:37 +0000808 // PC-relative method patch info for kBootImageLinkTimePcRelative/kBootImageRelRo.
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000809 // Also used for type/string patches for kBootImageRelRo (same linker patch as for methods).
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000810 ArenaDeque<PcRelativePatchInfo> boot_image_method_patches_;
Vladimir Marko0eb882b2017-05-15 13:39:18 +0100811 // PC-relative method patch info for kBssEntry.
812 ArenaDeque<PcRelativePatchInfo> method_bss_entry_patches_;
Vladimir Marko1998cd02017-01-13 13:02:58 +0000813 // PC-relative type patch info for kBootImageLinkTimePcRelative.
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000814 ArenaDeque<PcRelativePatchInfo> boot_image_type_patches_;
Vladimir Marko1998cd02017-01-13 13:02:58 +0000815 // PC-relative type patch info for kBssEntry.
816 ArenaDeque<PcRelativePatchInfo> type_bss_entry_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000817 // PC-relative String patch info for kBootImageLinkTimePcRelative.
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000818 ArenaDeque<PcRelativePatchInfo> boot_image_string_patches_;
Vladimir Marko6cfbdbc2017-07-25 13:26:39 +0100819 // PC-relative String patch info for kBssEntry.
820 ArenaDeque<PcRelativePatchInfo> string_bss_entry_patches_;
Vladimir Markoeee1c0e2017-04-21 17:58:41 +0100821 // Baker read barrier patch info.
822 ArenaDeque<BakerReadBarrierPatchInfo> baker_read_barrier_patches_;
Artem Serovc5fcb442016-12-02 19:19:58 +0000823
824 // Patches for string literals in JIT compiled code.
825 StringToLiteralMap jit_string_patches_;
826 // Patches for class literals in JIT compiled code.
827 TypeToLiteralMap jit_class_patches_;
Artem Serovd4cc5b22016-11-04 11:19:09 +0000828
Scott Wakelingfe885462016-09-22 10:24:38 +0100829 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorARMVIXL);
830};
831
Scott Wakelingfe885462016-09-22 10:24:38 +0100832} // namespace arm
833} // namespace art
834
835#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_VIXL_H_