OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // 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/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 CHECK_EQ(uint32_t(0x00000000), m.Call(uint32_t(0x00000000))); | 74 CHECK_EQ(uint32_t(0x00000000), m.Call(uint32_t(0x00000000))); |
75 CHECK_EQ(uint32_t(0x12345678), m.Call(uint32_t(0x1e6a2c48))); | 75 CHECK_EQ(uint32_t(0x12345678), m.Call(uint32_t(0x1e6a2c48))); |
76 CHECK_EQ(uint32_t(0xfedcba09), m.Call(uint32_t(0x905d3b7f))); | 76 CHECK_EQ(uint32_t(0xfedcba09), m.Call(uint32_t(0x905d3b7f))); |
77 CHECK_EQ(uint32_t(0x01010101), m.Call(uint32_t(0x80808080))); | 77 CHECK_EQ(uint32_t(0x01010101), m.Call(uint32_t(0x80808080))); |
78 CHECK_EQ(uint32_t(0x01020408), m.Call(uint32_t(0x10204080))); | 78 CHECK_EQ(uint32_t(0x01020408), m.Call(uint32_t(0x10204080))); |
79 CHECK_EQ(uint32_t(0xf0703010), m.Call(uint32_t(0x080c0e0f))); | 79 CHECK_EQ(uint32_t(0xf0703010), m.Call(uint32_t(0x080c0e0f))); |
80 CHECK_EQ(uint32_t(0x1f8d0a3a), m.Call(uint32_t(0x5c50b1f8))); | 80 CHECK_EQ(uint32_t(0x1f8d0a3a), m.Call(uint32_t(0x5c50b1f8))); |
81 CHECK_EQ(uint32_t(0xffffffff), m.Call(uint32_t(0xffffffff))); | 81 CHECK_EQ(uint32_t(0xffffffff), m.Call(uint32_t(0xffffffff))); |
82 } | 82 } |
83 | 83 |
| 84 TEST(RunWord32ReverseBytes) { |
| 85 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); |
| 86 if (!m.machine()->Word32ReverseBytes().IsSupported()) { |
| 87 // We can only test the operator if it exists on the testing platform. |
| 88 return; |
| 89 } |
| 90 m.Return(m.AddNode(m.machine()->Word32ReverseBytes().op(), m.Parameter(0))); |
| 91 |
| 92 CHECK_EQ(uint32_t(0x00000000), m.Call(uint32_t(0x00000000))); |
| 93 CHECK_EQ(uint32_t(0x12345678), m.Call(uint32_t(0x78563412))); |
| 94 CHECK_EQ(uint32_t(0xfedcba09), m.Call(uint32_t(0x09badcfe))); |
| 95 CHECK_EQ(uint32_t(0x01010101), m.Call(uint32_t(0x01010101))); |
| 96 CHECK_EQ(uint32_t(0x01020408), m.Call(uint32_t(0x08040201))); |
| 97 CHECK_EQ(uint32_t(0xf0703010), m.Call(uint32_t(0x103070f0))); |
| 98 CHECK_EQ(uint32_t(0x1f8d0a3a), m.Call(uint32_t(0x3a0a8d1f))); |
| 99 CHECK_EQ(uint32_t(0xffffffff), m.Call(uint32_t(0xffffffff))); |
| 100 } |
84 | 101 |
85 TEST(RunWord32Ctz) { | 102 TEST(RunWord32Ctz) { |
86 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); | 103 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); |
87 if (!m.machine()->Word32Ctz().IsSupported()) { | 104 if (!m.machine()->Word32Ctz().IsSupported()) { |
88 // We can only test the operator if it exists on the testing platform. | 105 // We can only test the operator if it exists on the testing platform. |
89 return; | 106 return; |
90 } | 107 } |
91 m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0))); | 108 m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0))); |
92 | 109 |
93 CHECK_EQ(32, m.Call(uint32_t(0x00000000))); | 110 CHECK_EQ(32, m.Call(uint32_t(0x00000000))); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 CHECK_EQ(uint64_t(0x0000000000000000), m.Call(uint64_t(0x0000000000000000))); | 213 CHECK_EQ(uint64_t(0x0000000000000000), m.Call(uint64_t(0x0000000000000000))); |
197 CHECK_EQ(uint64_t(0x1234567890abcdef), m.Call(uint64_t(0xf7b3d5091e6a2c48))); | 214 CHECK_EQ(uint64_t(0x1234567890abcdef), m.Call(uint64_t(0xf7b3d5091e6a2c48))); |
198 CHECK_EQ(uint64_t(0xfedcba0987654321), m.Call(uint64_t(0x84c2a6e1905d3b7f))); | 215 CHECK_EQ(uint64_t(0xfedcba0987654321), m.Call(uint64_t(0x84c2a6e1905d3b7f))); |
199 CHECK_EQ(uint64_t(0x0101010101010101), m.Call(uint64_t(0x8080808080808080))); | 216 CHECK_EQ(uint64_t(0x0101010101010101), m.Call(uint64_t(0x8080808080808080))); |
200 CHECK_EQ(uint64_t(0x0102040803060c01), m.Call(uint64_t(0x803060c010204080))); | 217 CHECK_EQ(uint64_t(0x0102040803060c01), m.Call(uint64_t(0x803060c010204080))); |
201 CHECK_EQ(uint64_t(0xf0703010e060200f), m.Call(uint64_t(0xf0040607080c0e0f))); | 218 CHECK_EQ(uint64_t(0xf0703010e060200f), m.Call(uint64_t(0xf0040607080c0e0f))); |
202 CHECK_EQ(uint64_t(0x2f8a6df01c21fa3b), m.Call(uint64_t(0xdc5f84380fb651f4))); | 219 CHECK_EQ(uint64_t(0x2f8a6df01c21fa3b), m.Call(uint64_t(0xdc5f84380fb651f4))); |
203 CHECK_EQ(uint64_t(0xffffffffffffffff), m.Call(uint64_t(0xffffffffffffffff))); | 220 CHECK_EQ(uint64_t(0xffffffffffffffff), m.Call(uint64_t(0xffffffffffffffff))); |
204 } | 221 } |
205 | 222 |
| 223 TEST(RunWord64ReverseBytes) { |
| 224 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Uint64()); |
| 225 if (!m.machine()->Word64ReverseBytes().IsSupported()) { |
| 226 return; |
| 227 } |
| 228 |
| 229 m.Return(m.AddNode(m.machine()->Word64ReverseBytes().op(), m.Parameter(0))); |
| 230 |
| 231 CHECK_EQ(uint64_t(0x0000000000000000), m.Call(uint64_t(0x0000000000000000))); |
| 232 CHECK_EQ(uint64_t(0x1234567890abcdef), m.Call(uint64_t(0xefcdab9078563412))); |
| 233 CHECK_EQ(uint64_t(0xfedcba0987654321), m.Call(uint64_t(0x2143658709badcfe))); |
| 234 CHECK_EQ(uint64_t(0x0101010101010101), m.Call(uint64_t(0x0101010101010101))); |
| 235 CHECK_EQ(uint64_t(0x0102040803060c01), m.Call(uint64_t(0x010c060308040201))); |
| 236 CHECK_EQ(uint64_t(0xf0703010e060200f), m.Call(uint64_t(0x0f2060e0103070f0))); |
| 237 CHECK_EQ(uint64_t(0x2f8a6df01c21fa3b), m.Call(uint64_t(0x3bfa211cf06d8a2f))); |
| 238 CHECK_EQ(uint64_t(0xffffffffffffffff), m.Call(uint64_t(0xffffffffffffffff))); |
| 239 } |
206 | 240 |
207 TEST(RunWord64Clz) { | 241 TEST(RunWord64Clz) { |
208 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64()); | 242 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64()); |
209 m.Return(m.Word64Clz(m.Parameter(0))); | 243 m.Return(m.Word64Clz(m.Parameter(0))); |
210 | 244 |
211 CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); | 245 CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); |
212 CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000))); | 246 CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000))); |
213 CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000))); | 247 CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000))); |
214 CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000))); | 248 CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000))); |
215 CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000))); | 249 CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000))); |
(...skipping 6317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6533 r.Goto(&merge); | 6567 r.Goto(&merge); |
6534 r.Bind(&merge); | 6568 r.Bind(&merge); |
6535 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6569 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6536 r.Return(phi); | 6570 r.Return(phi); |
6537 CHECK_EQ(1, r.Call(1)); | 6571 CHECK_EQ(1, r.Call(1)); |
6538 } | 6572 } |
6539 | 6573 |
6540 } // namespace compiler | 6574 } // namespace compiler |
6541 } // namespace internal | 6575 } // namespace internal |
6542 } // namespace v8 | 6576 } // namespace v8 |
OLD | NEW |