Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_64_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_64_H_ |
| 19 | |
| 20 | #include "code_generator.h" |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 21 | #include "dex/compiler_enums.h" |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 22 | #include "driver/compiler_options.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 23 | #include "nodes.h" |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 24 | #include "parallel_move_resolver.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 25 | #include "utils/x86_64/assembler_x86_64.h" |
| 26 | |
| 27 | namespace art { |
| 28 | namespace x86_64 { |
| 29 | |
Nicolas Geoffray | 86a8d7a | 2014-11-19 08:47:18 +0000 | [diff] [blame] | 30 | // Use a local definition to prevent copying mistakes. |
| 31 | static constexpr size_t kX86_64WordSize = kX86_64PointerSize; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 32 | |
| 33 | static constexpr Register kParameterCoreRegisters[] = { RSI, RDX, RCX, R8, R9 }; |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 34 | static constexpr FloatRegister kParameterFloatRegisters[] = |
| 35 | { XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7 }; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 36 | |
| 37 | static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 38 | static constexpr size_t kParameterFloatRegistersLength = arraysize(kParameterFloatRegisters); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 39 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 40 | static constexpr Register kRuntimeParameterCoreRegisters[] = { RDI, RSI, RDX, RCX }; |
Nicolas Geoffray | d75948a | 2015-03-27 09:53:16 +0000 | [diff] [blame] | 41 | static constexpr size_t kRuntimeParameterCoreRegistersLength = |
| 42 | arraysize(kRuntimeParameterCoreRegisters); |
| 43 | static constexpr FloatRegister kRuntimeParameterFpuRegisters[] = { XMM0, XMM1 }; |
| 44 | static constexpr size_t kRuntimeParameterFpuRegistersLength = |
| 45 | arraysize(kRuntimeParameterFpuRegisters); |
| 46 | |
| 47 | class InvokeRuntimeCallingConvention : public CallingConvention<Register, FloatRegister> { |
| 48 | public: |
| 49 | InvokeRuntimeCallingConvention() |
| 50 | : CallingConvention(kRuntimeParameterCoreRegisters, |
| 51 | kRuntimeParameterCoreRegistersLength, |
| 52 | kRuntimeParameterFpuRegisters, |
| 53 | kRuntimeParameterFpuRegistersLength) {} |
| 54 | |
| 55 | private: |
| 56 | DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention); |
| 57 | }; |
| 58 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 59 | class InvokeDexCallingConvention : public CallingConvention<Register, FloatRegister> { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 60 | public: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 61 | InvokeDexCallingConvention() : CallingConvention( |
| 62 | kParameterCoreRegisters, |
| 63 | kParameterCoreRegistersLength, |
| 64 | kParameterFloatRegisters, |
| 65 | kParameterFloatRegistersLength) {} |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 66 | |
| 67 | private: |
| 68 | DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); |
| 69 | }; |
| 70 | |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 71 | class InvokeDexCallingConventionVisitorX86_64 : public InvokeDexCallingConventionVisitor { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 72 | public: |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 73 | InvokeDexCallingConventionVisitorX86_64() {} |
| 74 | virtual ~InvokeDexCallingConventionVisitorX86_64() {} |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 75 | |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 76 | Location GetNextLocation(Primitive::Type type) OVERRIDE; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 77 | |
| 78 | private: |
| 79 | InvokeDexCallingConvention calling_convention; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 80 | |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 81 | DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorX86_64); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | class CodeGeneratorX86_64; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 85 | |
| 86 | class SlowPathCodeX86_64 : public SlowPathCode { |
| 87 | public: |
| 88 | SlowPathCodeX86_64() : entry_label_(), exit_label_() {} |
| 89 | |
| 90 | Label* GetEntryLabel() { return &entry_label_; } |
| 91 | Label* GetExitLabel() { return &exit_label_; } |
| 92 | |
| 93 | private: |
| 94 | Label entry_label_; |
| 95 | Label exit_label_; |
| 96 | |
| 97 | DISALLOW_COPY_AND_ASSIGN(SlowPathCodeX86_64); |
| 98 | }; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 99 | |
Zheng Xu | ad4450e | 2015-04-17 18:48:56 +0800 | [diff] [blame] | 100 | class ParallelMoveResolverX86_64 : public ParallelMoveResolverWithSwap { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 101 | public: |
| 102 | ParallelMoveResolverX86_64(ArenaAllocator* allocator, CodeGeneratorX86_64* codegen) |
Zheng Xu | ad4450e | 2015-04-17 18:48:56 +0800 | [diff] [blame] | 103 | : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {} |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 104 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 105 | void EmitMove(size_t index) OVERRIDE; |
| 106 | void EmitSwap(size_t index) OVERRIDE; |
| 107 | void SpillScratch(int reg) OVERRIDE; |
| 108 | void RestoreScratch(int reg) OVERRIDE; |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 109 | |
| 110 | X86_64Assembler* GetAssembler() const; |
| 111 | |
| 112 | private: |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 113 | void Exchange32(CpuRegister reg, int mem); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 114 | void Exchange32(XmmRegister reg, int mem); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 115 | void Exchange32(int mem1, int mem2); |
| 116 | void Exchange64(CpuRegister reg, int mem); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 117 | void Exchange64(XmmRegister reg, int mem); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 118 | void Exchange64(int mem1, int mem2); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 119 | |
| 120 | CodeGeneratorX86_64* const codegen_; |
| 121 | |
| 122 | DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverX86_64); |
| 123 | }; |
| 124 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 125 | class LocationsBuilderX86_64 : public HGraphVisitor { |
| 126 | public: |
| 127 | LocationsBuilderX86_64(HGraph* graph, CodeGeneratorX86_64* codegen) |
| 128 | : HGraphVisitor(graph), codegen_(codegen) {} |
| 129 | |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 130 | #define DECLARE_VISIT_INSTRUCTION(name, super) \ |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 131 | void Visit##name(H##name* instr) OVERRIDE; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 132 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 133 | FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 134 | |
| 135 | #undef DECLARE_VISIT_INSTRUCTION |
| 136 | |
| 137 | private: |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 138 | void HandleInvoke(HInvoke* invoke); |
| 139 | void HandleBitwiseOperation(HBinaryOperation* operation); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 140 | void HandleShift(HBinaryOperation* operation); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 141 | void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); |
| 142 | void HandleFieldGet(HInstruction* instruction); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 143 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 144 | CodeGeneratorX86_64* const codegen_; |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 145 | InvokeDexCallingConventionVisitorX86_64 parameter_visitor_; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 146 | |
| 147 | DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86_64); |
| 148 | }; |
| 149 | |
| 150 | class InstructionCodeGeneratorX86_64 : public HGraphVisitor { |
| 151 | public: |
| 152 | InstructionCodeGeneratorX86_64(HGraph* graph, CodeGeneratorX86_64* codegen); |
| 153 | |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 154 | #define DECLARE_VISIT_INSTRUCTION(name, super) \ |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 155 | void Visit##name(H##name* instr) OVERRIDE; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 156 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 157 | FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 158 | |
| 159 | #undef DECLARE_VISIT_INSTRUCTION |
| 160 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 161 | X86_64Assembler* GetAssembler() const { return assembler_; } |
| 162 | |
| 163 | private: |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 164 | // Generate code for the given suspend check. If not null, `successor` |
| 165 | // is the block to branch to if the suspend check is not needed, and after |
| 166 | // the suspend call. |
| 167 | void GenerateSuspendCheck(HSuspendCheck* instruction, HBasicBlock* successor); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 168 | void GenerateClassInitializationCheck(SlowPathCodeX86_64* slow_path, CpuRegister class_reg); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 169 | void HandleBitwiseOperation(HBinaryOperation* operation); |
Mark Mendell | 24f2dfa | 2015-01-14 19:51:45 -0500 | [diff] [blame] | 170 | void GenerateRemFP(HRem *rem); |
Guillaume Sanchez | 0f88e87 | 2015-03-30 17:55:45 +0100 | [diff] [blame] | 171 | void DivRemOneOrMinusOne(HBinaryOperation* instruction); |
Guillaume Sanchez | b19930c | 2015-04-09 21:12:15 +0100 | [diff] [blame] | 172 | void DivByPowerOfTwo(HDiv* instruction); |
Guillaume Sanchez | 0f88e87 | 2015-03-30 17:55:45 +0100 | [diff] [blame] | 173 | void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction); |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 174 | void GenerateDivRemIntegral(HBinaryOperation* instruction); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 175 | void HandleShift(HBinaryOperation* operation); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 176 | void GenerateMemoryBarrier(MemBarrierKind kind); |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame^] | 177 | void HandleFieldSet(HInstruction* instruction, |
| 178 | const FieldInfo& field_info, |
| 179 | bool value_can_be_null); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 180 | void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 181 | void GenerateImplicitNullCheck(HNullCheck* instruction); |
| 182 | void GenerateExplicitNullCheck(HNullCheck* instruction); |
Mark Mendell | 24f2dfa | 2015-01-14 19:51:45 -0500 | [diff] [blame] | 183 | void PushOntoFPStack(Location source, uint32_t temp_offset, |
| 184 | uint32_t stack_adjustment, bool is_float); |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 185 | void GenerateTestAndBranch(HInstruction* instruction, |
| 186 | Label* true_target, |
| 187 | Label* false_target, |
| 188 | Label* always_true_target); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 189 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 190 | X86_64Assembler* const assembler_; |
| 191 | CodeGeneratorX86_64* const codegen_; |
| 192 | |
| 193 | DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorX86_64); |
| 194 | }; |
| 195 | |
| 196 | class CodeGeneratorX86_64 : public CodeGenerator { |
| 197 | public: |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 198 | CodeGeneratorX86_64(HGraph* graph, |
| 199 | const X86_64InstructionSetFeatures& isa_features, |
| 200 | const CompilerOptions& compiler_options); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 201 | virtual ~CodeGeneratorX86_64() {} |
| 202 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 203 | void GenerateFrameEntry() OVERRIDE; |
| 204 | void GenerateFrameExit() OVERRIDE; |
| 205 | void Bind(HBasicBlock* block) OVERRIDE; |
| 206 | void Move(HInstruction* instruction, Location location, HInstruction* move_for) OVERRIDE; |
| 207 | size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE; |
| 208 | size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) OVERRIDE; |
| 209 | size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) OVERRIDE; |
| 210 | size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) OVERRIDE; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 211 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 212 | size_t GetWordSize() const OVERRIDE { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 213 | return kX86_64WordSize; |
| 214 | } |
| 215 | |
Mark Mendell | f85a9ca | 2015-01-13 09:20:58 -0500 | [diff] [blame] | 216 | size_t GetFloatingPointSpillSlotSize() const OVERRIDE { |
| 217 | return kX86_64WordSize; |
| 218 | } |
| 219 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 220 | HGraphVisitor* GetLocationBuilder() OVERRIDE { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 221 | return &location_builder_; |
| 222 | } |
| 223 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 224 | HGraphVisitor* GetInstructionVisitor() OVERRIDE { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 225 | return &instruction_visitor_; |
| 226 | } |
| 227 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 228 | X86_64Assembler* GetAssembler() OVERRIDE { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 229 | return &assembler_; |
| 230 | } |
| 231 | |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 232 | ParallelMoveResolverX86_64* GetMoveResolver() OVERRIDE { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 233 | return &move_resolver_; |
| 234 | } |
| 235 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 236 | uintptr_t GetAddressOf(HBasicBlock* block) const OVERRIDE { |
| 237 | return GetLabelOf(block)->Position(); |
| 238 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 239 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 240 | Location GetStackLocation(HLoadLocal* load) const OVERRIDE; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 241 | |
Nicolas Geoffray | 9889396 | 2015-01-21 12:32:32 +0000 | [diff] [blame] | 242 | void SetupBlockedRegisters(bool is_baseline) const OVERRIDE; |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 243 | Location AllocateFreeRegister(Primitive::Type type) const OVERRIDE; |
| 244 | void DumpCoreRegister(std::ostream& stream, int reg) const OVERRIDE; |
| 245 | void DumpFloatingPointRegister(std::ostream& stream, int reg) const OVERRIDE; |
Mark Mendell | f55c3e0 | 2015-03-26 21:07:46 -0400 | [diff] [blame] | 246 | void Finalize(CodeAllocator* allocator) OVERRIDE; |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 247 | |
| 248 | InstructionSet GetInstructionSet() const OVERRIDE { |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 249 | return InstructionSet::kX86_64; |
| 250 | } |
| 251 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 252 | // Emit a write barrier. |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame^] | 253 | void MarkGCCard(CpuRegister temp, |
| 254 | CpuRegister card, |
| 255 | CpuRegister object, |
| 256 | CpuRegister value, |
| 257 | bool value_can_be_null); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 258 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 259 | // Helper method to move a value between two locations. |
| 260 | void Move(Location destination, Location source); |
| 261 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 262 | void LoadCurrentMethod(CpuRegister reg); |
| 263 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 264 | Label* GetLabelOf(HBasicBlock* block) const { |
Nicolas Geoffray | dc23d83 | 2015-02-16 11:15:43 +0000 | [diff] [blame] | 265 | return CommonGetLabelOf<Label>(block_labels_.GetRawStorage(), block); |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 266 | } |
| 267 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 268 | void Initialize() OVERRIDE { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 269 | block_labels_.SetSize(GetGraph()->GetBlocks().Size()); |
| 270 | } |
| 271 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 272 | bool NeedsTwoRegisters(Primitive::Type type ATTRIBUTE_UNUSED) const OVERRIDE { |
| 273 | return false; |
| 274 | } |
| 275 | |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 276 | void GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, CpuRegister temp); |
| 277 | |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 278 | const X86_64InstructionSetFeatures& GetInstructionSetFeatures() const { |
| 279 | return isa_features_; |
| 280 | } |
| 281 | |
Mark Mendell | f55c3e0 | 2015-03-26 21:07:46 -0400 | [diff] [blame] | 282 | int ConstantAreaStart() const { |
| 283 | return constant_area_start_; |
| 284 | } |
| 285 | |
| 286 | Address LiteralDoubleAddress(double v); |
| 287 | Address LiteralFloatAddress(float v); |
| 288 | Address LiteralInt32Address(int32_t v); |
| 289 | Address LiteralInt64Address(int64_t v); |
| 290 | |
Mark Mendell | 92e83bf | 2015-05-07 11:25:03 -0400 | [diff] [blame] | 291 | // Load a 64 bit value into a register in the most efficient manner. |
| 292 | void Load64BitValue(CpuRegister dest, int64_t value); |
| 293 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 294 | private: |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 295 | // Labels for each block that will be compiled. |
| 296 | GrowableArray<Label> block_labels_; |
Nicolas Geoffray | 1cf9528 | 2014-12-12 19:22:03 +0000 | [diff] [blame] | 297 | Label frame_entry_label_; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 298 | LocationsBuilderX86_64 location_builder_; |
| 299 | InstructionCodeGeneratorX86_64 instruction_visitor_; |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 300 | ParallelMoveResolverX86_64 move_resolver_; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 301 | X86_64Assembler assembler_; |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 302 | const X86_64InstructionSetFeatures& isa_features_; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 303 | |
Mark Mendell | 39dcf55 | 2015-04-09 20:42:42 -0400 | [diff] [blame] | 304 | // Offset to the start of the constant area in the assembled code. |
Mark Mendell | f55c3e0 | 2015-03-26 21:07:46 -0400 | [diff] [blame] | 305 | // Used for fixups to the constant area. |
| 306 | int constant_area_start_; |
| 307 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 308 | DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86_64); |
| 309 | }; |
| 310 | |
| 311 | } // namespace x86_64 |
| 312 | } // namespace art |
| 313 | |
| 314 | #endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_64_H_ |