12 #include "testing/gmock-support.h"
16 using testing::Capture;
17 using testing::CaptureEq;
27 return os << ost.
c_str();
59 return static_cast<int>(0xffffffffu << (
SmiValueSize() - 1));
82 ChangeLowering reducer(&jsgraph, &linkage);
83 return reducer.Reduce(node);
89 const Matcher<Node*>& control_matcher) {
99 const Matcher<Node*>& rhs_matcher) {
115 public ::testing::WithParamInterface<MachineType> {
126 Node* val = Parameter(0);
127 Node* node = graph()->NewNode(simplified()->ChangeBitToBool(), val);
128 Reduction reduction = Reduce(node);
129 ASSERT_TRUE(reduction.Changed());
131 Node* phi = reduction.replacement();
132 Capture<Node*> branch;
135 IsTrueConstant(), IsFalseConstant(),
143 Node* val = Parameter(0);
144 Node* node = graph()->NewNode(simplified()->ChangeBoolToBit(), val);
145 Reduction reduction = Reduce(node);
146 ASSERT_TRUE(reduction.Changed());
148 EXPECT_THAT(reduction.replacement(), IsWordEqual(val, IsTrueConstant()));
153 Node* val = Parameter(0);
154 Node* node = graph()->NewNode(simplified()->ChangeFloat64ToTagged(), val);
155 Reduction reduction = Reduce(node);
156 ASSERT_TRUE(reduction.Changed());
158 Node* finish = reduction.replacement();
159 Capture<Node*> heap_number;
163 AllOf(CaptureEq(&heap_number),
167 CaptureEq(&heap_number), graph()->start())));
173 graph()->NewNode(simplified()->StringAdd(), Parameter(0), Parameter(1));
174 Reduction reduction = Reduce(node);
175 EXPECT_FALSE(reduction.Changed());
197 Node* val = Parameter(0);
198 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val);
199 Reduction reduction = Reduce(node);
200 ASSERT_TRUE(reduction.Changed());
202 Node* phi = reduction.replacement();
203 Capture<Node*> add, branch, heap_number, if_true;
208 AllOf(CaptureEq(&heap_number),
209 IsAllocateHeapNumber(
_, CaptureEq(&if_true))),
213 CaptureEq(&if_true))),
219 graph()->start()))))));
227 Node* val = Parameter(0);
228 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val);
229 Reduction reduction = Reduce(node);
230 ASSERT_TRUE(reduction.Changed());
232 Node* phi = reduction.replacement();
233 Capture<Node*> branch, if_true;
243 AllOf(CaptureEq(&if_true),
247 graph()->start())))),
256 Node* val = Parameter(0);
257 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val);
258 Reduction reduction = Reduce(node);
259 ASSERT_TRUE(reduction.Changed());
261 Node* phi = reduction.replacement();
262 Capture<Node*> branch, if_true;
274 graph()->start()))))));
282 Node* val = Parameter(0);
283 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val);
284 Reduction reduction = Reduce(node);
285 ASSERT_TRUE(reduction.Changed());
287 Node* phi = reduction.replacement();
288 Capture<Node*> branch, if_true;
300 graph()->start()))))));
308 Node* val = Parameter(0);
309 Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val);
310 Reduction reduction = Reduce(node);
311 ASSERT_TRUE(reduction.Changed());
313 Node* phi = reduction.replacement();
314 Capture<Node*> branch, heap_number, if_false;
320 AllOf(CaptureEq(&heap_number),
321 IsAllocateHeapNumber(
_, CaptureEq(&if_false))),
325 CaptureEq(&if_false))),
331 AllOf(CaptureEq(&if_false),
IsIfFalse(CaptureEq(&branch))))));
349 Node* val = Parameter(0);
350 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val);
351 Reduction reduction = Reduce(node);
352 ASSERT_TRUE(reduction.Changed());
354 EXPECT_THAT(reduction.replacement(),
364 Node* val = Parameter(0);
365 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val);
366 Reduction reduction = Reduce(node);
367 ASSERT_TRUE(reduction.Changed());
369 Node* phi = reduction.replacement();
370 Capture<Node*> branch, if_true;
380 AllOf(CaptureEq(&if_true),
384 graph()->start())))),
393 Node* val = Parameter(0);
394 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val);
395 Reduction reduction = Reduce(node);
396 ASSERT_TRUE(reduction.Changed());
398 Node* phi = reduction.replacement();
399 Capture<Node*> branch, if_true;
412 graph()->start()))))));
420 Node* val = Parameter(0);
421 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val);
422 Reduction reduction = Reduce(node);
423 ASSERT_TRUE(reduction.Changed());
425 Node* phi = reduction.replacement();
426 Capture<Node*> branch, if_true;
439 graph()->start()))))));
447 Node* val = Parameter(0);
448 Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), val);
449 Reduction reduction = Reduce(node);
450 ASSERT_TRUE(reduction.Changed());
452 Node* phi = reduction.replacement();
453 Capture<Node*> branch, heap_number, if_false;
460 AllOf(CaptureEq(&heap_number),
461 IsAllocateHeapNumber(
_, CaptureEq(&if_false))),
465 CaptureEq(&if_false))),
471 AllOf(CaptureEq(&if_false),
IsIfFalse(CaptureEq(&branch))))));
Isolate * isolate() const
static const int kValueOffset
const char * c_str() const
static const Function * FunctionForId(FunctionId id)
virtual MachineType WordRepresentation() const FINAL OVERRIDE
virtual ~ChangeLowering32Test()
virtual MachineType WordRepresentation() const FINAL OVERRIDE
virtual ~ChangeLowering64Test()
virtual MachineType WordRepresentation() const FINAL OVERRIDE
virtual ~ChangeLoweringCommonTest()
Matcher< Node * > IsAllocateHeapNumber(const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
int HeapNumberValueOffset() const
Node * Parameter(int32_t index=0)
Reduction Reduce(Node *node)
virtual MachineType WordRepresentation() const =0
int SmiShiftAmount() const
SimplifiedOperatorBuilder * simplified()
SimplifiedOperatorBuilder simplified_
Matcher< Node * > IsWordEqual(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
virtual ~ChangeLoweringTest()
CommonOperatorBuilder * common()
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Matcher< Node * > IsChangeInt32ToInt64(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsChangeUint32ToFloat64(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsWord32Equal(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsMerge(const Matcher< Node * > &control0_matcher, const Matcher< Node * > &control1_matcher)
Matcher< Node * > IsUint32LessThanOrEqual(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsIfFalse(const Matcher< Node * > &control_matcher)
Matcher< Node * > IsBranch(const Matcher< Node * > &value_matcher, const Matcher< Node * > &control_matcher)
std::ostream & operator<<(std::ostream &os, const MachineType &type)
Matcher< Node * > IsTruncateInt64ToInt32(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsNumberConstant(const Matcher< double > &value_matcher)
Matcher< Node * > IsIfTrue(const Matcher< Node * > &control_matcher)
TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged)
STATIC_ASSERT(DoubleRegister::kMaxNumAllocatableRegisters >=Register::kMaxNumAllocatableRegisters)
Matcher< Node * > IsControlEffect(const Matcher< Node * > &control_matcher)
Matcher< Node * > IsFinish(const Matcher< Node * > &value_matcher, const Matcher< Node * > &effect_matcher)
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool)
Matcher< Node * > IsWord32Shl(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsChangeUint32ToUint64(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsChangeInt32ToFloat64(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsInt32Constant(const Matcher< int32_t > &value_matcher)
Matcher< Node * > IsWord32And(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsCall(const Matcher< CallDescriptor * > &descriptor_matcher, const Matcher< Node * > &value0_matcher, const Matcher< Node * > &value1_matcher, const Matcher< Node * > &value2_matcher, const Matcher< Node * > &value3_matcher, const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
Matcher< Node * > IsWord64Sar(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsExternalConstant(const Matcher< ExternalReference > &value_matcher)
INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorDPITest, ::testing::ValuesIn(kDPIs))
Matcher< Node * > IsPhi(const Matcher< MachineType > &type_matcher, const Matcher< Node * > &value0_matcher, const Matcher< Node * > &value1_matcher, const Matcher< Node * > &merge_matcher)
Matcher< Node * > IsStore(const Matcher< MachineType > &type_matcher, const Matcher< WriteBarrierKind > &write_barrier_matcher, const Matcher< Node * > &base_matcher, const Matcher< Node * > &index_matcher, const Matcher< Node * > &value_matcher, const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
Matcher< Node * > IsValueEffect(const Matcher< Node * > &value_matcher)
Matcher< Node * > IsLoad(const Matcher< LoadRepresentation > &rep_matcher, const Matcher< Node * > &base_matcher, const Matcher< Node * > &index_matcher, const Matcher< Node * > &effect_matcher)
Matcher< Node * > IsProjection(const Matcher< size_t > &index_matcher, const Matcher< Node * > &base_matcher)
Matcher< Node * > IsChangeFloat64ToUint32(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsHeapConstant(const Matcher< Unique< HeapObject > > &value_matcher)
Matcher< Node * > IsChangeFloat64ToInt32(const Matcher< Node * > &input_matcher)
Matcher< Node * > IsWord64Shl(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsWord64Equal(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsInt32AddWithOverflow(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsWord64And(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
Matcher< Node * > IsWord32Sar(const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
const int kApiPointerSize
const intptr_t kSmiTagMask
Debugger support for the V8 JavaScript engine.