| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    68   TestWord32Ctz(0x27a9db40, 6); |    68   TestWord32Ctz(0x27a9db40, 6); | 
|    69   TestWord32Ctz(0xde3bcb20, 5); |    69   TestWord32Ctz(0xde3bcb20, 5); | 
|    70   TestWord32Ctz(0xd7e8a610, 4); |    70   TestWord32Ctz(0xd7e8a610, 4); | 
|    71   TestWord32Ctz(0x9afdbc88, 3); |    71   TestWord32Ctz(0x9afdbc88, 3); | 
|    72   TestWord32Ctz(0x9afdbc84, 2); |    72   TestWord32Ctz(0x9afdbc84, 2); | 
|    73   TestWord32Ctz(0x9afdbc82, 1); |    73   TestWord32Ctz(0x9afdbc82, 1); | 
|    74   TestWord32Ctz(0x9afdbc81, 0); |    74   TestWord32Ctz(0x9afdbc81, 0); | 
|    75 } |    75 } | 
|    76  |    76  | 
|    77  |    77  | 
 |    78 void TestWord32Clz(int32_t value, int32_t expected) { | 
 |    79   RawMachineAssemblerTester<int32_t> m; | 
 |    80   Node* clz = m.Word32Clz(m.Int32Constant(value)); | 
 |    81   m.Return(clz); | 
 |    82   CHECK_EQ(expected, m.Call()); | 
 |    83 } | 
 |    84  | 
 |    85  | 
 |    86 TEST(RunInt32Clz) { | 
 |    87   TestWord32Clz(0x80001000, 0); | 
 |    88   TestWord32Clz(0x40000500, 1); | 
 |    89   TestWord32Clz(0x20000300, 2); | 
 |    90   TestWord32Clz(0x10000003, 3); | 
 |    91   TestWord32Clz(0x08050000, 4); | 
 |    92   TestWord32Clz(0x04006000, 5); | 
 |    93   TestWord32Clz(0x02000000, 6); | 
 |    94   TestWord32Clz(0x010000a0, 7); | 
 |    95   TestWord32Clz(0x00800c00, 8); | 
 |    96   TestWord32Clz(0x00400000, 9); | 
 |    97   TestWord32Clz(0x0020000d, 10); | 
 |    98   TestWord32Clz(0x00100f00, 11); | 
 |    99   TestWord32Clz(0x00080000, 12); | 
 |   100   TestWord32Clz(0x00041000, 13); | 
 |   101   TestWord32Clz(0x00020020, 14); | 
 |   102   TestWord32Clz(0x00010300, 15); | 
 |   103   TestWord32Clz(0x00008040, 16); | 
 |   104   TestWord32Clz(0x00004005, 17); | 
 |   105   TestWord32Clz(0x00002050, 18); | 
 |   106   TestWord32Clz(0x00001700, 19); | 
 |   107   TestWord32Clz(0x00000870, 20); | 
 |   108   TestWord32Clz(0x00000405, 21); | 
 |   109   TestWord32Clz(0x00000203, 22); | 
 |   110   TestWord32Clz(0x00000101, 23); | 
 |   111   TestWord32Clz(0x00000089, 24); | 
 |   112   TestWord32Clz(0x00000041, 25); | 
 |   113   TestWord32Clz(0x00000022, 26); | 
 |   114   TestWord32Clz(0x00000013, 27); | 
 |   115   TestWord32Clz(0x00000008, 28); | 
 |   116   TestWord32Clz(0x00000004, 29); | 
 |   117   TestWord32Clz(0x00000002, 30); | 
 |   118   TestWord32Clz(0x00000001, 31); | 
 |   119   TestWord32Clz(0x00000000, 32); | 
 |   120 } | 
 |   121  | 
 |   122  | 
|    78 static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { |   123 static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { | 
|    79   switch (index) { |   124   switch (index) { | 
|    80     case 0: |   125     case 0: | 
|    81       return m->Parameter(0); |   126       return m->Parameter(0); | 
|    82     case 1: |   127     case 1: | 
|    83       return m->Parameter(1); |   128       return m->Parameter(1); | 
|    84     case 2: |   129     case 2: | 
|    85       return m->Int32Constant(0); |   130       return m->Int32Constant(0); | 
|    86     case 3: |   131     case 3: | 
|    87       return m->Int32Constant(1); |   132       return m->Int32Constant(1); | 
| (...skipping 5389 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5477       c->CalleeSavedRegisters(),                         // callee saved |  5522       c->CalleeSavedRegisters(),                         // callee saved | 
|  5478       c->CalleeSavedFPRegisters(),                       // callee saved FP |  5523       c->CalleeSavedFPRegisters(),                       // callee saved FP | 
|  5479       CallDescriptor::kNoFlags,                          // flags |  5524       CallDescriptor::kNoFlags,                          // flags | 
|  5480       "c-call-as-code"); |  5525       "c-call-as-code"); | 
|  5481   Node* call = r.AddNode(r.common()->Call(desc), phi); |  5526   Node* call = r.AddNode(r.common()->Call(desc), phi); | 
|  5482   r.Return(call); |  5527   r.Return(call); | 
|  5483  |  5528  | 
|  5484   CHECK_EQ(33, r.Call(1)); |  5529   CHECK_EQ(33, r.Call(1)); | 
|  5485   CHECK_EQ(44, r.Call(0)); |  5530   CHECK_EQ(44, r.Call(0)); | 
|  5486 } |  5531 } | 
| OLD | NEW |