chromium/v8/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc

// Copyright 2014 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 <limits>

#include "src/codegen/assembler.h"
#include "src/common/globals.h"
#include "src/compiler/backend/instruction-codes.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/objects/objects-inl.h"
#include "test/unittests/compiler/backend/instruction-selector-unittest.h"

#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/simd-shuffle.h"
#endif  // V8_ENABLE_WEBASSEMBLY

namespace v8 {
namespace internal {
namespace compiler {

// -----------------------------------------------------------------------------
// Conversions.


TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) {}


TEST_F(InstructionSelectorTest, ChangeInt32ToInt64WithParameter) {}

TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) {}


TEST_F(InstructionSelectorTest, ChangeUint32ToUint64WithParameter) {}


TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) {}


TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) {}

TEST_F(InstructionSelectorTest, SelectWord32) {}

TEST_F(InstructionSelectorTest, SelectWord64) {}

namespace {
struct LoadWithToInt64Extension {};

std::ostream& operator<<(std::ostream& os,
                         const LoadWithToInt64Extension& i32toi64) {}

static const LoadWithToInt64Extension kLoadWithToInt64Extensions[] =;

// The parameterized test that use the following type are intentionally part
// of the anonymous namespace. The issue here is that the type parameter is
// using a type that is in the anonymous namespace, but the class generated by
// TEST_P is not. This will cause GCC to generate a -Wsubobject-linkage warning.
//
// In this case there will only be single translation unit and the warning
// about subobject-linkage can be avoided by placing the class generated
// by TEST_P in the anoynmous namespace as well.
InstructionSelectorChangeInt32ToInt64Test;

TEST_P(InstructionSelectorChangeInt32ToInt64Test, ChangeInt32ToInt64WithLoad) {}

}  // namespace

INSTANTIATE_TEST_SUITE_P();

// -----------------------------------------------------------------------------
// Loads and stores


namespace {

struct MemoryAccess {};


std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {}


static const MemoryAccess kMemoryAccesses[] =;

// The parameterized test that use the following type are intentionally part
// of the anonymous namespace. The issue here is that the type parameter is
// using a type that is in the anonymous namespace, but the class generated by
// TEST_P is not. This will cause GCC to generate a -Wsubobject-linkage warning.
//
// In this case there will only be single translation unit and the warning
// about subobject-linkage can be avoided by placing the class generated
// by TEST_P in the anoynmous namespace as well.
InstructionSelectorMemoryAccessTest;

TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) {}


TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) {}

}  // namespace

INSTANTIATE_TEST_SUITE_P();

// -----------------------------------------------------------------------------
// ChangeUint32ToUint64.


namespace {

Constructor;

struct BinaryOperation {};


std::ostream& operator<<(std::ostream& os, const BinaryOperation& bop) {}


const BinaryOperation kWord32BinaryOperations[] =;

// The parameterized test that use the following type are intentionally part
// of the anonymous namespace. The issue here is that the type parameter is
// using a type that is in the anonymous namespace, but the class generated by
// TEST_P is not. This will cause GCC to generate a -Wsubobject-linkage warning.
//
// In this case there will only be single translation unit and the warning
// about subobject-linkage can be avoided by placing the class generated
// by TEST_P in the anoynmous namespace as well.
InstructionSelectorChangeUint32ToUint64Test;

TEST_P(InstructionSelectorChangeUint32ToUint64Test, ChangeUint32ToUint64) {}

}  // namespace

INSTANTIATE_TEST_SUITE_P();

// -----------------------------------------------------------------------------
// CanElideChangeUint32ToUint64

