code_generator_mips64.h revision 85b62f23fc6dfffe2ddd3ddfa74611666c9ff41d
14dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze/* 24dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * Copyright (C) 2015 The Android Open Source Project 34dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * 44dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * Licensed under the Apache License, Version 2.0 (the "License"); 54dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * you may not use this file except in compliance with the License. 64dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * You may obtain a copy of the License at 74dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * 84dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * http://www.apache.org/licenses/LICENSE-2.0 94dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * 104dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * Unless required by applicable law or agreed to in writing, software 114dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * distributed under the License is distributed on an "AS IS" BASIS, 124dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * See the License for the specific language governing permissions and 144dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze * limitations under the License. 154dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze */ 164dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 174dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#ifndef ART_COMPILER_OPTIMIZING_CODE_GENERATOR_MIPS64_H_ 184dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_MIPS64_H_ 194dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 204dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#include "code_generator.h" 214dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#include "dex/compiler_enums.h" 224dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#include "driver/compiler_options.h" 234dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#include "nodes.h" 244dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#include "parallel_move_resolver.h" 254dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#include "utils/mips64/assembler_mips64.h" 264dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 274dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzenamespace art { 284dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzenamespace mips64 { 294dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 304dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze// Use a local definition to prevent copying mistakes. 314dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr size_t kMips64WordSize = kMips64PointerSize; 324dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 334dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 344dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze// InvokeDexCallingConvention registers 354dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 364dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr GpuRegister kParameterCoreRegisters[] = 374dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze { A1, A2, A3, A4, A5, A6, A7 }; 384dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters); 394dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 404dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr FpuRegister kParameterFpuRegisters[] = 414dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze { F13, F14, F15, F16, F17, F18, F19 }; 424dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr size_t kParameterFpuRegistersLength = arraysize(kParameterFpuRegisters); 434dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 444dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 454dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze// InvokeRuntimeCallingConvention registers 464dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 474dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr GpuRegister kRuntimeParameterCoreRegisters[] = 484dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze { A0, A1, A2, A3, A4, A5, A6, A7 }; 494dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr size_t kRuntimeParameterCoreRegistersLength = 504dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze arraysize(kRuntimeParameterCoreRegisters); 514dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 524dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr FpuRegister kRuntimeParameterFpuRegisters[] = 534dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze { F12, F13, F14, F15, F16, F17, F18, F19 }; 544dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr size_t kRuntimeParameterFpuRegistersLength = 554dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze arraysize(kRuntimeParameterFpuRegisters); 564dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 574dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 584dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr GpuRegister kCoreCalleeSaves[] = 594dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze { S0, S1, S2, S3, S4, S5, S6, S7, GP, S8, RA }; // TODO: review 604dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzestatic constexpr FpuRegister kFpuCalleeSaves[] = 614dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze { F24, F25, F26, F27, F28, F29, F30, F31 }; 624dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 634dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 644dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass CodeGeneratorMIPS64; 654dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 664dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass InvokeDexCallingConvention : public CallingConvention<GpuRegister, FpuRegister> { 674dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 684dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InvokeDexCallingConvention() 694dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze : CallingConvention(kParameterCoreRegisters, 704dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kParameterCoreRegistersLength, 714dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kParameterFpuRegisters, 724dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kParameterFpuRegistersLength, 734dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kMips64PointerSize) {} 744dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 754dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 764dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); 774dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 784dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 794dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass InvokeDexCallingConventionVisitorMIPS64 : public InvokeDexCallingConventionVisitor { 804dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 814dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InvokeDexCallingConventionVisitorMIPS64() {} 824dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze virtual ~InvokeDexCallingConventionVisitorMIPS64() {} 834dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 844dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Location GetNextLocation(Primitive::Type type) OVERRIDE; 854dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Location GetReturnLocation(Primitive::Type type) const OVERRIDE; 864dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Location GetMethodLocation() const OVERRIDE; 874dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 884dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 894dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InvokeDexCallingConvention calling_convention; 904dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 914dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorMIPS64); 924dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 934dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 944dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass InvokeRuntimeCallingConvention : public CallingConvention<GpuRegister, FpuRegister> { 954dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 964dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InvokeRuntimeCallingConvention() 974dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze : CallingConvention(kRuntimeParameterCoreRegisters, 984dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kRuntimeParameterCoreRegistersLength, 994dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kRuntimeParameterFpuRegisters, 1004dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kRuntimeParameterFpuRegistersLength, 1014dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze kMips64PointerSize) {} 1024dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1034dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Location GetReturnLocation(Primitive::Type return_type); 1044dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1054dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 1064dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention); 1074dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 1084dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1094dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass ParallelMoveResolverMIPS64 : public ParallelMoveResolverWithSwap { 1104dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 1114dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze ParallelMoveResolverMIPS64(ArenaAllocator* allocator, CodeGeneratorMIPS64* codegen) 1124dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {} 1134dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1144dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void EmitMove(size_t index) OVERRIDE; 1154dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void EmitSwap(size_t index) OVERRIDE; 1164dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void SpillScratch(int reg) OVERRIDE; 1174dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void RestoreScratch(int reg) OVERRIDE; 1184dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1194dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void Exchange(int index1, int index2, bool double_slot); 1204dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1214dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Mips64Assembler* GetAssembler() const; 1224dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1234dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 1244dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze CodeGeneratorMIPS64* const codegen_; 1254dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1264dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverMIPS64); 1274dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 1284dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1294dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass SlowPathCodeMIPS64 : public SlowPathCode { 1304dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 1314dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze SlowPathCodeMIPS64() : entry_label_(), exit_label_() {} 1324dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1334dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label* GetEntryLabel() { return &entry_label_; } 1344dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label* GetExitLabel() { return &exit_label_; } 1354dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1364dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 1374dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label entry_label_; 1384dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label exit_label_; 1394dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1404dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(SlowPathCodeMIPS64); 1414dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 1424dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1434dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass LocationsBuilderMIPS64 : public HGraphVisitor { 1444dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 1454dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze LocationsBuilderMIPS64(HGraph* graph, CodeGeneratorMIPS64* codegen) 1464dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze : HGraphVisitor(graph), codegen_(codegen) {} 1474dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1484dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#define DECLARE_VISIT_INSTRUCTION(name, super) \ 149f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames void Visit##name(H##name* instr) OVERRIDE; 1504dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 151f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION) 152f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames FOR_EACH_CONCRETE_INSTRUCTION_MIPS64(DECLARE_VISIT_INSTRUCTION) 1534dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1544dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#undef DECLARE_VISIT_INSTRUCTION 1554dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 156f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames void VisitInstruction(HInstruction* instruction) OVERRIDE { 157f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames LOG(FATAL) << "Unreachable instruction " << instruction->DebugName() 158f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames << " (id " << instruction->GetId() << ")"; 159f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames } 160f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames 1614dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 1624dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleInvoke(HInvoke* invoke); 1634dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleBinaryOp(HBinaryOperation* operation); 1644dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleShift(HBinaryOperation* operation); 1654dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); 1664dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); 1674dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1684dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InvokeDexCallingConventionVisitorMIPS64 parameter_visitor_; 1694dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1704dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze CodeGeneratorMIPS64* const codegen_; 1714dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1724dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(LocationsBuilderMIPS64); 1734dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 1744dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1754dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass InstructionCodeGeneratorMIPS64 : public HGraphVisitor { 1764dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 1774dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InstructionCodeGeneratorMIPS64(HGraph* graph, CodeGeneratorMIPS64* codegen); 1784dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1794dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#define DECLARE_VISIT_INSTRUCTION(name, super) \ 180f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames void Visit##name(H##name* instr) OVERRIDE; 1814dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 182f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION) 183f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames FOR_EACH_CONCRETE_INSTRUCTION_MIPS64(DECLARE_VISIT_INSTRUCTION) 1844dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1854dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#undef DECLARE_VISIT_INSTRUCTION 1864dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 187f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames void VisitInstruction(HInstruction* instruction) OVERRIDE { 188f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames LOG(FATAL) << "Unreachable instruction " << instruction->DebugName() 189f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames << " (id " << instruction->GetId() << ")"; 190f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames } 191f39e0641a6d1a6561b20f6a130d1e763788cd70bAlexandre Rames 1924dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Mips64Assembler* GetAssembler() const { return assembler_; } 1934dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 1944dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 1954dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // Generate code for the given suspend check. If not null, `successor` 1964dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // is the block to branch to if the suspend check is not needed, and after 1974dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // the suspend call. 1984dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateClassInitializationCheck(SlowPathCodeMIPS64* slow_path, GpuRegister class_reg); 1994dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateMemoryBarrier(MemBarrierKind kind); 2004dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateSuspendCheck(HSuspendCheck* check, HBasicBlock* successor); 2014dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleBinaryOp(HBinaryOperation* operation); 2024dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleShift(HBinaryOperation* operation); 2034dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); 2044dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); 2054dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateImplicitNullCheck(HNullCheck* instruction); 2064dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateExplicitNullCheck(HNullCheck* instruction); 2074dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateTestAndBranch(HInstruction* instruction, 2084dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label* true_target, 2094dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label* false_target, 2104dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label* always_true_target); 211fc6a86ab2b70781e72b807c1798b83829ca7f931David Brazdil void HandleGoto(HInstruction* got, HBasicBlock* successor); 2124dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2134dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Mips64Assembler* const assembler_; 2144dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze CodeGeneratorMIPS64* const codegen_; 2154dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2164dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorMIPS64); 2174dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 2184dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2194dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunzeclass CodeGeneratorMIPS64 : public CodeGenerator { 2204dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze public: 2214dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze CodeGeneratorMIPS64(HGraph* graph, 2224dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze const Mips64InstructionSetFeatures& isa_features, 223ecc4366670e12b4812ef1653f7c8d52234ca1b1fSerban Constantinescu const CompilerOptions& compiler_options, 224ecc4366670e12b4812ef1653f7c8d52234ca1b1fSerban Constantinescu OptimizingCompilerStats* stats = nullptr); 2254dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze virtual ~CodeGeneratorMIPS64() {} 2264dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2274dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateFrameEntry() OVERRIDE; 2284dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void GenerateFrameExit() OVERRIDE; 2294dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2304dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void Bind(HBasicBlock* block) OVERRIDE; 2314dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2324dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void Move(HInstruction* instruction, Location location, HInstruction* move_for) OVERRIDE; 2334dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2344dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze size_t GetWordSize() const OVERRIDE { return kMips64WordSize; } 2354dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2364dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze size_t GetFloatingPointSpillSlotSize() const OVERRIDE { return kMips64WordSize; } 2374dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2384dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze uintptr_t GetAddressOf(HBasicBlock* block) const OVERRIDE { 2394dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze return GetLabelOf(block)->Position(); 2404dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze } 2414dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2424dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze HGraphVisitor* GetLocationBuilder() OVERRIDE { return &location_builder_; } 2434dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze HGraphVisitor* GetInstructionVisitor() OVERRIDE { return &instruction_visitor_; } 2444dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Mips64Assembler* GetAssembler() OVERRIDE { return &assembler_; } 245eb7b7399dbdb5e471b8ae00a567bf4f19edd3907Alexandre Rames const Mips64Assembler& GetAssembler() const OVERRIDE { return assembler_; } 2464dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2474dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void MarkGCCard(GpuRegister object, GpuRegister value); 2484dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2494dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // Register allocation. 2504dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2514dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void SetupBlockedRegisters(bool is_baseline) const OVERRIDE; 2524dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // AllocateFreeRegister() is only used when allocating registers locally 2534dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // during CompileBaseline(). 2544dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Location AllocateFreeRegister(Primitive::Type type) const OVERRIDE; 2554dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2564dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Location GetStackLocation(HLoadLocal* load) const OVERRIDE; 2574dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2584dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id); 2594dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id); 2604dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id); 2614dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id); 2624dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2634dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void DumpCoreRegister(std::ostream& stream, int reg) const OVERRIDE; 2644dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void DumpFloatingPointRegister(std::ostream& stream, int reg) const OVERRIDE; 2654dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2664dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InstructionSet GetInstructionSet() const OVERRIDE { return InstructionSet::kMips64; } 2674dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2684dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze const Mips64InstructionSetFeatures& GetInstructionSetFeatures() const { 2694dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze return isa_features_; 2704dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze } 2714dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2724dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label* GetLabelOf(HBasicBlock* block) const { 2734dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze return CommonGetLabelOf<Label>(block_labels_.GetRawStorage(), block); 2744dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze } 2754dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2764dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void Initialize() OVERRIDE { 277fa6b93c4b69e6d7ddfa2a4ed0aff01b0608c5a3aVladimir Marko block_labels_.SetSize(GetGraph()->GetBlocks().size()); 2784dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze } 2794dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2804dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void Finalize(CodeAllocator* allocator) OVERRIDE; 2814dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2824dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // Code generation helpers. 2834dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2844dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void MoveLocation(Location destination, Location source, Primitive::Type type); 2854dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 286175dc732c80e6f2afd83209348124df349290ba8Calin Juravle void MoveConstant(Location destination, int32_t value) OVERRIDE; 287175dc732c80e6f2afd83209348124df349290ba8Calin Juravle 2884dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void SwapLocations(Location loc1, Location loc2, Primitive::Type type); 2894dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 2904dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // Generate code to invoke a runtime entry point. 291175dc732c80e6f2afd83209348124df349290ba8Calin Juravle void InvokeRuntime(QuickEntrypointEnum entrypoint, 292175dc732c80e6f2afd83209348124df349290ba8Calin Juravle HInstruction* instruction, 293175dc732c80e6f2afd83209348124df349290ba8Calin Juravle uint32_t dex_pc, 294175dc732c80e6f2afd83209348124df349290ba8Calin Juravle SlowPathCode* slow_path) OVERRIDE; 295175dc732c80e6f2afd83209348124df349290ba8Calin Juravle 2964dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze void InvokeRuntime(int32_t offset, 2974dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze HInstruction* instruction, 2984dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze uint32_t dex_pc, 2994dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze SlowPathCode* slow_path); 3004dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 3014dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze ParallelMoveResolver* GetMoveResolver() OVERRIDE { return &move_resolver_; } 3024dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 3034dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze bool NeedsTwoRegisters(Primitive::Type type ATTRIBUTE_UNUSED) const { return false; } 3044dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 30585b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe void GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, Location temp) OVERRIDE; 30685b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe void GenerateVirtualCall(HInvokeVirtual* invoke ATTRIBUTE_UNUSED, 30785b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe Location temp ATTRIBUTE_UNUSED) OVERRIDE { 30885b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe UNIMPLEMENTED(FATAL); 30985b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe } 31085b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe 31185b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe void MoveFromReturnRegister(Location trg ATTRIBUTE_UNUSED, 31285b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe Primitive::Type type ATTRIBUTE_UNUSED) OVERRIDE { 31385b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe UNIMPLEMENTED(FATAL); 31485b62f23fc6dfffe2ddd3ddfa74611666c9ff41dAndreas Gampe } 3154dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 3164dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze private: 3174dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze // Labels for each block that will be compiled. 3184dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze GrowableArray<Label> block_labels_; 3194dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Label frame_entry_label_; 3204dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze LocationsBuilderMIPS64 location_builder_; 3214dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze InstructionCodeGeneratorMIPS64 instruction_visitor_; 3224dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze ParallelMoveResolverMIPS64 move_resolver_; 3234dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze Mips64Assembler assembler_; 3244dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze const Mips64InstructionSetFeatures& isa_features_; 3254dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 3264dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze DISALLOW_COPY_AND_ASSIGN(CodeGeneratorMIPS64); 3274dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze}; 3284dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 3294dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze} // namespace mips64 3304dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze} // namespace art 3314dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze 3324dda3376b71209fae07f5c3c8ac3eb4b54207aa8Alexey Frunze#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_MIPS64_H_ 333