Commit ec0094b4 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[ia32][x64] Create SharedTurboAssembler

SharedTurboAssembler is shared between ia32 and x64. It contains shared
functionality between these two backends. It derives from
TurboAssemblerBase, and the backend-specific TurboAssembler derives from
SharedTurboAssembler. That way, LiftoffAssembler does not need to
change.

As an example, we move a single member function I64x2SConvertI32x4High
into SharedTurboAssembler. This function has the exact same
implementation on ia32 and x64, and is now defined in a single place.

Bug: v8:11589
Change-Id: I1c4a0628d61960e7398d458fb813561751e0614f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2773609Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73652}
parent d1e751e2
......@@ -3137,6 +3137,7 @@ v8_header_set("v8_internal_headers") {
"src/codegen/ia32/macro-assembler-ia32.h",
"src/codegen/ia32/register-ia32.h",
"src/codegen/ia32/sse-instr.h",
"src/codegen/shared-ia32-x64-macro-assembler.h",
"src/compiler/backend/ia32/instruction-codes-ia32.h",
"src/execution/ia32/frame-constants-ia32.h",
"src/regexp/ia32/regexp-macro-assembler-ia32.h",
......@@ -3146,6 +3147,7 @@ v8_header_set("v8_internal_headers") {
sources += [ ### gcmole(arch:x64) ###
"src/baseline/x64/baseline-assembler-x64-inl.h",
"src/baseline/x64/baseline-compiler-x64-inl.h",
"src/codegen/shared-ia32-x64-macro-assembler.h",
"src/codegen/x64/assembler-x64-inl.h",
"src/codegen/x64/assembler-x64.h",
"src/codegen/x64/constants-x64.h",
......@@ -4033,6 +4035,7 @@ v8_source_set("v8_base_without_compiler") {
"src/codegen/ia32/cpu-ia32.cc",
"src/codegen/ia32/interface-descriptors-ia32.cc",
"src/codegen/ia32/macro-assembler-ia32.cc",
"src/codegen/shared-ia32-x64-macro-assembler.cc",
"src/compiler/backend/ia32/code-generator-ia32.cc",
"src/compiler/backend/ia32/instruction-scheduler-ia32.cc",
"src/compiler/backend/ia32/instruction-selector-ia32.cc",
......@@ -4045,6 +4048,7 @@ v8_source_set("v8_base_without_compiler") {
]
} else if (v8_current_cpu == "x64") {
sources += [ ### gcmole(arch:x64) ###
"src/codegen/shared-ia32-x64-macro-assembler.cc",
"src/codegen/x64/assembler-x64.cc",
"src/codegen/x64/cpu-x64.cc",
"src/codegen/x64/interface-descriptors-x64.cc",
......
......@@ -792,22 +792,6 @@ void TurboAssembler::S128Select(XMMRegister dst, XMMRegister mask,
}
}
void TurboAssembler::I64x2SConvertI32x4High(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(this, AVX);
vpunpckhqdq(dst, src, src);
vpmovsxdq(dst, dst);
} else {
CpuFeatureScope sse_scope(this, SSE4_1);
if (dst == src) {
movhlps(dst, src);
} else {
pshufd(dst, src, 0xEE);
}
pmovsxdq(dst, dst);
}
}
void TurboAssembler::I64x2UConvertI32x4High(XMMRegister dst, XMMRegister src,
XMMRegister scratch) {
if (CpuFeatures::IsSupported(AVX)) {
......
......@@ -23,6 +23,7 @@
#include "src/codegen/label.h"
#include "src/codegen/reglist.h"
#include "src/codegen/reloc-info.h"
#include "src/codegen/shared-ia32-x64-macro-assembler.h"
#include "src/codegen/turbo-assembler.h"
#include "src/common/globals.h"
#include "src/execution/frames.h"
......@@ -70,9 +71,9 @@ class StackArgumentsAccessor {
DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor);
};
class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
class V8_EXPORT_PRIVATE TurboAssembler : public SharedTurboAssembler {
public:
using TurboAssemblerBase::TurboAssemblerBase;
using SharedTurboAssembler::SharedTurboAssembler;
void CheckPageFlag(Register object, Register scratch, int mask, Condition cc,
Label* condition_met,
......@@ -725,7 +726,6 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Requires dst == mask when AVX is not supported.
void S128Select(XMMRegister dst, XMMRegister mask, XMMRegister src1,
XMMRegister src2, XMMRegister scratch);
void I64x2SConvertI32x4High(XMMRegister dst, XMMRegister src);
void I64x2UConvertI32x4High(XMMRegister dst, XMMRegister src,
XMMRegister scratch);
void I32x4SConvertI16x8High(XMMRegister dst, XMMRegister src);
......
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/codegen/shared-ia32-x64-macro-assembler.h"
#include "src/codegen/turbo-assembler.h"
#if V8_TARGET_ARCH_IA32
#include "src/codegen/ia32/register-ia32.h"
#elif V8_TARGET_ARCH_X64
#include "src/codegen/x64/register-x64.h"
#else
#error Unsupported target architecture.
#endif
namespace v8 {
namespace internal {
void SharedTurboAssembler::I64x2SConvertI32x4High(XMMRegister dst,
XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(this, AVX);
vpunpckhqdq(dst, src, src);
vpmovsxdq(dst, dst);
} else {
CpuFeatureScope sse_scope(this, SSE4_1);
if (dst == src) {
movhlps(dst, src);
} else {
pshufd(dst, src, 0xEE);
}
pmovsxdq(dst, dst);
}
}
} // namespace internal
} // namespace v8
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_CODEGEN_SHARED_IA32_X64_MACRO_ASSEMBLER_H_
#define V8_CODEGEN_SHARED_IA32_X64_MACRO_ASSEMBLER_H_
#include "src/codegen/turbo-assembler.h"
#if V8_TARGET_ARCH_IA32
#include "src/codegen/ia32/register-ia32.h"
#elif V8_TARGET_ARCH_X64
#include "src/codegen/x64/register-x64.h"
#else
#error Unsupported target architecture.
#endif
namespace v8 {
namespace internal {
class V8_EXPORT_PRIVATE SharedTurboAssembler : public TurboAssemblerBase {
public:
using TurboAssemblerBase::TurboAssemblerBase;
void I64x2SConvertI32x4High(XMMRegister dst, XMMRegister src);
};
} // namespace internal
} // namespace v8
#endif // V8_CODEGEN_SHARED_IA32_X64_MACRO_ASSEMBLER_H_
......@@ -2220,22 +2220,6 @@ void TurboAssembler::I16x8UConvertI8x16High(XMMRegister dst, XMMRegister src) {
}
}
void TurboAssembler::I64x2SConvertI32x4High(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(this, AVX);
vpunpckhqdq(dst, src, src);
vpmovsxdq(dst, dst);
} else {
CpuFeatureScope sse_scope(this, SSE4_1);
if (dst == src) {
movhlps(dst, src);
} else {
pshufd(dst, src, 0xEE);
}
pmovsxdq(dst, dst);
}
}
void TurboAssembler::I64x2UConvertI32x4High(XMMRegister dst, XMMRegister src) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(this, AVX);
......
......@@ -11,6 +11,7 @@
#include "src/base/flags.h"
#include "src/codegen/bailout-reason.h"
#include "src/codegen/shared-ia32-x64-macro-assembler.h"
#include "src/codegen/x64/assembler-x64.h"
#include "src/common/globals.h"
#include "src/objects/contexts.h"
......@@ -58,9 +59,9 @@ class StackArgumentsAccessor {
DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor);
};
class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
class V8_EXPORT_PRIVATE TurboAssembler : public SharedTurboAssembler {
public:
using TurboAssemblerBase::TurboAssemblerBase;
using SharedTurboAssembler::SharedTurboAssembler;
template <typename Dst, typename... Args>
struct AvxHelper {
......@@ -610,7 +611,6 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void I16x8UConvertI8x16High(XMMRegister dst, XMMRegister src);
void I32x4SConvertI16x8High(XMMRegister dst, XMMRegister src);
void I32x4UConvertI16x8High(XMMRegister dst, XMMRegister src);
void I64x2SConvertI32x4High(XMMRegister dst, XMMRegister src);
void I64x2UConvertI32x4High(XMMRegister dst, XMMRegister src);
// Requires dst == mask when AVX is not supported.
......
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