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