Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [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.h" |
| 18 | #include "utils/assembler.h" |
| 19 | #include "utils/x86/assembler_x86.h" |
| 20 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 21 | #include "mirror/array.h" |
| 22 | #include "mirror/art_method.h" |
| 23 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 24 | #define __ reinterpret_cast<X86Assembler*>(GetAssembler())-> |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 25 | |
| 26 | namespace art { |
| 27 | namespace x86 { |
| 28 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 29 | static constexpr int kNumberOfPushedRegistersAtEntry = 1; |
| 30 | static constexpr int kCurrentMethodStackOffset = 0; |
| 31 | |
| 32 | InstructionCodeGeneratorX86::InstructionCodeGeneratorX86(HGraph* graph, CodeGeneratorX86* codegen) |
| 33 | : HGraphVisitor(graph), |
| 34 | assembler_(codegen->GetAssembler()), |
| 35 | codegen_(codegen) {} |
| 36 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 37 | void CodeGeneratorX86::GenerateFrameEntry() { |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 38 | // Create a fake register to mimic Quick. |
| 39 | static const int kFakeReturnRegister = 8; |
| 40 | core_spill_mask_ |= (1 << kFakeReturnRegister); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 41 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 42 | // Add the current ART method to the frame size and the return PC. |
| 43 | SetFrameSize(RoundUp(GetFrameSize() + 2 * kWordSize, kStackAlignment)); |
| 44 | // The return PC has already been pushed on the stack. |
| 45 | __ subl(ESP, Immediate(GetFrameSize() - kNumberOfPushedRegistersAtEntry * kWordSize)); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 46 | __ movl(Address(ESP, 0), EAX); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void CodeGeneratorX86::GenerateFrameExit() { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 50 | __ addl(ESP, Immediate(GetFrameSize() - kNumberOfPushedRegistersAtEntry * kWordSize)); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void CodeGeneratorX86::Bind(Label* label) { |
| 54 | __ Bind(label); |
| 55 | } |
| 56 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 57 | void InstructionCodeGeneratorX86::LoadCurrentMethod(Register reg) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 58 | __ movl(reg, Address(ESP, kCurrentMethodStackOffset)); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 61 | int32_t CodeGeneratorX86::GetStackSlot(HLocal* local) const { |
| 62 | return (GetGraph()->GetMaximumNumberOfOutVRegs() + local->GetRegNumber()) * kWordSize; |
| 63 | } |
| 64 | |
| 65 | void CodeGeneratorX86::Move(HInstruction* instruction, Location location, HInstruction* move_for) { |
| 66 | if (instruction->AsIntConstant() != nullptr) { |
| 67 | __ movl(location.reg<Register>(), Immediate(instruction->AsIntConstant()->GetValue())); |
| 68 | } else if (instruction->AsLoadLocal() != nullptr) { |
| 69 | __ movl(location.reg<Register>(), |
| 70 | Address(ESP, GetStackSlot(instruction->AsLoadLocal()->GetLocal()))); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 71 | } else { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 72 | // This can currently only happen when the instruction that requests the move |
| 73 | // is the next to be compiled. |
| 74 | DCHECK_EQ(instruction->GetNext(), move_for); |
| 75 | __ movl(location.reg<Register>(), |
| 76 | instruction->GetLocations()->Out().reg<Register>()); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
| 80 | void LocationsBuilderX86::VisitGoto(HGoto* got) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 81 | got->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 84 | void InstructionCodeGeneratorX86::VisitGoto(HGoto* got) { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 85 | HBasicBlock* successor = got->GetSuccessor(); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 86 | if (GetGraph()->GetExitBlock() == successor) { |
| 87 | codegen_->GenerateFrameExit(); |
| 88 | } else if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) { |
| 89 | __ jmp(codegen_->GetLabelOf(successor)); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 93 | void LocationsBuilderX86::VisitExit(HExit* exit) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 94 | exit->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 97 | void InstructionCodeGeneratorX86::VisitExit(HExit* exit) { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 98 | if (kIsDebugBuild) { |
| 99 | __ Comment("Unreachable"); |
| 100 | __ int3(); |
| 101 | } |
| 102 | } |
| 103 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 104 | void LocationsBuilderX86::VisitIf(HIf* if_instr) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 105 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(if_instr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 106 | locations->SetInAt(0, Location(EAX)); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 107 | if_instr->SetLocations(locations); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 110 | void InstructionCodeGeneratorX86::VisitIf(HIf* if_instr) { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 111 | // TODO: Generate the input as a condition, instead of materializing in a register. |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 112 | __ cmpl(if_instr->GetLocations()->InAt(0).reg<Register>(), Immediate(0)); |
| 113 | __ j(kEqual, codegen_->GetLabelOf(if_instr->IfFalseSuccessor())); |
| 114 | if (!codegen_->GoesToNextBlock(if_instr->GetBlock(), if_instr->IfTrueSuccessor())) { |
| 115 | __ jmp(codegen_->GetLabelOf(if_instr->IfTrueSuccessor())); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | |
| 119 | void LocationsBuilderX86::VisitLocal(HLocal* local) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 120 | local->SetLocations(nullptr); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 121 | } |
| 122 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 123 | void InstructionCodeGeneratorX86::VisitLocal(HLocal* local) { |
| 124 | DCHECK_EQ(local->GetBlock(), GetGraph()->GetEntryBlock()); |
| 125 | codegen_->SetFrameSize(codegen_->GetFrameSize() + kWordSize); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 128 | void LocationsBuilderX86::VisitLoadLocal(HLoadLocal* local) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 129 | local->SetLocations(nullptr); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 132 | void InstructionCodeGeneratorX86::VisitLoadLocal(HLoadLocal* load) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 133 | // Nothing to do, this is driven by the code generator. |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | void LocationsBuilderX86::VisitStoreLocal(HStoreLocal* local) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 137 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(local); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 138 | locations->SetInAt(1, Location(EAX)); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 139 | local->SetLocations(locations); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 140 | } |
| 141 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 142 | void InstructionCodeGeneratorX86::VisitStoreLocal(HStoreLocal* store) { |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 143 | __ movl(Address(ESP, codegen_->GetStackSlot(store->GetLocal())), |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 144 | store->GetLocations()->InAt(1).reg<Register>()); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | void LocationsBuilderX86::VisitEqual(HEqual* equal) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 148 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(equal); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 149 | locations->SetInAt(0, Location(EAX)); |
| 150 | locations->SetInAt(1, Location(ECX)); |
| 151 | locations->SetOut(Location(EAX)); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 152 | equal->SetLocations(locations); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 155 | void InstructionCodeGeneratorX86::VisitEqual(HEqual* equal) { |
| 156 | __ cmpl(equal->GetLocations()->InAt(0).reg<Register>(), |
| 157 | equal->GetLocations()->InAt(1).reg<Register>()); |
| 158 | __ setb(kEqual, equal->GetLocations()->Out().reg<Register>()); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | void LocationsBuilderX86::VisitIntConstant(HIntConstant* constant) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 162 | constant->SetLocations(nullptr); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 165 | void InstructionCodeGeneratorX86::VisitIntConstant(HIntConstant* constant) { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 166 | // Will be generated at use site. |
| 167 | } |
| 168 | |
| 169 | void LocationsBuilderX86::VisitReturnVoid(HReturnVoid* ret) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 170 | ret->SetLocations(nullptr); |
Nicolas Geoffray | 3ff386a | 2014-03-04 14:46:47 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 173 | void InstructionCodeGeneratorX86::VisitReturnVoid(HReturnVoid* ret) { |
| 174 | codegen_->GenerateFrameExit(); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 175 | __ ret(); |
| 176 | } |
| 177 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 178 | void LocationsBuilderX86::VisitReturn(HReturn* ret) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 179 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(ret); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 180 | locations->SetInAt(0, Location(EAX)); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 181 | ret->SetLocations(locations); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 184 | void InstructionCodeGeneratorX86::VisitReturn(HReturn* ret) { |
| 185 | DCHECK_EQ(ret->GetLocations()->InAt(0).reg<Register>(), EAX); |
| 186 | codegen_->GenerateFrameExit(); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 187 | __ ret(); |
| 188 | } |
| 189 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 190 | static constexpr Register kParameterCoreRegisters[] = { ECX, EDX, EBX }; |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 191 | static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters); |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 192 | |
| 193 | class InvokeStaticCallingConvention : public CallingConvention<Register> { |
| 194 | public: |
| 195 | InvokeStaticCallingConvention() |
| 196 | : CallingConvention(kParameterCoreRegisters, kParameterCoreRegistersLength) {} |
| 197 | |
| 198 | private: |
| 199 | DISALLOW_COPY_AND_ASSIGN(InvokeStaticCallingConvention); |
| 200 | }; |
| 201 | |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 202 | static constexpr Register kRuntimeParameterCoreRegisters[] = { EAX, ECX, EDX }; |
| 203 | static constexpr size_t kRuntimeParameterCoreRegistersLength = |
| 204 | arraysize(kRuntimeParameterCoreRegisters); |
| 205 | |
| 206 | class InvokeRuntimeCallingConvention : public CallingConvention<Register> { |
| 207 | public: |
| 208 | InvokeRuntimeCallingConvention() |
| 209 | : CallingConvention(kRuntimeParameterCoreRegisters, |
| 210 | kRuntimeParameterCoreRegistersLength) {} |
| 211 | |
| 212 | private: |
| 213 | DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention); |
| 214 | }; |
| 215 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 216 | void LocationsBuilderX86::VisitPushArgument(HPushArgument* argument) { |
| 217 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(argument); |
| 218 | InvokeStaticCallingConvention calling_convention; |
| 219 | if (argument->GetArgumentIndex() < calling_convention.GetNumberOfRegisters()) { |
| 220 | Location location = Location(calling_convention.GetRegisterAt(argument->GetArgumentIndex())); |
| 221 | locations->SetInAt(0, location); |
| 222 | locations->SetOut(location); |
| 223 | } else { |
| 224 | locations->SetInAt(0, Location(EAX)); |
| 225 | } |
| 226 | argument->SetLocations(locations); |
| 227 | } |
| 228 | |
| 229 | void InstructionCodeGeneratorX86::VisitPushArgument(HPushArgument* argument) { |
| 230 | uint8_t argument_index = argument->GetArgumentIndex(); |
| 231 | InvokeStaticCallingConvention calling_convention; |
| 232 | size_t parameter_registers = calling_convention.GetNumberOfRegisters(); |
| 233 | if (argument_index >= parameter_registers) { |
| 234 | uint8_t offset = calling_convention.GetStackOffsetOf(argument_index); |
| 235 | __ movl(Address(ESP, offset), |
| 236 | argument->GetLocations()->InAt(0).reg<Register>()); |
| 237 | |
| 238 | } else { |
| 239 | DCHECK_EQ(argument->GetLocations()->Out().reg<Register>(), |
| 240 | argument->GetLocations()->InAt(0).reg<Register>()); |
| 241 | } |
| 242 | } |
| 243 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 244 | void LocationsBuilderX86::VisitInvokeStatic(HInvokeStatic* invoke) { |
| 245 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(invoke); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 246 | locations->AddTemp(Location(EAX)); |
| 247 | invoke->SetLocations(locations); |
| 248 | } |
| 249 | |
| 250 | void InstructionCodeGeneratorX86::VisitInvokeStatic(HInvokeStatic* invoke) { |
| 251 | Register temp = invoke->GetLocations()->GetTemp(0).reg<Register>(); |
| 252 | size_t index_in_cache = mirror::Array::DataOffset(sizeof(mirror::Object*)).Int32Value() + |
| 253 | invoke->GetIndexInDexCache() * kWordSize; |
| 254 | |
| 255 | // TODO: Implement all kinds of calls: |
| 256 | // 1) boot -> boot |
| 257 | // 2) app -> boot |
| 258 | // 3) app -> app |
| 259 | // |
| 260 | // Currently we implement the app -> app logic, which looks up in the resolve cache. |
| 261 | |
| 262 | // temp = method; |
| 263 | LoadCurrentMethod(temp); |
| 264 | // temp = temp->dex_cache_resolved_methods_; |
| 265 | __ movl(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value())); |
| 266 | // temp = temp[index_in_cache] |
| 267 | __ movl(temp, Address(temp, index_in_cache)); |
| 268 | // (temp + offset_of_quick_compiled_code)() |
| 269 | __ call(Address(temp, mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value())); |
| 270 | |
| 271 | codegen_->RecordPcInfo(invoke->GetDexPc()); |
| 272 | } |
| 273 | |
Nicolas Geoffray | d8ee737 | 2014-03-28 15:43:40 +0000 | [diff] [blame] | 274 | void LocationsBuilderX86::VisitAdd(HAdd* add) { |
| 275 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(add); |
| 276 | switch (add->GetResultType()) { |
| 277 | case Primitive::kPrimInt: { |
| 278 | locations->SetInAt(0, Location(EAX)); |
| 279 | locations->SetInAt(1, Location(ECX)); |
| 280 | locations->SetOut(Location(EAX)); |
| 281 | break; |
| 282 | } |
| 283 | default: |
| 284 | LOG(FATAL) << "Unimplemented"; |
| 285 | } |
| 286 | add->SetLocations(locations); |
| 287 | } |
| 288 | |
| 289 | void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) { |
| 290 | LocationSummary* locations = add->GetLocations(); |
| 291 | switch (add->GetResultType()) { |
| 292 | case Primitive::kPrimInt: |
| 293 | DCHECK_EQ(locations->InAt(0).reg<Register>(), locations->Out().reg<Register>()); |
| 294 | __ addl(locations->InAt(0).reg<Register>(), locations->InAt(1).reg<Register>()); |
| 295 | break; |
| 296 | default: |
| 297 | LOG(FATAL) << "Unimplemented"; |
| 298 | } |
| 299 | } |
| 300 | |
Nicolas Geoffray | 2e7038a | 2014-04-03 18:49:58 +0100 | [diff] [blame] | 301 | void LocationsBuilderX86::VisitNewInstance(HNewInstance* instruction) { |
| 302 | LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(instruction); |
| 303 | locations->SetOut(Location(EAX)); |
| 304 | instruction->SetLocations(locations); |
| 305 | } |
| 306 | |
| 307 | void InstructionCodeGeneratorX86::VisitNewInstance(HNewInstance* instruction) { |
| 308 | InvokeRuntimeCallingConvention calling_convention; |
| 309 | LoadCurrentMethod(calling_convention.GetRegisterAt(1)); |
| 310 | __ movl(calling_convention.GetRegisterAt(0), |
| 311 | Immediate(instruction->GetTypeIndex())); |
| 312 | |
| 313 | __ fs()->call(Address::Absolute(QUICK_ENTRYPOINT_OFFSET(kWordSize, pAllocObjectWithAccessCheck))); |
| 314 | |
| 315 | codegen_->RecordPcInfo(instruction->GetDexPc()); |
| 316 | } |
| 317 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 318 | } // namespace x86 |
| 319 | } // namespace art |