| OLD | NEW |
| 1 //===- subzero/crosstest/test_calling_conv_main.cpp - Driver for tests ----===// | 1 //===- subzero/crosstest/test_calling_conv_main.cpp - Driver for tests ----===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file contains the driver for cross testing the compatibility of | 10 // This file contains the driver for cross testing the compatibility of |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // llc, pass arguments to the callee in the same way. The Caller() and | 38 // llc, pass arguments to the callee in the same way. The Caller() and |
| 39 // Subzero_Caller() functions both call the same callee (which has been | 39 // Subzero_Caller() functions both call the same callee (which has been |
| 40 // compiled by llc). The result in the global buffer is compared to | 40 // compiled by llc). The result in the global buffer is compared to |
| 41 // check that it is the same value after the calls by both callers. | 41 // check that it is the same value after the calls by both callers. |
| 42 // | 42 // |
| 43 // testCallee() runs the same kind of test, except that the functions | 43 // testCallee() runs the same kind of test, except that the functions |
| 44 // Callee() and Subzero_Callee() are being tested to ensure that both | 44 // Callee() and Subzero_Callee() are being tested to ensure that both |
| 45 // functions receive arguments from the caller in the same way. The | 45 // functions receive arguments from the caller in the same way. The |
| 46 // caller is compiled by llc. | 46 // caller is compiled by llc. |
| 47 | 47 |
| 48 size_t ArgNum, Subzero_ArgNum; | 48 size_t ArgNum; |
| 49 CalleePtrTy Callee, Subzero_Callee; | 49 CalleePtrTy Callee; |
| 50 char *Buf, *Subzero_Buf; | 50 char *Buf; |
| 51 | 51 |
| 52 const static size_t BUF_SIZE = 16; | 52 const static size_t BUF_SIZE = 16; |
| 53 | 53 |
| 54 std::string bufAsString(const char Buf[BUF_SIZE]) { | 54 std::string bufAsString(const char Buf[BUF_SIZE]) { |
| 55 std::ostringstream OS; | 55 std::ostringstream OS; |
| 56 for (size_t i = 0; i < BUF_SIZE; ++i) { | 56 for (size_t i = 0; i < BUF_SIZE; ++i) { |
| 57 if (i > 0) | 57 if (i > 0) |
| 58 OS << " "; | 58 OS << " "; |
| 59 OS << (unsigned) Buf[i]; | 59 OS << (unsigned) Buf[i]; |
| 60 } | 60 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 } \ | 76 } \ |
| 77 , | 77 , |
| 78 TEST_FUNC_TABLE | 78 TEST_FUNC_TABLE |
| 79 #undef X | 79 #undef X |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 82 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
| 83 | 83 |
| 84 for (size_t f = 0; f < NumFuncs; ++f) { | 84 for (size_t f = 0; f < NumFuncs; ++f) { |
| 85 char BufLlc[BUF_SIZE], BufSz[BUF_SIZE]; | 85 char BufLlc[BUF_SIZE], BufSz[BUF_SIZE]; |
| 86 Callee = Subzero_Callee = Funcs[f].Callee; | 86 Callee = Funcs[f].Callee; |
| 87 | 87 |
| 88 for (size_t i = 0; i < Funcs[f].Args; ++i) { | 88 for (size_t i = 0; i < Funcs[f].Args; ++i) { |
| 89 memset(BufLlc, 0xff, sizeof(BufLlc)); | 89 memset(BufLlc, 0xff, sizeof(BufLlc)); |
| 90 memset(BufSz, 0xff, sizeof(BufSz)); | 90 memset(BufSz, 0xff, sizeof(BufSz)); |
| 91 | 91 |
| 92 ArgNum = Subzero_ArgNum = i; | 92 ArgNum = i; |
| 93 | 93 |
| 94 Buf = BufLlc; | 94 Buf = BufLlc; |
| 95 Funcs[f].Caller(); | 95 Funcs[f].Caller(); |
| 96 | 96 |
| 97 Buf = BufSz; | 97 Buf = BufSz; |
| 98 Funcs[f].Subzero_Caller(); | 98 Funcs[f].Subzero_Caller(); |
| 99 | 99 |
| 100 ++TotalTests; | 100 ++TotalTests; |
| 101 if (!memcmp(BufLlc, BufSz, sizeof(BufLlc))) { | 101 if (!memcmp(BufLlc, BufSz, sizeof(BufLlc))) { |
| 102 ++Passes; | 102 ++Passes; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 126 } \ | 126 } \ |
| 127 , | 127 , |
| 128 TEST_FUNC_TABLE | 128 TEST_FUNC_TABLE |
| 129 #undef X | 129 #undef X |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 132 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
| 133 | 133 |
| 134 for (size_t f = 0; f < NumFuncs; ++f) { | 134 for (size_t f = 0; f < NumFuncs; ++f) { |
| 135 char BufLlc[BUF_SIZE], BufSz[BUF_SIZE]; | 135 char BufLlc[BUF_SIZE], BufSz[BUF_SIZE]; |
| 136 Buf = BufLlc; | |
| 137 Subzero_Buf = BufSz; | |
| 138 | 136 |
| 139 for (size_t i = 0; i < Funcs[f].Args; ++i) { | 137 for (size_t i = 0; i < Funcs[f].Args; ++i) { |
| 140 memset(BufLlc, 0xff, sizeof(BufLlc)); | 138 memset(BufLlc, 0xff, sizeof(BufLlc)); |
| 141 memset(BufSz, 0xff, sizeof(BufSz)); | 139 memset(BufSz, 0xff, sizeof(BufSz)); |
| 142 | 140 |
| 143 ArgNum = Subzero_ArgNum = i; | 141 ArgNum = i; |
| 144 | 142 |
| 143 Buf = BufLlc; |
| 145 Callee = Funcs[f].Callee; | 144 Callee = Funcs[f].Callee; |
| 146 Funcs[f].Caller(); | 145 Funcs[f].Caller(); |
| 147 | 146 |
| 147 Buf = BufSz; |
| 148 Callee = Funcs[f].Subzero_Callee; | 148 Callee = Funcs[f].Subzero_Callee; |
| 149 Funcs[f].Caller(); | 149 Funcs[f].Caller(); |
| 150 | 150 |
| 151 ++TotalTests; | 151 ++TotalTests; |
| 152 if (!memcmp(BufLlc, BufSz, sizeof(BufLlc))) { | 152 if (!memcmp(BufLlc, BufSz, sizeof(BufLlc))) { |
| 153 ++Passes; | 153 ++Passes; |
| 154 } else { | 154 } else { |
| 155 ++Failures; | 155 ++Failures; |
| 156 std::cout << "testCallee(Caller=" << Funcs[f].CallerName | 156 std::cout << "testCallee(Caller=" << Funcs[f].CallerName |
| 157 << ", Callee=" << Funcs[f].CalleeName << ", ArgNum=" << ArgNum | 157 << ", Callee=" << Funcs[f].CalleeName << ", ArgNum=" << ArgNum |
| (...skipping 10 matching lines...) Expand all Loading... |
| 168 size_t Failures = 0; | 168 size_t Failures = 0; |
| 169 | 169 |
| 170 testCaller(TotalTests, Passes, Failures); | 170 testCaller(TotalTests, Passes, Failures); |
| 171 testCallee(TotalTests, Passes, Failures); | 171 testCallee(TotalTests, Passes, Failures); |
| 172 | 172 |
| 173 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 173 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
| 174 << " Failures=" << Failures << "\n"; | 174 << " Failures=" << Failures << "\n"; |
| 175 | 175 |
| 176 return Failures; | 176 return Failures; |
| 177 } | 177 } |
| OLD | NEW |