code_generator_x86.h revision 1cf95287364948689f6a1a320567acd7728e94a3
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" 2152c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle#include "dex/compiler_enums.h" 22cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3fCalin Juravle#include "driver/compiler_options.h" 23d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#include "nodes.h" 2486dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray#include "parallel_move_resolver.h" 25787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray#include "utils/x86/assembler_x86.h" 26d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 27d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffraynamespace art { 28d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffraynamespace x86 { 29d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 3086a8d7afc7f00ff0f5ea7b8aaf4d50514250a4e6Nicolas Geoffray// Use a local definition to prevent copying mistakes. 3186a8d7afc7f00ff0f5ea7b8aaf4d50514250a4e6Nicolas Geoffraystatic constexpr size_t kX86WordSize = kX86PointerSize; 32707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray 3301bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffrayclass CodeGeneratorX86; 34424f676379f2f872acd1478672022f19f3240fc1Nicolas Geoffrayclass SlowPathCodeX86; 3501bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray 36a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffraystatic constexpr Register kParameterCoreRegisters[] = { ECX, EDX, EBX }; 37a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffraystatic constexpr RegisterPair kParameterCorePairRegisters[] = { ECX_EDX, EDX_EBX }; 38a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffraystatic constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters); 39966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendellstatic constexpr XmmRegister kParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 }; 40966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendellstatic constexpr size_t kParameterFpuRegistersLength = arraysize(kParameterFpuRegisters); 41a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 427fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffrayclass InvokeDexCallingConvention : public CallingConvention<Register, XmmRegister> { 43a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray public: 447fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray InvokeDexCallingConvention() : CallingConvention( 457fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray kParameterCoreRegisters, 467fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray kParameterCoreRegistersLength, 477fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray kParameterFpuRegisters, 487fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray kParameterFpuRegistersLength) {} 49a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 50a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray RegisterPair GetRegisterPairAt(size_t argument_index) { 51a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray DCHECK_LT(argument_index + 1, GetNumberOfRegisters()); 52a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray return kParameterCorePairRegisters[argument_index]; 53a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray } 54a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 55a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray private: 56a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); 57a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray}; 58a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 59a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffrayclass InvokeDexCallingConventionVisitor { 60a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray public: 61966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell InvokeDexCallingConventionVisitor() : gp_index_(0), fp_index_(0), stack_index_(0) {} 62a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 63a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray Location GetNextLocation(Primitive::Type type); 64a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 65a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray private: 66a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray InvokeDexCallingConvention calling_convention; 67966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell // The current index for cpu registers. 68a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray uint32_t gp_index_; 69966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell // The current index for fpu registers. 70966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell uint32_t fp_index_; 71966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell // The current stack index. 72966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell uint32_t stack_index_; 73a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 74a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); 75a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray}; 76a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray 7786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffrayclass ParallelMoveResolverX86 : public ParallelMoveResolver { 7886dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray public: 7986dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray ParallelMoveResolverX86(ArenaAllocator* allocator, CodeGeneratorX86* codegen) 8086dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray : ParallelMoveResolver(allocator), codegen_(codegen) {} 8186dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 82de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void EmitMove(size_t index) OVERRIDE; 83de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void EmitSwap(size_t index) OVERRIDE; 84de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void SpillScratch(int reg) OVERRIDE; 85de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void RestoreScratch(int reg) OVERRIDE; 8686dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 8786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray X86Assembler* GetAssembler() const; 8886dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 8986dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray private: 9086dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray void Exchange(Register reg, int mem); 9186dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray void Exchange(int mem1, int mem2); 9286dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray void MoveMemoryToMemory(int dst, int src); 9386dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 9486dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray CodeGeneratorX86* const codegen_; 9586dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 9686dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverX86); 9786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray}; 9886dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 99bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffrayclass LocationsBuilderX86 : public HGraphVisitor { 100bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray public: 10101bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray LocationsBuilderX86(HGraph* graph, CodeGeneratorX86* codegen) 10201bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray : HGraphVisitor(graph), codegen_(codegen) {} 103bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 104360231a056e796c36ffe62348507e904dc9efb9bNicolas Geoffray#define DECLARE_VISIT_INSTRUCTION(name, super) \ 105de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void Visit##name(H##name* instr) OVERRIDE; 106bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 10796f89a290eb67d7bf4b1636798fa28df14309cc7Nicolas Geoffray FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) 108bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 109bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray#undef DECLARE_VISIT_INSTRUCTION 110bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 1119574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray private: 1129574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray void HandleBitwiseOperation(HBinaryOperation* instruction); 113e982f0b8e809cece6f460fa2d8df25873aa69de4Nicolas Geoffray void HandleInvoke(HInvoke* invoke); 1149aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle void HandleShift(HBinaryOperation* instruction); 11552c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); 11652c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); 117e982f0b8e809cece6f460fa2d8df25873aa69de4Nicolas Geoffray 11801bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray CodeGeneratorX86* const codegen_; 119a747a392fb5f88d2ecc4c6021edf9f1f6615ba16Nicolas Geoffray InvokeDexCallingConventionVisitor parameter_visitor_; 12001bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray 121bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86); 122bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray}; 123bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 124787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffrayclass InstructionCodeGeneratorX86 : public HGraphVisitor { 125d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray public: 1264a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray InstructionCodeGeneratorX86(HGraph* graph, CodeGeneratorX86* codegen); 127d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 128360231a056e796c36ffe62348507e904dc9efb9bNicolas Geoffray#define DECLARE_VISIT_INSTRUCTION(name, super) \ 129de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void Visit##name(H##name* instr) OVERRIDE; 130d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 13196f89a290eb67d7bf4b1636798fa28df14309cc7Nicolas Geoffray FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) 132d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 133d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#undef DECLARE_VISIT_INSTRUCTION 134d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 1354a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray X86Assembler* GetAssembler() const { return assembler_; } 136787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray 137787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray private: 1383c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray // Generate code for the given suspend check. If not null, `successor` 1393c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray // is the block to branch to if the suspend check is not needed, and after 1403c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray // the suspend call. 1413c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray void GenerateSuspendCheck(HSuspendCheck* check, HBasicBlock* successor); 142424f676379f2f872acd1478672022f19f3240fc1Nicolas Geoffray void GenerateClassInitializationCheck(SlowPathCodeX86* slow_path, Register class_reg); 1439574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray void HandleBitwiseOperation(HBinaryOperation* instruction); 144bacfec30ee9f2f6fdfd190f11b105b609938efcaCalin Juravle void GenerateDivRemIntegral(HBinaryOperation* instruction); 14524f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell void GenerateRemFP(HRem *rem); 1469aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle void HandleShift(HBinaryOperation* instruction); 1479aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle void GenerateShlLong(const Location& loc, Register shifter); 1489aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle void GenerateShrLong(const Location& loc, Register shifter); 1499aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle void GenerateUShrLong(const Location& loc, Register shifter); 15052c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle void GenerateMemoryBarrier(MemBarrierKind kind); 15152c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); 15252c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); 15324f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell void PushOntoFPStack(Location source, uint32_t temp_offset, 15424f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell uint32_t stack_adjustment, bool is_float); 1553c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray 156cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3fCalin Juravle void GenerateImplicitNullCheck(HNullCheck* instruction); 157cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3fCalin Juravle void GenerateExplicitNullCheck(HNullCheck* instruction); 158cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3fCalin Juravle 1594a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray X86Assembler* const assembler_; 1604a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray CodeGeneratorX86* const codegen_; 161787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray 162787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorX86); 163787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray}; 164787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray 165787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffrayclass CodeGeneratorX86 : public CodeGenerator { 166787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray public: 167cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3fCalin Juravle CodeGeneratorX86(HGraph* graph, const CompilerOptions& compiler_options); 168f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray virtual ~CodeGeneratorX86() {} 169787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray 170de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void GenerateFrameEntry() OVERRIDE; 171de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void GenerateFrameExit() OVERRIDE; 172de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void Bind(HBasicBlock* block) OVERRIDE; 173de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void Move(HInstruction* instruction, Location location, HInstruction* move_for) OVERRIDE; 174de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE; 175de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE; 176bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 177de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray size_t GetWordSize() const OVERRIDE { 178707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray return kX86WordSize; 179707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray } 180707c809f661554713edfacf338365adca8dfd3a3Nicolas Geoffray 181f85a9ca9859ad843dc03d3a2b600afbaf2e9bbddMark Mendell size_t GetFloatingPointSpillSlotSize() const OVERRIDE { 182f85a9ca9859ad843dc03d3a2b600afbaf2e9bbddMark Mendell // 8 bytes == 2 words for each spill. 183f85a9ca9859ad843dc03d3a2b600afbaf2e9bbddMark Mendell return 2 * kX86WordSize; 184f85a9ca9859ad843dc03d3a2b600afbaf2e9bbddMark Mendell } 185f85a9ca9859ad843dc03d3a2b600afbaf2e9bbddMark Mendell 186de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray HGraphVisitor* GetLocationBuilder() OVERRIDE { 187bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray return &location_builder_; 188bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray } 189bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray 190de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray HGraphVisitor* GetInstructionVisitor() OVERRIDE { 191787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray return &instruction_visitor_; 192787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray } 193787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray 194de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray X86Assembler* GetAssembler() OVERRIDE { 195787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray return &assembler_; 196787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray } 197787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray 198de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray uintptr_t GetAddressOf(HBasicBlock* block) const OVERRIDE { 199de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray return GetLabelOf(block)->Position(); 200de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray } 201de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray 202988939683c26c0b1c8808fc206add6337319509aNicolas Geoffray void SetupBlockedRegisters(bool is_baseline) const OVERRIDE; 20334bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle 204de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray Location AllocateFreeRegister(Primitive::Type type) const OVERRIDE; 205a7aca370a7d62ca04a1e24423d90e8020d6f1a58Nicolas Geoffray 206de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray Location GetStackLocation(HLoadLocal* load) const OVERRIDE; 2074a34a428c6a2588e0857ef6baf88f1b73ce65958Nicolas Geoffray 208de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void DumpCoreRegister(std::ostream& stream, int reg) const OVERRIDE; 209de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void DumpFloatingPointRegister(std::ostream& stream, int reg) const OVERRIDE; 210a7062e05e6048c7f817d784a5b94e3122e25b1ecNicolas Geoffray 21134bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle // Blocks all register pairs made out of blocked core registers. 21234bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle void UpdateBlockedPairRegisters() const; 21334bacdf7eb46c0ffbf24ba7aa14a904bc9176fb2Calin Juravle 214f0e3937b87453234d0d7970b8712082062709b8dNicolas Geoffray ParallelMoveResolverX86* GetMoveResolver() OVERRIDE { 21586dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray return &move_resolver_; 21686dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray } 21786dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray 218de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray InstructionSet GetInstructionSet() const OVERRIDE { 219412f10cfed002ab617c78f2621d68446ca4dd8bdNicolas Geoffray return InstructionSet::kX86; 220412f10cfed002ab617c78f2621d68446ca4dd8bdNicolas Geoffray } 221412f10cfed002ab617c78f2621d68446ca4dd8bdNicolas Geoffray 22201bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray // Helper method to move a 32bits value between two locations. 22301bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray void Move32(Location destination, Location source); 22401bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray // Helper method to move a 64bits value between two locations. 22501bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray void Move64(Location destination, Location source); 22601bc96d007b67fdb7fe349232a83e4b354ce3d08Nicolas Geoffray 2273c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray // Emit a write barrier. 2283c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray void MarkGCCard(Register temp, Register card, Register object, Register value); 2293c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray 23019a19cffd197a28ae4c9c3e59eff6352fd392241Nicolas Geoffray void LoadCurrentMethod(Register reg); 23119a19cffd197a28ae4c9c3e59eff6352fd392241Nicolas Geoffray 23292a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray Label* GetLabelOf(HBasicBlock* block) const { 23392a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray return block_labels_.GetRawStorage() + block->GetBlockId(); 23492a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray } 23592a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray 236de58ab2c03ff8112b07ab827c8fa38f670dfc656Nicolas Geoffray void Initialize() OVERRIDE { 23792a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray block_labels_.SetSize(GetGraph()->GetBlocks().Size()); 23892a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray } 23992a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray 240840e5461a85f8908f51e7f6cd562a9129ff0e7ceNicolas Geoffray bool NeedsTwoRegisters(Primitive::Type type) const OVERRIDE { 241840e5461a85f8908f51e7f6cd562a9129ff0e7ceNicolas Geoffray return type == Primitive::kPrimLong; 242840e5461a85f8908f51e7f6cd562a9129ff0e7ceNicolas Geoffray } 243840e5461a85f8908f51e7f6cd562a9129ff0e7ceNicolas Geoffray 2441cf95287364948689f6a1a320567acd7728e94a3Nicolas Geoffray Label* GetFrameEntryLabel() { return &frame_entry_label_; } 2451cf95287364948689f6a1a320567acd7728e94a3Nicolas Geoffray 2463c7bb98698f77af10372cf31824d3bb115d9bf0fNicolas Geoffray private: 24792a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray // Labels for each block that will be compiled. 24892a73aef279be78e3c2b04db1713076183933436Nicolas Geoffray GrowableArray<Label> block_labels_; 2491cf95287364948689f6a1a320567acd7728e94a3Nicolas Geoffray Label frame_entry_label_; 250bab4ed7057799a4fadc6283108ab56f389d117d4Nicolas Geoffray LocationsBuilderX86 location_builder_; 251787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray InstructionCodeGeneratorX86 instruction_visitor_; 25286dbb9a12119273039ce272b41c809fa548b37b6Nicolas Geoffray ParallelMoveResolverX86 move_resolver_; 253787c3076635cf117eb646c5a89a9014b2072fb44Nicolas Geoffray X86Assembler assembler_; 254d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 255d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86); 256d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray}; 257d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 258d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray} // namespace x86 259d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray} // namespace art 260d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray 261d4dd255db1d110ceb5551f6d95ff31fb57420994Nicolas Geoffray#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_ 262