blob: 240f8d281623303d570e1f8c8d6a4c14693f9359 [file] [log] [blame]
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +00001/*
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_H_
18#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_
19
Mark P Mendell17077d82015-12-16 19:15:59 +000020#include "arch/x86/instruction_set_features_x86.h"
Andreas Gampe542451c2016-07-26 09:02:02 -070021#include "base/enums.h"
Vladimir Markoe2727152019-10-10 10:46:42 +010022#include "base/macros.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000023#include "code_generator.h"
David Sehr9e734c72018-01-04 17:56:19 -080024#include "dex/dex_file_types.h"
Calin Juravlecd6dffe2015-01-08 17:35:35 +000025#include "driver/compiler_options.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000026#include "nodes.h"
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010027#include "parallel_move_resolver.h"
Nicolas Geoffray787c3072014-03-17 10:20:19 +000028#include "utils/x86/assembler_x86.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000029
Vladimir Markoe2727152019-10-10 10:46:42 +010030namespace art HIDDEN {
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000031namespace x86 {
32
Nicolas Geoffray86a8d7a2014-11-19 08:47:18 +000033// Use a local definition to prevent copying mistakes.
Andreas Gampe542451c2016-07-26 09:02:02 -070034static constexpr size_t kX86WordSize = static_cast<size_t>(kX86PointerSize);
Nicolas Geoffray707c8092014-04-04 10:50:14 +010035
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +010036class CodeGeneratorX86;
37
Nicolas Geoffraya747a392014-04-17 14:56:23 +010038static constexpr Register kParameterCoreRegisters[] = { ECX, EDX, EBX };
39static constexpr RegisterPair kParameterCorePairRegisters[] = { ECX_EDX, EDX_EBX };
40static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters);
Mark P Mendell966c3ae2015-01-27 15:45:27 +000041static constexpr XmmRegister kParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 };
42static constexpr size_t kParameterFpuRegistersLength = arraysize(kParameterFpuRegisters);
Nicolas Geoffraya747a392014-04-17 14:56:23 +010043
Nicolas Geoffrayd75948a2015-03-27 09:53:16 +000044static constexpr Register kRuntimeParameterCoreRegisters[] = { EAX, ECX, EDX, EBX };
45static constexpr size_t kRuntimeParameterCoreRegistersLength =
46 arraysize(kRuntimeParameterCoreRegisters);
47static constexpr XmmRegister kRuntimeParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 };
48static constexpr size_t kRuntimeParameterFpuRegistersLength =
49 arraysize(kRuntimeParameterFpuRegisters);
50
51class InvokeRuntimeCallingConvention : public CallingConvention<Register, XmmRegister> {
52 public:
53 InvokeRuntimeCallingConvention()
54 : CallingConvention(kRuntimeParameterCoreRegisters,
55 kRuntimeParameterCoreRegistersLength,
56 kRuntimeParameterFpuRegisters,
Mathieu Chartiere401d142015-04-22 13:56:20 -070057 kRuntimeParameterFpuRegistersLength,
58 kX86PointerSize) {}
Nicolas Geoffrayd75948a2015-03-27 09:53:16 +000059
60 private:
61 DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention);
62};
63
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010064class InvokeDexCallingConvention : public CallingConvention<Register, XmmRegister> {
Nicolas Geoffraya747a392014-04-17 14:56:23 +010065 public:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010066 InvokeDexCallingConvention() : CallingConvention(
67 kParameterCoreRegisters,
68 kParameterCoreRegistersLength,
69 kParameterFpuRegisters,
Mathieu Chartiere401d142015-04-22 13:56:20 -070070 kParameterFpuRegistersLength,
71 kX86PointerSize) {}
Nicolas Geoffraya747a392014-04-17 14:56:23 +010072
73 RegisterPair GetRegisterPairAt(size_t argument_index) {
74 DCHECK_LT(argument_index + 1, GetNumberOfRegisters());
75 return kParameterCorePairRegisters[argument_index];
76 }
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention);
80};
81
Roland Levillain2d27c8e2015-04-28 15:48:45 +010082class InvokeDexCallingConventionVisitorX86 : public InvokeDexCallingConventionVisitor {
Nicolas Geoffraya747a392014-04-17 14:56:23 +010083 public:
Roland Levillain2d27c8e2015-04-28 15:48:45 +010084 InvokeDexCallingConventionVisitorX86() {}
85 virtual ~InvokeDexCallingConventionVisitorX86() {}
Nicolas Geoffraya747a392014-04-17 14:56:23 +010086
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010087 Location GetNextLocation(DataType::Type type) override;
88 Location GetReturnLocation(DataType::Type type) const override;
89 Location GetMethodLocation() const override;
Nicolas Geoffraya747a392014-04-17 14:56:23 +010090
91 private:
92 InvokeDexCallingConvention calling_convention;
Nicolas Geoffraya747a392014-04-17 14:56:23 +010093
Roland Levillain2d27c8e2015-04-28 15:48:45 +010094 DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorX86);
Nicolas Geoffraya747a392014-04-17 14:56:23 +010095};
96
Calin Juravlee460d1d2015-09-29 04:52:17 +010097class FieldAccessCallingConventionX86 : public FieldAccessCallingConvention {
98 public:
99 FieldAccessCallingConventionX86() {}
100
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100101 Location GetObjectLocation() const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100102 return Location::RegisterLocation(ECX);
103 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100104 Location GetFieldIndexLocation() const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100105 return Location::RegisterLocation(EAX);
106 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100107 Location GetReturnLocation(DataType::Type type) const override {
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100108 return DataType::Is64BitType(type)
Calin Juravlee460d1d2015-09-29 04:52:17 +0100109 ? Location::RegisterPairLocation(EAX, EDX)
110 : Location::RegisterLocation(EAX);
111 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100112 Location GetSetValueLocation(DataType::Type type, bool is_instance) const override {
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100113 return DataType::Is64BitType(type)
Nicolas Geoffray5b3c6c02017-01-19 14:22:26 +0000114 ? (is_instance
115 ? Location::RegisterPairLocation(EDX, EBX)
116 : Location::RegisterPairLocation(ECX, EDX))
Calin Juravlee460d1d2015-09-29 04:52:17 +0100117 : (is_instance
118 ? Location::RegisterLocation(EDX)
119 : Location::RegisterLocation(ECX));
120 }
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100121 Location GetFpuLocation(DataType::Type type ATTRIBUTE_UNUSED) const override {
Calin Juravlee460d1d2015-09-29 04:52:17 +0100122 return Location::FpuRegisterLocation(XMM0);
123 }
124
125 private:
126 DISALLOW_COPY_AND_ASSIGN(FieldAccessCallingConventionX86);
127};
128
Zheng Xuad4450e2015-04-17 18:48:56 +0800129class ParallelMoveResolverX86 : public ParallelMoveResolverWithSwap {
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100130 public:
131 ParallelMoveResolverX86(ArenaAllocator* allocator, CodeGeneratorX86* codegen)
Zheng Xuad4450e2015-04-17 18:48:56 +0800132 : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {}
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100133
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100134 void EmitMove(size_t index) override;
135 void EmitSwap(size_t index) override;
136 void SpillScratch(int reg) override;
137 void RestoreScratch(int reg) override;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100138
139 X86Assembler* GetAssembler() const;
140
141 private:
142 void Exchange(Register reg, int mem);
Mark Mendell7c8d0092015-01-26 11:21:33 -0500143 void Exchange32(XmmRegister reg, int mem);
Aart Bikcfe50bb2017-12-12 14:54:12 -0800144 void Exchange128(XmmRegister reg, int mem);
145 void ExchangeMemory(int mem1, int mem2, int number_of_words);
146 void MoveMemoryToMemory(int dst, int src, int number_of_words);
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100147
148 CodeGeneratorX86* const codegen_;
149
150 DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverX86);
151};
152
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000153class LocationsBuilderX86 : public HGraphVisitor {
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000154 public:
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100155 LocationsBuilderX86(HGraph* graph, CodeGeneratorX86* codegen)
156 : HGraphVisitor(graph), codegen_(codegen) {}
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000157
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100158#define DECLARE_VISIT_INSTRUCTION(name, super) \
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100159 void Visit##name(H##name* instr) override;
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000160
Alexandre Ramesef20f712015-06-09 10:29:30 +0100161 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
162 FOR_EACH_CONCRETE_INSTRUCTION_X86(DECLARE_VISIT_INSTRUCTION)
Shalini Salomi Bodapatidd121f62018-10-26 15:03:53 +0530163 FOR_EACH_CONCRETE_INSTRUCTION_X86_COMMON(DECLARE_VISIT_INSTRUCTION)
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000164
165#undef DECLARE_VISIT_INSTRUCTION
166
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100167 void VisitInstruction(HInstruction* instruction) override {
Alexandre Ramesef20f712015-06-09 10:29:30 +0100168 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
169 << " (id " << instruction->GetId() << ")";
170 }
171
Nicolas Geoffray9574c4b2014-11-12 13:19:37 +0000172 private:
173 void HandleBitwiseOperation(HBinaryOperation* instruction);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100174 void HandleInvoke(HInvoke* invoke);
Vladimir Marko5f7b58e2015-11-23 19:49:34 +0000175 void HandleCondition(HCondition* condition);
Calin Juravle9aec02f2014-11-18 23:06:35 +0000176 void HandleShift(HBinaryOperation* instruction);
Calin Juravle52c48962014-12-16 17:02:57 +0000177 void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info);
178 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
Shalini Salomi Bodapatib45a4352019-07-10 16:09:41 +0530179 bool CpuHasAvxFeatureFlag();
180 bool CpuHasAvx2FeatureFlag();
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100181
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100182 CodeGeneratorX86* const codegen_;
Roland Levillain2d27c8e2015-04-28 15:48:45 +0100183 InvokeDexCallingConventionVisitorX86 parameter_visitor_;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100184
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000185 DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86);
186};
187
Aart Bik42249c32016-01-07 15:33:50 -0800188class InstructionCodeGeneratorX86 : public InstructionCodeGenerator {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000189 public:
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100190 InstructionCodeGeneratorX86(HGraph* graph, CodeGeneratorX86* codegen);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000191
Nicolas Geoffray360231a2014-10-08 21:07:48 +0100192#define DECLARE_VISIT_INSTRUCTION(name, super) \
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100193 void Visit##name(H##name* instr) override;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000194
Alexandre Ramesef20f712015-06-09 10:29:30 +0100195 FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
196 FOR_EACH_CONCRETE_INSTRUCTION_X86(DECLARE_VISIT_INSTRUCTION)
Shalini Salomi Bodapatidd121f62018-10-26 15:03:53 +0530197 FOR_EACH_CONCRETE_INSTRUCTION_X86_COMMON(DECLARE_VISIT_INSTRUCTION)
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000198
199#undef DECLARE_VISIT_INSTRUCTION
200
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100201 void VisitInstruction(HInstruction* instruction) override {
Alexandre Ramesef20f712015-06-09 10:29:30 +0100202 LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
203 << " (id " << instruction->GetId() << ")";
204 }
205
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100206 X86Assembler* GetAssembler() const { return assembler_; }
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000207
Vladimir Markof3e0ee22015-12-17 15:23:13 +0000208 // The compare/jump sequence will generate about (1.5 * num_entries) instructions. A jump
209 // table version generates 7 instructions and num_entries literals. Compare/jump sequence will
210 // generates less code/data with a small num_entries.
211 static constexpr uint32_t kPackedSwitchJumpTableThreshold = 5;
212
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000213 private:
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100214 // Generate code for the given suspend check. If not null, `successor`
215 // is the block to branch to if the suspend check is not needed, and after
216 // the suspend call.
217 void GenerateSuspendCheck(HSuspendCheck* check, HBasicBlock* successor);
Andreas Gampe85b62f22015-09-09 13:15:38 -0700218 void GenerateClassInitializationCheck(SlowPathCode* slow_path, Register class_reg);
Vladimir Marko175e7862018-03-27 09:03:13 +0000219 void GenerateBitstringTypeCheckCompare(HTypeCheckInstruction* check, Register temp);
Nicolas Geoffray9574c4b2014-11-12 13:19:37 +0000220 void HandleBitwiseOperation(HBinaryOperation* instruction);
Calin Juravlebacfec32014-11-14 15:54:36 +0000221 void GenerateDivRemIntegral(HBinaryOperation* instruction);
Guillaume Sanchez0f88e872015-03-30 17:55:45 +0100222 void DivRemOneOrMinusOne(HBinaryOperation* instruction);
Guillaume Sanchezb19930c2015-04-09 21:12:15 +0100223 void DivByPowerOfTwo(HDiv* instruction);
Shalini Salomi Bodapatia66784b2018-11-06 13:05:44 +0530224 void RemByPowerOfTwo(HRem* instruction);
Guillaume Sanchez0f88e872015-03-30 17:55:45 +0100225 void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction);
Mark Mendellc4701932015-04-10 13:18:51 -0400226 void GenerateRemFP(HRem* rem);
Vladimir Marko5f7b58e2015-11-23 19:49:34 +0000227 void HandleCondition(HCondition* condition);
Calin Juravle9aec02f2014-11-18 23:06:35 +0000228 void HandleShift(HBinaryOperation* instruction);
229 void GenerateShlLong(const Location& loc, Register shifter);
230 void GenerateShrLong(const Location& loc, Register shifter);
231 void GenerateUShrLong(const Location& loc, Register shifter);
Mark P Mendell73945692015-04-29 14:56:17 +0000232 void GenerateShlLong(const Location& loc, int shift);
233 void GenerateShrLong(const Location& loc, int shift);
234 void GenerateUShrLong(const Location& loc, int shift);
Aart Bik351df3e2018-03-07 11:54:57 -0800235 void GenerateMinMaxInt(LocationSummary* locations, bool is_min, DataType::Type type);
Aart Bik1f8d51b2018-02-15 10:42:37 -0800236 void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type);
Aart Bik351df3e2018-03-07 11:54:57 -0800237 void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
Roland Levillain7c1559a2015-12-15 10:55:36 +0000238
Nicolas Geoffray07276db2015-05-18 14:22:09 +0100239 void HandleFieldSet(HInstruction* instruction,
240 const FieldInfo& field_info,
241 bool value_can_be_null);
Calin Juravle52c48962014-12-16 17:02:57 +0000242 void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
Roland Levillain7c1559a2015-12-15 10:55:36 +0000243
244 // Generate a heap reference load using one register `out`:
245 //
246 // out <- *(out + offset)
247 //
248 // while honoring heap poisoning and/or read barriers (if any).
Roland Levillain95e7ffc2016-01-22 11:57:25 +0000249 //
250 // Location `maybe_temp` is used when generating a read barrier and
251 // shall be a register in that case; it may be an invalid location
252 // otherwise.
Roland Levillain7c1559a2015-12-15 10:55:36 +0000253 void GenerateReferenceLoadOneRegister(HInstruction* instruction,
254 Location out,
255 uint32_t offset,
Mathieu Chartieraa474eb2016-11-09 15:18:27 -0800256 Location maybe_temp,
Mathieu Chartier3af00dc2016-11-10 11:25:57 -0800257 ReadBarrierOption read_barrier_option);
Roland Levillain7c1559a2015-12-15 10:55:36 +0000258 // Generate a heap reference load using two different registers
259 // `out` and `obj`:
260 //
261 // out <- *(obj + offset)
262 //
263 // while honoring heap poisoning and/or read barriers (if any).
Roland Levillain95e7ffc2016-01-22 11:57:25 +0000264 //
265 // Location `maybe_temp` is used when generating a Baker's (fast
266 // path) read barrier and shall be a register in that case; it may
267 // be an invalid location otherwise.
Roland Levillain7c1559a2015-12-15 10:55:36 +0000268 void GenerateReferenceLoadTwoRegisters(HInstruction* instruction,
269 Location out,
270 Location obj,
Mathieu Chartier5c44c1b2016-11-04 18:13:04 -0700271 uint32_t offset,
Mathieu Chartier3af00dc2016-11-10 11:25:57 -0800272 ReadBarrierOption read_barrier_option);
Roland Levillain7c1559a2015-12-15 10:55:36 +0000273 // Generate a GC root reference load:
274 //
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000275 // root <- *address
Roland Levillain7c1559a2015-12-15 10:55:36 +0000276 //
Mathieu Chartier3af00dc2016-11-10 11:25:57 -0800277 // while honoring read barriers based on read_barrier_option.
Roland Levillain7c1559a2015-12-15 10:55:36 +0000278 void GenerateGcRootFieldLoad(HInstruction* instruction,
279 Location root,
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000280 const Address& address,
Roland Levillain00468f32016-10-27 18:02:48 +0100281 Label* fixup_label,
Mathieu Chartier3af00dc2016-11-10 11:25:57 -0800282 ReadBarrierOption read_barrier_option);
Roland Levillain7c1559a2015-12-15 10:55:36 +0000283
Roland Levillain232ade02015-04-20 15:14:36 +0100284 // Push value to FPU stack. `is_fp` specifies whether the value is floating point or not.
285 // `is_wide` specifies whether it is long/double or not.
Mark Mendell24f2dfa2015-01-14 19:51:45 -0500286 void PushOntoFPStack(Location source, uint32_t temp_offset,
Roland Levillain232ade02015-04-20 15:14:36 +0100287 uint32_t stack_adjustment, bool is_fp, bool is_wide);
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100288
Mark Mendell152408f2015-12-31 12:28:50 -0500289 template<class LabelType>
Mingyao Yangd43b3ac2015-04-01 14:03:04 -0700290 void GenerateTestAndBranch(HInstruction* instruction,
David Brazdil0debae72015-11-12 18:37:00 +0000291 size_t condition_input_index,
Mark Mendell152408f2015-12-31 12:28:50 -0500292 LabelType* true_target,
293 LabelType* false_target);
294 template<class LabelType>
David Brazdil0debae72015-11-12 18:37:00 +0000295 void GenerateCompareTestAndBranch(HCondition* condition,
Mark Mendell152408f2015-12-31 12:28:50 -0500296 LabelType* true_target,
297 LabelType* false_target);
298 template<class LabelType>
299 void GenerateFPJumps(HCondition* cond, LabelType* true_label, LabelType* false_label);
300 template<class LabelType>
301 void GenerateLongComparesAndJumps(HCondition* cond,
302 LabelType* true_label,
303 LabelType* false_label);
304
David Brazdilfc6a86a2015-06-26 10:33:45 +0000305 void HandleGoto(HInstruction* got, HBasicBlock* successor);
Vladimir Markof3e0ee22015-12-17 15:23:13 +0000306 void GenPackedSwitchWithCompares(Register value_reg,
307 int32_t lower_bound,
308 uint32_t num_entries,
309 HBasicBlock* switch_block,
310 HBasicBlock* default_block);
Calin Juravlecd6dffe2015-01-08 17:35:35 +0000311
Mark P Mendell2f10a5f2016-01-25 14:47:50 +0000312 void GenerateFPCompare(Location lhs, Location rhs, HInstruction* insn, bool is_double);
Shalini Salomi Bodapatib45a4352019-07-10 16:09:41 +0530313 bool CpuHasAvxFeatureFlag();
314 bool CpuHasAvx2FeatureFlag();
Mark P Mendell2f10a5f2016-01-25 14:47:50 +0000315
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100316 X86Assembler* const assembler_;
317 CodeGeneratorX86* const codegen_;
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000318
319 DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorX86);
320};
321
Mark Mendell805b3b52015-09-18 14:10:29 -0400322class JumpTableRIPFixup;
323
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000324class CodeGeneratorX86 : public CodeGenerator {
325 public:
Mark Mendellfb8d2792015-03-31 22:16:59 -0400326 CodeGeneratorX86(HGraph* graph,
Serban Constantinescuecc43662015-08-13 13:33:12 +0100327 const CompilerOptions& compiler_options,
328 OptimizingCompilerStats* stats = nullptr);
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100329 virtual ~CodeGeneratorX86() {}
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000330
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100331 void GenerateFrameEntry() override;
332 void GenerateFrameExit() override;
333 void Bind(HBasicBlock* block) override;
334 void MoveConstant(Location destination, int32_t value) override;
335 void MoveLocation(Location dst, Location src, DataType::Type dst_type) override;
336 void AddLocationAsTemp(Location location, LocationSummary* locations) override;
Calin Juravlee460d1d2015-09-29 04:52:17 +0100337
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100338 size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) override;
339 size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) override;
340 size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) override;
341 size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) override;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000342
Alexandre Rames8158f282015-08-07 10:26:17 +0100343 // Generate code to invoke a runtime entry point.
Calin Juravle175dc732015-08-25 15:42:32 +0100344 void InvokeRuntime(QuickEntrypointEnum entrypoint,
345 HInstruction* instruction,
346 uint32_t dex_pc,
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100347 SlowPathCode* slow_path = nullptr) override;
Alexandre Rames8158f282015-08-07 10:26:17 +0100348
Roland Levillaindec8f632016-07-22 17:10:06 +0100349 // Generate code to invoke a runtime entry point, but do not record
350 // PC-related information in a stack map.
351 void InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset,
352 HInstruction* instruction,
353 SlowPathCode* slow_path);
354
Serban Constantinescuba45db02016-07-12 22:53:02 +0100355 void GenerateInvokeRuntime(int32_t entry_point_offset);
356
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100357 size_t GetWordSize() const override {
Nicolas Geoffray707c8092014-04-04 10:50:14 +0100358 return kX86WordSize;
359 }
360
Artem Serov6a0b6572019-07-26 20:38:37 +0100361 size_t GetSlowPathFPWidth() const override {
Aart Bikb13c65b2017-03-21 20:14:07 -0700362 return GetGraph()->HasSIMD()
363 ? 4 * kX86WordSize // 16 bytes == 4 words for each spill
364 : 2 * kX86WordSize; // 8 bytes == 2 words for each spill
Mark Mendellf85a9ca2015-01-13 09:20:58 -0500365 }
366
Artem Serov6a0b6572019-07-26 20:38:37 +0100367 size_t GetCalleePreservedFPWidth() const override {
368 return 2 * kX86WordSize;
369 }
370
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100371 HGraphVisitor* GetLocationBuilder() override {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000372 return &location_builder_;
373 }
374
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100375 HGraphVisitor* GetInstructionVisitor() override {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000376 return &instruction_visitor_;
377 }
378
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100379 X86Assembler* GetAssembler() override {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000380 return &assembler_;
381 }
382
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100383 const X86Assembler& GetAssembler() const override {
Alexandre Rameseb7b7392015-06-19 14:47:01 +0100384 return assembler_;
385 }
386
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100387 uintptr_t GetAddressOf(HBasicBlock* block) override {
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000388 return GetLabelOf(block)->Position();
389 }
Calin Juravle34bacdf2014-10-07 20:23:36 +0100390
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100391 void SetupBlockedRegisters() const override;
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100392
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100393 void DumpCoreRegister(std::ostream& stream, int reg) const override;
394 void DumpFloatingPointRegister(std::ostream& stream, int reg) const override;
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100395
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100396 ParallelMoveResolverX86* GetMoveResolver() override {
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100397 return &move_resolver_;
398 }
399
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100400 InstructionSet GetInstructionSet() const override {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100401 return InstructionSet::kX86;
402 }
403
Vladimir Markoa0431112018-06-25 09:32:54 +0100404 const X86InstructionSetFeatures& GetInstructionSetFeatures() const;
405
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100406 // Helper method to move a 32bits value between two locations.
407 void Move32(Location destination, Location source);
408 // Helper method to move a 64bits value between two locations.
409 void Move64(Location destination, Location source);
410
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000411 // Check if the desired_string_load_kind is supported. If it is, return it,
412 // otherwise return a fall-back kind that should be used instead.
413 HLoadString::LoadKind GetSupportedLoadStringKind(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100414 HLoadString::LoadKind desired_string_load_kind) override;
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000415
Vladimir Markodbb7f5b2016-03-30 13:23:58 +0100416 // Check if the desired_class_load_kind is supported. If it is, return it,
417 // otherwise return a fall-back kind that should be used instead.
418 HLoadClass::LoadKind GetSupportedLoadClassKind(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100419 HLoadClass::LoadKind desired_class_load_kind) override;
Vladimir Markodbb7f5b2016-03-30 13:23:58 +0100420
Vladimir Markodc151b22015-10-15 18:02:30 +0100421 // Check if the desired_dispatch_info is supported. If it is, return it,
422 // otherwise return a fall-back info that should be used instead.
423 HInvokeStaticOrDirect::DispatchInfo GetSupportedInvokeStaticOrDirectDispatch(
424 const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info,
Nicolas Geoffraybdb2ecc2018-09-18 14:33:55 +0100425 ArtMethod* method) override;
Vladimir Markodc151b22015-10-15 18:02:30 +0100426
Mark Mendell09ed1a32015-03-25 08:30:06 -0400427 // Generate a call to a static or direct method.
Vladimir Markoe7197bf2017-06-02 17:00:23 +0100428 void GenerateStaticOrDirectCall(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100429 HInvokeStaticOrDirect* invoke, Location temp, SlowPathCode* slow_path = nullptr) override;
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000430 // Generate a call to a virtual method.
Vladimir Markoe7197bf2017-06-02 17:00:23 +0100431 void GenerateVirtualCall(
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100432 HInvokeVirtual* invoke, Location temp, SlowPathCode* slow_path = nullptr) override;
Andreas Gampe85b62f22015-09-09 13:15:38 -0700433
Vladimir Marko6fd16062018-06-26 11:02:04 +0100434 void RecordBootImageIntrinsicPatch(HX86ComputeBaseMethodAddress* method_address,
435 uint32_t intrinsic_data);
Vladimir Markob066d432018-01-03 13:14:37 +0000436 void RecordBootImageRelRoPatch(HX86ComputeBaseMethodAddress* method_address,
437 uint32_t boot_image_offset);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000438 void RecordBootImageMethodPatch(HInvokeStaticOrDirect* invoke);
439 void RecordMethodBssEntryPatch(HInvokeStaticOrDirect* invoke);
440 void RecordBootImageTypePatch(HLoadClass* load_class);
Vladimir Marko6bec91c2017-01-09 15:03:12 +0000441 Label* NewTypeBssEntryPatch(HLoadClass* load_class);
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000442 void RecordBootImageStringPatch(HLoadString* load_string);
Vladimir Markoaad75c62016-10-03 08:46:48 +0000443 Label* NewStringBssEntryPatch(HLoadString* load_string);
Vladimir Markoeebb8212018-06-05 14:57:24 +0100444
445 void LoadBootImageAddress(Register reg,
Vladimir Marko6fd16062018-06-26 11:02:04 +0100446 uint32_t boot_image_reference,
Vladimir Markoeebb8212018-06-05 14:57:24 +0100447 HInvokeStaticOrDirect* invoke);
Vladimir Marko6fd16062018-06-26 11:02:04 +0100448 void AllocateInstanceForIntrinsic(HInvokeStaticOrDirect* invoke, uint32_t boot_image_offset);
Vladimir Markoeebb8212018-06-05 14:57:24 +0100449
Nicolas Geoffrayf0acfe72017-01-09 20:54:52 +0000450 Label* NewJitRootStringPatch(const DexFile& dex_file,
Vladimir Marko174b2e22017-10-12 13:34:49 +0100451 dex::StringIndex string_index,
Nicolas Geoffrayf0acfe72017-01-09 20:54:52 +0000452 Handle<mirror::String> handle);
Nicolas Geoffray5247c082017-01-13 14:17:29 +0000453 Label* NewJitRootClassPatch(const DexFile& dex_file,
Vladimir Marko174b2e22017-10-12 13:34:49 +0100454 dex::TypeIndex type_index,
Nicolas Geoffray5247c082017-01-13 14:17:29 +0000455 Handle<mirror::Class> handle);
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000456
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100457 void MoveFromReturnRegister(Location trg, DataType::Type type) override;
Mark Mendell09ed1a32015-03-25 08:30:06 -0400458
Vladimir Marko58155012015-08-19 12:49:41 +0000459 // Emit linker patches.
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100460 void EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linker_patches) override;
Vladimir Marko58155012015-08-19 12:49:41 +0000461
Nicolas Geoffray22384ae2016-12-12 22:33:36 +0000462 void PatchJitRootUse(uint8_t* code,
463 const uint8_t* roots_data,
464 const PatchInfo<Label>& info,
465 uint64_t index_in_table) const;
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100466 void EmitJitRootPatches(uint8_t* code, const uint8_t* roots_data) override;
Nicolas Geoffray132d8362016-11-16 09:19:42 +0000467
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100468 // Emit a write barrier.
Nicolas Geoffray07276db2015-05-18 14:22:09 +0100469 void MarkGCCard(Register temp,
470 Register card,
471 Register object,
472 Register value,
473 bool value_can_be_null);
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100474
Roland Levillain7c1559a2015-12-15 10:55:36 +0000475 void GenerateMemoryBarrier(MemBarrierKind kind);
476
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100477 Label* GetLabelOf(HBasicBlock* block) const {
Vladimir Marko225b6462015-09-28 12:17:40 +0100478 return CommonGetLabelOf<Label>(block_labels_, block);
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100479 }
480
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100481 void Initialize() override {
Vladimir Marko225b6462015-09-28 12:17:40 +0100482 block_labels_ = CommonInitializeLabels<Label>();
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100483 }
484
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100485 bool NeedsTwoRegisters(DataType::Type type) const override {
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100486 return type == DataType::Type::kInt64;
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000487 }
488
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100489 bool ShouldSplitLongMoves() const override { return true; }
Nicolas Geoffray234d69d2015-03-09 10:28:50 +0000490
Nicolas Geoffray1cf95282014-12-12 19:22:03 +0000491 Label* GetFrameEntryLabel() { return &frame_entry_label_; }
492
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000493 void AddMethodAddressOffset(HX86ComputeBaseMethodAddress* method_base, int32_t offset) {
494 method_address_offset_.Put(method_base->GetId(), offset);
Mark Mendell0616ae02015-04-17 12:49:27 -0400495 }
496
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000497 int32_t GetMethodAddressOffset(HX86ComputeBaseMethodAddress* method_base) const {
498 return method_address_offset_.Get(method_base->GetId());
Mark Mendell0616ae02015-04-17 12:49:27 -0400499 }
500
501 int32_t ConstantAreaStart() const {
502 return constant_area_start_;
503 }
504
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000505 Address LiteralDoubleAddress(double v, HX86ComputeBaseMethodAddress* method_base, Register reg);
506 Address LiteralFloatAddress(float v, HX86ComputeBaseMethodAddress* method_base, Register reg);
507 Address LiteralInt32Address(int32_t v, HX86ComputeBaseMethodAddress* method_base, Register reg);
508 Address LiteralInt64Address(int64_t v, HX86ComputeBaseMethodAddress* method_base, Register reg);
Mark Mendell0616ae02015-04-17 12:49:27 -0400509
Aart Bika19616e2016-02-01 18:57:58 -0800510 // Load a 32-bit value into a register in the most efficient manner.
511 void Load32BitValue(Register dest, int32_t value);
512
513 // Compare a register with a 32-bit value in the most efficient manner.
514 void Compare32BitValue(Register dest, int32_t value);
515
Vladimir Marko56f4bdd2016-09-16 11:32:36 +0100516 // Compare int values. Supports only register locations for `lhs`.
517 void GenerateIntCompare(Location lhs, Location rhs);
jessicahandojo4877b792016-09-08 19:49:13 -0700518 void GenerateIntCompare(Register lhs, Location rhs);
Vladimir Marko56f4bdd2016-09-16 11:32:36 +0100519
520 // Construct address for array access.
521 static Address ArrayAddress(Register obj,
522 Location index,
523 ScaleFactor scale,
524 uint32_t data_offset);
525
Mark Mendell805b3b52015-09-18 14:10:29 -0400526 Address LiteralCaseTable(HX86PackedSwitch* switch_instr, Register reg, Register value);
527
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100528 void Finalize(CodeAllocator* allocator) override;
Mark Mendell0616ae02015-04-17 12:49:27 -0400529
Roland Levillain7c1559a2015-12-15 10:55:36 +0000530 // Fast path implementation of ReadBarrier::Barrier for a heap
531 // reference field load when Baker's read barriers are used.
532 void GenerateFieldLoadWithBakerReadBarrier(HInstruction* instruction,
Roland Levillaine3f43ac2016-01-19 15:07:47 +0000533 Location ref,
Roland Levillain7c1559a2015-12-15 10:55:36 +0000534 Register obj,
535 uint32_t offset,
Roland Levillain7c1559a2015-12-15 10:55:36 +0000536 bool needs_null_check);
537 // Fast path implementation of ReadBarrier::Barrier for a heap
538 // reference array load when Baker's read barriers are used.
539 void GenerateArrayLoadWithBakerReadBarrier(HInstruction* instruction,
Roland Levillaine3f43ac2016-01-19 15:07:47 +0000540 Location ref,
Roland Levillain7c1559a2015-12-15 10:55:36 +0000541 Register obj,
542 uint32_t data_offset,
543 Location index,
Roland Levillain7c1559a2015-12-15 10:55:36 +0000544 bool needs_null_check);
Roland Levillaina1aa3b12016-10-26 13:03:38 +0100545 // Factored implementation, used by GenerateFieldLoadWithBakerReadBarrier,
546 // GenerateArrayLoadWithBakerReadBarrier and some intrinsics.
547 //
548 // Load the object reference located at address `src`, held by
549 // object `obj`, into `ref`, and mark it if needed. The base of
550 // address `src` must be `obj`.
551 //
552 // If `always_update_field` is true, the value of the reference is
553 // atomically updated in the holder (`obj`). This operation
554 // requires a temporary register, which must be provided as a
555 // non-null pointer (`temp`).
Sang, Chunlei0fcd2b82016-04-05 17:12:59 +0800556 void GenerateReferenceLoadWithBakerReadBarrier(HInstruction* instruction,
557 Location ref,
558 Register obj,
559 const Address& src,
Roland Levillaina1aa3b12016-10-26 13:03:38 +0100560 bool needs_null_check,
561 bool always_update_field = false,
562 Register* temp = nullptr);
Roland Levillain7c1559a2015-12-15 10:55:36 +0000563
564 // Generate a read barrier for a heap reference within `instruction`
565 // using a slow path.
Roland Levillain0d5a2812015-11-13 10:07:31 +0000566 //
567 // A read barrier for an object reference read from the heap is
568 // implemented as a call to the artReadBarrierSlow runtime entry
569 // point, which is passed the values in locations `ref`, `obj`, and
570 // `offset`:
571 //
572 // mirror::Object* artReadBarrierSlow(mirror::Object* ref,
573 // mirror::Object* obj,
574 // uint32_t offset);
575 //
576 // The `out` location contains the value returned by
577 // artReadBarrierSlow.
578 //
579 // When `index` is provided (i.e. for array accesses), the offset
580 // value passed to artReadBarrierSlow is adjusted to take `index`
581 // into account.
Roland Levillain7c1559a2015-12-15 10:55:36 +0000582 void GenerateReadBarrierSlow(HInstruction* instruction,
583 Location out,
584 Location ref,
585 Location obj,
586 uint32_t offset,
587 Location index = Location::NoLocation());
Roland Levillain0d5a2812015-11-13 10:07:31 +0000588
Roland Levillain7c1559a2015-12-15 10:55:36 +0000589 // If read barriers are enabled, generate a read barrier for a heap
590 // reference using a slow path. If heap poisoning is enabled, also
591 // unpoison the reference in `out`.
592 void MaybeGenerateReadBarrierSlow(HInstruction* instruction,
593 Location out,
594 Location ref,
595 Location obj,
596 uint32_t offset,
597 Location index = Location::NoLocation());
Roland Levillain0d5a2812015-11-13 10:07:31 +0000598
Roland Levillain7c1559a2015-12-15 10:55:36 +0000599 // Generate a read barrier for a GC root within `instruction` using
600 // a slow path.
Roland Levillain0d5a2812015-11-13 10:07:31 +0000601 //
602 // A read barrier for an object reference GC root is implemented as
603 // a call to the artReadBarrierForRootSlow runtime entry point,
604 // which is passed the value in location `root`:
605 //
606 // mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root);
607 //
608 // The `out` location contains the value returned by
609 // artReadBarrierForRootSlow.
Roland Levillain7c1559a2015-12-15 10:55:36 +0000610 void GenerateReadBarrierForRootSlow(HInstruction* instruction, Location out, Location root);
Roland Levillain0d5a2812015-11-13 10:07:31 +0000611
Mark P Mendell17077d82015-12-16 19:15:59 +0000612 // Ensure that prior stores complete to memory before subsequent loads.
613 // The locked add implementation will avoid serializing device memory, but will
614 // touch (but not change) the top of the stack.
615 // The 'non_temporal' parameter should be used to ensure ordering of non-temporal stores.
616 void MemoryFence(bool non_temporal = false) {
Mark Mendell7aa04a12016-01-27 22:39:07 -0500617 if (!non_temporal) {
Mark P Mendell17077d82015-12-16 19:15:59 +0000618 assembler_.lock()->addl(Address(ESP, 0), Immediate(0));
619 } else {
620 assembler_.mfence();
621 }
622 }
623
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100624 void GenerateNop() override;
625 void GenerateImplicitNullCheck(HNullCheck* instruction) override;
626 void GenerateExplicitNullCheck(HNullCheck* instruction) override;
Mark P Mendell17077d82015-12-16 19:15:59 +0000627
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000628 // When we don't know the proper offset for the value, we use kDummy32BitOffset.
629 // The correct value will be inserted when processing Assembler fixups.
630 static constexpr int32_t kDummy32BitOffset = 256;
631
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100632 private:
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000633 struct X86PcRelativePatchInfo : PatchInfo<Label> {
634 X86PcRelativePatchInfo(HX86ComputeBaseMethodAddress* address,
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000635 const DexFile* target_dex_file,
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000636 uint32_t target_index)
637 : PatchInfo(target_dex_file, target_index),
638 method_address(address) {}
639 HX86ComputeBaseMethodAddress* method_address;
640 };
Vladimir Marko0f7dca42015-11-02 14:36:43 +0000641
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100642 template <linker::LinkerPatch (*Factory)(size_t, const DexFile*, uint32_t, uint32_t)>
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000643 void EmitPcRelativeLinkerPatches(const ArenaDeque<X86PcRelativePatchInfo>& infos,
Vladimir Markod8dbc8d2017-09-20 13:37:47 +0100644 ArenaVector<linker::LinkerPatch>* linker_patches);
Vladimir Marko0f7dca42015-11-02 14:36:43 +0000645
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000646 Register GetInvokeStaticOrDirectExtraParameter(HInvokeStaticOrDirect* invoke, Register temp);
647
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100648 // Labels for each block that will be compiled.
Vladimir Marko225b6462015-09-28 12:17:40 +0100649 Label* block_labels_; // Indexed by block id.
Nicolas Geoffray1cf95282014-12-12 19:22:03 +0000650 Label frame_entry_label_;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000651 LocationsBuilderX86 location_builder_;
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000652 InstructionCodeGeneratorX86 instruction_visitor_;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100653 ParallelMoveResolverX86 move_resolver_;
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000654 X86Assembler assembler_;
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000655
Vladimir Marko2d06e022019-07-08 15:45:19 +0100656 // PC-relative method patch info for kBootImageLinkTimePcRelative.
Vladimir Marko65979462017-05-19 17:25:12 +0100657 ArenaDeque<X86PcRelativePatchInfo> boot_image_method_patches_;
Vladimir Marko0eb882b2017-05-15 13:39:18 +0100658 // PC-relative method patch info for kBssEntry.
659 ArenaDeque<X86PcRelativePatchInfo> method_bss_entry_patches_;
Vladimir Marko764d4542017-05-16 10:31:41 +0100660 // PC-relative type patch info for kBootImageLinkTimePcRelative.
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000661 ArenaDeque<X86PcRelativePatchInfo> boot_image_type_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000662 // PC-relative type patch info for kBssEntry.
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000663 ArenaDeque<X86PcRelativePatchInfo> type_bss_entry_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000664 // PC-relative String patch info for kBootImageLinkTimePcRelative.
Vladimir Marko59eb30f2018-02-20 11:52:34 +0000665 ArenaDeque<X86PcRelativePatchInfo> boot_image_string_patches_;
Vladimir Markoe47f60c2018-02-21 13:43:28 +0000666 // PC-relative String patch info for kBssEntry.
Vladimir Marko6cfbdbc2017-07-25 13:26:39 +0100667 ArenaDeque<X86PcRelativePatchInfo> string_bss_entry_patches_;
Vladimir Marko2d06e022019-07-08 15:45:19 +0100668 // PC-relative patch info for IntrinsicObjects for the boot image,
669 // and for method/type/string patches for kBootImageRelRo otherwise.
670 ArenaDeque<X86PcRelativePatchInfo> boot_image_other_patches_;
Vladimir Marko58155012015-08-19 12:49:41 +0000671
Nicolas Geoffray132d8362016-11-16 09:19:42 +0000672 // Patches for string root accesses in JIT compiled code.
673 ArenaDeque<PatchInfo<Label>> jit_string_patches_;
Nicolas Geoffray22384ae2016-12-12 22:33:36 +0000674 // Patches for class root accesses in JIT compiled code.
675 ArenaDeque<PatchInfo<Label>> jit_class_patches_;
676
Mark Mendell0616ae02015-04-17 12:49:27 -0400677 // Offset to the start of the constant area in the assembled code.
678 // Used for fixups to the constant area.
679 int32_t constant_area_start_;
680
Mark Mendell805b3b52015-09-18 14:10:29 -0400681 // Fixups for jump tables that need to be patched after the constant table is generated.
682 ArenaVector<JumpTableRIPFixup*> fixups_to_jump_tables_;
683
Nicolas Geoffray133719e2017-01-22 15:44:39 +0000684 // Maps a HX86ComputeBaseMethodAddress instruction id, to its offset in the
685 // compiled code.
686 ArenaSafeMap<uint32_t, int32_t> method_address_offset_;
Mark Mendell0616ae02015-04-17 12:49:27 -0400687
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000688 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86);
689};
690
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000691} // namespace x86
692} // namespace art
693
694#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_