| 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 <cmath> | 5 #include <cmath> |
| 6 #include <functional> | 6 #include <functional> |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| 11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
| 12 #include "test/cctest/cctest.h" | 12 #include "test/cctest/cctest.h" |
| 13 #include "test/cctest/compiler/codegen-tester.h" | 13 #include "test/cctest/compiler/codegen-tester.h" |
| 14 #include "test/cctest/compiler/value-helper.h" | 14 #include "test/cctest/compiler/value-helper.h" |
| 15 | 15 |
| 16 #if V8_TURBOFAN_TARGET | |
| 17 | |
| 18 using namespace v8::base; | 16 using namespace v8::base; |
| 19 using namespace v8::internal; | 17 using namespace v8::internal; |
| 20 using namespace v8::internal::compiler; | 18 using namespace v8::internal::compiler; |
| 21 | 19 |
| 22 typedef RawMachineAssembler::Label MLabel; | 20 typedef RawMachineAssembler::Label MLabel; |
| 23 | 21 |
| 24 TEST(RunInt32Add) { | 22 TEST(RunInt32Add) { |
| 25 RawMachineAssemblerTester<int32_t> m; | 23 RawMachineAssemblerTester<int32_t> m; |
| 26 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); | 24 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); |
| 27 m.Return(add); | 25 m.Return(add); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 80 } |
| 83 | 81 |
| 84 | 82 |
| 85 TEST(CodeGenNop) { | 83 TEST(CodeGenNop) { |
| 86 RawMachineAssemblerTester<void> m; | 84 RawMachineAssemblerTester<void> m; |
| 87 m.Return(m.Int32Constant(0)); | 85 m.Return(m.Int32Constant(0)); |
| 88 m.GenerateCode(); | 86 m.GenerateCode(); |
| 89 } | 87 } |
| 90 | 88 |
| 91 | 89 |
| 92 #if V8_TURBOFAN_BACKEND_64 | 90 #if V8_TARGET_ARCH_64_BIT |
| 93 static Node* Int64Input(RawMachineAssemblerTester<int64_t>* m, int index) { | 91 static Node* Int64Input(RawMachineAssemblerTester<int64_t>* m, int index) { |
| 94 switch (index) { | 92 switch (index) { |
| 95 case 0: | 93 case 0: |
| 96 return m->Parameter(0); | 94 return m->Parameter(0); |
| 97 case 1: | 95 case 1: |
| 98 return m->Parameter(1); | 96 return m->Parameter(1); |
| 99 case 2: | 97 case 2: |
| 100 return m->Int64Constant(0); | 98 return m->Int64Constant(0); |
| 101 case 3: | 99 case 3: |
| 102 return m->Int64Constant(1); | 100 return m->Int64Constant(1); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 Node* b = Int64Input(&m, k); | 134 Node* b = Int64Input(&m, k); |
| 137 m.Return(m.NewNode(kOps[i], a, b)); | 135 m.Return(m.NewNode(kOps[i], a, b)); |
| 138 m.GenerateCode(); | 136 m.GenerateCode(); |
| 139 } | 137 } |
| 140 } | 138 } |
| 141 } | 139 } |
| 142 } | 140 } |
| 143 | 141 |
| 144 | 142 |
| 145 // TODO(titzer): add tests that run 64-bit integer operations. | 143 // TODO(titzer): add tests that run 64-bit integer operations. |
| 146 #endif // V8_TURBOFAN_BACKEND_64 | 144 #endif // V8_TARGET_ARCH_64_BIT |
| 147 | 145 |
| 148 | 146 |
| 149 TEST(RunGoto) { | 147 TEST(RunGoto) { |
| 150 RawMachineAssemblerTester<int32_t> m; | 148 RawMachineAssemblerTester<int32_t> m; |
| 151 int constant = 99999; | 149 int constant = 99999; |
| 152 | 150 |
| 153 MLabel next; | 151 MLabel next; |
| 154 m.Goto(&next); | 152 m.Goto(&next); |
| 155 m.Bind(&next); | 153 m.Bind(&next); |
| 156 m.Return(m.Int32Constant(constant)); | 154 m.Return(m.Int32Constant(constant)); |
| (...skipping 5117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5274 kMachInt32, kMachInt32, kMachInt32, kMachInt32, | 5272 kMachInt32, kMachInt32, kMachInt32, kMachInt32, |
| 5275 kMachInt32, function, param, param, param, param, | 5273 kMachInt32, function, param, param, param, param, |
| 5276 param, param, param, param)); | 5274 param, param, param, param)); |
| 5277 FOR_INT32_INPUTS(i) { | 5275 FOR_INT32_INPUTS(i) { |
| 5278 int32_t const x = *i; | 5276 int32_t const x = *i; |
| 5279 CHECK_EQ(x * 8, m.Call(x)); | 5277 CHECK_EQ(x * 8, m.Call(x)); |
| 5280 } | 5278 } |
| 5281 } | 5279 } |
| 5282 | 5280 |
| 5283 #endif // USE_SIMULATOR | 5281 #endif // USE_SIMULATOR |
| 5284 | |
| 5285 #endif // V8_TURBOFAN_TARGET | |
| OLD | NEW |