Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: test/unittests/compiler/int64-lowering-unittest.cc

Issue 1714793003: [wasm] Unittest for Int64Lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/int64-lowering.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/int64-lowering-unittest.cc
diff --git a/test/unittests/compiler/int64-lowering-unittest.cc b/test/unittests/compiler/int64-lowering-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bfd3857bcb4c2d7b7a042c516f7a0737a8f91ef1
--- /dev/null
+++ b/test/unittests/compiler/int64-lowering-unittest.cc
@@ -0,0 +1,65 @@
+// Copyright 2016 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 "src/compiler/int64-lowering.h"
+#include "src/compiler/common-operator.h"
+#include "src/compiler/machine-operator.h"
+#include "src/compiler/node.h"
+
+#include "src/compiler/node-properties.h"
+
+#include "src/signature.h"
+
+#include "test/unittests/compiler/graph-unittest.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+class Int64LoweringTest : public GraphTest {
+ public:
+ Int64LoweringTest() : GraphTest(), machine_(zone()) {}
+
+ MachineOperatorBuilder* machine() { return &machine_; }
+
+ void LowerGraph(Node* node, Signature<MachineRepresentation>* signature) {
+ Node* ret = graph()->NewNode(common()->Return(), node, graph()->start(),
+ graph()->start());
+ NodeProperties::MergeControlToEnd(graph(), common(), ret);
+
+ Int64Lowering lowering(graph(), machine(), common(), zone(), signature);
+ lowering.LowerGraph();
+ }
+
+ void LowerGraph(Node* node, MachineRepresentation return_type,
+ MachineRepresentation rep = MachineRepresentation::kWord32,
+ int num_params = 0) {
+ Signature<MachineRepresentation>::Builder sig_builder(zone(), 1,
+ num_params);
+ sig_builder.AddReturn(return_type);
+ for (int i = 0; i < num_params; i++) {
+ sig_builder.AddParam(rep);
+ }
+ LowerGraph(node, sig_builder.Build());
+ }
+
+ private:
+ MachineOperatorBuilder machine_;
+};
+
+TEST_F(Int64LoweringTest, Int64Constant) {
+ LowerGraph(Int64Constant(0x1234567890abcdef), MachineRepresentation::kWord64);
+
+ Node* ret = graph()->end()->InputAt(1);
+ EXPECT_THAT(ret->opcode(), IrOpcode::kReturn);
+ EXPECT_THAT(NodeProperties::PastValueIndex(ret), 2);
+ EXPECT_THAT(ret->InputAt(0)->opcode(), IrOpcode::kInt32Constant);
titzer 2016/02/21 12:50:29 Please have a look at some of the other unittests.
+ EXPECT_THAT(OpParameter<int32_t>(ret->InputAt(0)), 0x90abcdef);
+ EXPECT_THAT(ret->InputAt(1)->opcode(), IrOpcode::kInt32Constant);
+ EXPECT_THAT(OpParameter<int32_t>(ret->InputAt(1)), 0x12345678);
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/compiler/int64-lowering.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698