blob: db0b9d772b25b3a5666579965e737841933ee347 [file] [log] [blame]
Nicolas Geoffray9cf35522014-06-09 18:40:10 +01001/*
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_OPTIMIZING_CODE_GENERATOR_X86_64_H_
18#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_64_H_
19
Mark P Mendell17077d82015-12-16 19:15:59 +000020#include "arch/x86_64/instruction_set_features_x86_64.h"
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010021#include "code_generator.h"
Calin Juravlecd6dffe2015-01-08 17:35:35 +000022#include "driver/compiler_options.h"
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010023#include "nodes.h"
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +000024#include "parallel_move_resolver.h"
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010025#include "utils/x86_64/assembler_x86_64.h"
26
Vladimir Marko0a516052019-10-14 13:00:44 +000027namespace art {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010028namespace x86_64 {
29
Nicolas Geoffray86a8d7a2014-11-19 08:47:18 +000030// Use a local definition to prevent copying mistakes.
Andreas Gampe542451c2016-07-26 09:02:02 -070031static constexpr size_t kX86_64WordSize = static_cast<size_t>(kX86_64PointerSize);
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010032
Nicolas Geoffrayee3cf072015-10-06 11:45:02 +010033// Some x86_64 instructions require a register to be available as temp.
34static constexpr Register TMP = R11;
35
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010036static constexpr Register kParameterCoreRegisters[] = { RSI, RDX, RCX, R8, R9 };
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010037static constexpr FloatRegister kParameterFloatRegisters[] =
38 { XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7 };
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010039
40static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010041static constexpr size_t kParameterFloatRegistersLength = arraysize(kParameterFloatRegisters);
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010042
Jeff Hao848f70a2014-01-15 13:49:50 -080043static constexpr Register kRuntimeParameterCoreRegisters[] = { RDI, RSI, RDX, RCX };
Nicolas Geoffrayd75948a2015-03-27 09:53:16 +000044static constexpr size_t kRuntimeParameterCoreRegistersLength =
45 arraysize(kRuntimeParameterCoreRegisters);
46static constexpr FloatRegister kRuntimeParameterFpuRegisters[] = { XMM0, XMM1 };
47static constexpr size_t kRuntimeParameterFpuRegistersLength =
48 arraysize(kRuntimeParameterFpuRegisters);
49
Mark Mendella4f12202015-08-06 15:23:34 -040050// These XMM registers are non-volatile in ART ABI, but volatile in native ABI.
51// If the ART ABI changes, this list must be updated. It is used to ensure that
52// these are not clobbered by any direct call to native code (such as math intrinsics).
53static constexpr FloatRegister non_volatile_xmm_regs[] = { XMM12, XMM13, XMM14, XMM15 };
54
55
Nicolas Geoffrayd75948a2015-03-27 09:53:16 +000056class InvokeRuntimeCallingConvention : public CallingConvention<Register, FloatRegister> {
57 public:
58 InvokeRuntimeCallingConvention()
59 : CallingConvention(kRuntimeParameterCoreRegisters,
60 kRuntimeParameterCoreRegistersLength,
61 kRuntimeParameterFpuRegisters,
Mathieu Chartiere401d142015-04-22 13:56:20 -070062 kRuntimeParameterFpuRegistersLength,
63 kX86_64PointerSize) {}
Nicolas Geoffrayd75948a2015-03-27 09:53:16 +000064
65 private:
66 DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention);
67};
68
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010069class InvokeDexCallingConvention : public CallingConvention<Register, FloatRegister> {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010070 public:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010071 InvokeDexCallingConvention() : CallingConvention(
72 kParameterCoreRegisters,
73 kParameterCoreRegistersLength,
74 kParameterFloatRegisters,
Mathieu Chartiere401d142015-04-22 13:56:20 -070075 kParameterFloatRegistersLength,
76 kX86_64PointerSize) {}
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010077
78 private:
79 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention);
80};
81
Vladimir Marko86c87522020-05-11 16:55:55 +010082class CriticalNativeCallingConventionVisitorX86_64 : public InvokeDexCallingConventionVisitor {
83 public:
84 explicit CriticalNativeCallingConventionVisitorX86_64(bool for_register_allocation)
85 : for_register_allocation_(for_register_allocation) {}
86
87 virtual ~CriticalNativeCallingConventionVisitorX86_64() {}
88
89 Location GetNextLocation(DataType::Type type) override;
90 Location GetReturnLocation(DataType::Type type) const override;
91 Location GetMethodLocation() const override;
92
93 size_t GetStackOffset() const { return stack_offset_; }
94
95 private:
96 // Register allocator does not support adjusting frame size, so we cannot provide final locations
97 // of stack arguments for register allocation. We ask the register allocator for any location and
98 // move these arguments to the right place after adjusting the SP when generating the call.
99 const bool for_register_allocation_;
100 size_t gpr_index_ = 0u;
101 size_t fpr_index_ = 0u;
102 size_t stack_offset_ = 0u;
103
104 DISALLOW_COPY_AND_ASSIGN(CriticalNativeCallingConventionVisitorX86_64);
105};
106
Calin Juravlee460d1d2015-09-29 04:52:17 +0100107class FieldAccessCallingConventionX86_64 : public FieldAccessCallingConvention {
108 public:
109 FieldAccessCallingConventionX86_64() {}
110
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100111 Location GetObjectLocation() const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100112 return Location::RegisterLocation(RSI);
113 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100114 Location GetFieldIndexLocation() const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100115 return Location::RegisterLocation(RDI);
116 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100117 Location GetReturnLocation(DataType::Type type ATTRIBUTE_UNUSED) const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100118 return Location::RegisterLocation(RAX);
119 }
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100120 Location GetSetValueLocation(DataType::Type type ATTRIBUTE_UNUSED, bool is_instance)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100121 const override {
Nicolas Geoffray5b3c6c02017-01-19 14:22:26 +0000122 return is_instance
Calin Juravlee460d1d2015-09-29 04:52:17 +0100123 ? Location::RegisterLocation(RDX)
Nicolas Geoffray5b3c6c02017-01-19 14:22:26 +0000124 : Location::RegisterLocation(RSI);
Calin Juravlee460d1d2015-09-29 04:52:17 +0100125 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100126 Location GetFpuLocation(DataType::Type type ATTRIBUTE_UNUSED) const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100127 return Location::FpuRegisterLocation(XMM0);
128 }
129
130 private:
131 DISALLOW_COPY_AND_ASSIGN(FieldAccessCallingConventionX86_64);
132};
133
134
Roland Levillain2d27c8e2015-04-28 15:48:45 +0100135class InvokeDexCallingConventionVisitorX86_64 : public InvokeDexCallingConventionVisitor {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100136 public:
Roland Levillain2d27c8e2015-04-28 15:48:45 +0100137 InvokeDexCallingConventionVisitorX86_64() {}
138 virtual ~InvokeDexCallingConventionVisitorX86_64() {}
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100139
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100140 Location GetNextLocation(DataType::Type type) override;
141 Location GetReturnLocation(DataType::Type type) const override;
142 Location GetMethodLocation() const override;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100143
144 private:
145 InvokeDexCallingConvention calling_convention;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100146
Roland Levillain2d27c8e2015-04-28 15:48:45 +0100147 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorX86_64);
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100148};
149
150class CodeGeneratorX86_64;
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800151
Zheng Xuad4450e2015-04-17 18:48:56 +0800152class ParallelMoveResolverX86_64 : public ParallelMoveResolverWithSwap {
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +0000153 public:
154 ParallelMoveResolverX86_64(ArenaAllocator* allocator, CodeGeneratorX86_64* codegen)
Zheng Xuad4450e2015-04-17 18:48:56 +0800155 : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {}
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +0000156
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100157 void EmitMove(size_t index) override;
158 void EmitSwap(size_t index) override;
159 void SpillScratch(int reg) override;
160 void RestoreScratch(int reg) override;
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +0000161
162 X86_64Assembler* GetAssembler() const;
163
164 private:
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100165 void Exchange32(CpuRegister reg, int mem);
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100166 void Exchange32(XmmRegister reg, int mem);
Mark Mendell8a1c7282015-06-29 15:41:28 -0400167 void Exchange64(CpuRegister reg1, CpuRegister reg2);
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100168 void Exchange64(CpuRegister reg, int mem);
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100169 void Exchange64(XmmRegister reg, int mem);
Aart Bikcfe50bb2017-12-12 14:54:12 -0800170 void Exchange128(XmmRegister reg, int mem);
171 void ExchangeMemory32(int mem1, int mem2);
172 void ExchangeMemory64(int mem1, int mem2, int num_of_qwords);
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +0000173
174 CodeGeneratorX86_64* const codegen_;
175
176 DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverX86_64);
177};
178
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100179class LocationsBuilderX86_64 : public HGraphVisitor {
180 public:
181 LocationsBuilderX86_64(HGraph* graph, CodeGeneratorX86_64* codegen)
182 : HGraphVisitor(graph), codegen_(codegen) {}
183
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100184#define DECLARE_VISIT_INSTRUCTION(name, super) \
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100185 void Visit##name(H##name* instr) override;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100186
Alexandre Ramesef20f712015-06-09 10:29:30 +0100187 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
188 FOR_EACH_CONCRETE_INSTRUCTION_X86_64(DECLARE_VISIT_INSTRUCTION)
Shalini Salomi Bodapatidd121f62018-10-26 15:03:53 +0530189 FOR_EACH_CONCRETE_INSTRUCTION_X86_COMMON(DECLARE_VISIT_INSTRUCTION)
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100190
191#undef DECLARE_VISIT_INSTRUCTION
192
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100193 void VisitInstruction(HInstruction* instruction) override {
Alexandre Ramesef20f712015-06-09 10:29:30 +0100194 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
195 << " (id " << instruction->GetId() << ")";
196 }
197
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100198 private:
Nicolas Geoffray9574c4b2014-11-12 13:19:37 +0000199 void HandleInvoke(HInvoke* invoke);
200 void HandleBitwiseOperation(HBinaryOperation* operation);
Vladimir Marko5f7b58e2015-11-23 19:49:34 +0000201 void HandleCondition(HCondition* condition);
Calin Juravle9aec02f2014-11-18 23:06:35 +0000202 void HandleShift(HBinaryOperation* operation);
Calin Juravle52c48962014-12-16 17:02:57 +0000203 void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info);
204 void HandleFieldGet(HInstruction* instruction);
Shalini Salomi Bodapatib45a4352019-07-10 16:09:41 +0530205 bool CpuHasAvxFeatureFlag();
206 bool CpuHasAvx2FeatureFlag();
Nicolas Geoffray9574c4b2014-11-12 13:19:37 +0000207
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100208 CodeGeneratorX86_64* const codegen_;
Roland Levillain2d27c8e2015-04-28 15:48:45 +0100209 InvokeDexCallingConventionVisitorX86_64 parameter_visitor_;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100210
211 DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86_64);
212};
213
Aart Bik42249c32016-01-07 15:33:50 -0800214class InstructionCodeGeneratorX86_64 : public InstructionCodeGenerator {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100215 public:
216 InstructionCodeGeneratorX86_64(HGraph* graph, CodeGeneratorX86_64* codegen);
217
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100218#define DECLARE_VISIT_INSTRUCTION(name, super) \
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100219 void Visit##name(H##name* instr) override;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100220
Alexandre Ramesef20f712015-06-09 10:29:30 +0100221 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
222 FOR_EACH_CONCRETE_INSTRUCTION_X86_64(DECLARE_VISIT_INSTRUCTION)
Shalini Salomi Bodapatidd121f62018-10-26 15:03:53 +0530223 FOR_EACH_CONCRETE_INSTRUCTION_X86_COMMON(DECLARE_VISIT_INSTRUCTION)
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100224
225#undef DECLARE_VISIT_INSTRUCTION
226
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100227 void VisitInstruction(HInstruction* instruction) override {
Alexandre Ramesef20f712015-06-09 10:29:30 +0100228 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
229 << " (id " << instruction->GetId() << ")";
230 }
231
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100232 X86_64Assembler* GetAssembler() const { return assembler_; }
233
Ulya Trafimovich2ee69692021-05-19 14:15:14 +0100234 // Generate a GC root reference load:
235 //
236 // root <- *address
237 //
238 // while honoring read barriers based on read_barrier_option.
239 void GenerateGcRootFieldLoad(HInstruction* instruction,
240 Location root,
241 const Address& address,
242 Label* fixup_label,
243 ReadBarrierOption read_barrier_option);
Ulya Trafimovich6a4b2992021-06-11 12:02:17 +0100244 void HandleFieldSet(HInstruction* instruction,
245 uint32_t value_index,
246 uint32_t extra_temp_index,
247 DataType::Type field_type,
248 Address field_addr,
249 CpuRegister base,
250 bool is_volatile,
Ulya Trafimovich30bb6af2021-06-15 17:34:51 +0100251 bool is_atomic,
Ulya Trafimovich6a4b2992021-06-11 12:02:17 +0100252 bool value_can_be_null);
Ulya Trafimovich2ee69692021-05-19 14:15:14 +0100253
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100254 private:
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100255 // Generate code for the given suspend check. If not null, `successor`
256 // is the block to branch to if the suspend check is not needed, and after
257 // the suspend call.
258 void GenerateSuspendCheck(HSuspendCheck* instruction, HBasicBlock* successor);
Andreas Gampe85b62f22015-09-09 13:15:38 -0700259 void GenerateClassInitializationCheck(SlowPathCode* slow_path, CpuRegister class_reg);
Vladimir Marko175e7862018-03-27 09:03:13 +0000260 void GenerateBitstringTypeCheckCompare(HTypeCheckInstruction* check, CpuRegister temp);
Nicolas Geoffray9574c4b2014-11-12 13:19:37 +0000261 void HandleBitwiseOperation(HBinaryOperation* operation);
Mark Mendellc4701932015-04-10 13:18:51 -0400262 void GenerateRemFP(HRem* rem);
Guillaume Sanchez0f88e872015-03-30 17:55:45 +0100263 void DivRemOneOrMinusOne(HBinaryOperation* instruction);
Guillaume Sanchezb19930c2015-04-09 21:12:15 +0100264 void DivByPowerOfTwo(HDiv* instruction);
Shalini Salomi Bodapatia66784b2018-11-06 13:05:44 +0530265 void RemByPowerOfTwo(HRem* instruction);
Guillaume Sanchez0f88e872015-03-30 17:55:45 +0100266 void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction);
Calin Juravlebacfec32014-11-14 15:54:36 +0000267 void GenerateDivRemIntegral(HBinaryOperation* instruction);
Vladimir Marko5f7b58e2015-11-23 19:49:34 +0000268 void HandleCondition(HCondition* condition);
Calin Juravle9aec02f2014-11-18 23:06:35 +0000269 void HandleShift(HBinaryOperation* operation);
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000270
Nicolas Geoffray07276db2015-05-18 14:22:09 +0100271 void HandleFieldSet(HInstruction* instruction,
272 const FieldInfo& field_info,
273 bool value_can_be_null);
Calin Juravle52c48962014-12-16 17:02:57 +0000274 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000275
Aart Bik351df3e2018-03-07 11:54:57 -0800276 void GenerateMinMaxInt(LocationSummary* locations, bool is_min, DataType::Type type);
Aart Bik1f8d51b2018-02-15 10:42:37 -0800277 void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type);
Aart Bik351df3e2018-03-07 11:54:57 -0800278 void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
Aart Bik1f8d51b2018-02-15 10:42:37 -0800279
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000280 // Generate a heap reference load using one register `out`:
281 //
282 // out <- *(out + offset)
283 //
284 // while honoring heap poisoning and/or read barriers (if any).
Roland Levillain95e7ffc2016-01-22 11:57:25 +0000285 //
286 // Location `maybe_temp` is used when generating a read barrier and
287 // shall be a register in that case; it may be an invalid location
288 // otherwise.
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000289 void GenerateReferenceLoadOneRegister(HInstruction* instruction,
290 Location out,
291 uint32_t offset,
Mathieu Chartieraa474eb2016-11-09 15:18:27 -0800292 Location maybe_temp,
Mathieu Chartier3af00dc2016-11-10 11:25:57 -0800293 ReadBarrierOption read_barrier_option);
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000294 // Generate a heap reference load using two different registers
295 // `out` and `obj`:
296 //
297 // out <- *(obj + offset)
298 //
299 // while honoring heap poisoning and/or read barriers (if any).
Roland Levillain95e7ffc2016-01-22 11:57:25 +0000300 //
301 // Location `maybe_temp` is used when generating a Baker's (fast
302 // path) read barrier and shall be a register in that case; it may
303 // be an invalid location otherwise.
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000304 void GenerateReferenceLoadTwoRegisters(HInstruction* instruction,
305 Location out,
306 Location obj,
Mathieu Chartiercdba73b2016-11-03 19:23:06 -0700307 uint32_t offset,
Mathieu Chartier3af00dc2016-11-10 11:25:57 -0800308 ReadBarrierOption read_barrier_option);
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000309
Mark Mendell24f2dfa2015-01-14 19:51:45 -0500310 void PushOntoFPStack(Location source, uint32_t temp_offset,
311 uint32_t stack_adjustment, bool is_float);
Mark Mendell7c0b44f2016-02-01 10:08:35 -0500312 void GenerateCompareTest(HCondition* condition);
Mark Mendell152408f2015-12-31 12:28:50 -0500313 template<class LabelType>
Mingyao Yangd43b3ac2015-04-01 14:03:04 -0700314 void GenerateTestAndBranch(HInstruction* instruction,
David Brazdil0debae72015-11-12 18:37:00 +0000315 size_t condition_input_index,
Mark Mendell152408f2015-12-31 12:28:50 -0500316 LabelType* true_target,
317 LabelType* false_target);
318 template<class LabelType>
David Brazdil0debae72015-11-12 18:37:00 +0000319 void GenerateCompareTestAndBranch(HCondition* condition,
Mark Mendell152408f2015-12-31 12:28:50 -0500320 LabelType* true_target,
321 LabelType* false_target);
322 template<class LabelType>
323 void GenerateFPJumps(HCondition* cond, LabelType* true_label, LabelType* false_label);
324
David Brazdilfc6a86a2015-06-26 10:33:45 +0000325 void HandleGoto(HInstruction* got, HBasicBlock* successor);
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100326
Shalini Salomi Bodapatib45a4352019-07-10 16:09:41 +0530327 bool CpuHasAvxFeatureFlag();
328 bool CpuHasAvx2FeatureFlag();
329
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100330 X86_64Assembler* const assembler_;
331 CodeGeneratorX86_64* const codegen_;
332
333 DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorX86_64);
334};
335
Mark Mendell9c86b482015-09-18 13:36:07 -0400336// Class for fixups to jump tables.
337class JumpTableRIPFixup;
338
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100339class CodeGeneratorX86_64 : public CodeGenerator {
340 public:
Mark Mendellfb8d2792015-03-31 22:16:59 -0400341 CodeGeneratorX86_64(HGraph* graph,
Serban Constantinescuecc43662015-08-13 13:33:12 +0100342 const CompilerOptions& compiler_options,
343 OptimizingCompilerStats* stats = nullptr);
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100344 virtual ~CodeGeneratorX86_64() {}
345
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100346 void GenerateFrameEntry() override;
347 void GenerateFrameExit() override;
348 void Bind(HBasicBlock* block) override;
349 void MoveConstant(Location destination, int32_t value) override;
350 void MoveLocation(Location dst, Location src, DataType::Type dst_type) override;
351 void AddLocationAsTemp(Location location, LocationSummary* locations) override;
Calin Juravlee460d1d2015-09-29 04:52:17 +0100352
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100353 size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) override;
354 size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) override;
355 size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) override;
356 size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) override;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100357
Alexandre Rames8158f282015-08-07 10:26:17 +0100358 // Generate code to invoke a runtime entry point.
Calin Juravle175dc732015-08-25 15:42:32 +0100359 void InvokeRuntime(QuickEntrypointEnum entrypoint,
360 HInstruction* instruction,
361 uint32_t dex_pc,
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100362 SlowPathCode* slow_path = nullptr) override;
Alexandre Rames8158f282015-08-07 10:26:17 +0100363
Roland Levillaindec8f632016-07-22 17:10:06 +0100364 // Generate code to invoke a runtime entry point, but do not record
365 // PC-related information in a stack map.
366 void InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset,
367 HInstruction* instruction,
368 SlowPathCode* slow_path);
369
Serban Constantinescuba45db02016-07-12 22:53:02 +0100370 void GenerateInvokeRuntime(int32_t entry_point_offset);
371
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100372 size_t GetWordSize() const override {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100373 return kX86_64WordSize;
374 }
375
Artem Serov6a0b6572019-07-26 20:38:37 +0100376 size_t GetSlowPathFPWidth() const override {
Aart Bikb13c65b2017-03-21 20:14:07 -0700377 return GetGraph()->HasSIMD()
Artem Serovc8150b52019-07-31 18:28:00 +0100378 ? GetSIMDRegisterWidth()
Aart Bikb13c65b2017-03-21 20:14:07 -0700379 : 1 * kX86_64WordSize; // 8 bytes == 1 x86_64 words for each spill
Mark Mendellf85a9ca2015-01-13 09:20:58 -0500380 }
381
Artem Serov6a0b6572019-07-26 20:38:37 +0100382 size_t GetCalleePreservedFPWidth() const override {
383 return 1 * kX86_64WordSize;
384 }
385
Artem Serovc8150b52019-07-31 18:28:00 +0100386 size_t GetSIMDRegisterWidth() const override {
387 return 2 * kX86_64WordSize;
388 }
389
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100390 HGraphVisitor* GetLocationBuilder() override {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100391 return &location_builder_;
392 }
393
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100394 HGraphVisitor* GetInstructionVisitor() override {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100395 return &instruction_visitor_;
396 }
397
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100398 X86_64Assembler* GetAssembler() override {
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100399 return &assembler_;
400 }
401
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100402 const X86_64Assembler& GetAssembler() const override {
Alexandre Rameseb7b7392015-06-19 14:47:01 +0100403 return assembler_;
404 }
405
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100406 ParallelMoveResolverX86_64* GetMoveResolver() override {
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +0000407 return &move_resolver_;
408 }
409
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100410 uintptr_t GetAddressOf(HBasicBlock* block) override {
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000411 return GetLabelOf(block)->Position();
412 }
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100413
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100414 void SetupBlockedRegisters() const override;
415 void DumpCoreRegister(std::ostream& stream, int reg) const override;
416 void DumpFloatingPointRegister(std::ostream& stream, int reg) const override;
417 void Finalize(CodeAllocator* allocator) override;
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000418
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100419 InstructionSet GetInstructionSet() const override {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100420 return InstructionSet::kX86_64;
421 }
422
Vladimir Markoa0431112018-06-25 09:32:54 +0100423 const X86_64InstructionSetFeatures& GetInstructionSetFeatures() const;
424
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100425 // Emit a write barrier.
Nicolas Geoffray07276db2015-05-18 14:22:09 +0100426 void MarkGCCard(CpuRegister temp,
427 CpuRegister card,
428 CpuRegister object,
429 CpuRegister value,
430 bool value_can_be_null);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100431
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000432 void GenerateMemoryBarrier(MemBarrierKind kind);
433
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100434 // Helper method to move a value between two locations.
435 void Move(Location destination, Location source);
Ulya Trafimovich161911c2021-06-01 15:47:28 +0100436 // Helper method to load a value of non-reference type from memory.
437 void LoadFromMemoryNoReference(DataType::Type type, Location dst, Address src);
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100438
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100439 Label* GetLabelOf(HBasicBlock* block) const {
Vladimir Marko225b6462015-09-28 12:17:40 +0100440 return CommonGetLabelOf<Label>(block_labels_, block);
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100441 }
442
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100443 void Initialize() override {
Vladimir Marko225b6462015-09-28 12:17:40 +0100444 block_labels_ = CommonInitializeLabels<Label>();
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100445 }
446
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100447 bool NeedsTwoRegisters(DataType::Type type ATTRIBUTE_UNUSED) const override {
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000448 return false;
449 }
450
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000451 // Check if the desired_string_load_kind is supported. If it is, return it,
452 // otherwise return a fall-back kind that should be used instead.
453 HLoadString::LoadKind GetSupportedLoadStringKind(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100454 HLoadString::LoadKind desired_string_load_kind) override;
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000455
Vladimir Markodbb7f5b2016-03-30 13:23:58 +0100456 // Check if the desired_class_load_kind is supported. If it is, return it,
457 // otherwise return a fall-back kind that should be used instead.
458 HLoadClass::LoadKind GetSupportedLoadClassKind(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100459 HLoadClass::LoadKind desired_class_load_kind) override;
Vladimir Markodbb7f5b2016-03-30 13:23:58 +0100460
Vladimir Markodc151b22015-10-15 18:02:30 +0100461 // Check if the desired_dispatch_info is supported. If it is, return it,
462 // otherwise return a fall-back info that should be used instead.
463 HInvokeStaticOrDirect::DispatchInfo GetSupportedInvokeStaticOrDirectDispatch(
464 const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info,
Nicolas Geoffraybdb2ecc2018-09-18 14:33:55 +0100465 ArtMethod* method) override;
Vladimir Markodc151b22015-10-15 18:02:30 +0100466
Nicolas Geoffray8d34a182020-09-16 09:46:58 +0100467 void LoadMethod(MethodLoadKind load_kind, Location temp, HInvoke* invoke);
Vladimir Markoe7197bf2017-06-02 17:00:23 +0100468 void GenerateStaticOrDirectCall(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100469 HInvokeStaticOrDirect* invoke, Location temp, SlowPathCode* slow_path = nullptr) override;
Vladimir Markoe7197bf2017-06-02 17:00:23 +0100470 void GenerateVirtualCall(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100471 HInvokeVirtual* invoke, Location temp, SlowPathCode* slow_path = nullptr) override;
Andreas Gampe85b62f22015-09-09 13:15:38 -0700472
Vladimir Marko6fd16062018-06-26 11:02:04 +0100473 void RecordBootImageIntrinsicPatch(uint32_t intrinsic_data);
Vladimir Markob066d432018-01-03 13:14:37 +0000474 void RecordBootImageRelRoPatch(uint32_t boot_image_offset);
Nicolas Geoffray8d34a182020-09-16 09:46:58 +0100475 void RecordBootImageMethodPatch(HInvoke* invoke);
476 void RecordMethodBssEntryPatch(HInvoke* invoke);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000477 void RecordBootImageTypePatch(HLoadClass* load_class);
Vladimir Marko6bec91c2017-01-09 15:03:12 +0000478 Label* NewTypeBssEntryPatch(HLoadClass* load_class);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000479 void RecordBootImageStringPatch(HLoadString* load_string);
Vladimir Markoaad75c62016-10-03 08:46:48 +0000480 Label* NewStringBssEntryPatch(HLoadString* load_string);
Vladimir Markoeb9eb002020-10-02 13:54:19 +0100481 void RecordBootImageJniEntrypointPatch(HInvokeStaticOrDirect* invoke);
Nicolas Geoffrayf0acfe72017-01-09 20:54:52 +0000482 Label* NewJitRootStringPatch(const DexFile& dex_file,
Vladimir Marko174b2e22017-10-12 13:34:49 +0100483 dex::StringIndex string_index,
Nicolas Geoffrayf0acfe72017-01-09 20:54:52 +0000484 Handle<mirror::String> handle);
Nicolas Geoffray5247c082017-01-13 14:17:29 +0000485 Label* NewJitRootClassPatch(const DexFile& dex_file,
Vladimir Marko174b2e22017-10-12 13:34:49 +0100486 dex::TypeIndex type_index,
Nicolas Geoffray5247c082017-01-13 14:17:29 +0000487 Handle<mirror::Class> handle);
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000488
Vladimir Marko6fd16062018-06-26 11:02:04 +0100489 void LoadBootImageAddress(CpuRegister reg, uint32_t boot_image_reference);
Vladimir Markode91ca92020-10-27 13:41:40 +0000490 void LoadIntrinsicDeclaringClass(CpuRegister reg, HInvoke* invoke);
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800491
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100492 void EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linker_patches) override;
Vladimir Marko58155012015-08-19 12:49:41 +0000493
Nicolas Geoffray22384ae2016-12-12 22:33:36 +0000494 void PatchJitRootUse(uint8_t* code,
495 const uint8_t* roots_data,
496 const PatchInfo<Label>& info,
497 uint64_t index_in_table) const;
498
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100499 void EmitJitRootPatches(uint8_t* code, const uint8_t* roots_data) override;
Nicolas Geoffray132d8362016-11-16 09:19:42 +0000500
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000501 // Fast path implementation of ReadBarrier::Barrier for a heap
502 // reference field load when Baker's read barriers are used.
503 void GenerateFieldLoadWithBakerReadBarrier(HInstruction* instruction,
Roland Levillaine3f43ac2016-01-19 15:07:47 +0000504 Location ref,
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000505 CpuRegister obj,
506 uint32_t offset,
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000507 bool needs_null_check);
508 // Fast path implementation of ReadBarrier::Barrier for a heap
509 // reference array load when Baker's read barriers are used.
510 void GenerateArrayLoadWithBakerReadBarrier(HInstruction* instruction,
Roland Levillaine3f43ac2016-01-19 15:07:47 +0000511 Location ref,
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000512 CpuRegister obj,
513 uint32_t data_offset,
514 Location index,
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000515 bool needs_null_check);
Roland Levillaina1aa3b12016-10-26 13:03:38 +0100516 // Factored implementation, used by GenerateFieldLoadWithBakerReadBarrier,
517 // GenerateArrayLoadWithBakerReadBarrier and some intrinsics.
518 //
519 // Load the object reference located at address `src`, held by
520 // object `obj`, into `ref`, and mark it if needed. The base of
521 // address `src` must be `obj`.
522 //
523 // If `always_update_field` is true, the value of the reference is
524 // atomically updated in the holder (`obj`). This operation
525 // requires two temporary registers, which must be provided as
526 // non-null pointers (`temp1` and `temp2`).
Sang, Chunlei0fcd2b82016-04-05 17:12:59 +0800527 void GenerateReferenceLoadWithBakerReadBarrier(HInstruction* instruction,
528 Location ref,
529 CpuRegister obj,
530 const Address& src,
Roland Levillaina1aa3b12016-10-26 13:03:38 +0100531 bool needs_null_check,
532 bool always_update_field = false,
533 CpuRegister* temp1 = nullptr,
534 CpuRegister* temp2 = nullptr);
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000535
536 // Generate a read barrier for a heap reference within `instruction`
537 // using a slow path.
Roland Levillain0d5a2812015-11-13 10:07:31 +0000538 //
539 // A read barrier for an object reference read from the heap is
540 // implemented as a call to the artReadBarrierSlow runtime entry
541 // point, which is passed the values in locations `ref`, `obj`, and
542 // `offset`:
543 //
544 // mirror::Object* artReadBarrierSlow(mirror::Object* ref,
545 // mirror::Object* obj,
546 // uint32_t offset);
547 //
548 // The `out` location contains the value returned by
549 // artReadBarrierSlow.
550 //
551 // When `index` provided (i.e., when it is different from
552 // Location::NoLocation()), the offset value passed to
553 // artReadBarrierSlow is adjusted to take `index` into account.
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000554 void GenerateReadBarrierSlow(HInstruction* instruction,
555 Location out,
556 Location ref,
557 Location obj,
558 uint32_t offset,
559 Location index = Location::NoLocation());
Roland Levillain0d5a2812015-11-13 10:07:31 +0000560
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000561 // If read barriers are enabled, generate a read barrier for a heap
562 // reference using a slow path. If heap poisoning is enabled, also
563 // unpoison the reference in `out`.
564 void MaybeGenerateReadBarrierSlow(HInstruction* instruction,
565 Location out,
566 Location ref,
567 Location obj,
568 uint32_t offset,
569 Location index = Location::NoLocation());
Roland Levillain0d5a2812015-11-13 10:07:31 +0000570
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000571 // Generate a read barrier for a GC root within `instruction` using
572 // a slow path.
Roland Levillain0d5a2812015-11-13 10:07:31 +0000573 //
574 // A read barrier for an object reference GC root is implemented as
575 // a call to the artReadBarrierForRootSlow runtime entry point,
576 // which is passed the value in location `root`:
577 //
578 // mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root);
579 //
580 // The `out` location contains the value returned by
581 // artReadBarrierForRootSlow.
Roland Levillain1e7f8db2015-12-15 10:54:19 +0000582 void GenerateReadBarrierForRootSlow(HInstruction* instruction, Location out, Location root);
Roland Levillain0d5a2812015-11-13 10:07:31 +0000583
Mark Mendellf55c3e02015-03-26 21:07:46 -0400584 int ConstantAreaStart() const {
585 return constant_area_start_;
586 }
587
588 Address LiteralDoubleAddress(double v);
589 Address LiteralFloatAddress(float v);
590 Address LiteralInt32Address(int32_t v);
591 Address LiteralInt64Address(int64_t v);
592
Aart Bika19616e2016-02-01 18:57:58 -0800593 // Load a 32/64-bit value into a register in the most efficient manner.
Aart Bikc5d47542016-01-27 17:00:35 -0800594 void Load32BitValue(CpuRegister dest, int32_t value);
Mark Mendell92e83bf2015-05-07 11:25:03 -0400595 void Load64BitValue(CpuRegister dest, int64_t value);
Mark Mendell7c0b44f2016-02-01 10:08:35 -0500596 void Load32BitValue(XmmRegister dest, int32_t value);
597 void Load64BitValue(XmmRegister dest, int64_t value);
598 void Load32BitValue(XmmRegister dest, float value);
599 void Load64BitValue(XmmRegister dest, double value);
Aart Bikc5d47542016-01-27 17:00:35 -0800600
Aart Bika19616e2016-02-01 18:57:58 -0800601 // Compare a register with a 32/64-bit value in the most efficient manner.
602 void Compare32BitValue(CpuRegister dest, int32_t value);
603 void Compare64BitValue(CpuRegister dest, int64_t value);
604
jessicahandojo4877b792016-09-08 19:49:13 -0700605 // Compare int values. Supports register locations for `lhs`.
Vladimir Marko56f4bdd2016-09-16 11:32:36 +0100606 void GenerateIntCompare(Location lhs, Location rhs);
jessicahandojo4877b792016-09-08 19:49:13 -0700607 void GenerateIntCompare(CpuRegister lhs, Location rhs);
Vladimir Marko56f4bdd2016-09-16 11:32:36 +0100608
609 // Compare long values. Supports only register locations for `lhs`.
610 void GenerateLongCompare(Location lhs, Location rhs);
611
612 // Construct address for array access.
613 static Address ArrayAddress(CpuRegister obj,
614 Location index,
615 ScaleFactor scale,
616 uint32_t data_offset);
617
Mark Mendell9c86b482015-09-18 13:36:07 -0400618 Address LiteralCaseTable(HPackedSwitch* switch_instr);
Mark Mendell92e83bf2015-05-07 11:25:03 -0400619
Mark Mendellcfa410b2015-05-25 16:02:44 -0400620 // Store a 64 bit value into a DoubleStackSlot in the most efficient manner.
621 void Store64BitValueToStack(Location dest, int64_t value);
622
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100623 void MoveFromReturnRegister(Location trg, DataType::Type type) override;
Vladimir Markoeebb8212018-06-05 14:57:24 +0100624
Mark Mendellea5af682015-10-22 17:35:49 -0400625 // Assign a 64 bit constant to an address.
626 void MoveInt64ToAddress(const Address& addr_low,
627 const Address& addr_high,
628 int64_t v,
629 HInstruction* instruction);
630
Mark P Mendell17077d82015-12-16 19:15:59 +0000631 // Ensure that prior stores complete to memory before subsequent loads.
632 // The locked add implementation will avoid serializing device memory, but will
Mark Mendell7aa04a12016-01-27 22:39:07 -0500633 // touch (but not change) the top of the stack.
634 // The 'non_temporal' parameter should be used to ensure ordering of non-temporal stores.
Mark P Mendell17077d82015-12-16 19:15:59 +0000635 void MemoryFence(bool force_mfence = false) {
Mark Mendell7aa04a12016-01-27 22:39:07 -0500636 if (!force_mfence) {
Mark P Mendell17077d82015-12-16 19:15:59 +0000637 assembler_.lock()->addl(Address(CpuRegister(RSP), 0), Immediate(0));
638 } else {
639 assembler_.mfence();
640 }
641 }
642
Vladimir Markodec78172020-06-19 15:31:23 +0100643 void IncreaseFrame(size_t adjustment) override;
644 void DecreaseFrame(size_t adjustment) override;
645
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100646 void GenerateNop() override;
647 void GenerateImplicitNullCheck(HNullCheck* instruction) override;
648 void GenerateExplicitNullCheck(HNullCheck* instruction) override;
Nicolas Geoffray20036d82019-11-28 16:15:00 +0000649 void MaybeGenerateInlineCacheCheck(HInstruction* instruction, CpuRegister cls);
Nicolas Geoffraye2a3aa92019-11-25 17:52:58 +0000650
David Srbeckyc7098ff2016-02-09 14:30:11 +0000651
Nicolas Geoffraya59af8a2019-11-27 17:42:32 +0000652 void MaybeIncrementHotness(bool is_frame_entry);
653
Vladimir Marko86c87522020-05-11 16:55:55 +0100654 static void BlockNonVolatileXmmRegisters(LocationSummary* locations);
655
Vladimir Marko4ef451a2020-07-23 09:54:27 +0000656 // When we don't know the proper offset for the value, we use kPlaceholder32BitOffset.
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000657 // We will fix this up in the linker later to have the right value.
Vladimir Marko4ef451a2020-07-23 09:54:27 +0000658 static constexpr int32_t kPlaceholder32BitOffset = 256;
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000659
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100660 private:
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100661 template <linker::LinkerPatch (*Factory)(size_t, const DexFile*, uint32_t, uint32_t)>
Vladimir Markoaad75c62016-10-03 08:46:48 +0000662 static void EmitPcRelativeLinkerPatches(const ArenaDeque<PatchInfo<Label>>& infos,
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100663 ArenaVector<linker::LinkerPatch>* linker_patches);
Vladimir Marko58155012015-08-19 12:49:41 +0000664
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100665 // Labels for each block that will be compiled.
Vladimir Marko225b6462015-09-28 12:17:40 +0100666 Label* block_labels_; // Indexed by block id.
Nicolas Geoffray1cf95282014-12-12 19:22:03 +0000667 Label frame_entry_label_;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100668 LocationsBuilderX86_64 location_builder_;
669 InstructionCodeGeneratorX86_64 instruction_visitor_;
Nicolas Geoffrayecb2f9b2014-06-13 08:59:59 +0000670 ParallelMoveResolverX86_64 move_resolver_;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100671 X86_64Assembler assembler_;
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100672
Mark Mendell39dcf552015-04-09 20:42:42 -0400673 // Offset to the start of the constant area in the assembled code.
Mark Mendellf55c3e02015-03-26 21:07:46 -0400674 // Used for fixups to the constant area.
675 int constant_area_start_;
676
Vladimir Marko2d06e022019-07-08 15:45:19 +0100677 // PC-relative method patch info for kBootImageLinkTimePcRelative.
Vladimir Marko65979462017-05-19 17:25:12 +0100678 ArenaDeque<PatchInfo<Label>> boot_image_method_patches_;
Vladimir Marko0eb882b2017-05-15 13:39:18 +0100679 // PC-relative method patch info for kBssEntry.
680 ArenaDeque<PatchInfo<Label>> method_bss_entry_patches_;
Vladimir Marko764d4542017-05-16 10:31:41 +0100681 // PC-relative type patch info for kBootImageLinkTimePcRelative.
Vladimir Marko1998cd02017-01-13 13:02:58 +0000682 ArenaDeque<PatchInfo<Label>> boot_image_type_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000683 // PC-relative type patch info for kBssEntry.
Vladimir Marko1998cd02017-01-13 13:02:58 +0000684 ArenaDeque<PatchInfo<Label>> type_bss_entry_patches_;
Vladimir Marko8f63f102020-09-28 12:10:28 +0100685 // PC-relative public type patch info for kBssEntryPublic.
686 ArenaDeque<PatchInfo<Label>> public_type_bss_entry_patches_;
687 // PC-relative package type patch info for kBssEntryPackage.
688 ArenaDeque<PatchInfo<Label>> package_type_bss_entry_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000689 // PC-relative String patch info for kBootImageLinkTimePcRelative.
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000690 ArenaDeque<PatchInfo<Label>> boot_image_string_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000691 // PC-relative String patch info for kBssEntry.
Vladimir Marko6cfbdbc2017-07-25 13:26:39 +0100692 ArenaDeque<PatchInfo<Label>> string_bss_entry_patches_;
Vladimir Markoeb9eb002020-10-02 13:54:19 +0100693 // PC-relative method patch info for kBootImageLinkTimePcRelative+kCallCriticalNative.
694 ArenaDeque<PatchInfo<Label>> boot_image_jni_entrypoint_patches_;
Vladimir Marko2d06e022019-07-08 15:45:19 +0100695 // PC-relative patch info for IntrinsicObjects for the boot image,
696 // and for method/type/string patches for kBootImageRelRo otherwise.
697 ArenaDeque<PatchInfo<Label>> boot_image_other_patches_;
Mark Mendell9c86b482015-09-18 13:36:07 -0400698
Nicolas Geoffray132d8362016-11-16 09:19:42 +0000699 // Patches for string literals in JIT compiled code.
700 ArenaDeque<PatchInfo<Label>> jit_string_patches_;
Nicolas Geoffray22384ae2016-12-12 22:33:36 +0000701 // Patches for class literals in JIT compiled code.
702 ArenaDeque<PatchInfo<Label>> jit_class_patches_;
703
Vladimir Marko65979462017-05-19 17:25:12 +0100704 // Fixups for jump tables need to be handled specially.
705 ArenaVector<JumpTableRIPFixup*> fixups_to_jump_tables_;
706
Nicolas Geoffray9cf35522014-06-09 18:40:10 +0100707 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86_64);
708};
709
710} // namespace x86_64
711} // namespace art
712
713#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_64_H_