OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 t.Lower(); | 803 t.Lower(); |
804 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); | 804 CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); |
805 Node* cmp = use->InputAt(0)->InputAt(0); | 805 Node* cmp = use->InputAt(0)->InputAt(0); |
806 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); | 806 CHECK_EQ(t.machine()->WordEqual()->opcode(), cmp->opcode()); |
807 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); | 807 CHECK(b == cmp->InputAt(0) || b == cmp->InputAt(1)); |
808 Node* f = t.jsgraph.FalseConstant(); | 808 Node* f = t.jsgraph.FalseConstant(); |
809 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); | 809 CHECK(f == cmp->InputAt(0) || f == cmp->InputAt(1)); |
810 } | 810 } |
811 | 811 |
812 | 812 |
813 TEST(LowerBooleanToNumber_bit_int32) { | |
814 // BooleanToNumber(x: kRepBit) used as kMachInt32 | |
815 TestingGraph t(Type::Boolean()); | |
816 Node* b = t.ExampleWithOutput(kRepBit); | |
817 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | |
818 Node* use = t.Use(cnv, kMachInt32); | |
819 t.Return(use); | |
820 t.Lower(); | |
821 CHECK_EQ(b, use->InputAt(0)); | |
822 } | |
823 | |
824 | |
825 TEST(LowerBooleanToNumber_tagged_int32) { | |
titzer
2014/09/17 12:01:22
Maybe also want to test it being used as tagged, t
Michael Starzinger
2014/09/17 12:43:28
Done (both kRepBit and kRepTagged used as tagged).
| |
826 // BooleanToNumber(x: kRepTagged) used as kMachInt32 | |
827 TestingGraph t(Type::Boolean()); | |
828 Node* b = t.p0; | |
829 Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); | |
830 Node* use = t.Use(cnv, kMachInt32); | |
831 t.Return(use); | |
832 t.Lower(); | |
833 CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); | |
834 CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); | |
835 Node* c = t.jsgraph.TrueConstant(); | |
836 CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); | |
837 } | |
838 | |
839 | |
813 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), | 840 static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), |
814 Type::Number(), Type::Any()}; | 841 Type::Number(), Type::Any()}; |
815 | 842 |
816 | 843 |
817 TEST(LowerNumberCmp_to_int32) { | 844 TEST(LowerNumberCmp_to_int32) { |
818 TestingGraph t(Type::Signed32(), Type::Signed32()); | 845 TestingGraph t(Type::Signed32(), Type::Signed32()); |
819 | 846 |
820 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); | 847 t.CheckLoweringBinop(IrOpcode::kWord32Equal, t.simplified()->NumberEqual()); |
821 t.CheckLoweringBinop(IrOpcode::kInt32LessThan, | 848 t.CheckLoweringBinop(IrOpcode::kInt32LessThan, |
822 t.simplified()->NumberLessThan()); | 849 t.simplified()->NumberLessThan()); |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, | 1473 Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, |
1447 load1, t.start); | 1474 load1, t.start); |
1448 t.Return(t.Use(phi, kMachineTypes[i])); | 1475 t.Return(t.Use(phi, kMachineTypes[i])); |
1449 t.Lower(); | 1476 t.Lower(); |
1450 | 1477 |
1451 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); | 1478 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); |
1452 CHECK_EQ(RepresentationOf(kMachineTypes[i]), | 1479 CHECK_EQ(RepresentationOf(kMachineTypes[i]), |
1453 RepresentationOf(OpParameter<MachineType>(phi))); | 1480 RepresentationOf(OpParameter<MachineType>(phi))); |
1454 } | 1481 } |
1455 } | 1482 } |
OLD | NEW |