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 | #include "code_generator_x86_64.h" |
| 18 | |
| 19 | #include "entrypoints/quick/quick_entrypoints.h" |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 20 | #include "gc/accounting/card_table.h" |
Ian Rogers | 7e70b00 | 2014-10-08 11:47:24 -0700 | [diff] [blame] | 21 | #include "mirror/array-inl.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 22 | #include "mirror/art_method.h" |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 23 | #include "mirror/class.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 24 | #include "mirror/object_reference.h" |
| 25 | #include "thread.h" |
| 26 | #include "utils/assembler.h" |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 27 | #include "utils/stack_checks.h" |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 28 | #include "utils/x86_64/assembler_x86_64.h" |
| 29 | #include "utils/x86_64/managed_register_x86_64.h" |
| 30 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 31 | namespace art { |
| 32 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 33 | namespace x86_64 { |
| 34 | |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 35 | static constexpr bool kExplicitStackOverflowCheck = false; |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 36 | |
| 37 | // Some x86_64 instructions require a register to be available as temp. |
| 38 | static constexpr Register TMP = R11; |
| 39 | |
| 40 | static constexpr int kNumberOfPushedRegistersAtEntry = 1; |
| 41 | static constexpr int kCurrentMethodStackOffset = 0; |
| 42 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 43 | static constexpr Register kRuntimeParameterCoreRegisters[] = { RDI, RSI, RDX }; |
| 44 | static constexpr size_t kRuntimeParameterCoreRegistersLength = |
| 45 | arraysize(kRuntimeParameterCoreRegisters); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 46 | static constexpr FloatRegister kRuntimeParameterFpuRegisters[] = { }; |
| 47 | static constexpr size_t kRuntimeParameterFpuRegistersLength = 0; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 48 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 49 | class InvokeRuntimeCallingConvention : public CallingConvention<Register, FloatRegister> { |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 50 | public: |
| 51 | InvokeRuntimeCallingConvention() |
| 52 | : CallingConvention(kRuntimeParameterCoreRegisters, |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 53 | kRuntimeParameterCoreRegistersLength, |
| 54 | kRuntimeParameterFpuRegisters, |
| 55 | kRuntimeParameterFpuRegistersLength) {} |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 56 | |
| 57 | private: |
| 58 | DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention); |
| 59 | }; |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 60 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 61 | #define __ reinterpret_cast<X86_64Assembler*>(codegen->GetAssembler())-> |
| 62 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 63 | class SlowPathCodeX86_64 : public SlowPathCode { |
| 64 | public: |
| 65 | SlowPathCodeX86_64() : entry_label_(), exit_label_() {} |
| 66 | |
| 67 | Label* GetEntryLabel() { return &entry_label_; } |
| 68 | Label* GetExitLabel() { return &exit_label_; } |
| 69 | |
| 70 | private: |
| 71 | Label entry_label_; |
| 72 | Label exit_label_; |
| 73 | |
| 74 | DISALLOW_COPY_AND_ASSIGN(SlowPathCodeX86_64); |
| 75 | }; |
| 76 | |
| 77 | class NullCheckSlowPathX86_64 : public SlowPathCodeX86_64 { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 78 | public: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 79 | explicit NullCheckSlowPathX86_64(HNullCheck* instruction) : instruction_(instruction) {} |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 80 | |
| 81 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 82 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 83 | __ gs()->call( |
| 84 | Address::Absolute(QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pThrowNullPointer), true)); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 85 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | private: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 89 | HNullCheck* const instruction_; |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 90 | DISALLOW_COPY_AND_ASSIGN(NullCheckSlowPathX86_64); |
| 91 | }; |
| 92 | |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 93 | class DivZeroCheckSlowPathX86_64 : public SlowPathCodeX86_64 { |
| 94 | public: |
| 95 | explicit DivZeroCheckSlowPathX86_64(HDivZeroCheck* instruction) : instruction_(instruction) {} |
| 96 | |
| 97 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 98 | __ Bind(GetEntryLabel()); |
| 99 | __ gs()->call( |
| 100 | Address::Absolute(QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pThrowDivZero), true)); |
| 101 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
| 102 | } |
| 103 | |
| 104 | private: |
| 105 | HDivZeroCheck* const instruction_; |
| 106 | DISALLOW_COPY_AND_ASSIGN(DivZeroCheckSlowPathX86_64); |
| 107 | }; |
| 108 | |
| 109 | class DivMinusOneSlowPathX86_64 : public SlowPathCodeX86_64 { |
| 110 | public: |
| 111 | explicit DivMinusOneSlowPathX86_64(Register reg) : reg_(reg) {} |
| 112 | |
| 113 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 114 | __ Bind(GetEntryLabel()); |
| 115 | __ negl(CpuRegister(reg_)); |
| 116 | __ jmp(GetExitLabel()); |
| 117 | } |
| 118 | |
| 119 | private: |
| 120 | Register reg_; |
| 121 | DISALLOW_COPY_AND_ASSIGN(DivMinusOneSlowPathX86_64); |
| 122 | }; |
| 123 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 124 | class StackOverflowCheckSlowPathX86_64 : public SlowPathCodeX86_64 { |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 125 | public: |
| 126 | StackOverflowCheckSlowPathX86_64() {} |
| 127 | |
| 128 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 129 | __ Bind(GetEntryLabel()); |
| 130 | __ addq(CpuRegister(RSP), |
| 131 | Immediate(codegen->GetFrameSize() - kNumberOfPushedRegistersAtEntry * kX86_64WordSize)); |
| 132 | __ gs()->jmp( |
| 133 | Address::Absolute(QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pThrowStackOverflow), true)); |
| 134 | } |
| 135 | |
| 136 | private: |
| 137 | DISALLOW_COPY_AND_ASSIGN(StackOverflowCheckSlowPathX86_64); |
| 138 | }; |
| 139 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 140 | class SuspendCheckSlowPathX86_64 : public SlowPathCodeX86_64 { |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 141 | public: |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 142 | explicit SuspendCheckSlowPathX86_64(HSuspendCheck* instruction, HBasicBlock* successor) |
| 143 | : instruction_(instruction), successor_(successor) {} |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 144 | |
| 145 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 146 | CodeGeneratorX86_64* x64_codegen = down_cast<CodeGeneratorX86_64*>(codegen); |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 147 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 148 | codegen->SaveLiveRegisters(instruction_->GetLocations()); |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 149 | __ gs()->call(Address::Absolute(QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pTestSuspend), true)); |
| 150 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 151 | codegen->RestoreLiveRegisters(instruction_->GetLocations()); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 152 | if (successor_ == nullptr) { |
| 153 | __ jmp(GetReturnLabel()); |
| 154 | } else { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 155 | __ jmp(x64_codegen->GetLabelOf(successor_)); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 156 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 159 | Label* GetReturnLabel() { |
| 160 | DCHECK(successor_ == nullptr); |
| 161 | return &return_label_; |
| 162 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 163 | |
| 164 | private: |
| 165 | HSuspendCheck* const instruction_; |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 166 | HBasicBlock* const successor_; |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 167 | Label return_label_; |
| 168 | |
| 169 | DISALLOW_COPY_AND_ASSIGN(SuspendCheckSlowPathX86_64); |
| 170 | }; |
| 171 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 172 | class BoundsCheckSlowPathX86_64 : public SlowPathCodeX86_64 { |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 173 | public: |
Roland Levillain | 5799fc0 | 2014-09-25 12:15:20 +0100 | [diff] [blame] | 174 | BoundsCheckSlowPathX86_64(HBoundsCheck* instruction, |
| 175 | Location index_location, |
| 176 | Location length_location) |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 177 | : instruction_(instruction), |
| 178 | index_location_(index_location), |
| 179 | length_location_(length_location) {} |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 180 | |
| 181 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 182 | CodeGeneratorX86_64* x64_codegen = down_cast<CodeGeneratorX86_64*>(codegen); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 183 | __ Bind(GetEntryLabel()); |
| 184 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 185 | x64_codegen->Move( |
| 186 | Location::RegisterLocation(calling_convention.GetRegisterAt(0)), index_location_); |
| 187 | x64_codegen->Move( |
| 188 | Location::RegisterLocation(calling_convention.GetRegisterAt(1)), length_location_); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 189 | __ gs()->call(Address::Absolute( |
| 190 | QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pThrowArrayBounds), true)); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 191 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | private: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 195 | HBoundsCheck* const instruction_; |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 196 | const Location index_location_; |
| 197 | const Location length_location_; |
| 198 | |
| 199 | DISALLOW_COPY_AND_ASSIGN(BoundsCheckSlowPathX86_64); |
| 200 | }; |
| 201 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 202 | class LoadClassSlowPathX86_64 : public SlowPathCodeX86_64 { |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 203 | public: |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 204 | LoadClassSlowPathX86_64(HLoadClass* cls, |
| 205 | HInstruction* at, |
| 206 | uint32_t dex_pc, |
| 207 | bool do_clinit) |
| 208 | : cls_(cls), at_(at), dex_pc_(dex_pc), do_clinit_(do_clinit) { |
| 209 | DCHECK(at->IsLoadClass() || at->IsClinitCheck()); |
| 210 | } |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 211 | |
| 212 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 213 | LocationSummary* locations = at_->GetLocations(); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 214 | CodeGeneratorX86_64* x64_codegen = down_cast<CodeGeneratorX86_64*>(codegen); |
| 215 | __ Bind(GetEntryLabel()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 216 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 217 | codegen->SaveLiveRegisters(locations); |
| 218 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 219 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 220 | __ movl(CpuRegister(calling_convention.GetRegisterAt(0)), Immediate(cls_->GetTypeIndex())); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 221 | x64_codegen->LoadCurrentMethod(CpuRegister(calling_convention.GetRegisterAt(1))); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 222 | __ gs()->call(Address::Absolute((do_clinit_ |
| 223 | ? QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pInitializeStaticStorage) |
| 224 | : QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pInitializeType)) , true)); |
| 225 | codegen->RecordPcInfo(at_, dex_pc_); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 226 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 227 | // Move the class to the desired location. |
| 228 | if (locations->Out().IsValid()) { |
| 229 | DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); |
| 230 | x64_codegen->Move(locations->Out(), Location::RegisterLocation(RAX)); |
| 231 | } |
| 232 | |
| 233 | codegen->RestoreLiveRegisters(locations); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 234 | __ jmp(GetExitLabel()); |
| 235 | } |
| 236 | |
| 237 | private: |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 238 | // The class this slow path will load. |
| 239 | HLoadClass* const cls_; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 240 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 241 | // The instruction where this slow path is happening. |
| 242 | // (Might be the load class or an initialization check). |
| 243 | HInstruction* const at_; |
| 244 | |
| 245 | // The dex PC of `at_`. |
| 246 | const uint32_t dex_pc_; |
| 247 | |
| 248 | // Whether to initialize the class. |
| 249 | const bool do_clinit_; |
| 250 | |
| 251 | DISALLOW_COPY_AND_ASSIGN(LoadClassSlowPathX86_64); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 252 | }; |
| 253 | |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 254 | class LoadStringSlowPathX86_64 : public SlowPathCodeX86_64 { |
| 255 | public: |
| 256 | explicit LoadStringSlowPathX86_64(HLoadString* instruction) : instruction_(instruction) {} |
| 257 | |
| 258 | virtual void EmitNativeCode(CodeGenerator* codegen) OVERRIDE { |
| 259 | LocationSummary* locations = instruction_->GetLocations(); |
| 260 | DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); |
| 261 | |
| 262 | CodeGeneratorX86_64* x64_codegen = down_cast<CodeGeneratorX86_64*>(codegen); |
| 263 | __ Bind(GetEntryLabel()); |
| 264 | codegen->SaveLiveRegisters(locations); |
| 265 | |
| 266 | InvokeRuntimeCallingConvention calling_convention; |
| 267 | x64_codegen->LoadCurrentMethod(CpuRegister(calling_convention.GetRegisterAt(0))); |
| 268 | __ movl(CpuRegister(calling_convention.GetRegisterAt(1)), |
| 269 | Immediate(instruction_->GetStringIndex())); |
| 270 | __ gs()->call(Address::Absolute( |
| 271 | QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pResolveString), true)); |
| 272 | codegen->RecordPcInfo(instruction_, instruction_->GetDexPc()); |
| 273 | x64_codegen->Move(locations->Out(), Location::RegisterLocation(RAX)); |
| 274 | codegen->RestoreLiveRegisters(locations); |
| 275 | __ jmp(GetExitLabel()); |
| 276 | } |
| 277 | |
| 278 | private: |
| 279 | HLoadString* const instruction_; |
| 280 | |
| 281 | DISALLOW_COPY_AND_ASSIGN(LoadStringSlowPathX86_64); |
| 282 | }; |
| 283 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 284 | #undef __ |
| 285 | #define __ reinterpret_cast<X86_64Assembler*>(GetAssembler())-> |
| 286 | |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 287 | inline Condition X86_64Condition(IfCondition cond) { |
| 288 | switch (cond) { |
| 289 | case kCondEQ: return kEqual; |
| 290 | case kCondNE: return kNotEqual; |
| 291 | case kCondLT: return kLess; |
| 292 | case kCondLE: return kLessEqual; |
| 293 | case kCondGT: return kGreater; |
| 294 | case kCondGE: return kGreaterEqual; |
| 295 | default: |
| 296 | LOG(FATAL) << "Unknown if condition"; |
| 297 | } |
| 298 | return kEqual; |
| 299 | } |
| 300 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 301 | void CodeGeneratorX86_64::DumpCoreRegister(std::ostream& stream, int reg) const { |
| 302 | stream << X86_64ManagedRegister::FromCpuRegister(Register(reg)); |
| 303 | } |
| 304 | |
| 305 | void CodeGeneratorX86_64::DumpFloatingPointRegister(std::ostream& stream, int reg) const { |
| 306 | stream << X86_64ManagedRegister::FromXmmRegister(FloatRegister(reg)); |
| 307 | } |
| 308 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 309 | size_t CodeGeneratorX86_64::SaveCoreRegister(size_t stack_index, uint32_t reg_id) { |
| 310 | __ movq(Address(CpuRegister(RSP), stack_index), CpuRegister(reg_id)); |
| 311 | return kX86_64WordSize; |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 312 | } |
| 313 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 314 | size_t CodeGeneratorX86_64::RestoreCoreRegister(size_t stack_index, uint32_t reg_id) { |
| 315 | __ movq(CpuRegister(reg_id), Address(CpuRegister(RSP), stack_index)); |
| 316 | return kX86_64WordSize; |
| 317 | } |
| 318 | |
| 319 | size_t CodeGeneratorX86_64::SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) { |
| 320 | __ movsd(Address(CpuRegister(RSP), stack_index), XmmRegister(reg_id)); |
| 321 | return kX86_64WordSize; |
| 322 | } |
| 323 | |
| 324 | size_t CodeGeneratorX86_64::RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) { |
| 325 | __ movsd(XmmRegister(reg_id), Address(CpuRegister(RSP), stack_index)); |
| 326 | return kX86_64WordSize; |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 327 | } |
| 328 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 329 | CodeGeneratorX86_64::CodeGeneratorX86_64(HGraph* graph) |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 330 | : CodeGenerator(graph, kNumberOfCpuRegisters, kNumberOfFloatRegisters, 0), |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 331 | block_labels_(graph->GetArena(), 0), |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 332 | location_builder_(graph, this), |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 333 | instruction_visitor_(graph, this), |
| 334 | move_resolver_(graph->GetArena(), this) {} |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 335 | |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 336 | size_t CodeGeneratorX86_64::FrameEntrySpillSize() const { |
| 337 | return kNumberOfPushedRegistersAtEntry * kX86_64WordSize; |
| 338 | } |
| 339 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 340 | InstructionCodeGeneratorX86_64::InstructionCodeGeneratorX86_64(HGraph* graph, |
| 341 | CodeGeneratorX86_64* codegen) |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 342 | : HGraphVisitor(graph), |
| 343 | assembler_(codegen->GetAssembler()), |
| 344 | codegen_(codegen) {} |
| 345 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 346 | Location CodeGeneratorX86_64::AllocateFreeRegister(Primitive::Type type) const { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 347 | switch (type) { |
| 348 | case Primitive::kPrimLong: |
| 349 | case Primitive::kPrimByte: |
| 350 | case Primitive::kPrimBoolean: |
| 351 | case Primitive::kPrimChar: |
| 352 | case Primitive::kPrimShort: |
| 353 | case Primitive::kPrimInt: |
| 354 | case Primitive::kPrimNot: { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 355 | size_t reg = FindFreeEntry(blocked_core_registers_, kNumberOfCpuRegisters); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 356 | return Location::RegisterLocation(reg); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 360 | case Primitive::kPrimDouble: { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 361 | size_t reg = FindFreeEntry(blocked_fpu_registers_, kNumberOfFloatRegisters); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 362 | return Location::FpuRegisterLocation(reg); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 363 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 364 | |
| 365 | case Primitive::kPrimVoid: |
| 366 | LOG(FATAL) << "Unreachable type " << type; |
| 367 | } |
| 368 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 369 | return Location(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 370 | } |
| 371 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 372 | void CodeGeneratorX86_64::SetupBlockedRegisters() const { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 373 | // Stack register is always reserved. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 374 | blocked_core_registers_[RSP] = true; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 375 | |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 376 | // Block the register used as TMP. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 377 | blocked_core_registers_[TMP] = true; |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 378 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 379 | // TODO: We currently don't use Quick's callee saved registers. |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 380 | blocked_core_registers_[RBX] = true; |
| 381 | blocked_core_registers_[RBP] = true; |
| 382 | blocked_core_registers_[R12] = true; |
| 383 | blocked_core_registers_[R13] = true; |
| 384 | blocked_core_registers_[R14] = true; |
| 385 | blocked_core_registers_[R15] = true; |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 386 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 387 | blocked_fpu_registers_[XMM12] = true; |
| 388 | blocked_fpu_registers_[XMM13] = true; |
| 389 | blocked_fpu_registers_[XMM14] = true; |
| 390 | blocked_fpu_registers_[XMM15] = true; |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 391 | } |
| 392 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 393 | void CodeGeneratorX86_64::GenerateFrameEntry() { |
| 394 | // Create a fake register to mimic Quick. |
| 395 | static const int kFakeReturnRegister = 16; |
| 396 | core_spill_mask_ |= (1 << kFakeReturnRegister); |
| 397 | |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 398 | bool skip_overflow_check = IsLeafMethod() |
Dave Allison | 648d711 | 2014-07-25 16:15:27 -0700 | [diff] [blame] | 399 | && !FrameNeedsStackCheck(GetFrameSize(), InstructionSet::kX86_64); |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 400 | |
| 401 | if (!skip_overflow_check && !kExplicitStackOverflowCheck) { |
| 402 | __ testq(CpuRegister(RAX), Address( |
| 403 | CpuRegister(RSP), -static_cast<int32_t>(GetStackOverflowReservedBytes(kX86_64)))); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 404 | RecordPcInfo(nullptr, 0); |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 405 | } |
| 406 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 407 | // The return PC has already been pushed on the stack. |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 408 | __ subq(CpuRegister(RSP), |
| 409 | Immediate(GetFrameSize() - kNumberOfPushedRegistersAtEntry * kX86_64WordSize)); |
| 410 | |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 411 | if (!skip_overflow_check && kExplicitStackOverflowCheck) { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 412 | SlowPathCodeX86_64* slow_path = new (GetGraph()->GetArena()) StackOverflowCheckSlowPathX86_64(); |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 413 | AddSlowPath(slow_path); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 414 | |
Nicolas Geoffray | f6e206c | 2014-08-07 20:25:41 +0100 | [diff] [blame] | 415 | __ gs()->cmpq(CpuRegister(RSP), |
| 416 | Address::Absolute(Thread::StackEndOffset<kX86_64WordSize>(), true)); |
| 417 | __ j(kLess, slow_path->GetEntryLabel()); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 418 | } |
| 419 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 420 | __ movl(Address(CpuRegister(RSP), kCurrentMethodStackOffset), CpuRegister(RDI)); |
| 421 | } |
| 422 | |
| 423 | void CodeGeneratorX86_64::GenerateFrameExit() { |
| 424 | __ addq(CpuRegister(RSP), |
| 425 | Immediate(GetFrameSize() - kNumberOfPushedRegistersAtEntry * kX86_64WordSize)); |
| 426 | } |
| 427 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 428 | void CodeGeneratorX86_64::Bind(HBasicBlock* block) { |
| 429 | __ Bind(GetLabelOf(block)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 430 | } |
| 431 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 432 | void CodeGeneratorX86_64::LoadCurrentMethod(CpuRegister reg) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 433 | __ movl(reg, Address(CpuRegister(RSP), kCurrentMethodStackOffset)); |
| 434 | } |
| 435 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 436 | Location CodeGeneratorX86_64::GetStackLocation(HLoadLocal* load) const { |
| 437 | switch (load->GetType()) { |
| 438 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 439 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 440 | return Location::DoubleStackSlot(GetStackSlot(load->GetLocal())); |
| 441 | break; |
| 442 | |
| 443 | case Primitive::kPrimInt: |
| 444 | case Primitive::kPrimNot: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 445 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 446 | return Location::StackSlot(GetStackSlot(load->GetLocal())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 447 | |
| 448 | case Primitive::kPrimBoolean: |
| 449 | case Primitive::kPrimByte: |
| 450 | case Primitive::kPrimChar: |
| 451 | case Primitive::kPrimShort: |
| 452 | case Primitive::kPrimVoid: |
| 453 | LOG(FATAL) << "Unexpected type " << load->GetType(); |
| 454 | } |
| 455 | |
| 456 | LOG(FATAL) << "Unreachable"; |
| 457 | return Location(); |
| 458 | } |
| 459 | |
| 460 | void CodeGeneratorX86_64::Move(Location destination, Location source) { |
| 461 | if (source.Equals(destination)) { |
| 462 | return; |
| 463 | } |
| 464 | if (destination.IsRegister()) { |
| 465 | if (source.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 466 | __ movq(destination.As<CpuRegister>(), source.As<CpuRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 467 | } else if (source.IsFpuRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 468 | __ movd(destination.As<CpuRegister>(), source.As<XmmRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 469 | } else if (source.IsStackSlot()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 470 | __ movl(destination.As<CpuRegister>(), |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 471 | Address(CpuRegister(RSP), source.GetStackIndex())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 472 | } else { |
| 473 | DCHECK(source.IsDoubleStackSlot()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 474 | __ movq(destination.As<CpuRegister>(), |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 475 | Address(CpuRegister(RSP), source.GetStackIndex())); |
| 476 | } |
| 477 | } else if (destination.IsFpuRegister()) { |
| 478 | if (source.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 479 | __ movd(destination.As<XmmRegister>(), source.As<CpuRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 480 | } else if (source.IsFpuRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 481 | __ movaps(destination.As<XmmRegister>(), source.As<XmmRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 482 | } else if (source.IsStackSlot()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 483 | __ movss(destination.As<XmmRegister>(), |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 484 | Address(CpuRegister(RSP), source.GetStackIndex())); |
| 485 | } else { |
| 486 | DCHECK(source.IsDoubleStackSlot()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 487 | __ movsd(destination.As<XmmRegister>(), |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 488 | Address(CpuRegister(RSP), source.GetStackIndex())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 489 | } |
| 490 | } else if (destination.IsStackSlot()) { |
| 491 | if (source.IsRegister()) { |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 492 | __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 493 | source.As<CpuRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 494 | } else if (source.IsFpuRegister()) { |
| 495 | __ movss(Address(CpuRegister(RSP), destination.GetStackIndex()), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 496 | source.As<XmmRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 497 | } else { |
| 498 | DCHECK(source.IsStackSlot()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 499 | __ movl(CpuRegister(TMP), Address(CpuRegister(RSP), source.GetStackIndex())); |
| 500 | __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), CpuRegister(TMP)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 501 | } |
| 502 | } else { |
| 503 | DCHECK(destination.IsDoubleStackSlot()); |
| 504 | if (source.IsRegister()) { |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 505 | __ movq(Address(CpuRegister(RSP), destination.GetStackIndex()), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 506 | source.As<CpuRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 507 | } else if (source.IsFpuRegister()) { |
| 508 | __ movsd(Address(CpuRegister(RSP), destination.GetStackIndex()), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 509 | source.As<XmmRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 510 | } else { |
| 511 | DCHECK(source.IsDoubleStackSlot()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 512 | __ movq(CpuRegister(TMP), Address(CpuRegister(RSP), source.GetStackIndex())); |
| 513 | __ movq(Address(CpuRegister(RSP), destination.GetStackIndex()), CpuRegister(TMP)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 518 | void CodeGeneratorX86_64::Move(HInstruction* instruction, |
| 519 | Location location, |
| 520 | HInstruction* move_for) { |
Roland Levillain | 476df55 | 2014-10-09 17:51:36 +0100 | [diff] [blame] | 521 | if (instruction->IsIntConstant()) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 522 | Immediate imm(instruction->AsIntConstant()->GetValue()); |
| 523 | if (location.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 524 | __ movl(location.As<CpuRegister>(), imm); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 525 | } else if (location.IsStackSlot()) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 526 | __ movl(Address(CpuRegister(RSP), location.GetStackIndex()), imm); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 527 | } else { |
| 528 | DCHECK(location.IsConstant()); |
| 529 | DCHECK_EQ(location.GetConstant(), instruction); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 530 | } |
Roland Levillain | 476df55 | 2014-10-09 17:51:36 +0100 | [diff] [blame] | 531 | } else if (instruction->IsLongConstant()) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 532 | int64_t value = instruction->AsLongConstant()->GetValue(); |
| 533 | if (location.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 534 | __ movq(location.As<CpuRegister>(), Immediate(value)); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 535 | } else if (location.IsDoubleStackSlot()) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 536 | __ movq(CpuRegister(TMP), Immediate(value)); |
| 537 | __ movq(Address(CpuRegister(RSP), location.GetStackIndex()), CpuRegister(TMP)); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 538 | } else { |
| 539 | DCHECK(location.IsConstant()); |
| 540 | DCHECK_EQ(location.GetConstant(), instruction); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 541 | } |
Roland Levillain | 476df55 | 2014-10-09 17:51:36 +0100 | [diff] [blame] | 542 | } else if (instruction->IsLoadLocal()) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 543 | switch (instruction->GetType()) { |
| 544 | case Primitive::kPrimBoolean: |
| 545 | case Primitive::kPrimByte: |
| 546 | case Primitive::kPrimChar: |
| 547 | case Primitive::kPrimShort: |
| 548 | case Primitive::kPrimInt: |
| 549 | case Primitive::kPrimNot: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 550 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 551 | Move(location, Location::StackSlot(GetStackSlot(instruction->AsLoadLocal()->GetLocal()))); |
| 552 | break; |
| 553 | |
| 554 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 555 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 556 | Move(location, Location::DoubleStackSlot(GetStackSlot(instruction->AsLoadLocal()->GetLocal()))); |
| 557 | break; |
| 558 | |
| 559 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 560 | LOG(FATAL) << "Unexpected local type " << instruction->GetType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 561 | } |
| 562 | } else { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 563 | DCHECK((instruction->GetNext() == move_for) || instruction->GetNext()->IsTemporary()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 564 | switch (instruction->GetType()) { |
| 565 | case Primitive::kPrimBoolean: |
| 566 | case Primitive::kPrimByte: |
| 567 | case Primitive::kPrimChar: |
| 568 | case Primitive::kPrimShort: |
| 569 | case Primitive::kPrimInt: |
| 570 | case Primitive::kPrimNot: |
| 571 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 572 | case Primitive::kPrimFloat: |
| 573 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 574 | Move(location, instruction->GetLocations()->Out()); |
| 575 | break; |
| 576 | |
| 577 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 578 | LOG(FATAL) << "Unexpected type " << instruction->GetType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | void LocationsBuilderX86_64::VisitGoto(HGoto* got) { |
| 584 | got->SetLocations(nullptr); |
| 585 | } |
| 586 | |
| 587 | void InstructionCodeGeneratorX86_64::VisitGoto(HGoto* got) { |
| 588 | HBasicBlock* successor = got->GetSuccessor(); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 589 | DCHECK(!successor->IsExitBlock()); |
| 590 | |
| 591 | HBasicBlock* block = got->GetBlock(); |
| 592 | HInstruction* previous = got->GetPrevious(); |
| 593 | |
| 594 | HLoopInformation* info = block->GetLoopInformation(); |
| 595 | if (info != nullptr && info->IsBackEdge(block) && info->HasSuspendCheck()) { |
| 596 | codegen_->ClearSpillSlotsFromLoopPhisInStackMap(info->GetSuspendCheck()); |
| 597 | GenerateSuspendCheck(info->GetSuspendCheck(), successor); |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { |
| 602 | GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); |
| 603 | } |
| 604 | if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 605 | __ jmp(codegen_->GetLabelOf(successor)); |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | void LocationsBuilderX86_64::VisitExit(HExit* exit) { |
| 610 | exit->SetLocations(nullptr); |
| 611 | } |
| 612 | |
| 613 | void InstructionCodeGeneratorX86_64::VisitExit(HExit* exit) { |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 614 | UNUSED(exit); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 615 | if (kIsDebugBuild) { |
| 616 | __ Comment("Unreachable"); |
| 617 | __ int3(); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | void LocationsBuilderX86_64::VisitIf(HIf* if_instr) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 622 | LocationSummary* locations = |
| 623 | new (GetGraph()->GetArena()) LocationSummary(if_instr, LocationSummary::kNoCall); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 624 | HInstruction* cond = if_instr->InputAt(0); |
Nicolas Geoffray | 01ef345 | 2014-10-01 11:32:17 +0100 | [diff] [blame] | 625 | if (!cond->IsCondition() || cond->AsCondition()->NeedsMaterialization()) { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 626 | locations->SetInAt(0, Location::Any()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 627 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | void InstructionCodeGeneratorX86_64::VisitIf(HIf* if_instr) { |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 631 | HInstruction* cond = if_instr->InputAt(0); |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 632 | if (cond->IsIntConstant()) { |
| 633 | // Constant condition, statically compared against 1. |
| 634 | int32_t cond_value = cond->AsIntConstant()->GetValue(); |
| 635 | if (cond_value == 1) { |
| 636 | if (!codegen_->GoesToNextBlock(if_instr->GetBlock(), |
| 637 | if_instr->IfTrueSuccessor())) { |
| 638 | __ jmp(codegen_->GetLabelOf(if_instr->IfTrueSuccessor())); |
Nicolas Geoffray | 18efde5 | 2014-09-22 15:51:11 +0100 | [diff] [blame] | 639 | } |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 640 | return; |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 641 | } else { |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 642 | DCHECK_EQ(cond_value, 0); |
| 643 | } |
| 644 | } else { |
| 645 | bool materialized = |
| 646 | !cond->IsCondition() || cond->AsCondition()->NeedsMaterialization(); |
| 647 | // Moves do not affect the eflags register, so if the condition is |
| 648 | // evaluated just before the if, we don't need to evaluate it |
| 649 | // again. |
| 650 | bool eflags_set = cond->IsCondition() |
| 651 | && cond->AsCondition()->IsBeforeWhenDisregardMoves(if_instr); |
| 652 | if (materialized) { |
| 653 | if (!eflags_set) { |
| 654 | // Materialized condition, compare against 0. |
| 655 | Location lhs = if_instr->GetLocations()->InAt(0); |
| 656 | if (lhs.IsRegister()) { |
| 657 | __ cmpl(lhs.As<CpuRegister>(), Immediate(0)); |
| 658 | } else { |
| 659 | __ cmpl(Address(CpuRegister(RSP), lhs.GetStackIndex()), |
| 660 | Immediate(0)); |
| 661 | } |
| 662 | __ j(kNotEqual, codegen_->GetLabelOf(if_instr->IfTrueSuccessor())); |
| 663 | } else { |
| 664 | __ j(X86_64Condition(cond->AsCondition()->GetCondition()), |
| 665 | codegen_->GetLabelOf(if_instr->IfTrueSuccessor())); |
| 666 | } |
| 667 | } else { |
| 668 | Location lhs = cond->GetLocations()->InAt(0); |
| 669 | Location rhs = cond->GetLocations()->InAt(1); |
| 670 | if (rhs.IsRegister()) { |
| 671 | __ cmpl(lhs.As<CpuRegister>(), rhs.As<CpuRegister>()); |
| 672 | } else if (rhs.IsConstant()) { |
| 673 | __ cmpl(lhs.As<CpuRegister>(), |
| 674 | Immediate(rhs.GetConstant()->AsIntConstant()->GetValue())); |
| 675 | } else { |
| 676 | __ cmpl(lhs.As<CpuRegister>(), |
| 677 | Address(CpuRegister(RSP), rhs.GetStackIndex())); |
| 678 | } |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 679 | __ j(X86_64Condition(cond->AsCondition()->GetCondition()), |
| 680 | codegen_->GetLabelOf(if_instr->IfTrueSuccessor())); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 681 | } |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 682 | } |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 683 | if (!codegen_->GoesToNextBlock(if_instr->GetBlock(), |
| 684 | if_instr->IfFalseSuccessor())) { |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 685 | __ jmp(codegen_->GetLabelOf(if_instr->IfFalseSuccessor())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 686 | } |
| 687 | } |
| 688 | |
| 689 | void LocationsBuilderX86_64::VisitLocal(HLocal* local) { |
| 690 | local->SetLocations(nullptr); |
| 691 | } |
| 692 | |
| 693 | void InstructionCodeGeneratorX86_64::VisitLocal(HLocal* local) { |
| 694 | DCHECK_EQ(local->GetBlock(), GetGraph()->GetEntryBlock()); |
| 695 | } |
| 696 | |
| 697 | void LocationsBuilderX86_64::VisitLoadLocal(HLoadLocal* local) { |
| 698 | local->SetLocations(nullptr); |
| 699 | } |
| 700 | |
| 701 | void InstructionCodeGeneratorX86_64::VisitLoadLocal(HLoadLocal* load) { |
| 702 | // Nothing to do, this is driven by the code generator. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 703 | UNUSED(load); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | void LocationsBuilderX86_64::VisitStoreLocal(HStoreLocal* store) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 707 | LocationSummary* locations = |
| 708 | new (GetGraph()->GetArena()) LocationSummary(store, LocationSummary::kNoCall); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 709 | switch (store->InputAt(1)->GetType()) { |
| 710 | case Primitive::kPrimBoolean: |
| 711 | case Primitive::kPrimByte: |
| 712 | case Primitive::kPrimChar: |
| 713 | case Primitive::kPrimShort: |
| 714 | case Primitive::kPrimInt: |
| 715 | case Primitive::kPrimNot: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 716 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 717 | locations->SetInAt(1, Location::StackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 718 | break; |
| 719 | |
| 720 | case Primitive::kPrimLong: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 721 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 722 | locations->SetInAt(1, Location::DoubleStackSlot(codegen_->GetStackSlot(store->GetLocal()))); |
| 723 | break; |
| 724 | |
| 725 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 726 | LOG(FATAL) << "Unexpected local type " << store->InputAt(1)->GetType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 727 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | void InstructionCodeGeneratorX86_64::VisitStoreLocal(HStoreLocal* store) { |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 731 | UNUSED(store); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 732 | } |
| 733 | |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 734 | void LocationsBuilderX86_64::VisitCondition(HCondition* comp) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 735 | LocationSummary* locations = |
| 736 | new (GetGraph()->GetArena()) LocationSummary(comp, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 737 | locations->SetInAt(0, Location::RequiresRegister()); |
| 738 | locations->SetInAt(1, Location::Any()); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 739 | if (comp->NeedsMaterialization()) { |
| 740 | locations->SetOut(Location::RequiresRegister()); |
| 741 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 742 | } |
| 743 | |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 744 | void InstructionCodeGeneratorX86_64::VisitCondition(HCondition* comp) { |
| 745 | if (comp->NeedsMaterialization()) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 746 | LocationSummary* locations = comp->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 747 | CpuRegister reg = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 18efde5 | 2014-09-22 15:51:11 +0100 | [diff] [blame] | 748 | // Clear register: setcc only sets the low byte. |
| 749 | __ xorq(reg, reg); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 750 | if (locations->InAt(1).IsRegister()) { |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 751 | __ cmpl(locations->InAt(0).As<CpuRegister>(), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 752 | locations->InAt(1).As<CpuRegister>()); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 753 | } else if (locations->InAt(1).IsConstant()) { |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 754 | __ cmpl(locations->InAt(0).As<CpuRegister>(), |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 755 | Immediate(locations->InAt(1).GetConstant()->AsIntConstant()->GetValue())); |
| 756 | } else { |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 757 | __ cmpl(locations->InAt(0).As<CpuRegister>(), |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 758 | Address(CpuRegister(RSP), locations->InAt(1).GetStackIndex())); |
| 759 | } |
Nicolas Geoffray | 18efde5 | 2014-09-22 15:51:11 +0100 | [diff] [blame] | 760 | __ setcc(X86_64Condition(comp->GetCondition()), reg); |
Dave Allison | 20dfc79 | 2014-06-16 20:44:29 -0700 | [diff] [blame] | 761 | } |
| 762 | } |
| 763 | |
| 764 | void LocationsBuilderX86_64::VisitEqual(HEqual* comp) { |
| 765 | VisitCondition(comp); |
| 766 | } |
| 767 | |
| 768 | void InstructionCodeGeneratorX86_64::VisitEqual(HEqual* comp) { |
| 769 | VisitCondition(comp); |
| 770 | } |
| 771 | |
| 772 | void LocationsBuilderX86_64::VisitNotEqual(HNotEqual* comp) { |
| 773 | VisitCondition(comp); |
| 774 | } |
| 775 | |
| 776 | void InstructionCodeGeneratorX86_64::VisitNotEqual(HNotEqual* comp) { |
| 777 | VisitCondition(comp); |
| 778 | } |
| 779 | |
| 780 | void LocationsBuilderX86_64::VisitLessThan(HLessThan* comp) { |
| 781 | VisitCondition(comp); |
| 782 | } |
| 783 | |
| 784 | void InstructionCodeGeneratorX86_64::VisitLessThan(HLessThan* comp) { |
| 785 | VisitCondition(comp); |
| 786 | } |
| 787 | |
| 788 | void LocationsBuilderX86_64::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 789 | VisitCondition(comp); |
| 790 | } |
| 791 | |
| 792 | void InstructionCodeGeneratorX86_64::VisitLessThanOrEqual(HLessThanOrEqual* comp) { |
| 793 | VisitCondition(comp); |
| 794 | } |
| 795 | |
| 796 | void LocationsBuilderX86_64::VisitGreaterThan(HGreaterThan* comp) { |
| 797 | VisitCondition(comp); |
| 798 | } |
| 799 | |
| 800 | void InstructionCodeGeneratorX86_64::VisitGreaterThan(HGreaterThan* comp) { |
| 801 | VisitCondition(comp); |
| 802 | } |
| 803 | |
| 804 | void LocationsBuilderX86_64::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 805 | VisitCondition(comp); |
| 806 | } |
| 807 | |
| 808 | void InstructionCodeGeneratorX86_64::VisitGreaterThanOrEqual(HGreaterThanOrEqual* comp) { |
| 809 | VisitCondition(comp); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 810 | } |
| 811 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 812 | void LocationsBuilderX86_64::VisitCompare(HCompare* compare) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 813 | LocationSummary* locations = |
| 814 | new (GetGraph()->GetArena()) LocationSummary(compare, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 815 | locations->SetInAt(0, Location::RequiresRegister()); |
| 816 | locations->SetInAt(1, Location::RequiresRegister()); |
| 817 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | void InstructionCodeGeneratorX86_64::VisitCompare(HCompare* compare) { |
| 821 | Label greater, done; |
| 822 | LocationSummary* locations = compare->GetLocations(); |
| 823 | switch (compare->InputAt(0)->GetType()) { |
| 824 | case Primitive::kPrimLong: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 825 | __ cmpq(locations->InAt(0).As<CpuRegister>(), |
| 826 | locations->InAt(1).As<CpuRegister>()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 827 | break; |
| 828 | default: |
| 829 | LOG(FATAL) << "Unimplemented compare type " << compare->InputAt(0)->GetType(); |
| 830 | } |
| 831 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 832 | CpuRegister output = locations->Out().As<CpuRegister>(); |
| 833 | __ movl(output, Immediate(0)); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 834 | __ j(kEqual, &done); |
| 835 | __ j(kGreater, &greater); |
| 836 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 837 | __ movl(output, Immediate(-1)); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 838 | __ jmp(&done); |
| 839 | |
| 840 | __ Bind(&greater); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 841 | __ movl(output, Immediate(1)); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 842 | |
| 843 | __ Bind(&done); |
| 844 | } |
| 845 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 846 | void LocationsBuilderX86_64::VisitIntConstant(HIntConstant* constant) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 847 | LocationSummary* locations = |
| 848 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 849 | locations->SetOut(Location::ConstantLocation(constant)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | void InstructionCodeGeneratorX86_64::VisitIntConstant(HIntConstant* constant) { |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 853 | // Will be generated at use site. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 854 | UNUSED(constant); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | void LocationsBuilderX86_64::VisitLongConstant(HLongConstant* constant) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 858 | LocationSummary* locations = |
| 859 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 860 | locations->SetOut(Location::ConstantLocation(constant)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | void InstructionCodeGeneratorX86_64::VisitLongConstant(HLongConstant* constant) { |
Roland Levillain | 3a3fd0f | 2014-10-10 13:56:31 +0100 | [diff] [blame] | 864 | // Will be generated at use site. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 865 | UNUSED(constant); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 866 | } |
| 867 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 868 | void LocationsBuilderX86_64::VisitFloatConstant(HFloatConstant* constant) { |
| 869 | LocationSummary* locations = |
| 870 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 871 | locations->SetOut(Location::ConstantLocation(constant)); |
| 872 | } |
| 873 | |
| 874 | void InstructionCodeGeneratorX86_64::VisitFloatConstant(HFloatConstant* constant) { |
| 875 | // Will be generated at use site. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 876 | UNUSED(constant); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | void LocationsBuilderX86_64::VisitDoubleConstant(HDoubleConstant* constant) { |
| 880 | LocationSummary* locations = |
| 881 | new (GetGraph()->GetArena()) LocationSummary(constant, LocationSummary::kNoCall); |
| 882 | locations->SetOut(Location::ConstantLocation(constant)); |
| 883 | } |
| 884 | |
| 885 | void InstructionCodeGeneratorX86_64::VisitDoubleConstant(HDoubleConstant* constant) { |
| 886 | // Will be generated at use site. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 887 | UNUSED(constant); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 888 | } |
| 889 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 890 | void LocationsBuilderX86_64::VisitReturnVoid(HReturnVoid* ret) { |
| 891 | ret->SetLocations(nullptr); |
| 892 | } |
| 893 | |
| 894 | void InstructionCodeGeneratorX86_64::VisitReturnVoid(HReturnVoid* ret) { |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 895 | UNUSED(ret); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 896 | codegen_->GenerateFrameExit(); |
| 897 | __ ret(); |
| 898 | } |
| 899 | |
| 900 | void LocationsBuilderX86_64::VisitReturn(HReturn* ret) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 901 | LocationSummary* locations = |
| 902 | new (GetGraph()->GetArena()) LocationSummary(ret, LocationSummary::kNoCall); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 903 | switch (ret->InputAt(0)->GetType()) { |
| 904 | case Primitive::kPrimBoolean: |
| 905 | case Primitive::kPrimByte: |
| 906 | case Primitive::kPrimChar: |
| 907 | case Primitive::kPrimShort: |
| 908 | case Primitive::kPrimInt: |
| 909 | case Primitive::kPrimNot: |
| 910 | case Primitive::kPrimLong: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 911 | locations->SetInAt(0, Location::RegisterLocation(RAX)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 912 | break; |
| 913 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 914 | case Primitive::kPrimFloat: |
| 915 | case Primitive::kPrimDouble: |
| 916 | locations->SetInAt(0, |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 917 | Location::FpuRegisterLocation(XMM0)); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 918 | break; |
| 919 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 920 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 921 | LOG(FATAL) << "Unexpected return type " << ret->InputAt(0)->GetType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 922 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | void InstructionCodeGeneratorX86_64::VisitReturn(HReturn* ret) { |
| 926 | if (kIsDebugBuild) { |
| 927 | switch (ret->InputAt(0)->GetType()) { |
| 928 | case Primitive::kPrimBoolean: |
| 929 | case Primitive::kPrimByte: |
| 930 | case Primitive::kPrimChar: |
| 931 | case Primitive::kPrimShort: |
| 932 | case Primitive::kPrimInt: |
| 933 | case Primitive::kPrimNot: |
| 934 | case Primitive::kPrimLong: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 935 | DCHECK_EQ(ret->GetLocations()->InAt(0).As<CpuRegister>().AsRegister(), RAX); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 936 | break; |
| 937 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 938 | case Primitive::kPrimFloat: |
| 939 | case Primitive::kPrimDouble: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 940 | DCHECK_EQ(ret->GetLocations()->InAt(0).As<XmmRegister>().AsFloatRegister(), |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 941 | XMM0); |
| 942 | break; |
| 943 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 944 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 945 | LOG(FATAL) << "Unexpected return type " << ret->InputAt(0)->GetType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 946 | } |
| 947 | } |
| 948 | codegen_->GenerateFrameExit(); |
| 949 | __ ret(); |
| 950 | } |
| 951 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 952 | Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type) { |
| 953 | switch (type) { |
| 954 | case Primitive::kPrimBoolean: |
| 955 | case Primitive::kPrimByte: |
| 956 | case Primitive::kPrimChar: |
| 957 | case Primitive::kPrimShort: |
| 958 | case Primitive::kPrimInt: |
| 959 | case Primitive::kPrimNot: { |
| 960 | uint32_t index = gp_index_++; |
| 961 | stack_index_++; |
| 962 | if (index < calling_convention.GetNumberOfRegisters()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 963 | return Location::RegisterLocation(calling_convention.GetRegisterAt(index)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 964 | } else { |
| 965 | return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 1)); |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | case Primitive::kPrimLong: { |
| 970 | uint32_t index = gp_index_; |
| 971 | stack_index_ += 2; |
| 972 | if (index < calling_convention.GetNumberOfRegisters()) { |
| 973 | gp_index_ += 1; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 974 | return Location::RegisterLocation(calling_convention.GetRegisterAt(index)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 975 | } else { |
| 976 | gp_index_ += 2; |
| 977 | return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 2)); |
| 978 | } |
| 979 | } |
| 980 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 981 | case Primitive::kPrimFloat: { |
| 982 | uint32_t index = fp_index_++; |
| 983 | stack_index_++; |
| 984 | if (index < calling_convention.GetNumberOfFpuRegisters()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 985 | return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 986 | } else { |
| 987 | return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 1)); |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | case Primitive::kPrimDouble: { |
| 992 | uint32_t index = fp_index_++; |
| 993 | stack_index_ += 2; |
| 994 | if (index < calling_convention.GetNumberOfFpuRegisters()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 995 | return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 996 | } else { |
| 997 | return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 2)); |
| 998 | } |
| 999 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1000 | |
| 1001 | case Primitive::kPrimVoid: |
| 1002 | LOG(FATAL) << "Unexpected parameter type " << type; |
| 1003 | break; |
| 1004 | } |
| 1005 | return Location(); |
| 1006 | } |
| 1007 | |
| 1008 | void LocationsBuilderX86_64::VisitInvokeStatic(HInvokeStatic* invoke) { |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1009 | HandleInvoke(invoke); |
| 1010 | } |
| 1011 | |
| 1012 | void InstructionCodeGeneratorX86_64::VisitInvokeStatic(HInvokeStatic* invoke) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1013 | CpuRegister temp = invoke->GetLocations()->GetTemp(0).As<CpuRegister>(); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1014 | // TODO: Implement all kinds of calls: |
| 1015 | // 1) boot -> boot |
| 1016 | // 2) app -> boot |
| 1017 | // 3) app -> app |
| 1018 | // |
| 1019 | // Currently we implement the app -> app logic, which looks up in the resolve cache. |
| 1020 | |
| 1021 | // temp = method; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1022 | codegen_->LoadCurrentMethod(temp); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1023 | // temp = temp->dex_cache_resolved_methods_; |
| 1024 | __ movl(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().SizeValue())); |
| 1025 | // temp = temp[index_in_cache] |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1026 | __ movl(temp, Address(temp, CodeGenerator::GetCacheOffset(invoke->GetIndexInDexCache()))); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1027 | // (temp + offset_of_quick_compiled_code)() |
| 1028 | __ call(Address(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().SizeValue())); |
| 1029 | |
| 1030 | DCHECK(!codegen_->IsLeafMethod()); |
| 1031 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
| 1032 | } |
| 1033 | |
| 1034 | void LocationsBuilderX86_64::VisitInvokeVirtual(HInvokeVirtual* invoke) { |
| 1035 | HandleInvoke(invoke); |
| 1036 | } |
| 1037 | |
| 1038 | void LocationsBuilderX86_64::HandleInvoke(HInvoke* invoke) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1039 | LocationSummary* locations = |
| 1040 | new (GetGraph()->GetArena()) LocationSummary(invoke, LocationSummary::kCall); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1041 | locations->AddTemp(Location::RegisterLocation(RDI)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1042 | |
| 1043 | InvokeDexCallingConventionVisitor calling_convention_visitor; |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1044 | for (size_t i = 0; i < invoke->InputCount(); i++) { |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1045 | HInstruction* input = invoke->InputAt(i); |
| 1046 | locations->SetInAt(i, calling_convention_visitor.GetNextLocation(input->GetType())); |
| 1047 | } |
| 1048 | |
| 1049 | switch (invoke->GetType()) { |
| 1050 | case Primitive::kPrimBoolean: |
| 1051 | case Primitive::kPrimByte: |
| 1052 | case Primitive::kPrimChar: |
| 1053 | case Primitive::kPrimShort: |
| 1054 | case Primitive::kPrimInt: |
| 1055 | case Primitive::kPrimNot: |
| 1056 | case Primitive::kPrimLong: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1057 | locations->SetOut(Location::RegisterLocation(RAX)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1058 | break; |
| 1059 | |
| 1060 | case Primitive::kPrimVoid: |
| 1061 | break; |
| 1062 | |
| 1063 | case Primitive::kPrimDouble: |
| 1064 | case Primitive::kPrimFloat: |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1065 | locations->SetOut(Location::FpuRegisterLocation(XMM0)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1066 | break; |
| 1067 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1068 | } |
| 1069 | |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1070 | void InstructionCodeGeneratorX86_64::VisitInvokeVirtual(HInvokeVirtual* invoke) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1071 | CpuRegister temp = invoke->GetLocations()->GetTemp(0).As<CpuRegister>(); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1072 | size_t method_offset = mirror::Class::EmbeddedVTableOffset().SizeValue() + |
| 1073 | invoke->GetVTableIndex() * sizeof(mirror::Class::VTableEntry); |
| 1074 | LocationSummary* locations = invoke->GetLocations(); |
| 1075 | Location receiver = locations->InAt(0); |
| 1076 | size_t class_offset = mirror::Object::ClassOffset().SizeValue(); |
| 1077 | // temp = object->GetClass(); |
| 1078 | if (receiver.IsStackSlot()) { |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 1079 | __ movl(temp, Address(CpuRegister(RSP), receiver.GetStackIndex())); |
| 1080 | __ movl(temp, Address(temp, class_offset)); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1081 | } else { |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 1082 | __ movl(temp, Address(receiver.As<CpuRegister>(), class_offset)); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 1083 | } |
| 1084 | // temp = temp->GetMethodAt(method_offset); |
| 1085 | __ movl(temp, Address(temp, method_offset)); |
| 1086 | // call temp->GetEntryPoint(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1087 | __ call(Address(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().SizeValue())); |
| 1088 | |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 1089 | DCHECK(!codegen_->IsLeafMethod()); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1090 | codegen_->RecordPcInfo(invoke, invoke->GetDexPc()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1091 | } |
| 1092 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1093 | void LocationsBuilderX86_64::VisitNeg(HNeg* neg) { |
| 1094 | LocationSummary* locations = |
| 1095 | new (GetGraph()->GetArena()) LocationSummary(neg, LocationSummary::kNoCall); |
| 1096 | switch (neg->GetResultType()) { |
| 1097 | case Primitive::kPrimInt: |
Roland Levillain | 2e07b4f | 2014-10-23 18:12:09 +0100 | [diff] [blame] | 1098 | case Primitive::kPrimLong: |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1099 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1100 | locations->SetOut(Location::SameAsFirstInput()); |
| 1101 | break; |
| 1102 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1103 | case Primitive::kPrimFloat: |
| 1104 | case Primitive::kPrimDouble: |
| 1105 | LOG(FATAL) << "Not yet implemented neg type " << neg->GetResultType(); |
| 1106 | break; |
| 1107 | |
| 1108 | default: |
| 1109 | LOG(FATAL) << "Unexpected neg type " << neg->GetResultType(); |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | void InstructionCodeGeneratorX86_64::VisitNeg(HNeg* neg) { |
| 1114 | LocationSummary* locations = neg->GetLocations(); |
| 1115 | Location out = locations->Out(); |
| 1116 | Location in = locations->InAt(0); |
| 1117 | switch (neg->GetResultType()) { |
| 1118 | case Primitive::kPrimInt: |
| 1119 | DCHECK(in.IsRegister()); |
| 1120 | __ negl(out.As<CpuRegister>()); |
| 1121 | break; |
| 1122 | |
| 1123 | case Primitive::kPrimLong: |
Roland Levillain | 2e07b4f | 2014-10-23 18:12:09 +0100 | [diff] [blame] | 1124 | DCHECK(in.IsRegister()); |
| 1125 | __ negq(out.As<CpuRegister>()); |
| 1126 | break; |
| 1127 | |
Roland Levillain | 88cb175 | 2014-10-20 16:36:47 +0100 | [diff] [blame] | 1128 | case Primitive::kPrimFloat: |
| 1129 | case Primitive::kPrimDouble: |
| 1130 | LOG(FATAL) << "Not yet implemented neg type " << neg->GetResultType(); |
| 1131 | break; |
| 1132 | |
| 1133 | default: |
| 1134 | LOG(FATAL) << "Unexpected neg type " << neg->GetResultType(); |
| 1135 | } |
| 1136 | } |
| 1137 | |
Roland Levillain | dff1f28 | 2014-11-05 14:15:05 +0000 | [diff] [blame] | 1138 | void LocationsBuilderX86_64::VisitTypeConversion(HTypeConversion* conversion) { |
| 1139 | LocationSummary* locations = |
| 1140 | new (GetGraph()->GetArena()) LocationSummary(conversion, LocationSummary::kNoCall); |
| 1141 | Primitive::Type result_type = conversion->GetResultType(); |
| 1142 | Primitive::Type input_type = conversion->GetInputType(); |
| 1143 | switch (result_type) { |
| 1144 | case Primitive::kPrimLong: |
| 1145 | switch (input_type) { |
| 1146 | case Primitive::kPrimByte: |
| 1147 | case Primitive::kPrimShort: |
| 1148 | case Primitive::kPrimInt: |
| 1149 | // int-to-long conversion. |
| 1150 | // TODO: We would benefit from a (to-be-implemented) |
| 1151 | // Location::RegisterOrStackSlot requirement for this input. |
| 1152 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1153 | locations->SetOut(Location::RequiresRegister()); |
| 1154 | break; |
| 1155 | |
| 1156 | case Primitive::kPrimFloat: |
| 1157 | case Primitive::kPrimDouble: |
| 1158 | LOG(FATAL) << "Type conversion from " << input_type << " to " |
| 1159 | << result_type << " not yet implemented"; |
| 1160 | break; |
| 1161 | |
| 1162 | default: |
| 1163 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1164 | << " to " << result_type; |
| 1165 | } |
| 1166 | break; |
| 1167 | |
| 1168 | case Primitive::kPrimInt: |
| 1169 | case Primitive::kPrimFloat: |
| 1170 | case Primitive::kPrimDouble: |
| 1171 | LOG(FATAL) << "Type conversion from " << input_type |
| 1172 | << " to " << result_type << " not yet implemented"; |
| 1173 | break; |
| 1174 | |
| 1175 | default: |
| 1176 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1177 | << " to " << result_type; |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conversion) { |
| 1182 | LocationSummary* locations = conversion->GetLocations(); |
| 1183 | Location out = locations->Out(); |
| 1184 | Location in = locations->InAt(0); |
| 1185 | Primitive::Type result_type = conversion->GetResultType(); |
| 1186 | Primitive::Type input_type = conversion->GetInputType(); |
| 1187 | switch (result_type) { |
| 1188 | case Primitive::kPrimLong: |
| 1189 | switch (input_type) { |
| 1190 | DCHECK(out.IsRegister()); |
| 1191 | case Primitive::kPrimByte: |
| 1192 | case Primitive::kPrimShort: |
| 1193 | case Primitive::kPrimInt: |
| 1194 | // int-to-long conversion. |
| 1195 | DCHECK(in.IsRegister()); |
| 1196 | __ movsxd(out.As<CpuRegister>(), in.As<CpuRegister>()); |
| 1197 | break; |
| 1198 | |
| 1199 | case Primitive::kPrimFloat: |
| 1200 | case Primitive::kPrimDouble: |
| 1201 | LOG(FATAL) << "Type conversion from " << input_type << " to " |
| 1202 | << result_type << " not yet implemented"; |
| 1203 | break; |
| 1204 | |
| 1205 | default: |
| 1206 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1207 | << " to " << result_type; |
| 1208 | } |
| 1209 | break; |
| 1210 | |
| 1211 | case Primitive::kPrimInt: |
| 1212 | case Primitive::kPrimFloat: |
| 1213 | case Primitive::kPrimDouble: |
| 1214 | LOG(FATAL) << "Type conversion from " << input_type |
| 1215 | << " to " << result_type << " not yet implemented"; |
| 1216 | break; |
| 1217 | |
| 1218 | default: |
| 1219 | LOG(FATAL) << "Unexpected type conversion from " << input_type |
| 1220 | << " to " << result_type; |
| 1221 | } |
| 1222 | } |
| 1223 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1224 | void LocationsBuilderX86_64::VisitAdd(HAdd* add) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1225 | LocationSummary* locations = |
| 1226 | new (GetGraph()->GetArena()) LocationSummary(add, LocationSummary::kNoCall); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1227 | switch (add->GetResultType()) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1228 | case Primitive::kPrimInt: { |
| 1229 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1230 | locations->SetInAt(1, Location::Any()); |
| 1231 | locations->SetOut(Location::SameAsFirstInput()); |
| 1232 | break; |
| 1233 | } |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1234 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1235 | case Primitive::kPrimLong: { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1236 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1237 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1238 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1239 | break; |
| 1240 | } |
| 1241 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1242 | case Primitive::kPrimDouble: |
| 1243 | case Primitive::kPrimFloat: { |
| 1244 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1245 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1246 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1247 | break; |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1248 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1249 | |
| 1250 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1251 | LOG(FATAL) << "Unexpected add type " << add->GetResultType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1252 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) { |
| 1256 | LocationSummary* locations = add->GetLocations(); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1257 | Location first = locations->InAt(0); |
| 1258 | Location second = locations->InAt(1); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1259 | DCHECK(first.Equals(locations->Out())); |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1260 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1261 | switch (add->GetResultType()) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1262 | case Primitive::kPrimInt: { |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1263 | if (second.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1264 | __ addl(first.As<CpuRegister>(), second.As<CpuRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1265 | } else if (second.IsConstant()) { |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1266 | Immediate imm(second.GetConstant()->AsIntConstant()->GetValue()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1267 | __ addl(first.As<CpuRegister>(), imm); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1268 | } else { |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1269 | __ addl(first.As<CpuRegister>(), Address(CpuRegister(RSP), second.GetStackIndex())); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1270 | } |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1271 | break; |
| 1272 | } |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1273 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1274 | case Primitive::kPrimLong: { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1275 | __ addq(first.As<CpuRegister>(), second.As<CpuRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1276 | break; |
| 1277 | } |
| 1278 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1279 | case Primitive::kPrimFloat: { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1280 | __ addss(first.As<XmmRegister>(), second.As<XmmRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1281 | break; |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | case Primitive::kPrimDouble: { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1285 | __ addsd(first.As<XmmRegister>(), second.As<XmmRegister>()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1286 | break; |
| 1287 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1288 | |
| 1289 | default: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 1290 | LOG(FATAL) << "Unexpected add type " << add->GetResultType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | void LocationsBuilderX86_64::VisitSub(HSub* sub) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1295 | LocationSummary* locations = |
| 1296 | new (GetGraph()->GetArena()) LocationSummary(sub, LocationSummary::kNoCall); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1297 | switch (sub->GetResultType()) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1298 | case Primitive::kPrimInt: { |
| 1299 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1300 | locations->SetInAt(1, Location::Any()); |
| 1301 | locations->SetOut(Location::SameAsFirstInput()); |
| 1302 | break; |
| 1303 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1304 | case Primitive::kPrimLong: { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1305 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1306 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1307 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1308 | break; |
| 1309 | } |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1310 | case Primitive::kPrimFloat: |
| 1311 | case Primitive::kPrimDouble: { |
| 1312 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1313 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 1314 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1315 | break; |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1316 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1317 | default: |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1318 | LOG(FATAL) << "Unexpected sub type " << sub->GetResultType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1319 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1320 | } |
| 1321 | |
| 1322 | void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) { |
| 1323 | LocationSummary* locations = sub->GetLocations(); |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1324 | Location first = locations->InAt(0); |
| 1325 | Location second = locations->InAt(1); |
| 1326 | DCHECK(first.Equals(locations->Out())); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1327 | switch (sub->GetResultType()) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1328 | case Primitive::kPrimInt: { |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1329 | if (second.IsRegister()) { |
| 1330 | __ subl(first.As<CpuRegister>(), second.As<CpuRegister>()); |
| 1331 | } else if (second.IsConstant()) { |
| 1332 | Immediate imm(second.GetConstant()->AsIntConstant()->GetValue()); |
| 1333 | __ subl(first.As<CpuRegister>(), imm); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1334 | } else { |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1335 | __ subl(first.As<CpuRegister>(), Address(CpuRegister(RSP), second.GetStackIndex())); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 1336 | } |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1337 | break; |
| 1338 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1339 | case Primitive::kPrimLong: { |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1340 | __ subq(first.As<CpuRegister>(), second.As<CpuRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1341 | break; |
| 1342 | } |
| 1343 | |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1344 | case Primitive::kPrimFloat: { |
| 1345 | __ subss(first.As<XmmRegister>(), second.As<XmmRegister>()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1346 | break; |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | case Primitive::kPrimDouble: { |
| 1350 | __ subsd(first.As<XmmRegister>(), second.As<XmmRegister>()); |
| 1351 | break; |
| 1352 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1353 | |
| 1354 | default: |
Calin Juravle | 1135168 | 2014-10-23 15:38:15 +0100 | [diff] [blame] | 1355 | LOG(FATAL) << "Unexpected sub type " << sub->GetResultType(); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1356 | } |
| 1357 | } |
| 1358 | |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1359 | void LocationsBuilderX86_64::VisitMul(HMul* mul) { |
| 1360 | LocationSummary* locations = |
| 1361 | new (GetGraph()->GetArena()) LocationSummary(mul, LocationSummary::kNoCall); |
| 1362 | switch (mul->GetResultType()) { |
| 1363 | case Primitive::kPrimInt: { |
| 1364 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1365 | locations->SetInAt(1, Location::Any()); |
| 1366 | locations->SetOut(Location::SameAsFirstInput()); |
| 1367 | break; |
| 1368 | } |
| 1369 | case Primitive::kPrimLong: { |
| 1370 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1371 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1372 | locations->SetOut(Location::SameAsFirstInput()); |
| 1373 | break; |
| 1374 | } |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 1375 | case Primitive::kPrimFloat: |
| 1376 | case Primitive::kPrimDouble: { |
| 1377 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1378 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 1379 | locations->SetOut(Location::SameAsFirstInput()); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1380 | break; |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 1381 | } |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1382 | |
| 1383 | default: |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 1384 | LOG(FATAL) << "Unexpected mul type " << mul->GetResultType(); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) { |
| 1389 | LocationSummary* locations = mul->GetLocations(); |
| 1390 | Location first = locations->InAt(0); |
| 1391 | Location second = locations->InAt(1); |
| 1392 | DCHECK(first.Equals(locations->Out())); |
| 1393 | switch (mul->GetResultType()) { |
| 1394 | case Primitive::kPrimInt: { |
| 1395 | if (second.IsRegister()) { |
| 1396 | __ imull(first.As<CpuRegister>(), second.As<CpuRegister>()); |
| 1397 | } else if (second.IsConstant()) { |
| 1398 | Immediate imm(second.GetConstant()->AsIntConstant()->GetValue()); |
| 1399 | __ imull(first.As<CpuRegister>(), imm); |
| 1400 | } else { |
| 1401 | DCHECK(second.IsStackSlot()); |
| 1402 | __ imull(first.As<CpuRegister>(), Address(CpuRegister(RSP), second.GetStackIndex())); |
| 1403 | } |
| 1404 | break; |
| 1405 | } |
| 1406 | case Primitive::kPrimLong: { |
| 1407 | __ imulq(first.As<CpuRegister>(), second.As<CpuRegister>()); |
| 1408 | break; |
| 1409 | } |
| 1410 | |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 1411 | case Primitive::kPrimFloat: { |
| 1412 | __ mulss(first.As<XmmRegister>(), second.As<XmmRegister>()); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1413 | break; |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | case Primitive::kPrimDouble: { |
| 1417 | __ mulsd(first.As<XmmRegister>(), second.As<XmmRegister>()); |
| 1418 | break; |
| 1419 | } |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1420 | |
| 1421 | default: |
Calin Juravle | b5bfa96 | 2014-10-21 18:02:24 +0100 | [diff] [blame] | 1422 | LOG(FATAL) << "Unexpected mul type " << mul->GetResultType(); |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 1423 | } |
| 1424 | } |
| 1425 | |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 1426 | void LocationsBuilderX86_64::VisitDiv(HDiv* div) { |
| 1427 | LocationSummary* locations = |
| 1428 | new (GetGraph()->GetArena()) LocationSummary(div, LocationSummary::kNoCall); |
| 1429 | switch (div->GetResultType()) { |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 1430 | case Primitive::kPrimInt: { |
| 1431 | locations->SetInAt(0, Location::RegisterLocation(RAX)); |
| 1432 | locations->SetInAt(1, Location::RequiresRegister()); |
| 1433 | locations->SetOut(Location::SameAsFirstInput()); |
| 1434 | // Intel uses edx:eax as the dividend. |
| 1435 | locations->AddTemp(Location::RegisterLocation(RDX)); |
| 1436 | break; |
| 1437 | } |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 1438 | case Primitive::kPrimLong: { |
| 1439 | LOG(FATAL) << "Not implemented div type" << div->GetResultType(); |
| 1440 | break; |
| 1441 | } |
| 1442 | case Primitive::kPrimFloat: |
| 1443 | case Primitive::kPrimDouble: { |
| 1444 | locations->SetInAt(0, Location::RequiresFpuRegister()); |
| 1445 | locations->SetInAt(1, Location::RequiresFpuRegister()); |
| 1446 | locations->SetOut(Location::SameAsFirstInput()); |
| 1447 | break; |
| 1448 | } |
| 1449 | |
| 1450 | default: |
| 1451 | LOG(FATAL) << "Unexpected div type " << div->GetResultType(); |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | void InstructionCodeGeneratorX86_64::VisitDiv(HDiv* div) { |
| 1456 | LocationSummary* locations = div->GetLocations(); |
| 1457 | Location first = locations->InAt(0); |
| 1458 | Location second = locations->InAt(1); |
| 1459 | DCHECK(first.Equals(locations->Out())); |
| 1460 | |
| 1461 | switch (div->GetResultType()) { |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 1462 | case Primitive::kPrimInt: { |
| 1463 | CpuRegister first_reg = first.As<CpuRegister>(); |
| 1464 | CpuRegister second_reg = second.As<CpuRegister>(); |
| 1465 | DCHECK_EQ(RAX, first_reg.AsRegister()); |
| 1466 | DCHECK_EQ(RDX, locations->GetTemp(0).As<CpuRegister>().AsRegister()); |
| 1467 | |
| 1468 | SlowPathCodeX86_64* slow_path = |
| 1469 | new (GetGraph()->GetArena()) DivMinusOneSlowPathX86_64(first_reg.AsRegister()); |
| 1470 | codegen_->AddSlowPath(slow_path); |
| 1471 | |
| 1472 | // 0x80000000/-1 triggers an arithmetic exception! |
| 1473 | // Dividing by -1 is actually negation and -0x800000000 = 0x80000000 so |
| 1474 | // it's safe to just use negl instead of more complex comparisons. |
| 1475 | |
| 1476 | __ cmpl(second_reg, Immediate(-1)); |
| 1477 | __ j(kEqual, slow_path->GetEntryLabel()); |
| 1478 | |
| 1479 | // edx:eax <- sign-extended of eax |
| 1480 | __ cdq(); |
| 1481 | // eax = quotient, edx = remainder |
| 1482 | __ idivl(second_reg); |
| 1483 | |
| 1484 | __ Bind(slow_path->GetExitLabel()); |
| 1485 | break; |
| 1486 | } |
| 1487 | |
Calin Juravle | 7c4954d | 2014-10-28 16:57:40 +0000 | [diff] [blame] | 1488 | case Primitive::kPrimLong: { |
| 1489 | LOG(FATAL) << "Not implemented div type" << div->GetResultType(); |
| 1490 | break; |
| 1491 | } |
| 1492 | |
| 1493 | case Primitive::kPrimFloat: { |
| 1494 | __ divss(first.As<XmmRegister>(), second.As<XmmRegister>()); |
| 1495 | break; |
| 1496 | } |
| 1497 | |
| 1498 | case Primitive::kPrimDouble: { |
| 1499 | __ divsd(first.As<XmmRegister>(), second.As<XmmRegister>()); |
| 1500 | break; |
| 1501 | } |
| 1502 | |
| 1503 | default: |
| 1504 | LOG(FATAL) << "Unexpected div type " << div->GetResultType(); |
| 1505 | } |
| 1506 | } |
| 1507 | |
Calin Juravle | d0d4852 | 2014-11-04 16:40:20 +0000 | [diff] [blame] | 1508 | void LocationsBuilderX86_64::VisitDivZeroCheck(HDivZeroCheck* instruction) { |
| 1509 | LocationSummary* locations = |
| 1510 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 1511 | locations->SetInAt(0, Location::Any()); |
| 1512 | if (instruction->HasUses()) { |
| 1513 | locations->SetOut(Location::SameAsFirstInput()); |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | void InstructionCodeGeneratorX86_64::VisitDivZeroCheck(HDivZeroCheck* instruction) { |
| 1518 | SlowPathCodeX86_64* slow_path = |
| 1519 | new (GetGraph()->GetArena()) DivZeroCheckSlowPathX86_64(instruction); |
| 1520 | codegen_->AddSlowPath(slow_path); |
| 1521 | |
| 1522 | LocationSummary* locations = instruction->GetLocations(); |
| 1523 | Location value = locations->InAt(0); |
| 1524 | |
| 1525 | if (value.IsRegister()) { |
| 1526 | __ testl(value.As<CpuRegister>(), value.As<CpuRegister>()); |
| 1527 | } else if (value.IsStackSlot()) { |
| 1528 | __ cmpl(Address(CpuRegister(RSP), value.GetStackIndex()), Immediate(0)); |
| 1529 | } else { |
| 1530 | DCHECK(value.IsConstant()) << value; |
| 1531 | if (value.GetConstant()->AsIntConstant()->GetValue() == 0) { |
| 1532 | __ jmp(slow_path->GetEntryLabel()); |
| 1533 | } |
| 1534 | return; |
| 1535 | } |
| 1536 | __ j(kEqual, slow_path->GetEntryLabel()); |
| 1537 | } |
| 1538 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1539 | void LocationsBuilderX86_64::VisitNewInstance(HNewInstance* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1540 | LocationSummary* locations = |
| 1541 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
Nicolas Geoffray | 9ae0daa | 2014-09-30 22:40:23 +0100 | [diff] [blame] | 1542 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1543 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 1544 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 1545 | locations->SetOut(Location::RegisterLocation(RAX)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1546 | } |
| 1547 | |
| 1548 | void InstructionCodeGeneratorX86_64::VisitNewInstance(HNewInstance* instruction) { |
| 1549 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1550 | codegen_->LoadCurrentMethod(CpuRegister(calling_convention.GetRegisterAt(1))); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1551 | __ movq(CpuRegister(calling_convention.GetRegisterAt(0)), Immediate(instruction->GetTypeIndex())); |
| 1552 | |
| 1553 | __ gs()->call(Address::Absolute( |
| 1554 | QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pAllocObjectWithAccessCheck), true)); |
| 1555 | |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 1556 | DCHECK(!codegen_->IsLeafMethod()); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1557 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1558 | } |
| 1559 | |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 1560 | void LocationsBuilderX86_64::VisitNewArray(HNewArray* instruction) { |
| 1561 | LocationSummary* locations = |
| 1562 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCall); |
| 1563 | InvokeRuntimeCallingConvention calling_convention; |
| 1564 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 1565 | locations->AddTemp(Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 1566 | locations->SetOut(Location::RegisterLocation(RAX)); |
| 1567 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(2))); |
| 1568 | } |
| 1569 | |
| 1570 | void InstructionCodeGeneratorX86_64::VisitNewArray(HNewArray* instruction) { |
| 1571 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 1572 | codegen_->LoadCurrentMethod(CpuRegister(calling_convention.GetRegisterAt(1))); |
Nicolas Geoffray | a3d05a4 | 2014-10-20 17:41:32 +0100 | [diff] [blame] | 1573 | __ movq(CpuRegister(calling_convention.GetRegisterAt(0)), Immediate(instruction->GetTypeIndex())); |
| 1574 | |
| 1575 | __ gs()->call(Address::Absolute( |
| 1576 | QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pAllocArrayWithAccessCheck), true)); |
| 1577 | |
| 1578 | DCHECK(!codegen_->IsLeafMethod()); |
| 1579 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
| 1580 | } |
| 1581 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1582 | void LocationsBuilderX86_64::VisitParameterValue(HParameterValue* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1583 | LocationSummary* locations = |
| 1584 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1585 | Location location = parameter_visitor_.GetNextLocation(instruction->GetType()); |
| 1586 | if (location.IsStackSlot()) { |
| 1587 | location = Location::StackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
| 1588 | } else if (location.IsDoubleStackSlot()) { |
| 1589 | location = Location::DoubleStackSlot(location.GetStackIndex() + codegen_->GetFrameSize()); |
| 1590 | } |
| 1591 | locations->SetOut(location); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | void InstructionCodeGeneratorX86_64::VisitParameterValue(HParameterValue* instruction) { |
| 1595 | // Nothing to do, the parameter is already at its location. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1596 | UNUSED(instruction); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1597 | } |
| 1598 | |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 1599 | void LocationsBuilderX86_64::VisitNot(HNot* not_) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1600 | LocationSummary* locations = |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 1601 | new (GetGraph()->GetArena()) LocationSummary(not_, LocationSummary::kNoCall); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 1602 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1603 | locations->SetOut(Location::SameAsFirstInput()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1604 | } |
| 1605 | |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 1606 | void InstructionCodeGeneratorX86_64::VisitNot(HNot* not_) { |
| 1607 | LocationSummary* locations = not_->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1608 | DCHECK_EQ(locations->InAt(0).As<CpuRegister>().AsRegister(), |
| 1609 | locations->Out().As<CpuRegister>().AsRegister()); |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 1610 | Location out = locations->Out(); |
| 1611 | switch (not_->InputAt(0)->GetType()) { |
| 1612 | case Primitive::kPrimBoolean: |
| 1613 | __ xorq(out.As<CpuRegister>(), Immediate(1)); |
| 1614 | break; |
| 1615 | |
| 1616 | case Primitive::kPrimInt: |
| 1617 | __ notl(out.As<CpuRegister>()); |
| 1618 | break; |
| 1619 | |
| 1620 | case Primitive::kPrimLong: |
Roland Levillain | 7056643 | 2014-10-24 16:20:17 +0100 | [diff] [blame] | 1621 | __ notq(out.As<CpuRegister>()); |
Roland Levillain | 1cc5f251 | 2014-10-22 18:06:21 +0100 | [diff] [blame] | 1622 | break; |
| 1623 | |
| 1624 | default: |
| 1625 | LOG(FATAL) << "Unimplemented type for not operation " << not_->GetResultType(); |
| 1626 | } |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1627 | } |
| 1628 | |
| 1629 | void LocationsBuilderX86_64::VisitPhi(HPhi* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1630 | LocationSummary* locations = |
| 1631 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1632 | for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { |
| 1633 | locations->SetInAt(i, Location::Any()); |
| 1634 | } |
| 1635 | locations->SetOut(Location::Any()); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1636 | } |
| 1637 | |
| 1638 | void InstructionCodeGeneratorX86_64::VisitPhi(HPhi* instruction) { |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 1639 | UNUSED(instruction); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 1640 | LOG(FATAL) << "Unimplemented"; |
| 1641 | } |
| 1642 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1643 | void LocationsBuilderX86_64::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1644 | LocationSummary* locations = |
| 1645 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 9ae0daa | 2014-09-30 22:40:23 +0100 | [diff] [blame] | 1646 | Primitive::Type field_type = instruction->GetFieldType(); |
| 1647 | bool is_object_type = field_type == Primitive::kPrimNot; |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1648 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1649 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 9ae0daa | 2014-09-30 22:40:23 +0100 | [diff] [blame] | 1650 | if (is_object_type) { |
| 1651 | // Temporary registers for the write barrier. |
Nicolas Geoffray | 1a43dd7 | 2014-07-17 15:15:34 +0100 | [diff] [blame] | 1652 | locations->AddTemp(Location::RequiresRegister()); |
| 1653 | locations->AddTemp(Location::RequiresRegister()); |
| 1654 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | void InstructionCodeGeneratorX86_64::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
| 1658 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1659 | CpuRegister obj = locations->InAt(0).As<CpuRegister>(); |
| 1660 | CpuRegister value = locations->InAt(1).As<CpuRegister>(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1661 | size_t offset = instruction->GetFieldOffset().SizeValue(); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1662 | Primitive::Type field_type = instruction->GetFieldType(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1663 | |
| 1664 | switch (field_type) { |
| 1665 | case Primitive::kPrimBoolean: |
| 1666 | case Primitive::kPrimByte: { |
| 1667 | __ movb(Address(obj, offset), value); |
| 1668 | break; |
| 1669 | } |
| 1670 | |
| 1671 | case Primitive::kPrimShort: |
| 1672 | case Primitive::kPrimChar: { |
| 1673 | __ movw(Address(obj, offset), value); |
| 1674 | break; |
| 1675 | } |
| 1676 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1677 | case Primitive::kPrimInt: |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1678 | case Primitive::kPrimNot: { |
| 1679 | __ movl(Address(obj, offset), value); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1680 | if (field_type == Primitive::kPrimNot) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1681 | CpuRegister temp = locations->GetTemp(0).As<CpuRegister>(); |
| 1682 | CpuRegister card = locations->GetTemp(1).As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1683 | codegen_->MarkGCCard(temp, card, obj, value); |
| 1684 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1685 | break; |
| 1686 | } |
| 1687 | |
| 1688 | case Primitive::kPrimLong: { |
| 1689 | __ movq(Address(obj, offset), value); |
| 1690 | break; |
| 1691 | } |
| 1692 | |
| 1693 | case Primitive::kPrimFloat: |
| 1694 | case Primitive::kPrimDouble: |
| 1695 | LOG(FATAL) << "Unimplemented register type " << field_type; |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 1696 | UNREACHABLE(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1697 | case Primitive::kPrimVoid: |
| 1698 | LOG(FATAL) << "Unreachable type " << field_type; |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 1699 | UNREACHABLE(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1700 | } |
| 1701 | } |
| 1702 | |
| 1703 | void LocationsBuilderX86_64::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1704 | LocationSummary* locations = |
| 1705 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1706 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1707 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | void InstructionCodeGeneratorX86_64::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 1711 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1712 | CpuRegister obj = locations->InAt(0).As<CpuRegister>(); |
| 1713 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1714 | size_t offset = instruction->GetFieldOffset().SizeValue(); |
| 1715 | |
| 1716 | switch (instruction->GetType()) { |
| 1717 | case Primitive::kPrimBoolean: { |
| 1718 | __ movzxb(out, Address(obj, offset)); |
| 1719 | break; |
| 1720 | } |
| 1721 | |
| 1722 | case Primitive::kPrimByte: { |
| 1723 | __ movsxb(out, Address(obj, offset)); |
| 1724 | break; |
| 1725 | } |
| 1726 | |
| 1727 | case Primitive::kPrimShort: { |
| 1728 | __ movsxw(out, Address(obj, offset)); |
| 1729 | break; |
| 1730 | } |
| 1731 | |
| 1732 | case Primitive::kPrimChar: { |
| 1733 | __ movzxw(out, Address(obj, offset)); |
| 1734 | break; |
| 1735 | } |
| 1736 | |
| 1737 | case Primitive::kPrimInt: |
| 1738 | case Primitive::kPrimNot: { |
| 1739 | __ movl(out, Address(obj, offset)); |
| 1740 | break; |
| 1741 | } |
| 1742 | |
| 1743 | case Primitive::kPrimLong: { |
| 1744 | __ movq(out, Address(obj, offset)); |
| 1745 | break; |
| 1746 | } |
| 1747 | |
| 1748 | case Primitive::kPrimFloat: |
| 1749 | case Primitive::kPrimDouble: |
| 1750 | LOG(FATAL) << "Unimplemented register type " << instruction->GetType(); |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 1751 | UNREACHABLE(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1752 | case Primitive::kPrimVoid: |
| 1753 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 1754 | UNREACHABLE(); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | void LocationsBuilderX86_64::VisitNullCheck(HNullCheck* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1759 | LocationSummary* locations = |
| 1760 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1761 | locations->SetInAt(0, Location::Any()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1762 | if (instruction->HasUses()) { |
| 1763 | locations->SetOut(Location::SameAsFirstInput()); |
| 1764 | } |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1765 | } |
| 1766 | |
| 1767 | void InstructionCodeGeneratorX86_64::VisitNullCheck(HNullCheck* instruction) { |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 1768 | SlowPathCodeX86_64* slow_path = new (GetGraph()->GetArena()) NullCheckSlowPathX86_64(instruction); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1769 | codegen_->AddSlowPath(slow_path); |
| 1770 | |
| 1771 | LocationSummary* locations = instruction->GetLocations(); |
| 1772 | Location obj = locations->InAt(0); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1773 | |
| 1774 | if (obj.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1775 | __ cmpl(obj.As<CpuRegister>(), Immediate(0)); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1776 | } else if (obj.IsStackSlot()) { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1777 | __ cmpl(Address(CpuRegister(RSP), obj.GetStackIndex()), Immediate(0)); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1778 | } else { |
| 1779 | DCHECK(obj.IsConstant()) << obj; |
| 1780 | DCHECK_EQ(obj.GetConstant()->AsIntConstant()->GetValue(), 0); |
| 1781 | __ jmp(slow_path->GetEntryLabel()); |
| 1782 | return; |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 1783 | } |
| 1784 | __ j(kEqual, slow_path->GetEntryLabel()); |
| 1785 | } |
| 1786 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1787 | void LocationsBuilderX86_64::VisitArrayGet(HArrayGet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1788 | LocationSummary* locations = |
| 1789 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1790 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 9ae0daa | 2014-09-30 22:40:23 +0100 | [diff] [blame] | 1791 | locations->SetInAt( |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1792 | 1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1793 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1794 | } |
| 1795 | |
| 1796 | void InstructionCodeGeneratorX86_64::VisitArrayGet(HArrayGet* instruction) { |
| 1797 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1798 | CpuRegister obj = locations->InAt(0).As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1799 | Location index = locations->InAt(1); |
| 1800 | |
| 1801 | switch (instruction->GetType()) { |
| 1802 | case Primitive::kPrimBoolean: { |
| 1803 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1804 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1805 | if (index.IsConstant()) { |
| 1806 | __ movzxb(out, Address(obj, |
| 1807 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset)); |
| 1808 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1809 | __ movzxb(out, Address(obj, index.As<CpuRegister>(), TIMES_1, data_offset)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1810 | } |
| 1811 | break; |
| 1812 | } |
| 1813 | |
| 1814 | case Primitive::kPrimByte: { |
| 1815 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int8_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1816 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1817 | if (index.IsConstant()) { |
| 1818 | __ movsxb(out, Address(obj, |
| 1819 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset)); |
| 1820 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1821 | __ movsxb(out, Address(obj, index.As<CpuRegister>(), TIMES_1, data_offset)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1822 | } |
| 1823 | break; |
| 1824 | } |
| 1825 | |
| 1826 | case Primitive::kPrimShort: { |
| 1827 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int16_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1828 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1829 | if (index.IsConstant()) { |
| 1830 | __ movsxw(out, Address(obj, |
| 1831 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset)); |
| 1832 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1833 | __ movsxw(out, Address(obj, index.As<CpuRegister>(), TIMES_2, data_offset)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1834 | } |
| 1835 | break; |
| 1836 | } |
| 1837 | |
| 1838 | case Primitive::kPrimChar: { |
| 1839 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1840 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1841 | if (index.IsConstant()) { |
| 1842 | __ movzxw(out, Address(obj, |
| 1843 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset)); |
| 1844 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1845 | __ movzxw(out, Address(obj, index.As<CpuRegister>(), TIMES_2, data_offset)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1846 | } |
| 1847 | break; |
| 1848 | } |
| 1849 | |
| 1850 | case Primitive::kPrimInt: |
| 1851 | case Primitive::kPrimNot: { |
| 1852 | DCHECK_EQ(sizeof(mirror::HeapReference<mirror::Object>), sizeof(int32_t)); |
| 1853 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1854 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1855 | if (index.IsConstant()) { |
| 1856 | __ movl(out, Address(obj, |
| 1857 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset)); |
| 1858 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1859 | __ movl(out, Address(obj, index.As<CpuRegister>(), TIMES_4, data_offset)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1860 | } |
| 1861 | break; |
| 1862 | } |
| 1863 | |
| 1864 | case Primitive::kPrimLong: { |
| 1865 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1866 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1867 | if (index.IsConstant()) { |
| 1868 | __ movq(out, Address(obj, |
| 1869 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset)); |
| 1870 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1871 | __ movq(out, Address(obj, index.As<CpuRegister>(), TIMES_8, data_offset)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1872 | } |
| 1873 | break; |
| 1874 | } |
| 1875 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1876 | case Primitive::kPrimFloat: { |
| 1877 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(float)).Uint32Value(); |
| 1878 | XmmRegister out = locations->Out().As<XmmRegister>(); |
| 1879 | if (index.IsConstant()) { |
| 1880 | __ movss(out, Address(obj, |
| 1881 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset)); |
| 1882 | } else { |
| 1883 | __ movss(out, Address(obj, index.As<CpuRegister>(), TIMES_4, data_offset)); |
| 1884 | } |
| 1885 | break; |
| 1886 | } |
| 1887 | |
| 1888 | case Primitive::kPrimDouble: { |
| 1889 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(double)).Uint32Value(); |
| 1890 | XmmRegister out = locations->Out().As<XmmRegister>(); |
| 1891 | if (index.IsConstant()) { |
| 1892 | __ movsd(out, Address(obj, |
| 1893 | (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset)); |
| 1894 | } else { |
| 1895 | __ movsd(out, Address(obj, index.As<CpuRegister>(), TIMES_8, data_offset)); |
| 1896 | } |
| 1897 | break; |
| 1898 | } |
| 1899 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1900 | case Primitive::kPrimVoid: |
| 1901 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 1902 | UNREACHABLE(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1903 | } |
| 1904 | } |
| 1905 | |
| 1906 | void LocationsBuilderX86_64::VisitArraySet(HArraySet* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1907 | Primitive::Type value_type = instruction->GetComponentType(); |
| 1908 | bool is_object = value_type == Primitive::kPrimNot; |
| 1909 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary( |
| 1910 | instruction, is_object ? LocationSummary::kCall : LocationSummary::kNoCall); |
| 1911 | if (is_object) { |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1912 | InvokeRuntimeCallingConvention calling_convention; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1913 | locations->SetInAt(0, Location::RegisterLocation(calling_convention.GetRegisterAt(0))); |
| 1914 | locations->SetInAt(1, Location::RegisterLocation(calling_convention.GetRegisterAt(1))); |
| 1915 | locations->SetInAt(2, Location::RegisterLocation(calling_convention.GetRegisterAt(2))); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1916 | } else { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1917 | locations->SetInAt(0, Location::RequiresRegister()); |
Nicolas Geoffray | 9ae0daa | 2014-09-30 22:40:23 +0100 | [diff] [blame] | 1918 | locations->SetInAt( |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1919 | 1, Location::RegisterOrConstant(instruction->InputAt(1))); |
| 1920 | locations->SetInAt(2, Location::RequiresRegister()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1921 | if (value_type == Primitive::kPrimLong) { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1922 | locations->SetInAt(2, Location::RequiresRegister()); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1923 | } else if (value_type == Primitive::kPrimFloat || value_type == Primitive::kPrimDouble) { |
| 1924 | locations->SetInAt(2, Location::RequiresFpuRegister()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1925 | } else { |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 1926 | locations->SetInAt(2, Location::RegisterOrConstant(instruction->InputAt(2))); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1927 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1928 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1929 | } |
| 1930 | |
| 1931 | void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) { |
| 1932 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1933 | CpuRegister obj = locations->InAt(0).As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1934 | Location index = locations->InAt(1); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1935 | Location value = locations->InAt(2); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1936 | Primitive::Type value_type = instruction->GetComponentType(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1937 | |
| 1938 | switch (value_type) { |
| 1939 | case Primitive::kPrimBoolean: |
| 1940 | case Primitive::kPrimByte: { |
| 1941 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint8_t)).Uint32Value(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1942 | if (index.IsConstant()) { |
| 1943 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_1) + data_offset; |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1944 | if (value.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1945 | __ movb(Address(obj, offset), value.As<CpuRegister>()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1946 | } else { |
| 1947 | __ movb(Address(obj, offset), Immediate(value.GetConstant()->AsIntConstant()->GetValue())); |
| 1948 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1949 | } else { |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1950 | if (value.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1951 | __ movb(Address(obj, index.As<CpuRegister>(), TIMES_1, data_offset), |
| 1952 | value.As<CpuRegister>()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1953 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1954 | __ movb(Address(obj, index.As<CpuRegister>(), TIMES_1, data_offset), |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1955 | Immediate(value.GetConstant()->AsIntConstant()->GetValue())); |
| 1956 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1957 | } |
| 1958 | break; |
| 1959 | } |
| 1960 | |
| 1961 | case Primitive::kPrimShort: |
| 1962 | case Primitive::kPrimChar: { |
| 1963 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Uint32Value(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1964 | if (index.IsConstant()) { |
| 1965 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_2) + data_offset; |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1966 | if (value.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1967 | __ movw(Address(obj, offset), value.As<CpuRegister>()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1968 | } else { |
| 1969 | __ movw(Address(obj, offset), Immediate(value.GetConstant()->AsIntConstant()->GetValue())); |
| 1970 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1971 | } else { |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1972 | if (value.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1973 | __ movw(Address(obj, index.As<CpuRegister>(), TIMES_2, data_offset), |
| 1974 | value.As<CpuRegister>()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1975 | } else { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1976 | __ movw(Address(obj, index.As<CpuRegister>(), TIMES_2, data_offset), |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1977 | Immediate(value.GetConstant()->AsIntConstant()->GetValue())); |
| 1978 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1979 | } |
| 1980 | break; |
| 1981 | } |
| 1982 | |
| 1983 | case Primitive::kPrimInt: { |
| 1984 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int32_t)).Uint32Value(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1985 | if (index.IsConstant()) { |
| 1986 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1987 | if (value.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1988 | __ movl(Address(obj, offset), value.As<CpuRegister>()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1989 | } else { |
| 1990 | __ movl(Address(obj, offset), Immediate(value.GetConstant()->AsIntConstant()->GetValue())); |
| 1991 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 1992 | } else { |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1993 | if (value.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1994 | __ movl(Address(obj, index.As<CpuRegister>(), TIMES_4, data_offset), |
| 1995 | value.As<CpuRegister>()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1996 | } else { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 1997 | DCHECK(value.IsConstant()) << value; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 1998 | __ movl(Address(obj, index.As<CpuRegister>(), TIMES_4, data_offset), |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 1999 | Immediate(value.GetConstant()->AsIntConstant()->GetValue())); |
| 2000 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2001 | } |
| 2002 | break; |
| 2003 | } |
| 2004 | |
| 2005 | case Primitive::kPrimNot: { |
| 2006 | __ gs()->call(Address::Absolute(QUICK_ENTRYPOINT_OFFSET(kX86_64WordSize, pAputObject), true)); |
| 2007 | DCHECK(!codegen_->IsLeafMethod()); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 2008 | codegen_->RecordPcInfo(instruction, instruction->GetDexPc()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2009 | break; |
| 2010 | } |
| 2011 | |
| 2012 | case Primitive::kPrimLong: { |
| 2013 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(int64_t)).Uint32Value(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2014 | if (index.IsConstant()) { |
| 2015 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 2016 | DCHECK(value.IsRegister()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2017 | __ movq(Address(obj, offset), value.As<CpuRegister>()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2018 | } else { |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 2019 | DCHECK(value.IsRegister()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2020 | __ movq(Address(obj, index.As<CpuRegister>(), TIMES_8, data_offset), |
| 2021 | value.As<CpuRegister>()); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2022 | } |
| 2023 | break; |
| 2024 | } |
| 2025 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2026 | case Primitive::kPrimFloat: { |
| 2027 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(float)).Uint32Value(); |
| 2028 | if (index.IsConstant()) { |
| 2029 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; |
| 2030 | DCHECK(value.IsFpuRegister()); |
| 2031 | __ movss(Address(obj, offset), value.As<XmmRegister>()); |
| 2032 | } else { |
| 2033 | DCHECK(value.IsFpuRegister()); |
| 2034 | __ movss(Address(obj, index.As<CpuRegister>(), TIMES_4, data_offset), |
| 2035 | value.As<XmmRegister>()); |
| 2036 | } |
| 2037 | break; |
| 2038 | } |
| 2039 | |
| 2040 | case Primitive::kPrimDouble: { |
| 2041 | uint32_t data_offset = mirror::Array::DataOffset(sizeof(double)).Uint32Value(); |
| 2042 | if (index.IsConstant()) { |
| 2043 | size_t offset = (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_8) + data_offset; |
| 2044 | DCHECK(value.IsFpuRegister()); |
| 2045 | __ movsd(Address(obj, offset), value.As<XmmRegister>()); |
| 2046 | } else { |
| 2047 | DCHECK(value.IsFpuRegister()); |
| 2048 | __ movsd(Address(obj, index.As<CpuRegister>(), TIMES_8, data_offset), |
| 2049 | value.As<XmmRegister>()); |
| 2050 | } |
| 2051 | break; |
| 2052 | } |
| 2053 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2054 | case Primitive::kPrimVoid: |
| 2055 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
Ian Rogers | fc787ec | 2014-10-09 21:56:44 -0700 | [diff] [blame] | 2056 | UNREACHABLE(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2057 | } |
| 2058 | } |
| 2059 | |
| 2060 | void LocationsBuilderX86_64::VisitArrayLength(HArrayLength* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 2061 | LocationSummary* locations = |
| 2062 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 2063 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2064 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2065 | } |
| 2066 | |
| 2067 | void InstructionCodeGeneratorX86_64::VisitArrayLength(HArrayLength* instruction) { |
| 2068 | LocationSummary* locations = instruction->GetLocations(); |
| 2069 | uint32_t offset = mirror::Array::LengthOffset().Uint32Value(); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2070 | CpuRegister obj = locations->InAt(0).As<CpuRegister>(); |
| 2071 | CpuRegister out = locations->Out().As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2072 | __ movl(out, Address(obj, offset)); |
| 2073 | } |
| 2074 | |
| 2075 | void LocationsBuilderX86_64::VisitBoundsCheck(HBoundsCheck* instruction) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 2076 | LocationSummary* locations = |
| 2077 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2078 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2079 | locations->SetInAt(1, Location::RequiresRegister()); |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 2080 | if (instruction->HasUses()) { |
| 2081 | locations->SetOut(Location::SameAsFirstInput()); |
| 2082 | } |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | void InstructionCodeGeneratorX86_64::VisitBoundsCheck(HBoundsCheck* instruction) { |
| 2086 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 2087 | SlowPathCodeX86_64* slow_path = new (GetGraph()->GetArena()) BoundsCheckSlowPathX86_64( |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 2088 | instruction, locations->InAt(0), locations->InAt(1)); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2089 | codegen_->AddSlowPath(slow_path); |
| 2090 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2091 | CpuRegister index = locations->InAt(0).As<CpuRegister>(); |
| 2092 | CpuRegister length = locations->InAt(1).As<CpuRegister>(); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 2093 | |
| 2094 | __ cmpl(index, length); |
| 2095 | __ j(kAboveEqual, slow_path->GetEntryLabel()); |
| 2096 | } |
| 2097 | |
| 2098 | void CodeGeneratorX86_64::MarkGCCard(CpuRegister temp, |
| 2099 | CpuRegister card, |
| 2100 | CpuRegister object, |
| 2101 | CpuRegister value) { |
| 2102 | Label is_null; |
| 2103 | __ testl(value, value); |
| 2104 | __ j(kEqual, &is_null); |
| 2105 | __ gs()->movq(card, Address::Absolute( |
| 2106 | Thread::CardTableOffset<kX86_64WordSize>().Int32Value(), true)); |
| 2107 | __ movq(temp, object); |
| 2108 | __ shrq(temp, Immediate(gc::accounting::CardTable::kCardShift)); |
| 2109 | __ movb(Address(temp, card, TIMES_1, 0), card); |
| 2110 | __ Bind(&is_null); |
| 2111 | } |
| 2112 | |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 2113 | void LocationsBuilderX86_64::VisitTemporary(HTemporary* temp) { |
| 2114 | temp->SetLocations(nullptr); |
| 2115 | } |
| 2116 | |
| 2117 | void InstructionCodeGeneratorX86_64::VisitTemporary(HTemporary* temp) { |
| 2118 | // Nothing to do, this is driven by the code generator. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 2119 | UNUSED(temp); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 2120 | } |
| 2121 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 2122 | void LocationsBuilderX86_64::VisitParallelMove(HParallelMove* instruction) { |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 2123 | UNUSED(instruction); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 2124 | LOG(FATAL) << "Unimplemented"; |
| 2125 | } |
| 2126 | |
| 2127 | void InstructionCodeGeneratorX86_64::VisitParallelMove(HParallelMove* instruction) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2128 | codegen_->GetMoveResolver()->EmitNativeCode(instruction); |
| 2129 | } |
| 2130 | |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 2131 | void LocationsBuilderX86_64::VisitSuspendCheck(HSuspendCheck* instruction) { |
| 2132 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kCallOnSlowPath); |
| 2133 | } |
| 2134 | |
| 2135 | void InstructionCodeGeneratorX86_64::VisitSuspendCheck(HSuspendCheck* instruction) { |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 2136 | HBasicBlock* block = instruction->GetBlock(); |
| 2137 | if (block->GetLoopInformation() != nullptr) { |
| 2138 | DCHECK(block->GetLoopInformation()->GetSuspendCheck() == instruction); |
| 2139 | // The back edge will generate the suspend check. |
| 2140 | return; |
| 2141 | } |
| 2142 | if (block->IsEntryBlock() && instruction->GetNext()->IsGoto()) { |
| 2143 | // The goto will generate the suspend check. |
| 2144 | return; |
| 2145 | } |
| 2146 | GenerateSuspendCheck(instruction, nullptr); |
| 2147 | } |
| 2148 | |
| 2149 | void InstructionCodeGeneratorX86_64::GenerateSuspendCheck(HSuspendCheck* instruction, |
| 2150 | HBasicBlock* successor) { |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 2151 | SuspendCheckSlowPathX86_64* slow_path = |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 2152 | new (GetGraph()->GetArena()) SuspendCheckSlowPathX86_64(instruction, successor); |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 2153 | codegen_->AddSlowPath(slow_path); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 2154 | __ gs()->cmpw(Address::Absolute( |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 2155 | Thread::ThreadFlagsOffset<kX86_64WordSize>().Int32Value(), true), Immediate(0)); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 2156 | if (successor == nullptr) { |
| 2157 | __ j(kNotEqual, slow_path->GetEntryLabel()); |
| 2158 | __ Bind(slow_path->GetReturnLabel()); |
| 2159 | } else { |
| 2160 | __ j(kEqual, codegen_->GetLabelOf(successor)); |
| 2161 | __ jmp(slow_path->GetEntryLabel()); |
| 2162 | } |
Nicolas Geoffray | fbc695f | 2014-09-15 15:33:30 +0000 | [diff] [blame] | 2163 | } |
| 2164 | |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2165 | X86_64Assembler* ParallelMoveResolverX86_64::GetAssembler() const { |
| 2166 | return codegen_->GetAssembler(); |
| 2167 | } |
| 2168 | |
| 2169 | void ParallelMoveResolverX86_64::EmitMove(size_t index) { |
| 2170 | MoveOperands* move = moves_.Get(index); |
| 2171 | Location source = move->GetSource(); |
| 2172 | Location destination = move->GetDestination(); |
| 2173 | |
| 2174 | if (source.IsRegister()) { |
| 2175 | if (destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2176 | __ movq(destination.As<CpuRegister>(), source.As<CpuRegister>()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2177 | } else if (destination.IsStackSlot()) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2178 | __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2179 | source.As<CpuRegister>()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2180 | } else { |
| 2181 | DCHECK(destination.IsDoubleStackSlot()); |
| 2182 | __ movq(Address(CpuRegister(RSP), destination.GetStackIndex()), |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2183 | source.As<CpuRegister>()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2184 | } |
| 2185 | } else if (source.IsStackSlot()) { |
| 2186 | if (destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2187 | __ movl(destination.As<CpuRegister>(), |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2188 | Address(CpuRegister(RSP), source.GetStackIndex())); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2189 | } else if (destination.IsFpuRegister()) { |
| 2190 | __ movss(destination.As<XmmRegister>(), |
| 2191 | Address(CpuRegister(RSP), source.GetStackIndex())); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2192 | } else { |
| 2193 | DCHECK(destination.IsStackSlot()); |
| 2194 | __ movl(CpuRegister(TMP), Address(CpuRegister(RSP), source.GetStackIndex())); |
| 2195 | __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), CpuRegister(TMP)); |
| 2196 | } |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2197 | } else if (source.IsDoubleStackSlot()) { |
| 2198 | if (destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2199 | __ movq(destination.As<CpuRegister>(), |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2200 | Address(CpuRegister(RSP), source.GetStackIndex())); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2201 | } else if (destination.IsFpuRegister()) { |
| 2202 | __ movsd(destination.As<XmmRegister>(), Address(CpuRegister(RSP), source.GetStackIndex())); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2203 | } else { |
Nicolas Geoffray | c8147a7 | 2014-10-21 16:06:20 +0100 | [diff] [blame] | 2204 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2205 | __ movq(CpuRegister(TMP), Address(CpuRegister(RSP), source.GetStackIndex())); |
| 2206 | __ movq(Address(CpuRegister(RSP), destination.GetStackIndex()), CpuRegister(TMP)); |
| 2207 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2208 | } else if (source.IsConstant()) { |
| 2209 | HConstant* constant = source.GetConstant(); |
| 2210 | if (constant->IsIntConstant()) { |
| 2211 | Immediate imm(constant->AsIntConstant()->GetValue()); |
| 2212 | if (destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2213 | __ movl(destination.As<CpuRegister>(), imm); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2214 | } else { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2215 | DCHECK(destination.IsStackSlot()) << destination; |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2216 | __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), imm); |
| 2217 | } |
| 2218 | } else if (constant->IsLongConstant()) { |
| 2219 | int64_t value = constant->AsLongConstant()->GetValue(); |
| 2220 | if (destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2221 | __ movq(destination.As<CpuRegister>(), Immediate(value)); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2222 | } else { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2223 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2224 | __ movq(CpuRegister(TMP), Immediate(value)); |
| 2225 | __ movq(Address(CpuRegister(RSP), destination.GetStackIndex()), CpuRegister(TMP)); |
| 2226 | } |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2227 | } else if (constant->IsFloatConstant()) { |
| 2228 | Immediate imm(bit_cast<float, int32_t>(constant->AsFloatConstant()->GetValue())); |
| 2229 | if (destination.IsFpuRegister()) { |
| 2230 | __ movl(CpuRegister(TMP), imm); |
| 2231 | __ movd(destination.As<XmmRegister>(), CpuRegister(TMP)); |
| 2232 | } else { |
| 2233 | DCHECK(destination.IsStackSlot()) << destination; |
| 2234 | __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), imm); |
| 2235 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2236 | } else { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2237 | DCHECK(constant->IsDoubleConstant()) << constant->DebugName(); |
| 2238 | Immediate imm(bit_cast<double, int64_t>(constant->AsDoubleConstant()->GetValue())); |
| 2239 | if (destination.IsFpuRegister()) { |
| 2240 | __ movq(CpuRegister(TMP), imm); |
| 2241 | __ movd(destination.As<XmmRegister>(), CpuRegister(TMP)); |
| 2242 | } else { |
| 2243 | DCHECK(destination.IsDoubleStackSlot()) << destination; |
| 2244 | __ movq(CpuRegister(TMP), imm); |
| 2245 | __ movq(Address(CpuRegister(RSP), destination.GetStackIndex()), CpuRegister(TMP)); |
| 2246 | } |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 2247 | } |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2248 | } else if (source.IsFpuRegister()) { |
| 2249 | if (destination.IsFpuRegister()) { |
| 2250 | __ movaps(destination.As<XmmRegister>(), source.As<XmmRegister>()); |
| 2251 | } else if (destination.IsStackSlot()) { |
| 2252 | __ movss(Address(CpuRegister(RSP), destination.GetStackIndex()), |
| 2253 | source.As<XmmRegister>()); |
| 2254 | } else { |
| 2255 | DCHECK(destination.IsDoubleStackSlot()); |
| 2256 | __ movsd(Address(CpuRegister(RSP), destination.GetStackIndex()), |
| 2257 | source.As<XmmRegister>()); |
| 2258 | } |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2259 | } |
| 2260 | } |
| 2261 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2262 | void ParallelMoveResolverX86_64::Exchange32(CpuRegister reg, int mem) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2263 | __ movl(CpuRegister(TMP), Address(CpuRegister(RSP), mem)); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2264 | __ movl(Address(CpuRegister(RSP), mem), reg); |
| 2265 | __ movl(reg, CpuRegister(TMP)); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2266 | } |
| 2267 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2268 | void ParallelMoveResolverX86_64::Exchange32(int mem1, int mem2) { |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2269 | ScratchRegisterScope ensure_scratch( |
| 2270 | this, TMP, RAX, codegen_->GetNumberOfCoreRegisters()); |
| 2271 | |
| 2272 | int stack_offset = ensure_scratch.IsSpilled() ? kX86_64WordSize : 0; |
| 2273 | __ movl(CpuRegister(TMP), Address(CpuRegister(RSP), mem1 + stack_offset)); |
| 2274 | __ movl(CpuRegister(ensure_scratch.GetRegister()), |
| 2275 | Address(CpuRegister(RSP), mem2 + stack_offset)); |
| 2276 | __ movl(Address(CpuRegister(RSP), mem2 + stack_offset), CpuRegister(TMP)); |
| 2277 | __ movl(Address(CpuRegister(RSP), mem1 + stack_offset), |
| 2278 | CpuRegister(ensure_scratch.GetRegister())); |
| 2279 | } |
| 2280 | |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2281 | void ParallelMoveResolverX86_64::Exchange64(CpuRegister reg, int mem) { |
| 2282 | __ movq(CpuRegister(TMP), Address(CpuRegister(RSP), mem)); |
| 2283 | __ movq(Address(CpuRegister(RSP), mem), reg); |
| 2284 | __ movq(reg, CpuRegister(TMP)); |
| 2285 | } |
| 2286 | |
| 2287 | void ParallelMoveResolverX86_64::Exchange64(int mem1, int mem2) { |
| 2288 | ScratchRegisterScope ensure_scratch( |
| 2289 | this, TMP, RAX, codegen_->GetNumberOfCoreRegisters()); |
| 2290 | |
| 2291 | int stack_offset = ensure_scratch.IsSpilled() ? kX86_64WordSize : 0; |
| 2292 | __ movq(CpuRegister(TMP), Address(CpuRegister(RSP), mem1 + stack_offset)); |
| 2293 | __ movq(CpuRegister(ensure_scratch.GetRegister()), |
| 2294 | Address(CpuRegister(RSP), mem2 + stack_offset)); |
| 2295 | __ movq(Address(CpuRegister(RSP), mem2 + stack_offset), CpuRegister(TMP)); |
| 2296 | __ movq(Address(CpuRegister(RSP), mem1 + stack_offset), |
| 2297 | CpuRegister(ensure_scratch.GetRegister())); |
| 2298 | } |
| 2299 | |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2300 | void ParallelMoveResolverX86_64::Exchange32(XmmRegister reg, int mem) { |
| 2301 | __ movl(CpuRegister(TMP), Address(CpuRegister(RSP), mem)); |
| 2302 | __ movss(Address(CpuRegister(RSP), mem), reg); |
| 2303 | __ movd(reg, CpuRegister(TMP)); |
| 2304 | } |
| 2305 | |
| 2306 | void ParallelMoveResolverX86_64::Exchange64(XmmRegister reg, int mem) { |
| 2307 | __ movq(CpuRegister(TMP), Address(CpuRegister(RSP), mem)); |
| 2308 | __ movsd(Address(CpuRegister(RSP), mem), reg); |
| 2309 | __ movd(reg, CpuRegister(TMP)); |
| 2310 | } |
| 2311 | |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2312 | void ParallelMoveResolverX86_64::EmitSwap(size_t index) { |
| 2313 | MoveOperands* move = moves_.Get(index); |
| 2314 | Location source = move->GetSource(); |
| 2315 | Location destination = move->GetDestination(); |
| 2316 | |
| 2317 | if (source.IsRegister() && destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2318 | __ xchgq(destination.As<CpuRegister>(), source.As<CpuRegister>()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2319 | } else if (source.IsRegister() && destination.IsStackSlot()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2320 | Exchange32(source.As<CpuRegister>(), destination.GetStackIndex()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2321 | } else if (source.IsStackSlot() && destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2322 | Exchange32(destination.As<CpuRegister>(), source.GetStackIndex()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2323 | } else if (source.IsStackSlot() && destination.IsStackSlot()) { |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2324 | Exchange32(destination.GetStackIndex(), source.GetStackIndex()); |
| 2325 | } else if (source.IsRegister() && destination.IsDoubleStackSlot()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2326 | Exchange64(source.As<CpuRegister>(), destination.GetStackIndex()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2327 | } else if (source.IsDoubleStackSlot() && destination.IsRegister()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 2328 | Exchange64(destination.As<CpuRegister>(), source.GetStackIndex()); |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 2329 | } else if (source.IsDoubleStackSlot() && destination.IsDoubleStackSlot()) { |
| 2330 | Exchange64(destination.GetStackIndex(), source.GetStackIndex()); |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2331 | } else if (source.IsFpuRegister() && destination.IsFpuRegister()) { |
| 2332 | __ movd(CpuRegister(TMP), source.As<XmmRegister>()); |
| 2333 | __ movaps(source.As<XmmRegister>(), destination.As<XmmRegister>()); |
| 2334 | __ movd(destination.As<XmmRegister>(), CpuRegister(TMP)); |
| 2335 | } else if (source.IsFpuRegister() && destination.IsStackSlot()) { |
| 2336 | Exchange32(source.As<XmmRegister>(), destination.GetStackIndex()); |
| 2337 | } else if (source.IsStackSlot() && destination.IsFpuRegister()) { |
| 2338 | Exchange32(destination.As<XmmRegister>(), source.GetStackIndex()); |
| 2339 | } else if (source.IsFpuRegister() && destination.IsDoubleStackSlot()) { |
| 2340 | Exchange64(source.As<XmmRegister>(), destination.GetStackIndex()); |
| 2341 | } else if (source.IsDoubleStackSlot() && destination.IsFpuRegister()) { |
| 2342 | Exchange64(destination.As<XmmRegister>(), source.GetStackIndex()); |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2343 | } else { |
Nicolas Geoffray | 102cbed | 2014-10-15 18:31:05 +0100 | [diff] [blame] | 2344 | LOG(FATAL) << "Unimplemented swap between " << source << " and " << destination; |
Nicolas Geoffray | ecb2f9b | 2014-06-13 08:59:59 +0000 | [diff] [blame] | 2345 | } |
| 2346 | } |
| 2347 | |
| 2348 | |
| 2349 | void ParallelMoveResolverX86_64::SpillScratch(int reg) { |
| 2350 | __ pushq(CpuRegister(reg)); |
| 2351 | } |
| 2352 | |
| 2353 | |
| 2354 | void ParallelMoveResolverX86_64::RestoreScratch(int reg) { |
| 2355 | __ popq(CpuRegister(reg)); |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 2356 | } |
| 2357 | |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2358 | void InstructionCodeGeneratorX86_64::GenerateClassInitializationCheck( |
| 2359 | SlowPathCodeX86_64* slow_path, CpuRegister class_reg) { |
| 2360 | __ cmpl(Address(class_reg, mirror::Class::StatusOffset().Int32Value()), |
| 2361 | Immediate(mirror::Class::kStatusInitialized)); |
| 2362 | __ j(kLess, slow_path->GetEntryLabel()); |
| 2363 | __ Bind(slow_path->GetExitLabel()); |
| 2364 | // No need for memory fence, thanks to the X86_64 memory model. |
| 2365 | } |
| 2366 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2367 | void LocationsBuilderX86_64::VisitLoadClass(HLoadClass* cls) { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2368 | LocationSummary::CallKind call_kind = cls->CanCallRuntime() |
| 2369 | ? LocationSummary::kCallOnSlowPath |
| 2370 | : LocationSummary::kNoCall; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2371 | LocationSummary* locations = |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2372 | new (GetGraph()->GetArena()) LocationSummary(cls, call_kind); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2373 | locations->SetOut(Location::RequiresRegister()); |
| 2374 | } |
| 2375 | |
| 2376 | void InstructionCodeGeneratorX86_64::VisitLoadClass(HLoadClass* cls) { |
| 2377 | CpuRegister out = cls->GetLocations()->Out().As<CpuRegister>(); |
| 2378 | if (cls->IsReferrersClass()) { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2379 | DCHECK(!cls->CanCallRuntime()); |
| 2380 | DCHECK(!cls->MustGenerateClinitCheck()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2381 | codegen_->LoadCurrentMethod(out); |
| 2382 | __ movl(out, Address(out, mirror::ArtMethod::DeclaringClassOffset().Int32Value())); |
| 2383 | } else { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2384 | DCHECK(cls->CanCallRuntime()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2385 | codegen_->LoadCurrentMethod(out); |
| 2386 | __ movl(out, Address(out, mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value())); |
| 2387 | __ movl(out, Address(out, CodeGenerator::GetCacheOffset(cls->GetTypeIndex()))); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2388 | SlowPathCodeX86_64* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathX86_64( |
| 2389 | cls, cls, cls->GetDexPc(), cls->MustGenerateClinitCheck()); |
| 2390 | codegen_->AddSlowPath(slow_path); |
| 2391 | __ testl(out, out); |
| 2392 | __ j(kEqual, slow_path->GetEntryLabel()); |
| 2393 | if (cls->MustGenerateClinitCheck()) { |
| 2394 | GenerateClassInitializationCheck(slow_path, out); |
| 2395 | } else { |
| 2396 | __ Bind(slow_path->GetExitLabel()); |
| 2397 | } |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2398 | } |
| 2399 | } |
| 2400 | |
| 2401 | void LocationsBuilderX86_64::VisitClinitCheck(HClinitCheck* check) { |
| 2402 | LocationSummary* locations = |
| 2403 | new (GetGraph()->GetArena()) LocationSummary(check, LocationSummary::kCallOnSlowPath); |
| 2404 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2405 | if (check->HasUses()) { |
| 2406 | locations->SetOut(Location::SameAsFirstInput()); |
| 2407 | } |
| 2408 | } |
| 2409 | |
| 2410 | void InstructionCodeGeneratorX86_64::VisitClinitCheck(HClinitCheck* check) { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2411 | // We assume the class to not be null. |
| 2412 | SlowPathCodeX86_64* slow_path = new (GetGraph()->GetArena()) LoadClassSlowPathX86_64( |
| 2413 | check->GetLoadClass(), check, check->GetDexPc(), true); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2414 | codegen_->AddSlowPath(slow_path); |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 2415 | GenerateClassInitializationCheck(slow_path, check->GetLocations()->InAt(0).As<CpuRegister>()); |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 2416 | } |
| 2417 | |
| 2418 | void LocationsBuilderX86_64::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 2419 | LocationSummary* locations = |
| 2420 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 2421 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2422 | locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); |
| 2423 | } |
| 2424 | |
| 2425 | void InstructionCodeGeneratorX86_64::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 2426 | LocationSummary* locations = instruction->GetLocations(); |
| 2427 | CpuRegister cls = locations->InAt(0).As<CpuRegister>(); |
| 2428 | CpuRegister out = locations->Out().As<CpuRegister>(); |
| 2429 | size_t offset = instruction->GetFieldOffset().SizeValue(); |
| 2430 | |
| 2431 | switch (instruction->GetType()) { |
| 2432 | case Primitive::kPrimBoolean: { |
| 2433 | __ movzxb(out, Address(cls, offset)); |
| 2434 | break; |
| 2435 | } |
| 2436 | |
| 2437 | case Primitive::kPrimByte: { |
| 2438 | __ movsxb(out, Address(cls, offset)); |
| 2439 | break; |
| 2440 | } |
| 2441 | |
| 2442 | case Primitive::kPrimShort: { |
| 2443 | __ movsxw(out, Address(cls, offset)); |
| 2444 | break; |
| 2445 | } |
| 2446 | |
| 2447 | case Primitive::kPrimChar: { |
| 2448 | __ movzxw(out, Address(cls, offset)); |
| 2449 | break; |
| 2450 | } |
| 2451 | |
| 2452 | case Primitive::kPrimInt: |
| 2453 | case Primitive::kPrimNot: { |
| 2454 | __ movl(out, Address(cls, offset)); |
| 2455 | break; |
| 2456 | } |
| 2457 | |
| 2458 | case Primitive::kPrimLong: { |
| 2459 | __ movq(out, Address(cls, offset)); |
| 2460 | break; |
| 2461 | } |
| 2462 | |
| 2463 | case Primitive::kPrimFloat: |
| 2464 | case Primitive::kPrimDouble: |
| 2465 | LOG(FATAL) << "Unimplemented register type " << instruction->GetType(); |
| 2466 | UNREACHABLE(); |
| 2467 | case Primitive::kPrimVoid: |
| 2468 | LOG(FATAL) << "Unreachable type " << instruction->GetType(); |
| 2469 | UNREACHABLE(); |
| 2470 | } |
| 2471 | } |
| 2472 | |
| 2473 | void LocationsBuilderX86_64::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
| 2474 | LocationSummary* locations = |
| 2475 | new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); |
| 2476 | Primitive::Type field_type = instruction->GetFieldType(); |
| 2477 | bool is_object_type = field_type == Primitive::kPrimNot; |
| 2478 | locations->SetInAt(0, Location::RequiresRegister()); |
| 2479 | locations->SetInAt(1, Location::RequiresRegister()); |
| 2480 | if (is_object_type) { |
| 2481 | // Temporary registers for the write barrier. |
| 2482 | locations->AddTemp(Location::RequiresRegister()); |
| 2483 | locations->AddTemp(Location::RequiresRegister()); |
| 2484 | } |
| 2485 | } |
| 2486 | |
| 2487 | void InstructionCodeGeneratorX86_64::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
| 2488 | LocationSummary* locations = instruction->GetLocations(); |
| 2489 | CpuRegister cls = locations->InAt(0).As<CpuRegister>(); |
| 2490 | CpuRegister value = locations->InAt(1).As<CpuRegister>(); |
| 2491 | size_t offset = instruction->GetFieldOffset().SizeValue(); |
| 2492 | Primitive::Type field_type = instruction->GetFieldType(); |
| 2493 | |
| 2494 | switch (field_type) { |
| 2495 | case Primitive::kPrimBoolean: |
| 2496 | case Primitive::kPrimByte: { |
| 2497 | __ movb(Address(cls, offset), value); |
| 2498 | break; |
| 2499 | } |
| 2500 | |
| 2501 | case Primitive::kPrimShort: |
| 2502 | case Primitive::kPrimChar: { |
| 2503 | __ movw(Address(cls, offset), value); |
| 2504 | break; |
| 2505 | } |
| 2506 | |
| 2507 | case Primitive::kPrimInt: |
| 2508 | case Primitive::kPrimNot: { |
| 2509 | __ movl(Address(cls, offset), value); |
| 2510 | if (field_type == Primitive::kPrimNot) { |
| 2511 | CpuRegister temp = locations->GetTemp(0).As<CpuRegister>(); |
| 2512 | CpuRegister card = locations->GetTemp(1).As<CpuRegister>(); |
| 2513 | codegen_->MarkGCCard(temp, card, cls, value); |
| 2514 | } |
| 2515 | break; |
| 2516 | } |
| 2517 | |
| 2518 | case Primitive::kPrimLong: { |
| 2519 | __ movq(Address(cls, offset), value); |
| 2520 | break; |
| 2521 | } |
| 2522 | |
| 2523 | case Primitive::kPrimFloat: |
| 2524 | case Primitive::kPrimDouble: |
| 2525 | LOG(FATAL) << "Unimplemented register type " << field_type; |
| 2526 | UNREACHABLE(); |
| 2527 | case Primitive::kPrimVoid: |
| 2528 | LOG(FATAL) << "Unreachable type " << field_type; |
| 2529 | UNREACHABLE(); |
| 2530 | } |
| 2531 | } |
| 2532 | |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 2533 | void LocationsBuilderX86_64::VisitLoadString(HLoadString* load) { |
| 2534 | LocationSummary* locations = |
| 2535 | new (GetGraph()->GetArena()) LocationSummary(load, LocationSummary::kCallOnSlowPath); |
| 2536 | locations->SetOut(Location::RequiresRegister()); |
| 2537 | } |
| 2538 | |
| 2539 | void InstructionCodeGeneratorX86_64::VisitLoadString(HLoadString* load) { |
| 2540 | SlowPathCodeX86_64* slow_path = new (GetGraph()->GetArena()) LoadStringSlowPathX86_64(load); |
| 2541 | codegen_->AddSlowPath(slow_path); |
| 2542 | |
| 2543 | CpuRegister out = load->GetLocations()->Out().As<CpuRegister>(); |
| 2544 | codegen_->LoadCurrentMethod(CpuRegister(out)); |
| 2545 | __ movl(out, Address(out, mirror::ArtMethod::DexCacheStringsOffset().Int32Value())); |
| 2546 | __ movl(out, Address(out, CodeGenerator::GetCacheOffset(load->GetStringIndex()))); |
| 2547 | __ testl(out, out); |
| 2548 | __ j(kEqual, slow_path->GetEntryLabel()); |
| 2549 | __ Bind(slow_path->GetExitLabel()); |
| 2550 | } |
| 2551 | |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 2552 | } // namespace x86_64 |
| 2553 | } // namespace art |