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" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 Node* a = Int32Input(&m, j); | 75 Node* a = Int32Input(&m, j); |
76 Node* b = Int32Input(&m, k); | 76 Node* b = Int32Input(&m, k); |
77 m.Return(m.NewNode(kOps[i], a, b)); | 77 m.Return(m.NewNode(kOps[i], a, b)); |
78 m.GenerateCode(); | 78 m.GenerateCode(); |
79 } | 79 } |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 | 84 |
| 85 #if V8_TURBOFAN_BACKEND_64 |
| 86 static Node* Int64Input(RawMachineAssemblerTester<int64_t>* m, int index) { |
| 87 switch (index) { |
| 88 case 0: |
| 89 return m->Parameter(0); |
| 90 case 1: |
| 91 return m->Parameter(1); |
| 92 case 2: |
| 93 return m->Int64Constant(0); |
| 94 case 3: |
| 95 return m->Int64Constant(1); |
| 96 case 4: |
| 97 return m->Int64Constant(-1); |
| 98 case 5: |
| 99 return m->Int64Constant(0xff); |
| 100 case 6: |
| 101 return m->Int64Constant(0x0123456789abcdefLL); |
| 102 case 7: |
| 103 return m->Load(kMachInt64, m->PointerConstant(NULL)); |
| 104 default: |
| 105 return NULL; |
| 106 } |
| 107 } |
| 108 |
| 109 |
| 110 TEST(CodeGenInt64Binop) { |
| 111 RawMachineAssemblerTester<void> m; |
| 112 |
| 113 const Operator* kOps[] = { |
| 114 m.machine()->Word64And(), m.machine()->Word64Or(), |
| 115 m.machine()->Word64Xor(), m.machine()->Word64Shl(), |
| 116 m.machine()->Word64Shr(), m.machine()->Word64Sar(), |
| 117 m.machine()->Word64Equal(), m.machine()->Int64Add(), |
| 118 m.machine()->Int64Sub(), m.machine()->Int64Mul(), m.machine()->Int64Div(), |
| 119 m.machine()->Uint64Div(), m.machine()->Int64Mod(), |
| 120 m.machine()->Uint64Mod(), m.machine()->Int64LessThan(), |
| 121 m.machine()->Int64LessThanOrEqual(), m.machine()->Uint64LessThan(), |
| 122 m.machine()->Uint64LessThanOrEqual()}; |
| 123 |
| 124 for (size_t i = 0; i < arraysize(kOps); ++i) { |
| 125 for (int j = 0; j < 8; j++) { |
| 126 for (int k = 0; k < 8; k++) { |
| 127 RawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64); |
| 128 Node* a = Int64Input(&m, j); |
| 129 Node* b = Int64Input(&m, k); |
| 130 m.Return(m.NewNode(kOps[i], a, b)); |
| 131 m.GenerateCode(); |
| 132 } |
| 133 } |
| 134 } |
| 135 } |
| 136 |
| 137 |
| 138 // TODO(titzer): add tests that run 64-bit integer operations. |
| 139 #endif // V8_TURBOFAN_BACKEND_64 |
| 140 |
| 141 |
85 TEST(RunGoto) { | 142 TEST(RunGoto) { |
86 RawMachineAssemblerTester<int32_t> m; | 143 RawMachineAssemblerTester<int32_t> m; |
87 int constant = 99999; | 144 int constant = 99999; |
88 | 145 |
89 MLabel next; | 146 MLabel next; |
90 m.Goto(&next); | 147 m.Goto(&next); |
91 m.Bind(&next); | 148 m.Bind(&next); |
92 m.Return(m.Int32Constant(constant)); | 149 m.Return(m.Int32Constant(constant)); |
93 | 150 |
94 CHECK_EQ(constant, m.Call()); | 151 CHECK_EQ(constant, m.Call()); |
(...skipping 5116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5211 param, param, param, param)); | 5268 param, param, param, param)); |
5212 FOR_INT32_INPUTS(i) { | 5269 FOR_INT32_INPUTS(i) { |
5213 int32_t const x = *i; | 5270 int32_t const x = *i; |
5214 CHECK_EQ(x * 8, m.Call(x)); | 5271 CHECK_EQ(x * 8, m.Call(x)); |
5215 } | 5272 } |
5216 } | 5273 } |
5217 | 5274 |
5218 #endif // USE_SIMULATOR | 5275 #endif // USE_SIMULATOR |
5219 | 5276 |
5220 #endif // V8_TURBOFAN_TARGET | 5277 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |