diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 68 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.h | 11 |
2 files changed, 34 insertions, 45 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 66f1d5e58d..c0fdcaa8aa 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -36,9 +36,8 @@ static constexpr int kCurrentMethodStackOffset = 0; static constexpr Register kRuntimeParameterCoreRegisters[] = { EAX, ECX, EDX, EBX }; static constexpr size_t kRuntimeParameterCoreRegistersLength = arraysize(kRuntimeParameterCoreRegisters); -static constexpr XmmRegister kRuntimeParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 }; -static constexpr size_t kRuntimeParameterFpuRegistersLength = - arraysize(kRuntimeParameterFpuRegisters); +static constexpr XmmRegister kRuntimeParameterFpuRegisters[] = { }; +static constexpr size_t kRuntimeParameterFpuRegistersLength = 0; static constexpr int kC2ConditionMask = 0x400; @@ -505,49 +504,30 @@ Location InvokeDexCallingConventionVisitor::GetNextLocation(Primitive::Type type case Primitive::kPrimChar: case Primitive::kPrimShort: case Primitive::kPrimInt: + case Primitive::kPrimFloat: case Primitive::kPrimNot: { uint32_t index = gp_index_++; - stack_index_++; if (index < calling_convention.GetNumberOfRegisters()) { return Location::RegisterLocation(calling_convention.GetRegisterAt(index)); } else { - return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 1)); + return Location::StackSlot(calling_convention.GetStackOffsetOf(index)); } } - case Primitive::kPrimLong: { + case Primitive::kPrimLong: + case Primitive::kPrimDouble: { uint32_t index = gp_index_; gp_index_ += 2; - stack_index_ += 2; if (index + 1 < calling_convention.GetNumberOfRegisters()) { X86ManagedRegister pair = X86ManagedRegister::FromRegisterPair( calling_convention.GetRegisterPairAt(index)); return Location::RegisterPairLocation(pair.AsRegisterPairLow(), pair.AsRegisterPairHigh()); } else if (index + 1 == calling_convention.GetNumberOfRegisters()) { - // stack_index_ is the right offset for the memory. - return Location::QuickParameter(index, stack_index_ - 2); - } else { - return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 2)); - } - } - - case Primitive::kPrimFloat: { - uint32_t index = fp_index_++; - stack_index_++; - if (index < calling_convention.GetNumberOfFpuRegisters()) { - return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); - } else { - return Location::StackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 1)); - } - } - - case Primitive::kPrimDouble: { - uint32_t index = fp_index_++; - stack_index_ += 2; - if (index < calling_convention.GetNumberOfFpuRegisters()) { - return Location::FpuRegisterLocation(calling_convention.GetFpuRegisterAt(index)); + // On X86, the register index and stack index of a quick parameter is the same, since + // we are passing floating pointer values in core registers. + return Location::QuickParameter(index, index); } else { - return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(stack_index_ - 2)); + return Location::DoubleStackSlot(calling_convention.GetStackOffsetOf(index)); } } @@ -1206,7 +1186,7 @@ void InstructionCodeGeneratorX86::VisitInvokeVirtual(HInvokeVirtual* invoke) { void LocationsBuilderX86::VisitInvokeInterface(HInvokeInterface* invoke) { HandleInvoke(invoke); // Add the hidden argument. - invoke->GetLocations()->AddTemp(Location::FpuRegisterLocation(XMM7)); + invoke->GetLocations()->AddTemp(Location::FpuRegisterLocation(XMM0)); } void InstructionCodeGeneratorX86::VisitInvokeInterface(HInvokeInterface* invoke) { @@ -1408,17 +1388,31 @@ void LocationsBuilderX86::VisitTypeConversion(HTypeConversion* conversion) { locations->SetOut(Location::RegisterPairLocation(EAX, EDX)); break; - case Primitive::kPrimFloat: - case Primitive::kPrimDouble: { - // Processing a Dex `float-to-long' or 'double-to-long' instruction. + case Primitive::kPrimFloat: { + // Processing a Dex `float-to-long' instruction. InvokeRuntimeCallingConvention calling_convention; - XmmRegister parameter = calling_convention.GetFpuRegisterAt(0); - locations->SetInAt(0, Location::FpuRegisterLocation(parameter)); + // Note that on x86 floating-point parameters are passed + // through core registers (here, EAX). + locations->SetInAt(0, Location::RegisterLocation( + calling_convention.GetRegisterAt(0))); + // The runtime helper puts the result in EAX, EDX. + locations->SetOut(Location::RegisterPairLocation(EAX, EDX)); + break; + } + case Primitive::kPrimDouble: { + // Processing a Dex `double-to-long' instruction. + InvokeRuntimeCallingConvention calling_convention; + // Note that on x86 floating-point parameters are passed + // through core registers (here, EAX and ECX). + locations->SetInAt(0, Location::RegisterPairLocation( + calling_convention.GetRegisterAt(0), + calling_convention.GetRegisterAt(1))); // The runtime helper puts the result in EAX, EDX. locations->SetOut(Location::RegisterPairLocation(EAX, EDX)); + break; } - break; + break; default: LOG(FATAL) << "Unexpected type conversion from " << input_type diff --git a/compiler/optimizing/code_generator_x86.h b/compiler/optimizing/code_generator_x86.h index 55d71e39c4..73b647c1c4 100644 --- a/compiler/optimizing/code_generator_x86.h +++ b/compiler/optimizing/code_generator_x86.h @@ -36,8 +36,8 @@ class SlowPathCodeX86; static constexpr Register kParameterCoreRegisters[] = { ECX, EDX, EBX }; static constexpr RegisterPair kParameterCorePairRegisters[] = { ECX_EDX, EDX_EBX }; static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters); -static constexpr XmmRegister kParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 }; -static constexpr size_t kParameterFpuRegistersLength = arraysize(kParameterFpuRegisters); +static constexpr XmmRegister kParameterFpuRegisters[] = { }; +static constexpr size_t kParameterFpuRegistersLength = 0; class InvokeDexCallingConvention : public CallingConvention<Register, XmmRegister> { public: @@ -58,18 +58,13 @@ class InvokeDexCallingConvention : public CallingConvention<Register, XmmRegiste class InvokeDexCallingConventionVisitor { public: - InvokeDexCallingConventionVisitor() : gp_index_(0), fp_index_(0), stack_index_(0) {} + InvokeDexCallingConventionVisitor() : gp_index_(0) {} Location GetNextLocation(Primitive::Type type); private: InvokeDexCallingConvention calling_convention; - // The current index for cpu registers. uint32_t gp_index_; - // The current index for fpu registers. - uint32_t fp_index_; - // The current stack index. - uint32_t stack_index_; DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitor); }; |