Commit d8864701 authored by pan.deng@intel.com's avatar pan.deng@intel.com Committed by Commit Bot

[csa] Add constant folding more universally to CodeAssembler operators

             
Contributed by kanghua.yu@intel.com.

Bug: None
Change-Id: I5651ef38eb0c08deb97770a5eaa985dba2dab9a9
Reviewed-on: https://chromium-review.googlesource.com/604648Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Pan Deng <pan.deng@intel.com>
Cr-Commit-Position: refs/heads/master@{#47968}
parent 6ba92d0f
......@@ -504,6 +504,10 @@ TNode<Smi> CodeStubAssembler::SmiTag(SloppyTNode<IntPtrT> value) {
}
TNode<IntPtrT> CodeStubAssembler::SmiUntag(SloppyTNode<Smi> value) {
intptr_t constant_value;
if (ToIntPtrConstant(value, constant_value)) {
return IntPtrConstant(constant_value >> (kSmiShiftSize + kSmiTagSize));
}
return UncheckedCast<IntPtrT>(
WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()));
}
......@@ -5374,12 +5378,24 @@ TNode<IntPtrT> CodeStubAssembler::HashTableComputeCapacity(
TNode<IntPtrT> CodeStubAssembler::IntPtrMax(SloppyTNode<IntPtrT> left,
SloppyTNode<IntPtrT> right) {
intptr_t left_constant;
intptr_t right_constant;
if (ToIntPtrConstant(left, left_constant) &&
ToIntPtrConstant(right, right_constant)) {
return IntPtrConstant(std::max(left_constant, right_constant));
}
return SelectConstant(IntPtrGreaterThanOrEqual(left, right), left, right,
MachineType::PointerRepresentation());
}
TNode<IntPtrT> CodeStubAssembler::IntPtrMin(SloppyTNode<IntPtrT> left,
SloppyTNode<IntPtrT> right) {
intptr_t left_constant;
intptr_t right_constant;
if (ToIntPtrConstant(left, left_constant) &&
ToIntPtrConstant(right, right_constant)) {
return IntPtrConstant(std::min(left_constant, right_constant));
}
return SelectConstant(IntPtrLessThanOrEqual(left, right), left, right,
MachineType::PointerRepresentation());
}
......
This diff is collapsed.
......@@ -268,7 +268,6 @@ class SloppyTNode : public TNode<A> {
V(Float64InsertHighWord32, Float64T, Float64T, Word32T) \
V(IntPtrAddWithOverflow, IntPtrT, IntPtrT, IntPtrT) \
V(IntPtrSubWithOverflow, IntPtrT, IntPtrT, IntPtrT) \
V(IntPtrMul, IntPtrT, IntPtrT, IntPtrT) \
V(Int32Add, Word32T, Word32T, Word32T) \
V(Int32AddWithOverflow, Int32T, Int32T, Int32T) \
V(Int32Sub, Word32T, Word32T, Word32T) \
......@@ -276,25 +275,8 @@ class SloppyTNode : public TNode<A> {
V(Int32MulWithOverflow, Int32T, Int32T, Int32T) \
V(Int32Div, Int32T, Int32T, Int32T) \
V(Int32Mod, Int32T, Int32T, Int32T) \
V(WordOr, WordT, WordT, WordT) \
V(WordAnd, WordT, WordT, WordT) \
V(WordXor, WordT, WordT, WordT) \
V(WordShl, WordT, WordT, IntegralT) \
V(WordShr, WordT, WordT, IntegralT) \
V(WordSar, WordT, WordT, IntegralT) \
V(WordRor, WordT, WordT, IntegralT) \
V(Word32Or, Word32T, Word32T, Word32T) \
V(Word32And, Word32T, Word32T, Word32T) \
V(Word32Xor, Word32T, Word32T, Word32T) \
V(Word32Shl, Word32T, Word32T, Word32T) \
V(Word32Shr, Word32T, Word32T, Word32T) \
V(Word32Sar, Word32T, Word32T, Word32T) \
V(Word32Ror, Word32T, Word32T, Word32T) \
V(Word64Or, Word64T, Word64T, Word64T) \
V(Word64And, Word64T, Word64T, Word64T) \
V(Word64Xor, Word64T, Word64T, Word64T) \
V(Word64Shr, Word64T, Word64T, Word64T) \
V(Word64Sar, Word64T, Word64T, Word64T) \
V(Word64Ror, Word64T, Word64T, Word64T)
TNode<Float64T> Float64Add(TNode<Float64T> a, TNode<Float64T> b);
......@@ -625,6 +607,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<WordT> IntPtrAdd(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<WordT> IntPtrSub(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<WordT> IntPtrMul(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<IntPtrT> IntPtrAdd(TNode<IntPtrT> left, TNode<IntPtrT> right) {
return Signed(
IntPtrAdd(static_cast<Node*>(left), static_cast<Node*>(right)));
......@@ -633,6 +616,10 @@ class V8_EXPORT_PRIVATE CodeAssembler {
return Signed(
IntPtrSub(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<IntPtrT> IntPtrMul(TNode<IntPtrT> left, TNode<IntPtrT> right) {
return Signed(
IntPtrMul(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<WordT> WordShl(SloppyTNode<WordT> value, int shift);
TNode<WordT> WordShr(SloppyTNode<WordT> value, int shift);
......@@ -641,6 +628,37 @@ class V8_EXPORT_PRIVATE CodeAssembler {
}
TNode<Word32T> Word32Shr(SloppyTNode<Word32T> value, int shift);
TNode<WordT> WordOr(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<WordT> WordAnd(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<WordT> WordXor(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<WordT> WordShl(SloppyTNode<WordT> left, SloppyTNode<IntegralT> right);
TNode<WordT> WordShr(SloppyTNode<WordT> left, SloppyTNode<IntegralT> right);
TNode<WordT> WordSar(SloppyTNode<WordT> left, SloppyTNode<IntegralT> right);
TNode<Word32T> Word32Or(SloppyTNode<Word32T> left,
SloppyTNode<Word32T> right);
TNode<Word32T> Word32And(SloppyTNode<Word32T> left,
SloppyTNode<Word32T> right);
TNode<Word32T> Word32Xor(SloppyTNode<Word32T> left,
SloppyTNode<Word32T> right);
TNode<Word32T> Word32Shl(SloppyTNode<Word32T> left,
SloppyTNode<Word32T> right);
TNode<Word32T> Word32Shr(SloppyTNode<Word32T> left,
SloppyTNode<Word32T> right);
TNode<Word32T> Word32Sar(SloppyTNode<Word32T> left,
SloppyTNode<Word32T> right);
TNode<Word64T> Word64Or(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
TNode<Word64T> Word64And(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
TNode<Word64T> Word64Xor(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
TNode<Word64T> Word64Shl(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
TNode<Word64T> Word64Shr(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
TNode<Word64T> Word64Sar(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
// Unary
#define DECLARE_CODE_ASSEMBLER_UNARY_OP(name, ResType, ArgType) \
TNode<ResType> name(SloppyTNode<ArgType> a);
......
......@@ -343,7 +343,7 @@ static const int kMaxBuiltinRegisterParams = 5;
kStackParameterCount = kArity + 1 \
};
class VoidDescriptor : public CallInterfaceDescriptor {
class V8_EXPORT_PRIVATE VoidDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor)
};
......
......@@ -41,6 +41,8 @@ v8_executable("unittests") {
"base/utils/random-number-generator-unittest.cc",
"cancelable-tasks-unittest.cc",
"char-predicates-unittest.cc",
"code-stub-assembler-unittest.cc",
"code-stub-assembler-unittest.h",
"compiler-dispatcher/compiler-dispatcher-tracer-unittest.cc",
"compiler-dispatcher/compiler-dispatcher-unittest.cc",
"compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc",
......@@ -48,6 +50,8 @@ v8_executable("unittests") {
"compiler/branch-elimination-unittest.cc",
"compiler/bytecode-analysis-unittest.cc",
"compiler/checkpoint-elimination-unittest.cc",
"compiler/code-assembler-unittest.cc",
"compiler/code-assembler-unittest.h",
"compiler/common-operator-reducer-unittest.cc",
"compiler/common-operator-unittest.cc",
"compiler/compiler-test-utils.h",
......
// Copyright 2017 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 "test/unittests/code-stub-assembler-unittest.h"
#include "src/code-factory.h"
#include "src/compiler/node.h"
#include "src/interface-descriptors.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/node-test-utils.h"
using ::testing::_;
using v8::internal::compiler::Node;
namespace c = v8::internal::compiler;
namespace v8 {
namespace internal {
#ifdef ENABLE_VERIFY_CSA
#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) IsBitcastWordToTaggedSigned(x)
#define IS_BITCAST_TAGGED_TO_WORD(x) IsBitcastTaggedToWord(x)
#else
#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) (x)
#define IS_BITCAST_TAGGED_TO_WORD(x) (x)
#endif
CodeStubAssemblerTestState::CodeStubAssemblerTestState(
CodeStubAssemblerTest* test)
: compiler::CodeAssemblerState(test->isolate(), test->zone(),
VoidDescriptor(test->isolate()),
Code::ComputeFlags(Code::STUB), "test") {}
TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) {
CodeStubAssemblerTestState state(this);
CodeStubAssemblerForTest m(&state);
Node* value = m.Int32Constant(44);
EXPECT_THAT(m.SmiTag(value),
IS_BITCAST_WORD_TO_TAGGED_SIGNED(c::IsIntPtrConstant(
static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize))));
EXPECT_THAT(m.SmiUntag(value),
c::IsIntPtrConstant(static_cast<intptr_t>(44) >>
(kSmiShiftSize + kSmiTagSize)));
}
TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMax) {
CodeStubAssemblerTestState state(this);
CodeStubAssemblerForTest m(&state);
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(1);
Node* z = m.IntPtrMax(a, b);
EXPECT_THAT(z, c::IsIntPtrConstant(100));
}
}
TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMin) {
CodeStubAssemblerTestState state(this);
CodeStubAssemblerForTest m(&state);
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(1);
Node* z = m.IntPtrMin(a, b);
EXPECT_THAT(z, c::IsIntPtrConstant(1));
}
}
} // namespace internal
} // namespace v8
// Copyright 2017 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_UNITTESTS_CODE_STUB_ASSEMBLER_UNITTEST_H_
#define V8_UNITTESTS_CODE_STUB_ASSEMBLER_UNITTEST_H_
#include "src/code-stub-assembler.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
namespace v8 {
namespace internal {
class CodeStubAssemblerTest : public TestWithIsolateAndZone {
public:
CodeStubAssemblerTest() {}
~CodeStubAssemblerTest() override {}
};
class CodeStubAssemblerTestState : public compiler::CodeAssemblerState {
public:
explicit CodeStubAssemblerTestState(CodeStubAssemblerTest* test);
};
class CodeStubAssemblerForTest : public CodeStubAssembler {
public:
explicit CodeStubAssemblerForTest(CodeStubAssemblerTestState* state)
: CodeStubAssembler(state) {}
};
} // namespace internal
} // namespace v8
#endif // V8_UNITTESTS_CODE_STUB_ASSEMBLER_UNITTEST_H_
// Copyright 2017 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 "test/unittests/compiler/code-assembler-unittest.h"
#include "src/code-factory.h"
#include "src/compiler/node.h"
#include "src/interface-descriptors.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/node-test-utils.h"
using ::testing::_;
namespace v8 {
namespace internal {
namespace compiler {
CodeAssemblerTestState::CodeAssemblerTestState(CodeAssemblerTest* test)
: CodeAssemblerState(test->isolate(), test->zone(),
VoidDescriptor(test->isolate()),
Code::ComputeFlags(Code::STUB), "test") {}
TARGET_TEST_F(CodeAssemblerTest, IntPtrAdd) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* add = m.IntPtrAdd(a, b);
EXPECT_THAT(add, IsIntPtrAdd(a, b));
}
// x + 0 => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(0);
Node* add = m.IntPtrAdd(a, b);
EXPECT_THAT(add, a);
}
// 0 + x => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(0);
Node* add = m.IntPtrAdd(b, a);
EXPECT_THAT(add, a);
}
// CONST_a + CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(22);
Node* b = m.IntPtrConstant(33);
Node* c = m.IntPtrAdd(a, b);
EXPECT_THAT(c, IsIntPtrConstant(55));
}
}
TARGET_TEST_F(CodeAssemblerTest, IntPtrSub) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* sub = m.IntPtrSub(a, b);
EXPECT_THAT(sub, IsIntPtrSub(a, b));
}
// x - 0 => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(0);
Node* c = m.IntPtrSub(a, b);
EXPECT_THAT(c, a);
}
// CONST_a - CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(1);
Node* c = m.IntPtrSub(a, b);
EXPECT_THAT(c, IsIntPtrConstant(99));
}
}
TARGET_TEST_F(CodeAssemblerTest, IntPtrMul) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(100);
Node* mul = m.IntPtrMul(a, b);
EXPECT_THAT(mul, IsIntPtrMul(a, b));
}
// x * 1 => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* mul = m.IntPtrMul(a, b);
EXPECT_THAT(mul, a);
}
// 1 * x => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* mul = m.IntPtrMul(b, a);
EXPECT_THAT(mul, a);
}
// CONST_a * CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(5);
Node* c = m.IntPtrMul(a, b);
EXPECT_THAT(c, IsIntPtrConstant(500));
}
}
TARGET_TEST_F(CodeAssemblerTest, WordShl) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* add = m.WordShl(a, 10);
EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10)));
}
// x << 0 => x
{
Node* a = m.Parameter(0);
Node* add = m.WordShl(a, 0);
EXPECT_THAT(add, a);
}
// CONST_a << CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(1024);
Node* shl = m.WordShl(a, 2);
EXPECT_THAT(shl, IsIntPtrConstant(4096));
}
}
TARGET_TEST_F(CodeAssemblerTest, WordShr) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* shr = m.WordShr(a, 10);
EXPECT_THAT(shr, IsWordShr(a, IsIntPtrConstant(10)));
}
// x >> 0 => x
{
Node* a = m.Parameter(0);
Node* shr = m.WordShr(a, 0);
EXPECT_THAT(shr, a);
}
// +CONST_a >> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(4096);
Node* shr = m.WordShr(a, 2);
EXPECT_THAT(shr, IsIntPtrConstant(1024));
}
// -CONST_a >> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(-1234);
Node* shr = m.WordShr(a, 2);
EXPECT_THAT(shr, IsIntPtrConstant(static_cast<uintptr_t>(-1234) >> 2));
}
}
TARGET_TEST_F(CodeAssemblerTest, WordSar) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* sar = m.WordSar(a, m.IntPtrConstant(10));
EXPECT_THAT(sar, IsWordSar(a, IsIntPtrConstant(10)));
}
// x >>> 0 => x
{
Node* a = m.Parameter(0);
Node* sar = m.WordSar(a, m.IntPtrConstant(0));
EXPECT_THAT(sar, a);
}
// +CONST_a >>> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(4096);
Node* sar = m.WordSar(a, m.IntPtrConstant(2));
EXPECT_THAT(sar, IsIntPtrConstant(1024));
}
// -CONST_a >>> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(-1234);
Node* sar = m.WordSar(a, m.IntPtrConstant(2));
EXPECT_THAT(sar, IsIntPtrConstant(static_cast<intptr_t>(-1234) >> 2));
}
}
TARGET_TEST_F(CodeAssemblerTest, WordOr) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* z = m.WordOr(a, m.IntPtrConstant(8));
EXPECT_THAT(z, IsWordOr(a, IsIntPtrConstant(8)));
}
// x | 0 => x
{
Node* a = m.Parameter(0);
Node* z = m.WordOr(a, m.IntPtrConstant(0));
EXPECT_THAT(z, a);
}
// 0 | x => x
{
Node* a = m.Parameter(0);
Node* z = m.WordOr(m.IntPtrConstant(0), a);
EXPECT_THAT(z, a);
}
// CONST_a | CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(3);
Node* b = m.WordOr(a, m.IntPtrConstant(7));
EXPECT_THAT(b, IsIntPtrConstant(7));
}
}
TARGET_TEST_F(CodeAssemblerTest, WordAnd) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* z = m.WordAnd(a, m.IntPtrConstant(8));
EXPECT_THAT(z, IsWordAnd(a, IsIntPtrConstant(8)));
}
// CONST_a & CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(3);
Node* b = m.WordAnd(a, m.IntPtrConstant(7));
EXPECT_THAT(b, IsIntPtrConstant(3));
}
}
TARGET_TEST_F(CodeAssemblerTest, WordXor) {
CodeAssemblerTestState state(this);
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* z = m.WordXor(a, m.IntPtrConstant(8));
EXPECT_THAT(z, IsWordXor(a, IsIntPtrConstant(8)));
}
// CONST_a ^ CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(3);
Node* b = m.WordXor(a, m.IntPtrConstant(7));
EXPECT_THAT(b, IsIntPtrConstant(4));
}
}
} // namespace compiler
} // namespace internal
} // namespace v8
// Copyright 2017 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_UNITTESTS_COMPILER_CODE_ASSEMBLER_UNITTEST_H_
#define V8_UNITTESTS_COMPILER_CODE_ASSEMBLER_UNITTEST_H_
#include "src/compiler/code-assembler.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
namespace v8 {
namespace internal {
namespace compiler {
class CodeAssemblerTest : public TestWithIsolateAndZone {
public:
CodeAssemblerTest() {}
~CodeAssemblerTest() override {}
};
class CodeAssemblerTestState : public CodeAssemblerState {
public:
explicit CodeAssemblerTestState(CodeAssemblerTest* test);
};
class CodeAssemblerForTest : public CodeAssembler {
public:
explicit CodeAssemblerForTest(CodeAssemblerTestState* state)
: CodeAssembler(state) {}
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_UNITTESTS_COMPILER_CODE_ASSEMBLER_UNITTEST_H_
......@@ -2110,8 +2110,10 @@ IS_BINOP_MATCHER(Word32Ror)
IS_BINOP_MATCHER(Word32Equal)
IS_BINOP_MATCHER(Word64And)
IS_BINOP_MATCHER(Word64Or)
IS_BINOP_MATCHER(Word64Xor)
IS_BINOP_MATCHER(Word64Sar)
IS_BINOP_MATCHER(Word64Shl)
IS_BINOP_MATCHER(Word64Shr)
IS_BINOP_MATCHER(Word64Equal)
IS_BINOP_MATCHER(Int32AddWithOverflow)
IS_BINOP_MATCHER(Int32SubWithOverflow)
......
......@@ -358,8 +358,12 @@ Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord64Or(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord64Xor(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord64Shr(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
......@@ -473,6 +477,81 @@ Matcher<Node*> IsWord32ReverseBytes(const Matcher<Node*>& value_matcher);
Matcher<Node*> IsStackSlot();
// Helpers
static inline Matcher<Node*> IsIntPtrConstant(const intptr_t value) {
return kPointerSize == 8 ? IsInt64Constant(static_cast<int64_t>(value))
: IsInt32Constant(static_cast<int32_t>(value));
}
static inline Matcher<Node*> IsIntPtrAdd(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher)
: IsInt32Add(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher)
: IsInt32Sub(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsIntPtrMul(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsInt64Mul(lhs_matcher, rhs_matcher)
: IsInt32Mul(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher)
: IsWord32Shl(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsWordShr(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsWord64Shr(lhs_matcher, rhs_matcher)
: IsWord32Shr(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher)
: IsWord32Sar(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsWordAnd(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsWord64And(lhs_matcher, rhs_matcher)
: IsWord32And(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher)
: IsWord32Or(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsWordXor(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher) {
return kPointerSize == 8 ? IsWord64Xor(lhs_matcher, rhs_matcher)
: IsWord32Xor(lhs_matcher, rhs_matcher);
}
static inline Matcher<Node*> IsChangeInt32ToIntPtr(
const Matcher<Node*>& matcher) {
return kPointerSize == 8 ? IsChangeInt32ToInt64(matcher) : matcher;
}
static inline Matcher<Node*> IsChangeUint32ToWord(
const Matcher<Node*>& matcher) {
return kPointerSize == 8 ? IsChangeUint32ToUint64(matcher) : matcher;
}
static inline Matcher<Node*> IsTruncateWordToWord32(
const Matcher<Node*>& matcher) {
return kPointerSize == 8 ? IsTruncateInt64ToInt32(matcher) : matcher;
}
} // namespace compiler
} // namespace internal
} // namespace v8
......
......@@ -38,9 +38,13 @@
'base/utils/random-number-generator-unittest.cc',
'cancelable-tasks-unittest.cc',
'char-predicates-unittest.cc',
"code-stub-assembler-unittest.cc",
"code-stub-assembler-unittest.h",
'compiler/branch-elimination-unittest.cc',
'compiler/bytecode-analysis-unittest.cc',
'compiler/checkpoint-elimination-unittest.cc',
"compiler/code-assembler-unittest.cc",
"compiler/code-assembler-unittest.h",
'compiler/common-operator-reducer-unittest.cc',
'compiler/common-operator-unittest.cc',
'compiler/compiler-test-utils.h',
......
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