namespace {

template <typename T>
struct MachInst {};

MachInst2;

// X64 instructions that clear the top 32 bits of the destination.
const MachInst2 kCanElideChangeUint32ToUint64[] = {
    {&RawMachineAssembler::Word32And, "Word32And", kX64And32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Or, "Word32Or", kX64Or32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Xor, "Word32Xor", kX64Xor32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Shl, "Word32Shl", kX64Shl32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Shr, "Word32Shr", kX64Shr32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Sar, "Word32Sar", kX64Sar32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Ror, "Word32Ror", kX64Ror32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Word32Equal, "Word32Equal", kX64Cmp32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Int32Add, "Int32Add", kX64Lea32,
     MachineType::Int32()},
    {&RawMachineAssembler::Int32Sub, "Int32Sub", kX64Sub32,
     MachineType::Int32()},
    {&RawMachineAssembler::Int32Mul, "Int32Mul", kX64Imul32,
     MachineType::Int32()},
    {&RawMachineAssembler::Int32MulHigh, "Int32MulHigh", kX64ImulHigh32,
     MachineType::Int32()},
    {&RawMachineAssembler::Int32Div, "Int32Div", kX64Idiv32,
     MachineType::Int32()},
    {&RawMachineAssembler::Int32LessThan, "Int32LessThan", kX64Cmp32,
     MachineType::Int32()},
    {&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual",
     kX64Cmp32, MachineType::Int32()},
    {&RawMachineAssembler::Int32Mod, "Int32Mod", kX64Idiv32,
     MachineType::Int32()},
    {&RawMachineAssembler::Uint32Div, "Uint32Div", kX64Udiv32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kX64Cmp32,
     MachineType::Uint32()},
    {&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual",
     kX64Cmp32, MachineType::Uint32()},
    {&RawMachineAssembler::Uint32Mod, "Uint32Mod", kX64Udiv32,
     MachineType::Uint32()},
};

// The parameterized test that use the following type are intentionally part
// of the anonymous namespace. The issue here is that the type parameter is
// using a type that is in the anonymous namespace, but the class generated by
// TEST_P is not. This will cause GCC to generate a -Wsubobject-linkage warning.
//
// In this case there will only be single translation unit and the warning
// about subobject-linkage can be avoided by placing the class generated
// by TEST_P in the anoynmous namespace as well.
InstructionSelectorElidedChangeUint32ToUint64Test;

TEST_P(InstructionSelectorElidedChangeUint32ToUint64Test, Parameter) {}

}  // namespace

INSTANTIATE_TEST_SUITE_P();

// ChangeUint32ToUint64AfterLoad
TEST_F(InstructionSelectorTest, ChangeUint32ToUint64AfterLoad) {}

// -----------------------------------------------------------------------------
// TruncateInt64ToInt32.


TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) {}


TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) {}


// -----------------------------------------------------------------------------
// Addition.


TEST_F(InstructionSelectorTest, Int32AddWithInt32ParametersLea) {}


TEST_F(InstructionSelectorTest, Int32AddConstantAsLeaSingle) {}


TEST_F(InstructionSelectorTest, Int32AddConstantAsAdd) {}


TEST_F(InstructionSelectorTest, Int32AddConstantAsLeaDouble) {}


TEST_F(InstructionSelectorTest, Int32AddCommutedConstantAsLeaSingle) {}


TEST_F(InstructionSelectorTest, Int32AddCommutedConstantAsLeaDouble) {}


TEST_F(InstructionSelectorTest, Int32AddSimpleAsAdd) {}


TEST_F(InstructionSelectorTest, Int32AddSimpleAsLea) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2Mul) {}


TEST_F(InstructionSelectorTest, Int32AddCommutedScaled2Mul) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2Shl) {}


TEST_F(InstructionSelectorTest, Int32AddCommutedScaled2Shl) {}


TEST_F(InstructionSelectorTest, Int32AddScaled4Mul) {}


TEST_F(InstructionSelectorTest, Int32AddScaled4Shl) {}


TEST_F(InstructionSelectorTest, Int32AddScaled8Mul) {}


TEST_F(InstructionSelectorTest, Int32AddScaled8Shl) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstant) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle1) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle2) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle3) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle4) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2MulWithConstantShuffle5) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2ShlWithConstant) {}


TEST_F(InstructionSelectorTest, Int32AddScaled4MulWithConstant) {}


TEST_F(InstructionSelectorTest, Int32AddScaled4ShlWithConstant) {}


TEST_F(InstructionSelectorTest, Int32AddScaled8MulWithConstant) {}


TEST_F(InstructionSelectorTest, Int32AddScaled8ShlWithConstant) {}


TEST_F(InstructionSelectorTest, Int32SubConstantAsSub) {}


TEST_F(InstructionSelectorTest, Int32SubConstantAsLea) {}


TEST_F(InstructionSelectorTest, Int32AddScaled2Other) {}

TEST_F(InstructionSelectorTest, Int32AddMinNegativeDisplacement) {}

// -----------------------------------------------------------------------------
// Multiplication.


TEST_F(InstructionSelectorTest, Int32MulWithInt32MulWithParameters) {}


TEST_F(InstructionSelectorTest, Int32MulHigh) {}


TEST_F(InstructionSelectorTest, Uint32MulHigh) {}


TEST_F(InstructionSelectorTest, Int32Mul2BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Mul3BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Mul4BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Mul5BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Mul8BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Mul9BecomesLea) {}


// -----------------------------------------------------------------------------
// Word32Shl.


TEST_F(InstructionSelectorTest, Int32Shl1BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Shl2BecomesLea) {}


TEST_F(InstructionSelectorTest, Int32Shl4BecomesLea) {}

// -----------------------------------------------------------------------------
// Binops with a memory operand.

TEST_F(InstructionSelectorTest, LoadCmp32) {}

TEST_F(InstructionSelectorTest, LoadAnd32) {}

TEST_F(InstructionSelectorTest, LoadOr32) {}

TEST_F(InstructionSelectorTest, LoadXor32) {}

TEST_F(InstructionSelectorTest, LoadAdd32) {}

TEST_F(InstructionSelectorTest, LoadSub32) {}

TEST_F(InstructionSelectorTest, LoadAnd64) {}

TEST_F(InstructionSelectorTest, LoadOr64) {}

TEST_F(InstructionSelectorTest, LoadXor64) {}

TEST_F(InstructionSelectorTest, LoadAdd64) {}

TEST_F(InstructionSelectorTest, LoadSub64) {}

// -----------------------------------------------------------------------------
// Floating point operations.

TEST_F(InstructionSelectorTest, Float32Abs) {}


TEST_F(InstructionSelectorTest, Float64Abs) {}


TEST_F(InstructionSelectorTest, Float64BinopArithmetic) {}

TEST_F(InstructionSelectorTest, Float32BinopArithmeticWithLoad) {}

TEST_F(InstructionSelectorTest, Float64BinopArithmeticWithLoad) {}

// -----------------------------------------------------------------------------
// Miscellaneous.


TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) {}


TEST_F(InstructionSelectorTest, Word64ShlWithChangeUint32ToUint64) {}

TEST_F(InstructionSelectorTest, Word32AndWith0xFF) {}

TEST_F(InstructionSelectorTest, Word64AndWith0xFFFFFFFF) {}

TEST_F(InstructionSelectorTest, Word64AndWith0xFFFF) {}

TEST_F(InstructionSelectorTest, Word64AndWith0xFF) {}

TEST_F(InstructionSelectorTest, Word64AndWithInt64FitsUint32) {}

TEST_F(InstructionSelectorTest, Word64AndWithInt64DontFitsUint32) {}

TEST_F(InstructionSelectorTest, Word32AndWith0xFFFF) {}


TEST_F(InstructionSelectorTest, Word32Clz) {}

TEST_F(InstructionSelectorTest, LoadAndWord64ShiftRight32) {}

#if V8_ENABLE_WEBASSEMBLY
// -----------------------------------------------------------------------------
// SIMD.

TEST_F(InstructionSelectorTest, SIMDSplatZero) {}

struct ArchShuffle {};

static constexpr ArchShuffle kArchShuffles[] =;

InstructionSelectorSIMDArchShuffleTest;

TEST_P(InstructionSelectorSIMDArchShuffleTest, SIMDArchShuffle) {}

INSTANTIATE_TEST_SUITE_P();

struct ArchShuffle256 {};

static constexpr ArchShuffle256 kArchShuffles256[] =;

InstructionSelectorSIMDArchShuffle256Test;

TEST_P(InstructionSelectorSIMDArchShuffle256Test, SIMDArchShuffle256) {}

INSTANTIATE_TEST_SUITE_P();

struct ShuffleWithZeroInput {};

static constexpr ShuffleWithZeroInput kShuffleWithZeroInput[] =;

InstructionSelectorSIMDShuffleWithZeroInputTest;

TEST_P(InstructionSelectorSIMDShuffleWithZeroInputTest,
       SIMDShuffleWithZeroInputTest) {}

INSTANTIATE_TEST_SUITE_P();

struct SwizzleConstants {};

static constexpr SwizzleConstants kSwizzleConstants[] =;

InstructionSelectorSIMDSwizzleConstantTest;

TEST_P(InstructionSelectorSIMDSwizzleConstantTest, SimdSwizzleConstant) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(InstructionSelectorTest, F64x2PromoteLowF32x4WithS128Load64Zero) {}
#endif  // V8_ENABLE_WEBASSEMBLY

}  // namespace compiler
}  // namespace internal
}  // namespace v8