blob: 956a466f9bcb2291043fc5e6ac4fcea81430e997 [file] [log] [blame]
Goran Jakovljevicf652cec2015-08-25 16:11:42 +02001/*
2 * Copyright (C) 2015 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_MIPS_H_
18#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_MIPS_H_
19
20#include "code_generator.h"
Goran Jakovljevicf652cec2015-08-25 16:11:42 +020021#include "driver/compiler_options.h"
22#include "nodes.h"
23#include "parallel_move_resolver.h"
Alexey Frunze06a46c42016-07-19 15:00:40 -070024#include "string_reference.h"
Goran Jakovljevicf652cec2015-08-25 16:11:42 +020025#include "utils/mips/assembler_mips.h"
Alexey Frunze06a46c42016-07-19 15:00:40 -070026#include "utils/type_reference.h"
Goran Jakovljevicf652cec2015-08-25 16:11:42 +020027
28namespace art {
29namespace mips {
30
31// InvokeDexCallingConvention registers
32
33static constexpr Register kParameterCoreRegisters[] =
34 { A1, A2, A3 };
35static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters);
36
37static constexpr FRegister kParameterFpuRegisters[] =
38 { F12, F14 };
39static constexpr size_t kParameterFpuRegistersLength = arraysize(kParameterFpuRegisters);
40
41
42// InvokeRuntimeCallingConvention registers
43
44static constexpr Register kRuntimeParameterCoreRegisters[] =
45 { A0, A1, A2, A3 };
46static constexpr size_t kRuntimeParameterCoreRegistersLength =
47 arraysize(kRuntimeParameterCoreRegisters);
48
49static constexpr FRegister kRuntimeParameterFpuRegisters[] =
50 { F12, F14};
51static constexpr size_t kRuntimeParameterFpuRegistersLength =
52 arraysize(kRuntimeParameterFpuRegisters);
53
54
55static constexpr Register kCoreCalleeSaves[] =
56 { S0, S1, S2, S3, S4, S5, S6, S7, FP, RA };
57static constexpr FRegister kFpuCalleeSaves[] =
58 { F20, F22, F24, F26, F28, F30 };
59
60
61class CodeGeneratorMIPS;
62
63class InvokeDexCallingConvention : public CallingConvention<Register, FRegister> {
64 public:
65 InvokeDexCallingConvention()
66 : CallingConvention(kParameterCoreRegisters,
67 kParameterCoreRegistersLength,
68 kParameterFpuRegisters,
69 kParameterFpuRegistersLength,
70 kMipsPointerSize) {}
71
72 private:
73 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention);
74};
75
76class InvokeDexCallingConventionVisitorMIPS : public InvokeDexCallingConventionVisitor {
77 public:
78 InvokeDexCallingConventionVisitorMIPS() {}
79 virtual ~InvokeDexCallingConventionVisitorMIPS() {}
80
81 Location GetNextLocation(Primitive::Type type) OVERRIDE;
82 Location GetReturnLocation(Primitive::Type type) const OVERRIDE;
83 Location GetMethodLocation() const OVERRIDE;
84
85 private:
86 InvokeDexCallingConvention calling_convention;
87
88 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorMIPS);
89};
90
91class InvokeRuntimeCallingConvention : public CallingConvention<Register, FRegister> {
92 public:
93 InvokeRuntimeCallingConvention()
94 : CallingConvention(kRuntimeParameterCoreRegisters,
95 kRuntimeParameterCoreRegistersLength,
96 kRuntimeParameterFpuRegisters,
97 kRuntimeParameterFpuRegistersLength,
98 kMipsPointerSize) {}
99
100 Location GetReturnLocation(Primitive::Type return_type);
101
102 private:
103 DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention);
104};
105
106class FieldAccessCallingConventionMIPS : public FieldAccessCallingConvention {
107 public:
108 FieldAccessCallingConventionMIPS() {}
109
110 Location GetObjectLocation() const OVERRIDE {
111 return Location::RegisterLocation(A1);
112 }
113 Location GetFieldIndexLocation() const OVERRIDE {
114 return Location::RegisterLocation(A0);
115 }
116 Location GetReturnLocation(Primitive::Type type) const OVERRIDE {
117 return Primitive::Is64BitType(type)
118 ? Location::RegisterPairLocation(V0, V1)
119 : Location::RegisterLocation(V0);
120 }
121 Location GetSetValueLocation(Primitive::Type type, bool is_instance) const OVERRIDE {
122 return Primitive::Is64BitType(type)
123 ? Location::RegisterPairLocation(A2, A3)
124 : (is_instance ? Location::RegisterLocation(A2) : Location::RegisterLocation(A1));
125 }
126 Location GetFpuLocation(Primitive::Type type ATTRIBUTE_UNUSED) const OVERRIDE {
127 return Location::FpuRegisterLocation(F0);
128 }
129
130 private:
131 DISALLOW_COPY_AND_ASSIGN(FieldAccessCallingConventionMIPS);
132};
133
134class ParallelMoveResolverMIPS : public ParallelMoveResolverWithSwap {
135 public:
136 ParallelMoveResolverMIPS(ArenaAllocator* allocator, CodeGeneratorMIPS* codegen)
137 : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {}
138
139 void EmitMove(size_t index) OVERRIDE;
140 void EmitSwap(size_t index) OVERRIDE;
141 void SpillScratch(int reg) OVERRIDE;
142 void RestoreScratch(int reg) OVERRIDE;
143
144 void Exchange(int index1, int index2, bool double_slot);
145
146 MipsAssembler* GetAssembler() const;
147
148 private:
149 CodeGeneratorMIPS* const codegen_;
150
151 DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverMIPS);
152};
153
154class SlowPathCodeMIPS : public SlowPathCode {
155 public:
David Srbecky9cd6d372016-02-09 15:24:47 +0000156 explicit SlowPathCodeMIPS(HInstruction* instruction)
157 : SlowPathCode(instruction), entry_label_(), exit_label_() {}
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200158
159 MipsLabel* GetEntryLabel() { return &entry_label_; }
160 MipsLabel* GetExitLabel() { return &exit_label_; }
161
162 private:
163 MipsLabel entry_label_;
164 MipsLabel exit_label_;
165
166 DISALLOW_COPY_AND_ASSIGN(SlowPathCodeMIPS);
167};
168
169class LocationsBuilderMIPS : public HGraphVisitor {
170 public:
171 LocationsBuilderMIPS(HGraph* graph, CodeGeneratorMIPS* codegen)
172 : HGraphVisitor(graph), codegen_(codegen) {}
173
174#define DECLARE_VISIT_INSTRUCTION(name, super) \
175 void Visit##name(H##name* instr) OVERRIDE;
176
177 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
178 FOR_EACH_CONCRETE_INSTRUCTION_MIPS(DECLARE_VISIT_INSTRUCTION)
179
180#undef DECLARE_VISIT_INSTRUCTION
181
182 void VisitInstruction(HInstruction* instruction) OVERRIDE {
183 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
184 << " (id " << instruction->GetId() << ")";
185 }
186
187 private:
188 void HandleInvoke(HInvoke* invoke);
189 void HandleBinaryOp(HBinaryOperation* operation);
Vladimir Marko5f7b58e2015-11-23 19:49:34 +0000190 void HandleCondition(HCondition* instruction);
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200191 void HandleShift(HBinaryOperation* operation);
192 void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info);
193 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
194
195 InvokeDexCallingConventionVisitorMIPS parameter_visitor_;
196
197 CodeGeneratorMIPS* const codegen_;
198
199 DISALLOW_COPY_AND_ASSIGN(LocationsBuilderMIPS);
200};
201
Aart Bik42249c32016-01-07 15:33:50 -0800202class InstructionCodeGeneratorMIPS : public InstructionCodeGenerator {
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200203 public:
204 InstructionCodeGeneratorMIPS(HGraph* graph, CodeGeneratorMIPS* codegen);
205
206#define DECLARE_VISIT_INSTRUCTION(name, super) \
207 void Visit##name(H##name* instr) OVERRIDE;
208
209 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
210 FOR_EACH_CONCRETE_INSTRUCTION_MIPS(DECLARE_VISIT_INSTRUCTION)
211
212#undef DECLARE_VISIT_INSTRUCTION
213
214 void VisitInstruction(HInstruction* instruction) OVERRIDE {
215 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
216 << " (id " << instruction->GetId() << ")";
217 }
218
219 MipsAssembler* GetAssembler() const { return assembler_; }
220
Alexey Frunze96b66822016-09-10 02:32:44 -0700221 // Compare-and-jump packed switch generates approx. 3 + 2.5 * N 32-bit
222 // instructions for N cases.
223 // Table-based packed switch generates approx. 11 32-bit instructions
224 // and N 32-bit data words for N cases.
225 // At N = 6 they come out as 18 and 17 32-bit words respectively.
226 // We switch to the table-based method starting with 7 cases.
227 static constexpr uint32_t kPackedSwitchJumpTableThreshold = 6;
228
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200229 private:
230 void GenerateClassInitializationCheck(SlowPathCodeMIPS* slow_path, Register class_reg);
231 void GenerateMemoryBarrier(MemBarrierKind kind);
232 void GenerateSuspendCheck(HSuspendCheck* check, HBasicBlock* successor);
233 void HandleBinaryOp(HBinaryOperation* operation);
Vladimir Marko5f7b58e2015-11-23 19:49:34 +0000234 void HandleCondition(HCondition* instruction);
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200235 void HandleShift(HBinaryOperation* operation);
236 void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info, uint32_t dex_pc);
237 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info, uint32_t dex_pc);
Alexey Frunze06a46c42016-07-19 15:00:40 -0700238 // Generate a GC root reference load:
239 //
240 // root <- *(obj + offset)
241 //
242 // while honoring read barriers (if any).
243 void GenerateGcRootFieldLoad(HInstruction* instruction,
244 Location root,
245 Register obj,
246 uint32_t offset);
Alexey Frunzecd7b0ee2015-12-03 16:46:38 -0800247 void GenerateIntCompare(IfCondition cond, LocationSummary* locations);
248 void GenerateIntCompareAndBranch(IfCondition cond,
249 LocationSummary* locations,
250 MipsLabel* label);
251 void GenerateLongCompareAndBranch(IfCondition cond,
252 LocationSummary* locations,
253 MipsLabel* label);
Alexey Frunze2ddb7172016-09-06 17:04:55 -0700254 void GenerateFpCompare(IfCondition cond,
255 bool gt_bias,
256 Primitive::Type type,
257 LocationSummary* locations);
Alexey Frunzecd7b0ee2015-12-03 16:46:38 -0800258 void GenerateFpCompareAndBranch(IfCondition cond,
259 bool gt_bias,
260 Primitive::Type type,
261 LocationSummary* locations,
262 MipsLabel* label);
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200263 void GenerateTestAndBranch(HInstruction* instruction,
David Brazdil0debae72015-11-12 18:37:00 +0000264 size_t condition_input_index,
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200265 MipsLabel* true_target,
David Brazdil0debae72015-11-12 18:37:00 +0000266 MipsLabel* false_target);
Alexey Frunze7e99e052015-11-24 19:28:01 -0800267 void DivRemOneOrMinusOne(HBinaryOperation* instruction);
268 void DivRemByPowerOfTwo(HBinaryOperation* instruction);
269 void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction);
270 void GenerateDivRemIntegral(HBinaryOperation* instruction);
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200271 void HandleGoto(HInstruction* got, HBasicBlock* successor);
Alexey Frunze2923db72016-08-20 01:55:47 -0700272 auto GetImplicitNullChecker(HInstruction* instruction);
Alexey Frunze96b66822016-09-10 02:32:44 -0700273 void GenPackedSwitchWithCompares(Register value_reg,
274 int32_t lower_bound,
275 uint32_t num_entries,
276 HBasicBlock* switch_block,
277 HBasicBlock* default_block);
278 void GenTableBasedPackedSwitch(Register value_reg,
279 Register constant_area,
280 int32_t lower_bound,
281 uint32_t num_entries,
282 HBasicBlock* switch_block,
283 HBasicBlock* default_block);
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200284
285 MipsAssembler* const assembler_;
286 CodeGeneratorMIPS* const codegen_;
287
288 DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorMIPS);
289};
290
291class CodeGeneratorMIPS : public CodeGenerator {
292 public:
293 CodeGeneratorMIPS(HGraph* graph,
294 const MipsInstructionSetFeatures& isa_features,
295 const CompilerOptions& compiler_options,
296 OptimizingCompilerStats* stats = nullptr);
297 virtual ~CodeGeneratorMIPS() {}
298
Alexey Frunze73296a72016-06-03 22:51:46 -0700299 void ComputeSpillMask() OVERRIDE;
Alexey Frunze58320ce2016-08-30 21:40:46 -0700300 bool HasAllocatedCalleeSaveRegisters() const OVERRIDE;
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200301 void GenerateFrameEntry() OVERRIDE;
302 void GenerateFrameExit() OVERRIDE;
303
304 void Bind(HBasicBlock* block) OVERRIDE;
305
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200306 void Move32(Location destination, Location source);
307 void Move64(Location destination, Location source);
308 void MoveConstant(Location location, HConstant* c);
309
310 size_t GetWordSize() const OVERRIDE { return kMipsWordSize; }
311
312 size_t GetFloatingPointSpillSlotSize() const OVERRIDE { return kMipsDoublewordSize; }
313
Alexandre Ramesc01a6642016-04-15 11:54:06 +0100314 uintptr_t GetAddressOf(HBasicBlock* block) OVERRIDE {
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200315 return assembler_.GetLabelLocation(GetLabelOf(block));
316 }
317
318 HGraphVisitor* GetLocationBuilder() OVERRIDE { return &location_builder_; }
319 HGraphVisitor* GetInstructionVisitor() OVERRIDE { return &instruction_visitor_; }
320 MipsAssembler* GetAssembler() OVERRIDE { return &assembler_; }
321 const MipsAssembler& GetAssembler() const OVERRIDE { return assembler_; }
322
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700323 // Emit linker patches.
324 void EmitLinkerPatches(ArenaVector<LinkerPatch>* linker_patches) OVERRIDE;
325
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200326 void MarkGCCard(Register object, Register value);
327
328 // Register allocation.
329
David Brazdil58282f42016-01-14 12:45:10 +0000330 void SetupBlockedRegisters() const OVERRIDE;
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200331
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200332 size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id);
333 size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id);
334 size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id);
335 size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id);
Alexey Frunze06a46c42016-07-19 15:00:40 -0700336 void ClobberRA() {
337 clobbered_ra_ = true;
338 }
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200339
340 void DumpCoreRegister(std::ostream& stream, int reg) const OVERRIDE;
341 void DumpFloatingPointRegister(std::ostream& stream, int reg) const OVERRIDE;
342
343 // Blocks all register pairs made out of blocked core registers.
344 void UpdateBlockedPairRegisters() const;
345
346 InstructionSet GetInstructionSet() const OVERRIDE { return InstructionSet::kMips; }
347
348 const MipsInstructionSetFeatures& GetInstructionSetFeatures() const {
349 return isa_features_;
350 }
351
352 MipsLabel* GetLabelOf(HBasicBlock* block) const {
353 return CommonGetLabelOf<MipsLabel>(block_labels_, block);
354 }
355
356 void Initialize() OVERRIDE {
357 block_labels_ = CommonInitializeLabels<MipsLabel>();
358 }
359
360 void Finalize(CodeAllocator* allocator) OVERRIDE;
361
362 // Code generation helpers.
363
364 void MoveLocation(Location dst, Location src, Primitive::Type dst_type) OVERRIDE;
365
366 void MoveConstant(Location destination, int32_t value);
367
368 void AddLocationAsTemp(Location location, LocationSummary* locations) OVERRIDE;
369
370 // Generate code to invoke a runtime entry point.
371 void InvokeRuntime(QuickEntrypointEnum entrypoint,
372 HInstruction* instruction,
373 uint32_t dex_pc,
Serban Constantinescufca16662016-07-14 09:21:59 +0100374 SlowPathCode* slow_path = nullptr) OVERRIDE;
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200375
376 ParallelMoveResolver* GetMoveResolver() OVERRIDE { return &move_resolver_; }
377
378 bool NeedsTwoRegisters(Primitive::Type type) const {
379 return type == Primitive::kPrimLong;
380 }
381
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000382 // Check if the desired_string_load_kind is supported. If it is, return it,
383 // otherwise return a fall-back kind that should be used instead.
384 HLoadString::LoadKind GetSupportedLoadStringKind(
385 HLoadString::LoadKind desired_string_load_kind) OVERRIDE;
386
Vladimir Markodbb7f5b2016-03-30 13:23:58 +0100387 // Check if the desired_class_load_kind is supported. If it is, return it,
388 // otherwise return a fall-back kind that should be used instead.
389 HLoadClass::LoadKind GetSupportedLoadClassKind(
390 HLoadClass::LoadKind desired_class_load_kind) OVERRIDE;
391
Vladimir Markodc151b22015-10-15 18:02:30 +0100392 // Check if the desired_dispatch_info is supported. If it is, return it,
393 // otherwise return a fall-back info that should be used instead.
394 HInvokeStaticOrDirect::DispatchInfo GetSupportedInvokeStaticOrDirectDispatch(
395 const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info,
396 MethodReference target_method) OVERRIDE;
397
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200398 void GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, Location temp);
Chris Larsen3acee732015-11-18 13:31:08 -0800399 void GenerateVirtualCall(HInvokeVirtual* invoke, Location temp) OVERRIDE;
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200400
401 void MoveFromReturnRegister(Location trg ATTRIBUTE_UNUSED,
402 Primitive::Type type ATTRIBUTE_UNUSED) OVERRIDE {
403 UNIMPLEMENTED(FATAL) << "Not implemented on MIPS";
404 }
405
David Srbeckyc7098ff2016-02-09 14:30:11 +0000406 void GenerateNop();
Calin Juravle2ae48182016-03-16 14:05:09 +0000407 void GenerateImplicitNullCheck(HNullCheck* instruction);
408 void GenerateExplicitNullCheck(HNullCheck* instruction);
David Srbeckyc7098ff2016-02-09 14:30:11 +0000409
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700410 // The PcRelativePatchInfo is used for PC-relative addressing of dex cache arrays
411 // and boot image strings. The only difference is the interpretation of the offset_or_index.
412 struct PcRelativePatchInfo {
413 PcRelativePatchInfo(const DexFile& dex_file, uint32_t off_or_idx)
414 : target_dex_file(dex_file), offset_or_index(off_or_idx) { }
415 PcRelativePatchInfo(PcRelativePatchInfo&& other) = default;
416
417 const DexFile& target_dex_file;
Alexey Frunze06a46c42016-07-19 15:00:40 -0700418 // Either the dex cache array element offset or the string/type index.
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700419 uint32_t offset_or_index;
420 // Label for the instruction loading the most significant half of the offset that's added to PC
421 // to form the base address (the least significant half is loaded with the instruction that
422 // follows).
423 MipsLabel high_label;
424 // Label for the instruction corresponding to PC+0.
425 MipsLabel pc_rel_label;
426 };
427
Alexey Frunze06a46c42016-07-19 15:00:40 -0700428 PcRelativePatchInfo* NewPcRelativeStringPatch(const DexFile& dex_file, uint32_t string_index);
429 PcRelativePatchInfo* NewPcRelativeTypePatch(const DexFile& dex_file, uint32_t type_index);
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700430 PcRelativePatchInfo* NewPcRelativeDexCacheArrayPatch(const DexFile& dex_file,
431 uint32_t element_offset);
Alexey Frunze06a46c42016-07-19 15:00:40 -0700432 Literal* DeduplicateBootImageStringLiteral(const DexFile& dex_file, uint32_t string_index);
433 Literal* DeduplicateBootImageTypeLiteral(const DexFile& dex_file, uint32_t type_index);
434 Literal* DeduplicateBootImageAddressLiteral(uint32_t address);
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700435
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200436 private:
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700437 Register GetInvokeStaticOrDirectExtraParameter(HInvokeStaticOrDirect* invoke, Register temp);
438
Alexey Frunze06a46c42016-07-19 15:00:40 -0700439 using Uint32ToLiteralMap = ArenaSafeMap<uint32_t, Literal*>;
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700440 using MethodToLiteralMap = ArenaSafeMap<MethodReference, Literal*, MethodReferenceComparator>;
Alexey Frunze06a46c42016-07-19 15:00:40 -0700441 using BootStringToLiteralMap = ArenaSafeMap<StringReference,
442 Literal*,
443 StringReferenceValueComparator>;
444 using BootTypeToLiteralMap = ArenaSafeMap<TypeReference,
445 Literal*,
446 TypeReferenceValueComparator>;
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700447
Alexey Frunze06a46c42016-07-19 15:00:40 -0700448 Literal* DeduplicateUint32Literal(uint32_t value, Uint32ToLiteralMap* map);
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700449 Literal* DeduplicateMethodLiteral(MethodReference target_method, MethodToLiteralMap* map);
450 Literal* DeduplicateMethodAddressLiteral(MethodReference target_method);
451 Literal* DeduplicateMethodCodeLiteral(MethodReference target_method);
452 PcRelativePatchInfo* NewPcRelativePatch(const DexFile& dex_file,
453 uint32_t offset_or_index,
454 ArenaDeque<PcRelativePatchInfo>* patches);
455
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200456 // Labels for each block that will be compiled.
457 MipsLabel* block_labels_;
458 MipsLabel frame_entry_label_;
459 LocationsBuilderMIPS location_builder_;
460 InstructionCodeGeneratorMIPS instruction_visitor_;
461 ParallelMoveResolverMIPS move_resolver_;
462 MipsAssembler assembler_;
463 const MipsInstructionSetFeatures& isa_features_;
464
Alexey Frunze06a46c42016-07-19 15:00:40 -0700465 // Deduplication map for 32-bit literals, used for non-patchable boot image addresses.
466 Uint32ToLiteralMap uint32_literals_;
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700467 // Method patch info, map MethodReference to a literal for method address and method code.
468 MethodToLiteralMap method_patches_;
469 MethodToLiteralMap call_patches_;
470 // PC-relative patch info for each HMipsDexCacheArraysBase.
471 ArenaDeque<PcRelativePatchInfo> pc_relative_dex_cache_patches_;
Alexey Frunze06a46c42016-07-19 15:00:40 -0700472 // Deduplication map for boot string literals for kBootImageLinkTimeAddress.
473 BootStringToLiteralMap boot_image_string_patches_;
474 // PC-relative String patch info.
475 ArenaDeque<PcRelativePatchInfo> pc_relative_string_patches_;
476 // Deduplication map for boot type literals for kBootImageLinkTimeAddress.
477 BootTypeToLiteralMap boot_image_type_patches_;
478 // PC-relative type patch info.
479 ArenaDeque<PcRelativePatchInfo> pc_relative_type_patches_;
480 // Deduplication map for patchable boot image addresses.
481 Uint32ToLiteralMap boot_image_address_patches_;
482
483 // PC-relative loads on R2 clobber RA, which may need to be preserved explicitly in leaf methods.
484 // This is a flag set by pc_relative_fixups_mips and dex_cache_array_fixups_mips optimizations.
485 bool clobbered_ra_;
Alexey Frunzee3fb2452016-05-10 16:08:05 -0700486
Goran Jakovljevicf652cec2015-08-25 16:11:42 +0200487 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorMIPS);
488};
489
490} // namespace mips
491} // namespace art
492
493#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_MIPS_H_