Commit ab547021 authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[codegen] Add FP returns to code stub linkage

- Adds kFPReturnRegister0 for all platforms.
- Reworks linkage.cc to assign return registers to the proper
  register type, using the new FP return register.

Bug: v8:10070

Change-Id: I5c876d248de9b825a1c80847ab134881dcda6f04
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2107510Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67183}
parent 9825b45d
......@@ -351,6 +351,8 @@ constexpr Register kWasmCompileLazyFuncIndexRegister = r4;
constexpr Register cp = r7; // JavaScript context pointer.
constexpr Register kRootRegister = r10; // Roots array pointer.
constexpr DoubleRegister kFPReturnRegister0 = d0;
} // namespace internal
} // namespace v8
......
......@@ -694,6 +694,8 @@ constexpr Register kRuntimeCallArgvRegister = x11;
constexpr Register kWasmInstanceRegister = x7;
constexpr Register kWasmCompileLazyFuncIndexRegister = x8;
constexpr DoubleRegister kFPReturnRegister0 = d0;
} // namespace internal
} // namespace v8
......
......@@ -159,6 +159,8 @@ constexpr Register kRootRegister = ebx;
// TODO(860429): Remove remaining poisoning infrastructure on ia32.
constexpr Register kSpeculationPoisonRegister = no_reg;
constexpr DoubleRegister kFPReturnRegister0 = xmm1; // xmm0 isn't allocatable.
} // namespace internal
} // namespace v8
......
......@@ -376,6 +376,8 @@ constexpr Register kRuntimeCallArgvRegister = a2;
constexpr Register kWasmInstanceRegister = a0;
constexpr Register kWasmCompileLazyFuncIndexRegister = t0;
constexpr DoubleRegister kFPReturnRegister0 = f0;
} // namespace internal
} // namespace v8
......
......@@ -383,6 +383,8 @@ constexpr Register kRuntimeCallArgvRegister = a2;
constexpr Register kWasmInstanceRegister = a0;
constexpr Register kWasmCompileLazyFuncIndexRegister = t0;
constexpr DoubleRegister kFPReturnRegister0 = f0;
} // namespace internal
} // namespace v8
......
......@@ -306,6 +306,8 @@ constexpr Register kRuntimeCallArgvRegister = r5;
constexpr Register kWasmInstanceRegister = r10;
constexpr Register kWasmCompileLazyFuncIndexRegister = r15;
constexpr DoubleRegister kFPReturnRegister0 = d0;
} // namespace internal
} // namespace v8
......
......@@ -263,6 +263,8 @@ constexpr Register kRuntimeCallArgvRegister = r4;
constexpr Register kWasmInstanceRegister = r6;
constexpr Register kWasmCompileLazyFuncIndexRegister = r7;
constexpr DoubleRegister kFPReturnRegister0 = d0;
} // namespace internal
} // namespace v8
......
......@@ -217,6 +217,8 @@ constexpr Register kRootRegister = r13; // callee save
constexpr Register kOffHeapTrampolineRegister = kScratchRegister;
constexpr DoubleRegister kFPReturnRegister0 = xmm0;
} // namespace internal
} // namespace v8
......
......@@ -21,6 +21,10 @@ inline LinkageLocation regloc(Register reg, MachineType type) {
return LinkageLocation::ForRegister(reg.code(), type);
}
inline LinkageLocation regloc(DoubleRegister reg, MachineType type) {
return LinkageLocation::ForRegister(reg.code(), type);
}
} // namespace
......@@ -380,20 +384,33 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
LocationSignature::Builder locations(zone, return_count, parameter_count);
// Add returns.
if (locations.return_count_ > 0) {
locations.AddReturn(regloc(kReturnRegister0, descriptor.GetReturnType(0)));
}
if (locations.return_count_ > 1) {
locations.AddReturn(regloc(kReturnRegister1, descriptor.GetReturnType(1)));
}
if (locations.return_count_ > 2) {
locations.AddReturn(regloc(kReturnRegister2, descriptor.GetReturnType(2)));
static constexpr Register return_registers[] = {
kReturnRegister0, kReturnRegister1, kReturnRegister2};
size_t num_returns = 0;
size_t num_fp_returns = 0;
for (size_t i = 0; i < locations.return_count_; i++) {
MachineType type = descriptor.GetReturnType(static_cast<int>(i));
if (IsFloatingPoint(type.representation())) {
DCHECK_LT(num_fp_returns, 1); // Only 1 FP return is supported.
locations.AddReturn(regloc(kFPReturnRegister0, type));
num_fp_returns++;
} else {
DCHECK_LT(num_returns, arraysize(return_registers));
locations.AddReturn(regloc(return_registers[num_returns], type));
num_returns++;
}
}
// Add parameters in registers and on the stack.
for (int i = 0; i < js_parameter_count; i++) {
if (i < register_parameter_count) {
// The first parameters go in registers.
// TODO(bbudge) Add floating point registers to the InterfaceDescriptor
// and use them for FP types. Currently, this works because on most
// platforms, all FP registers are available for use. On ia32, xmm0 is
// not allocatable and so we must work around that with platform-specific
// descriptors, adjusting the GP register set to avoid eax, which has
// register code 0.
Register reg = descriptor.GetRegisterParameter(i);
MachineType type = descriptor.GetParameterType(i);
locations.AddParam(regloc(reg, type));
......
......@@ -104,6 +104,7 @@ TEST(TestLinkageRuntimeCall) {
TEST(TestLinkageStubCall) {
// TODO(bbudge) Add tests for FP registers.
Isolate* isolate = CcTest::InitIsolateOnce();
Zone zone(isolate->allocator(), ZONE_NAME);
Callable callable = Builtins::CallableFor(isolate, Builtins::kToNumber);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment