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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/change-lowering.h" | 9 #include "src/compiler/change-lowering.h" |
10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 } | 1133 } |
1134 | 1134 |
1135 | 1135 |
1136 TEST(LowerReferenceEqual_to_wordeq) { | 1136 TEST(LowerReferenceEqual_to_wordeq) { |
1137 TestingGraph t(Type::Any(), Type::Any()); | 1137 TestingGraph t(Type::Any(), Type::Any()); |
1138 IrOpcode::Value opcode = | 1138 IrOpcode::Value opcode = |
1139 static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode()); | 1139 static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode()); |
1140 t.CheckLoweringBinop(opcode, t.simplified()->ReferenceEqual(Type::Any())); | 1140 t.CheckLoweringBinop(opcode, t.simplified()->ReferenceEqual(Type::Any())); |
1141 } | 1141 } |
1142 | 1142 |
1143 | 1143 void CheckChangeInsertion(IrOpcode::Value expected, MachineType from, |
1144 TEST(LowerStringOps_to_call_and_compare) { | 1144 MachineType to, Type* type = Type::Any()) { |
1145 // These tests need linkage for the calls. | |
1146 TestingGraph t(Type::String(), Type::String()); | |
1147 IrOpcode::Value compare_lt = | |
1148 static_cast<IrOpcode::Value>(t.machine()->IntLessThan()->opcode()); | |
1149 IrOpcode::Value compare_le = static_cast<IrOpcode::Value>( | |
1150 t.machine()->IntLessThanOrEqual()->opcode()); | |
1151 t.CheckLoweringStringBinop(compare_lt, t.simplified()->StringLessThan()); | |
1152 t.CheckLoweringStringBinop(compare_le, | |
1153 t.simplified()->StringLessThanOrEqual()); | |
1154 } | |
1155 | |
1156 | |
1157 void CheckChangeInsertion(IrOpcode::Value expected, MachineType from, | |
1158 MachineType to, Type* type = Type::Any()) { | |
1159 TestingGraph t(Type::Any()); | 1145 TestingGraph t(Type::Any()); |
1160 Node* in = t.ExampleWithOutput(from); | 1146 Node* in = t.ExampleWithOutput(from); |
1161 NodeProperties::SetType(in, type); | 1147 NodeProperties::SetType(in, type); |
1162 Node* use = t.Use(in, to); | 1148 Node* use = t.Use(in, to); |
1163 t.Return(use); | 1149 t.Return(use); |
1164 t.Lower(); | 1150 t.Lower(); |
1165 CHECK_EQ(expected, use->InputAt(0)->opcode()); | 1151 CHECK_EQ(expected, use->InputAt(0)->opcode()); |
1166 CHECK_EQ(in, use->InputAt(0)->InputAt(0)); | 1152 CHECK_EQ(in, use->InputAt(0)->InputAt(0)); |
1167 } | 1153 } |
1168 | 1154 |
1169 | |
1170 TEST(InsertBasicChanges) { | 1155 TEST(InsertBasicChanges) { |
1171 CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, MachineType::Float64(), | 1156 CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, MachineType::Float64(), |
1172 MachineType::Int32(), Type::Signed32()); | 1157 MachineType::Int32(), Type::Signed32()); |
1173 CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, MachineType::Float64(), | 1158 CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, MachineType::Float64(), |
1174 MachineType::Uint32(), Type::Unsigned32()); | 1159 MachineType::Uint32(), Type::Unsigned32()); |
1175 CheckChangeInsertion(IrOpcode::kTruncateFloat64ToInt32, | 1160 CheckChangeInsertion(IrOpcode::kTruncateFloat64ToInt32, |
1176 MachineType::Float64(), MachineType::Uint32(), | 1161 MachineType::Float64(), MachineType::Uint32(), |
1177 Type::Integral32()); | 1162 Type::Integral32()); |
1178 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, MachineType::AnyTagged(), | 1163 CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, MachineType::AnyTagged(), |
1179 MachineType::Int32(), Type::Signed32()); | 1164 MachineType::Int32(), Type::Signed32()); |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 t.Return(use); | 1945 t.Return(use); |
1961 t.Lower(); | 1946 t.Lower(); |
1962 | 1947 |
1963 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); | 1948 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); |
1964 } | 1949 } |
1965 } | 1950 } |
1966 | 1951 |
1967 } // namespace compiler | 1952 } // namespace compiler |
1968 } // namespace internal | 1953 } // namespace internal |
1969 } // namespace v8 | 1954 } // namespace v8 |
OLD | NEW |