code_generator_x86.h revision 9574c4b5f5ef039d694ac12c97e25ca02eca83c0
1d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray/*
2d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project
3d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray *
4d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License");
5d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * you may not use this file except in compliance with the License.
6d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * You may obtain a copy of the License at
7d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray *
8d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray *      http://www.apache.org/licenses/LICENSE-2.0
9d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray *
10d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software
11d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS,
12d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * See the License for the specific language governing permissions and
14d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray * limitations under the License.
15d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray */
16d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
17d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#ifndef ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_
18d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_
19d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
20d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#include "code_generator.h"
21d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#include "nodes.h"
2286dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray#include "parallel_move_resolver.h"
23787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray#include "utils/x86/assembler_x86.h"
24d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
25d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffraynamespace art {
26d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffraynamespace x86 {
27d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
28707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffraystatic constexpr size_t kX86WordSize = 4;
29707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray
3001bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffrayclass CodeGeneratorX86;
31424f676379f2f872acd1478672022f19f3240fc1Nicolas Geoffrayclass SlowPathCodeX86;
3201bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray
33a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffraystatic constexpr Register kParameterCoreRegisters[] = { ECX, EDX, EBX };
34a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffraystatic constexpr RegisterPair kParameterCorePairRegisters[] = { ECX_EDX, EDX_EBX };
35a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffraystatic constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters);
367fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffraystatic constexpr XmmRegister kParameterFpuRegisters[] = { };
377fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffraystatic constexpr size_t kParameterFpuRegistersLength = 0;
38a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
397fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffrayclass InvokeDexCallingConvention : public CallingConvention<Register, XmmRegister> {
40a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray public:
417fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray  InvokeDexCallingConvention() : CallingConvention(
427fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray      kParameterCoreRegisters,
437fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray      kParameterCoreRegistersLength,
447fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray      kParameterFpuRegisters,
457fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray      kParameterFpuRegistersLength) {}
46a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
47a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  RegisterPair GetRegisterPairAt(size_t argument_index) {
48a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray    DCHECK_LT(argument_index + 1, GetNumberOfRegisters());
49a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray    return kParameterCorePairRegisters[argument_index];
50a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  }
51a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
52a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray private:
53a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention);
54a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray};
55a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
56a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffrayclass InvokeDexCallingConventionVisitor {
57a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray public:
58a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  InvokeDexCallingConventionVisitor() : gp_index_(0) {}
59a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
60a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  Location GetNextLocation(Primitive::Type type);
61a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
62a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray private:
63a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  InvokeDexCallingConvention calling_convention;
64a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  uint32_t gp_index_;
65a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
66a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor);
67a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray};
68a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray
6986dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffrayclass ParallelMoveResolverX86 : public ParallelMoveResolver {
7086dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray public:
7186dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  ParallelMoveResolverX86(ArenaAllocator* allocator, CodeGeneratorX86* codegen)
7286dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray      : ParallelMoveResolver(allocator), codegen_(codegen) {}
7386dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
74de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void EmitMove(size_t index) OVERRIDE;
75de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void EmitSwap(size_t index) OVERRIDE;
76de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void SpillScratch(int reg) OVERRIDE;
77de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void RestoreScratch(int reg) OVERRIDE;
7886dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
7986dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  X86Assembler* GetAssembler() const;
8086dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
8186dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray private:
8286dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  void Exchange(Register reg, int mem);
8386dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  void Exchange(int mem1, int mem2);
8486dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  void MoveMemoryToMemory(int dst, int src);
8586dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
8686dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  CodeGeneratorX86* const codegen_;
8786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
8886dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverX86);
8986dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray};
9086dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
91bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffrayclass LocationsBuilderX86 : public HGraphVisitor {
92bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray public:
9301bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray  LocationsBuilderX86(HGraph* graph, CodeGeneratorX86* codegen)
9401bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray      : HGraphVisitor(graph), codegen_(codegen) {}
95bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
96360231a056e796c36ffe62348507e904dc9efb9bNicolas Geoffray#define DECLARE_VISIT_INSTRUCTION(name, super)     \
97de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void Visit##name(H##name* instr) OVERRIDE;
98bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
9996f89a290eb67d7bf4b1636798fa28df14309cc7Nicolas Geoffray  FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_VISIT_INSTRUCTION)
100bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
101bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray#undef DECLARE_VISIT_INSTRUCTION
102bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
1039574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray private:
1049574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  void HandleBitwiseOperation(HBinaryOperation* instruction);
105e982f0b8e809cece6f460fa2d8df25873aa69de4Nicolas Geoffray  void HandleInvoke(HInvoke* invoke);
106e982f0b8e809cece6f460fa2d8df25873aa69de4Nicolas Geoffray
10701bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray  CodeGeneratorX86* const codegen_;
108a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray  InvokeDexCallingConventionVisitor parameter_visitor_;
10901bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray
110bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray  DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86);
111bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray};
112bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
113787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffrayclass InstructionCodeGeneratorX86 : public HGraphVisitor {
114d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray public:
1154a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray  InstructionCodeGeneratorX86(HGraph* graph, CodeGeneratorX86* codegen);
116d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
117360231a056e796c36ffe62348507e904dc9efb9bNicolas Geoffray#define DECLARE_VISIT_INSTRUCTION(name, super)     \
118de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void Visit##name(H##name* instr) OVERRIDE;
119d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
12096f89a290eb67d7bf4b1636798fa28df14309cc7Nicolas Geoffray  FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_VISIT_INSTRUCTION)
121d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
122d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#undef DECLARE_VISIT_INSTRUCTION
123d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
1244a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray  X86Assembler* GetAssembler() const { return assembler_; }
125787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray
126787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray private:
1273c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  // Generate code for the given suspend check. If not null, `successor`
1283c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  // is the block to branch to if the suspend check is not needed, and after
1293c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  // the suspend call.
1303c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  void GenerateSuspendCheck(HSuspendCheck* check, HBasicBlock* successor);
131424f676379f2f872acd1478672022f19f3240fc1Nicolas Geoffray  void GenerateClassInitializationCheck(SlowPathCodeX86* slow_path, Register class_reg);
1329574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  void HandleBitwiseOperation(HBinaryOperation* instruction);
1333c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
1344a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray  X86Assembler* const assembler_;
1354a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray  CodeGeneratorX86* const codegen_;
136787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray
137787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray  DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorX86);
138787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray};
139787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray
140787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffrayclass CodeGeneratorX86 : public CodeGenerator {
141787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray public:
142a7aca370a7d62ca04a1e24423d90e8020d6f1a58Nicolas Geoffray  explicit CodeGeneratorX86(HGraph* graph);
143f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray  virtual ~CodeGeneratorX86() {}
144787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray
145de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void GenerateFrameEntry() OVERRIDE;
146de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void GenerateFrameExit() OVERRIDE;
147de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void Bind(HBasicBlock* block) OVERRIDE;
148de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void Move(HInstruction* instruction, Location location, HInstruction* move_for) OVERRIDE;
149de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE;
150de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE;
151bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
152de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  size_t GetWordSize() const OVERRIDE {
153707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray    return kX86WordSize;
154707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray  }
155707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray
156de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  size_t FrameEntrySpillSize() const OVERRIDE;
157ab032bc1ff57831106fdac6a91a136293609401fNicolas Geoffray
158de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  HGraphVisitor* GetLocationBuilder() OVERRIDE {
159bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray    return &location_builder_;
160bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray  }
161bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray
162de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  HGraphVisitor* GetInstructionVisitor() OVERRIDE {
163787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray    return &instruction_visitor_;
164787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray  }
165787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray
166de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  X86Assembler* GetAssembler() OVERRIDE {
167787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray    return &assembler_;
168787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray  }
169787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray
170de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  uintptr_t GetAddressOf(HBasicBlock* block) const OVERRIDE {
171de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray    return GetLabelOf(block)->Position();
172de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  }
173de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray
174de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void SetupBlockedRegisters() const OVERRIDE;
17534bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle
176de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  Location AllocateFreeRegister(Primitive::Type type) const OVERRIDE;
177a7aca370a7d62ca04a1e24423d90e8020d6f1a58Nicolas Geoffray
178de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  Location GetStackLocation(HLoadLocal* load) const OVERRIDE;
1794a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray
180de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void DumpCoreRegister(std::ostream& stream, int reg) const OVERRIDE;
181de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void DumpFloatingPointRegister(std::ostream& stream, int reg) const OVERRIDE;
182a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray
18334bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle  // Blocks all register pairs made out of blocked core registers.
18434bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle  void UpdateBlockedPairRegisters() const;
18534bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle
18686dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  ParallelMoveResolverX86* GetMoveResolver() {
18786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray    return &move_resolver_;
18886dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  }
18986dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray
190de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  InstructionSet GetInstructionSet() const OVERRIDE {
191412f10cfed002ab617c78f2621d68446ca4dd8bdNicolas Geoffray    return InstructionSet::kX86;
192412f10cfed002ab617c78f2621d68446ca4dd8bdNicolas Geoffray  }
193412f10cfed002ab617c78f2621d68446ca4dd8bdNicolas Geoffray
19401bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray  // Helper method to move a 32bits value between two locations.
19501bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray  void Move32(Location destination, Location source);
19601bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray  // Helper method to move a 64bits value between two locations.
19701bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray  void Move64(Location destination, Location source);
19801bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray
1993c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray  // Emit a write barrier.
2003c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray  void MarkGCCard(Register temp, Register card, Register object, Register value);
2013c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray
20219a19cffd197a28ae4c9c3e59eff6352fd392241Nicolas Geoffray  void LoadCurrentMethod(Register reg);
20319a19cffd197a28ae4c9c3e59eff6352fd392241Nicolas Geoffray
20492a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray  Label* GetLabelOf(HBasicBlock* block) const {
20592a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray    return block_labels_.GetRawStorage() + block->GetBlockId();
20692a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray  }
20792a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray
208de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray  void Initialize() OVERRIDE {
20992a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray    block_labels_.SetSize(GetGraph()->GetBlocks().Size());
21092a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray  }
21192a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray
2123c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray private:
21392a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray  // Labels for each block that will be compiled.
21492a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray  GrowableArray<Label> block_labels_;
215bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray  LocationsBuilderX86 location_builder_;
216787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray  InstructionCodeGeneratorX86 instruction_visitor_;
21786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray  ParallelMoveResolverX86 move_resolver_;
218787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray  X86Assembler assembler_;
219d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
220d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray  DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86);
221d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray};
222d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
223d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray}  // namespace x86
224d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray}  // namespace art
225d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray
226d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#endif  // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_
227