Commit ca8a16ef by Antonio Maiorano

Subzero: clang-format crosstest, pnacl-llvm, runtime, and unittest

Formatted using: find ${DIR} -iname "*.cc" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file Bug: b/144825072 Change-Id: Ie6ebd83f85dc11a044dec4514a1e81edbbd4ed21 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50169Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent debdfa2a
......@@ -3,9 +3,9 @@
* (fixed length buffers, variable length buffers, etc.)
*/
#include <stdint.h> /* cstdint requires -std=c++0x or higher */
#include <cstdlib>
#include <cstring>
#include <stdint.h> /* cstdint requires -std=c++0x or higher */
#include "mem_intrin.h"
#include "xdefs.h"
......
/* crosstest.py --test=mem_intrin.cpp --driver=mem_intrin_main.cpp \
--prefix=Subzero_ --output=mem_intrin */
#include <stdint.h> /* cstdint requires -std=c++0x or higher */
#include <cstdio>
#include <stdint.h> /* cstdint requires -std=c++0x or higher */
#include "mem_intrin.h"
#include "xdefs.h"
......
......@@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include "test_arith.def"
#include "xdefs.h"
#include <stdint.h>
#include "vectors.h"
......
......@@ -17,12 +17,12 @@
#include <stdint.h>
#include <climits> // CHAR_BIT
#include <limits>
#include <cfloat>
#include <climits> // CHAR_BIT
#include <cmath> // fmodf
#include <cstring> // memcmp
#include <iostream>
#include <limits>
// Include test_arith.h twice - once normally, and once within the
// Subzero_ namespace, corresponding to the llc and Subzero translated
......@@ -66,22 +66,26 @@ void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
bool ExcludeDivExceptions; // for divide related tests
} Funcs[] = {
#define X(inst, op, isdiv, isshift) \
{ STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \
,
{STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv},
UINTOP_TABLE
#undef X
#define X(inst, op, isdiv, isshift) \
{ STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \
,
{STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv},
SINTOP_TABLE
#undef X
#define X(mult_by) \
{ \
"Mult-By-" STR(mult_by), testMultiplyBy##mult_by, \
Subzero_::testMultiplyBy##mult_by, NULL, NULL, false \
} \
, {"Mult-By-Neg-" STR(mult_by), testMultiplyByNeg##mult_by, \
Subzero_::testMultiplyByNeg##mult_by, NULL, NULL, false},
{"Mult-By-" STR(mult_by), \
testMultiplyBy##mult_by, \
Subzero_::testMultiplyBy##mult_by, \
NULL, \
NULL, \
false}, \
{"Mult-By-Neg-" STR(mult_by), \
testMultiplyByNeg##mult_by, \
Subzero_::testMultiplyByNeg##mult_by, \
NULL, \
NULL, \
false},
MULIMM_TABLE};
#undef X
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
......@@ -187,13 +191,11 @@ void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
bool MaskShiftOperations; // for shift related tests
} Funcs[] = {
#define X(inst, op, isdiv, isshift) \
{ STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, isshift } \
,
{STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, isshift},
UINTOP_TABLE
#undef X
#define X(inst, op, isdiv, isshift) \
{ STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, isshift } \
,
{STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, isshift},
SINTOP_TABLE
#undef X
};
......@@ -256,8 +258,7 @@ void testsFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncType FuncSz;
} Funcs[] = {
#define X(inst, op, func) \
{ STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \
,
{STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst},
FPOP_TABLE
#undef X
};
......@@ -327,8 +328,7 @@ void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncType FuncSz;
} Funcs[] = {
#define X(inst, op, func) \
{ STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \
,
{STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst},
FPOP_TABLE
#undef X
};
......
......@@ -29,19 +29,56 @@ namespace Subzero_ {
#include "test_bitmanip.h"
}
volatile uint64 Values[] = {
0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 0x8000, 0x8001,
0xfffe, 0xffff, 0xc0de, 0xabcd, 0xdcba, 0x007fffff /*Max subnormal + */,
0x00800000 /*Min+ */, 0x7f7fffff /*Max+ */, 0x7f800000 /*+Inf*/,
0xff800000 /*-Inf*/, 0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/, 0x7ffffffe,
0x7fffffff, 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, 0x12345678,
0xabcd1234, 0x1234dcba, 0x100000000ll, 0x100000001ll, 0x123456789abcdef1ll,
0x987654321ab1fedcll, 0x000fffffffffffffll /*Max subnormal + */,
0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */,
0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/,
0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/,
0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll,
0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll};
volatile uint64 Values[] = {0,
1,
0x7e,
0x7f,
0x80,
0x81,
0xfe,
0xff,
0x7ffe,
0x7fff,
0x8000,
0x8001,
0xfffe,
0xffff,
0xc0de,
0xabcd,
0xdcba,
0x007fffff /*Max subnormal + */,
0x00800000 /*Min+ */,
0x7f7fffff /*Max+ */,
0x7f800000 /*+Inf*/,
0xff800000 /*-Inf*/,
0x7fa00000 /*SNaN*/,
0x7fc00000 /*QNaN*/,
0x7ffffffe,
0x7fffffff,
0x80000000,
0x80000001,
0xfffffffe,
0xffffffff,
0x12345678,
0xabcd1234,
0x1234dcba,
0x100000000ll,
0x100000001ll,
0x123456789abcdef1ll,
0x987654321ab1fedcll,
0x000fffffffffffffll /*Max subnormal + */,
0x0010000000000000ll /*Min+ */,
0x7fefffffffffffffll /*Max+ */,
0x7ff0000000000000ll /*+Inf*/,
0xfff0000000000000ll /*-Inf*/,
0x7ff0000000000001ll /*SNaN*/,
0x7ff8000000000000ll /*QNaN*/,
0x7ffffffffffffffell,
0x7fffffffffffffffll,
0x8000000000000000ll,
0x8000000000000001ll,
0xfffffffffffffffell,
0xffffffffffffffffll};
const static size_t NumValues = sizeof(Values) / sizeof(*Values);
......@@ -54,8 +91,8 @@ void testBitManip(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncType FuncSz;
} Funcs[] = {
#define X(inst) \
{ STR(inst), test_##inst, Subzero_::test_##inst } \
, {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \
{STR(inst), test_##inst, Subzero_::test_##inst}, \
{STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \
{STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst},
BMI_OPS
#undef X
......
......@@ -50,9 +50,8 @@ void caller_vlvilvfvdviv(void) {
int arg11 = 26;
v4f32 arg12 = {27, 28, 29, 30};
CALL_AS_TYPE(callee_vlvilvfvdviv_Ty, Callee)(arg1, arg2, arg3, arg4, arg5,
arg6, arg7, arg8, arg9, arg10,
arg11, arg12);
CALL_AS_TYPE(callee_vlvilvfvdviv_Ty, Callee)
(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
}
#define HANDLE_ARG(ARGNUM) \
......
......@@ -72,19 +72,21 @@ void testCaller(size_t &TotalTests, size_t &Passes, size_t &Failures) {
#ifdef MIPS32
#define X(caller, callee, argc) \
{ \
STR(caller), STR(callee), argc, &caller, &Subzero_::caller, \
reinterpret_cast<CalleePtrTy>(&Subzero_::callee), \
} \
,
STR(caller), \
STR(callee), \
argc, \
&caller, \
&Subzero_::caller, \
reinterpret_cast<CalleePtrTy>(&Subzero_::callee), \
},
TEST_FUNC_TABLE
#undef X
#else
#define X(caller, callee, argc) \
{ \
STR(caller), STR(callee), argc, &caller, &Subzero_::caller, \
reinterpret_cast<CalleePtrTy>(&callee), \
} \
,
STR(caller), STR(callee), argc, \
&caller, &Subzero_::caller, reinterpret_cast<CalleePtrTy>(&callee), \
},
TEST_FUNC_TABLE
#undef X
#endif
......@@ -130,12 +132,12 @@ void testCallee(size_t &TotalTests, size_t &Passes, size_t &Failures) {
CalleePtrTy Callee, Subzero_Callee;
} Funcs[] = {
#define X(caller, callee, argc) \
{ \
STR(caller), STR(callee), argc, &caller, \
reinterpret_cast<CalleePtrTy>(&callee), \
reinterpret_cast<CalleePtrTy>(&Subzero_::callee) \
} \
,
{STR(caller), \
STR(callee), \
argc, \
&caller, \
reinterpret_cast<CalleePtrTy>(&callee), \
reinterpret_cast<CalleePtrTy>(&Subzero_::callee)},
TEST_FUNC_TABLE
#undef X
};
......
......@@ -14,9 +14,9 @@
// This aims to test all the conversion bitcode instructions across
// all PNaCl primitive data types.
#include <stdint.h>
#include "test_cast.h"
#include "xdefs.h"
#include <stdint.h>
template <typename FromType, typename ToType>
ToType __attribute__((noinline)) cast(FromType a) {
......
......@@ -179,20 +179,64 @@ int main(int argc, char *argv[]) {
0x80000000, 0x80000001, 0xfffffffe, 0xffffffff};
static const size_t NumValsSi32 = sizeof(ValsSi32) / sizeof(*ValsSi32);
volatile uint64 ValsUi64[] = {
0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 0x8000, 0x8001,
0xfffe, 0xffff, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001,
0xfffffffe, 0xffffffff, 0x100000000ull, 0x100000001ull,
0x7ffffffffffffffeull, 0x7fffffffffffffffull, 0x8000000000000000ull,
0x8000000000000001ull, 0xfffffffffffffffeull, 0xffffffffffffffffull};
volatile uint64 ValsUi64[] = {0,
1,
0x7e,
0x7f,
0x80,
0x81,
0xfe,
0xff,
0x7ffe,
0x7fff,
0x8000,
0x8001,
0xfffe,
0xffff,
0x7ffffffe,
0x7fffffff,
0x80000000,
0x80000001,
0xfffffffe,
0xffffffff,
0x100000000ull,
0x100000001ull,
0x7ffffffffffffffeull,
0x7fffffffffffffffull,
0x8000000000000000ull,
0x8000000000000001ull,
0xfffffffffffffffeull,
0xffffffffffffffffull};
static const size_t NumValsUi64 = sizeof(ValsUi64) / sizeof(*ValsUi64);
volatile int64 ValsSi64[] = {
0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 0x8000, 0x8001,
0xfffe, 0xffff, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001,
0xfffffffe, 0xffffffff, 0x100000000ll, 0x100000001ll,
0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll,
0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll};
volatile int64 ValsSi64[] = {0,
1,
0x7e,
0x7f,
0x80,
0x81,
0xfe,
0xff,
0x7ffe,
0x7fff,
0x8000,
0x8001,
0xfffe,
0xffff,
0x7ffffffe,
0x7fffffff,
0x80000000,
0x80000001,
0xfffffffe,
0xffffffff,
0x100000000ll,
0x100000001ll,
0x7ffffffffffffffell,
0x7fffffffffffffffll,
0x8000000000000000ll,
0x8000000000000001ll,
0xfffffffffffffffell,
0xffffffffffffffffll};
static const size_t NumValsSi64 = sizeof(ValsSi64) / sizeof(*ValsSi64);
static const double NegInf = -1.0 / 0.0;
......
......@@ -20,9 +20,9 @@
#include <cstring>
#include <iostream>
#include "vectors.h"
#include "test_arith.def"
#include "test_fcmp.def"
#include "vectors.h"
#define X(cmp) \
extern "C" bool fcmp##cmp##Float(float a, float b); \
......@@ -79,13 +79,11 @@ void testsScalar(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncTypeDoubleSelect FuncDoubleSelectLlc;
} Funcs[] = {
#define X(cmp) \
{ \
"fcmp" STR(cmp), Subzero_fcmp##cmp##Float, fcmp##cmp##Float, \
Subzero_fcmp##cmp##Double, fcmp##cmp##Double, \
Subzero_fcmpSelect##cmp##Float, fcmpSelect##cmp##Float, \
Subzero_fcmpSelect##cmp##Double, fcmpSelect##cmp##Double \
} \
,
{"fcmp" STR(cmp), Subzero_fcmp##cmp##Float, \
fcmp##cmp##Float, Subzero_fcmp##cmp##Double, \
fcmp##cmp##Double, Subzero_fcmpSelect##cmp##Float, \
fcmpSelect##cmp##Float, Subzero_fcmpSelect##cmp##Double, \
fcmpSelect##cmp##Double},
FCMP_TABLE
#undef X
};
......@@ -164,9 +162,7 @@ void testsVector(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncTypeVector FuncVectorSz;
FuncTypeVector FuncVectorLlc;
} Funcs[] = {
#define X(cmp) \
{ "fcmp" STR(cmp), Subzero_fcmp##cmp##Vector, fcmp##cmp##Vector } \
,
#define X(cmp) {"fcmp" STR(cmp), Subzero_fcmp##cmp##Vector, fcmp##cmp##Vector},
FCMP_TABLE
#undef X
};
......
......@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <cstdlib>
#include <stdint.h>
#include "test_global.h"
......
......@@ -14,9 +14,9 @@
/* crosstest.py --test=test_global.cpp \
--driver=test_global_main.cpp --prefix=Subzero_ --output=test_global */
#include <stdint.h>
#include <cstdlib>
#include <iostream>
#include <stdint.h>
#include "test_global.h"
namespace Subzero_ {
......
......@@ -16,8 +16,8 @@
#include <climits> // CHAR_BIT
#include <cstring> // memcmp, memset
#include <stdint.h>
#include <iostream>
#include <stdint.h>
// Include test_icmp.h twice - once normally, and once within the
// Subzero_ namespace, corresponding to the llc and Subzero translated
......@@ -49,19 +49,13 @@ void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncTypeUnsigned FuncSz;
} Funcs[] = {
#define X(cmp, op) \
{ \
STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
(FuncTypeUnsigned)Subzero_::icmp##cmp \
} \
,
{STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
(FuncTypeUnsigned)Subzero_::icmp##cmp},
ICMP_U_TABLE
#undef X
#define X(cmp, op) \
{ \
STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \
(FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp \
} \
,
{STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \
(FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp},
ICMP_S_TABLE
#undef X
};
......@@ -132,19 +126,13 @@ void testsIntWithZero(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncTypeUnsigned FuncSz;
} Funcs[] = {
#define X(cmp, op) \
{ \
STR(cmp), (FuncTypeUnsigned)icmp_zero##cmp, \
(FuncTypeUnsigned)Subzero_::icmp_zero##cmp \
} \
,
{STR(cmp), (FuncTypeUnsigned)icmp_zero##cmp, \
(FuncTypeUnsigned)Subzero_::icmp_zero##cmp},
ICMP_U_TABLE
#undef X
#define X(cmp, op) \
{ \
STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp_zero##cmp, \
(FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp_zero##cmp \
} \
,
{STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp_zero##cmp, \
(FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp_zero##cmp},
ICMP_S_TABLE
#undef X
};
......@@ -210,19 +198,13 @@ void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncTypeUnsigned FuncSz;
} Funcs[] = {
#define X(cmp, op) \
{ \
STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
(FuncTypeUnsigned)Subzero_::icmp##cmp \
} \
,
{STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
(FuncTypeUnsigned)Subzero_::icmp##cmp},
ICMP_U_TABLE
#undef X
#define X(cmp, op) \
{ \
STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \
(FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp \
} \
,
{STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \
(FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp},
ICMP_S_TABLE
#undef X
};
......@@ -283,8 +265,7 @@ void testsVecI1(size_t &TotalTests, size_t &Passes, size_t &Failures) {
FuncType FuncSz;
} Funcs[] = {
#define X(cmp, op) \
{ STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \
,
{STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp},
ICMP_U_TABLE ICMP_S_TABLE};
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
const static size_t NumElements = Vectors<T>::NumElements;
......
......@@ -33,18 +33,48 @@ namespace Subzero_ {
#include "test_sync_atomic.h"
}
volatile uint64 Values[] = {
0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff, 0x8000, 0x8001,
0xfffe, 0xffff, 0x007fffff /*Max subnormal + */, 0x00800000 /*Min+ */,
0x7f7fffff /*Max+ */, 0x7f800000 /*+Inf*/, 0xff800000 /*-Inf*/,
0x7fa00000 /*SNaN*/, 0x7fc00000 /*QNaN*/, 0x7ffffffe, 0x7fffffff,
0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, 0x100000000ll,
0x100000001ll, 0x000fffffffffffffll /*Max subnormal + */,
0x0010000000000000ll /*Min+ */, 0x7fefffffffffffffll /*Max+ */,
0x7ff0000000000000ll /*+Inf*/, 0xfff0000000000000ll /*-Inf*/,
0x7ff0000000000001ll /*SNaN*/, 0x7ff8000000000000ll /*QNaN*/,
0x7ffffffffffffffell, 0x7fffffffffffffffll, 0x8000000000000000ll,
0x8000000000000001ll, 0xfffffffffffffffell, 0xffffffffffffffffll};
volatile uint64 Values[] = {0,
1,
0x7e,
0x7f,
0x80,
0x81,
0xfe,
0xff,
0x7ffe,
0x7fff,
0x8000,
0x8001,
0xfffe,
0xffff,
0x007fffff /*Max subnormal + */,
0x00800000 /*Min+ */,
0x7f7fffff /*Max+ */,
0x7f800000 /*+Inf*/,
0xff800000 /*-Inf*/,
0x7fa00000 /*SNaN*/,
0x7fc00000 /*QNaN*/,
0x7ffffffe,
0x7fffffff,
0x80000000,
0x80000001,
0xfffffffe,
0xffffffff,
0x100000000ll,
0x100000001ll,
0x000fffffffffffffll /*Max subnormal + */,
0x0010000000000000ll /*Min+ */,
0x7fefffffffffffffll /*Max+ */,
0x7ff0000000000000ll /*+Inf*/,
0xfff0000000000000ll /*-Inf*/,
0x7ff0000000000001ll /*SNaN*/,
0x7ff8000000000000ll /*QNaN*/,
0x7ffffffffffffffell,
0x7fffffffffffffffll,
0x8000000000000000ll,
0x8000000000000001ll,
0xfffffffffffffffell,
0xffffffffffffffffll};
const static size_t NumValues = sizeof(Values) / sizeof(*Values);
......@@ -65,8 +95,8 @@ void testAtomicRMW(volatile Type *AtomicLoc, size_t &TotalTests, size_t &Passes,
FuncType FuncSz;
} Funcs[] = {
#define X(inst) \
{ STR(inst), test_##inst, Subzero_::test_##inst } \
, {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \
{STR(inst), test_##inst, Subzero_::test_##inst}, \
{STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst}, \
{STR(inst) "_const", test_const_##inst, Subzero_::test_const_##inst},
RMWOP_TABLE
#undef X
......@@ -186,8 +216,8 @@ void testAtomicRMWThreads(volatile Type *AtomicLoc, size_t &TotalTests,
FuncType FuncSz;
} Funcs[] = {
#define X(inst) \
{ STR(inst), test_##inst, Subzero_::test_##inst } \
, {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst},
{STR(inst), test_##inst, Subzero_::test_##inst}, \
{STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst},
RMWOP_TABLE
#undef X
};
......
......@@ -44,18 +44,23 @@ template <typename T> struct VectorOps;
TY(NAME) Subzero_shufflevector_##NAME(TY(NAME), TY(NAME), uint32_t); \
uint32_t shufflevector_count_##NAME(); \
} \
TY(NAME) (*FIELD(NAME, insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \
TY(NAME) \
(*FIELD(NAME, insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \
&insertelement_##NAME; \
TY(NAME) (*FIELD(NAME, Subzero_insertelement))( \
TY(NAME), CASTTY(NAME), int32_t) = &Subzero_insertelement_##NAME; \
CASTTY(NAME) (*FIELD(NAME, extractelement))(TY(NAME), int32_t) = \
&extractelement_##NAME; \
CASTTY(NAME) (*FIELD(NAME, Subzero_extractelement))(TY(NAME), int32_t) = \
TY(NAME) \
(*FIELD(NAME, Subzero_insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \
&Subzero_insertelement_##NAME; \
CASTTY(NAME) \
(*FIELD(NAME, extractelement))(TY(NAME), int32_t) = &extractelement_##NAME; \
CASTTY(NAME) \
(*FIELD(NAME, Subzero_extractelement))(TY(NAME), int32_t) = \
&Subzero_extractelement_##NAME; \
TY(NAME) (*FIELD(NAME, shufflevector))(TY(NAME), TY(NAME), uint32_t) = \
TY(NAME) \
(*FIELD(NAME, shufflevector))(TY(NAME), TY(NAME), uint32_t) = \
&shufflevector_##NAME; \
TY(NAME) (*FIELD(NAME, Subzero_shufflevector))( \
TY(NAME), TY(NAME), uint32_t) = &Subzero_shufflevector_##NAME; \
TY(NAME) \
(*FIELD(NAME, Subzero_shufflevector))(TY(NAME), TY(NAME), uint32_t) = \
&Subzero_shufflevector_##NAME; \
uint32_t (*FIELD(NAME, shufflevector_count))() = &shufflevector_count_##NAME;
#define X(ty, eltty, castty) DECLARE_VECTOR_OPS(ty)
......
......@@ -16,9 +16,9 @@
#ifndef VECTORS_H
#define VECTORS_H
#include <sstream>
#include <stdint.h>
#include <string>
#include <sstream>
// The driver and the test program may be compiled by different
// versions of clang, with different standard libraries that have
......
......@@ -15,8 +15,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/DataStream.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
#include <string>
......@@ -45,14 +45,15 @@ STATISTIC(NumStreamFetches, "Number of calls to Data stream fetch");
namespace llvm {
DataStreamer::~DataStreamer() {}
}
} // namespace llvm
namespace {
// Very simple stream backed by a file. Mostly useful for stdin and debugging;
// actual file access is probably still best done with mmap.
class DataFileStreamer : public DataStreamer {
int Fd;
int Fd;
public:
DataFileStreamer() : Fd(0) {}
~DataFileStreamer() override { close(Fd); }
......@@ -72,14 +73,14 @@ public:
}
};
}
} // namespace
std::unique_ptr<DataStreamer>
llvm::getDataFileStreamer(const std::string &Filename, std::string *StrError) {
std::unique_ptr<DataFileStreamer> s = make_unique<DataFileStreamer>();
if (std::error_code e = s->OpenFile(Filename)) {
*StrError = std::string("Could not open ") + Filename + ": " +
e.message() + "\n";
*StrError =
std::string("Could not open ") + Filename + ": " + e.message() + "\n";
return nullptr;
}
return std::move(s);
......
......@@ -9,6 +9,5 @@
#include "llvm/Support/MemoryObject.h"
using namespace llvm;
MemoryObject::~MemoryObject() {
}
MemoryObject::~MemoryObject() {}
......@@ -13,30 +13,26 @@
//===----------------------------------------------------------------------===//
#include "llvm/Bitcode/NaCl/NaClBitCodes.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
const bool NaClBitCodeAbbrevOp::HasValueArray[] = {
true, // Literal
true, // Fixed
true, // VBR
false, // Array
false // Char6
true, // Literal
true, // Fixed
true, // VBR
false, // Array
false // Char6
};
const char *NaClBitCodeAbbrevOp::EncodingNameArray[] = {
"Literal",
"Fixed",
"VBR",
"Array",
"Char6"
};
"Literal", "Fixed", "VBR", "Array", "Char6"};
NaClBitCodeAbbrevOp::NaClBitCodeAbbrevOp(Encoding E, uint64_t Data)
: Enc(E), Val(Data) {
if (isValid(E, Data)) return;
if (isValid(E, Data))
return;
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Invalid NaClBitCodeAbbrevOp(" << E << ", " << Data << ")";
......@@ -57,7 +53,7 @@ bool NaClBitCodeAbbrevOp::isValid(Encoding E, uint64_t Val) {
llvm_unreachable("unhandled abbreviation");
}
void NaClBitCodeAbbrevOp::Print(raw_ostream& Stream) const {
void NaClBitCodeAbbrevOp::Print(raw_ostream &Stream) const {
if (Enc == Literal) {
Stream << getValue();
return;
......@@ -69,11 +65,11 @@ void NaClBitCodeAbbrevOp::Print(raw_ostream& Stream) const {
}
static void PrintExpression(raw_ostream &Stream,
const NaClBitCodeAbbrev *Abbrev,
unsigned &Index) {
const NaClBitCodeAbbrev *Abbrev, unsigned &Index) {
// Bail out early, in case we are incrementally building the
// expression and the argument is not available yet.
if (Index >= Abbrev->getNumOperandInfos()) return;
if (Index >= Abbrev->getNumOperandInfos())
return;
const NaClBitCodeAbbrevOp &Op = Abbrev->getOperandInfo(Index);
Op.Print(Stream);
......@@ -81,7 +77,8 @@ static void PrintExpression(raw_ostream &Stream,
Stream << "(";
for (unsigned i = 0; i < NumArgs; ++i) {
++Index;
if (i > 0) Stream << ",";
if (i > 0)
Stream << ",";
PrintExpression(Stream, Abbrev, Index);
}
Stream << ")";
......@@ -91,11 +88,13 @@ static void PrintExpression(raw_ostream &Stream,
void NaClBitCodeAbbrev::Print(raw_ostream &Stream, bool AddNewLine) const {
Stream << "[";
for (unsigned i = 0; i < getNumOperandInfos(); ++i) {
if (i > 0) Stream << ", ";
if (i > 0)
Stream << ", ";
PrintExpression(Stream, this, i);
}
Stream << "]";
if (AddNewLine) Stream << "\n";
if (AddNewLine)
Stream << "\n";
}
NaClBitCodeAbbrev *NaClBitCodeAbbrev::Simplify() const {
......@@ -106,9 +105,9 @@ NaClBitCodeAbbrev *NaClBitCodeAbbrev::Simplify() const {
// is to remove unnecessary operands appearing immediately before an
// array operator. That is, apply the simplification:
// Op Array(Op) -> Array(Op)
assert(!Op.isArrayOp() || i == OperandList.size()-2);
assert(!Op.isArrayOp() || i == OperandList.size() - 2);
while (Op.isArrayOp() && !Abbrev->OperandList.empty() &&
Abbrev->OperandList.back() == OperandList[i+1]) {
Abbrev->OperandList.back() == OperandList[i + 1]) {
Abbrev->OperandList.pop_back();
}
Abbrev->OperandList.push_back(Op);
......@@ -120,7 +119,8 @@ bool NaClBitCodeAbbrev::isValid() const {
// Verify that an array op appears can only appear if it is the
// second to last element.
unsigned NumOperands = getNumOperandInfos();
if (NumOperands == 0) return false;
if (NumOperands == 0)
return false;
for (unsigned i = 0; i < NumOperands; ++i) {
const NaClBitCodeAbbrevOp &Op = getOperandInfo(i);
if (Op.isArrayOp() && i + 2 != NumOperands)
......
......@@ -13,8 +13,7 @@
namespace llvm {
namespace naclbitc {
bool DecodeCastOpcode(uint64_t NaClOpcode,
Instruction::CastOps &LLVMOpcode) {
bool DecodeCastOpcode(uint64_t NaClOpcode, Instruction::CastOps &LLVMOpcode) {
switch (NaClOpcode) {
default:
LLVMOpcode = Instruction::BitCast;
......@@ -223,6 +222,5 @@ bool DecodeIcmpPredicate(uint64_t NaClPredicate,
}
}
}
}
} // namespace naclbitc
} // namespace llvm
......@@ -15,8 +15,8 @@
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/StreamingMemoryObject.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <iomanip>
......@@ -28,24 +28,24 @@ namespace {
// The name for each ID tag.
static const char *TagName[] = {
"Invalid", // kInvalid
"PNaCl Version", // kPNaClVersion
"Align bitcode records" // kAlignBitcodeRecords
"Invalid", // kInvalid
"PNaCl Version", // kPNaClVersion
"Align bitcode records" // kAlignBitcodeRecords
};
// The name for each field type.
static const char *FieldTypeName[] = {
"uint8[]", // kBufferType
"uint32", // kUInt32Type
"flag", // kFlagType
"unknown" // kUnknownType
"uint8[]", // kBufferType
"uint32", // kUInt32Type
"flag", // kFlagType
"unknown" // kUnknownType
};
// The type associated with each ID tag.
static const NaClBitcodeHeaderField::FieldType ExpectedType[] = {
NaClBitcodeHeaderField::kUnknownType, // kInvalid
NaClBitcodeHeaderField::kUInt32Type, // kPNaClVersion
NaClBitcodeHeaderField::kFlagType // kAlignBitcodeRecords
NaClBitcodeHeaderField::kUnknownType, // kInvalid
NaClBitcodeHeaderField::kUInt32Type, // kPNaClVersion
NaClBitcodeHeaderField::kFlagType // kAlignBitcodeRecords
};
} // end of anonymous namespace
......@@ -59,10 +59,10 @@ const char *NaClBitcodeHeaderField::TypeName(FieldType FType) {
}
NaClBitcodeHeaderField::NaClBitcodeHeaderField()
: ID(kInvalid), FType(kBufferType), Len(0), Data(0) {}
: ID(kInvalid), FType(kBufferType), Len(0), Data(0) {}
NaClBitcodeHeaderField::NaClBitcodeHeaderField(Tag MyID)
: ID(MyID), FType(kFlagType), Len(0), Data(0) {
: ID(MyID), FType(kFlagType), Len(0), Data(0) {
assert(MyID <= kTag_MAX);
}
......@@ -94,7 +94,7 @@ NaClBitcodeHeaderField::NaClBitcodeHeaderField(Tag MyID, size_t MyLen,
bool NaClBitcodeHeaderField::Write(uint8_t *Buf, size_t BufLen) const {
size_t FieldsLen = kTagLenSize + Len;
size_t PadLen = (WordSize - (FieldsLen & (WordSize-1))) & (WordSize-1);
size_t PadLen = (WordSize - (FieldsLen & (WordSize - 1))) & (WordSize - 1);
// Ensure buffer is large enough and that length can be represented
// in 32 bits
if (BufLen < FieldsLen + PadLen ||
......@@ -182,7 +182,7 @@ bool NaClBitcodeHeader::ReadPrefix(const unsigned char *BufPtr,
UnsupportedMessage = "Invalid PNaCl bitcode header";
if (isBitcode(BufPtr, BufEnd)) {
UnsupportedMessage += " (to run in Chrome, bitcode files must be "
"finalized using pnacl-finalize)";
"finalized using pnacl-finalize)";
}
return true;
}
......@@ -192,9 +192,9 @@ bool NaClBitcodeHeader::ReadPrefix(const unsigned char *BufPtr,
if (BufPtr + WordSize > BufEnd)
return UnsupportedError("Bitcode read failure");
NumFields = static_cast<unsigned>(BufPtr[0]) |
(static_cast<unsigned>(BufPtr[1]) << 8);
(static_cast<unsigned>(BufPtr[1]) << 8);
NumBytes = static_cast<unsigned>(BufPtr[2]) |
(static_cast<unsigned>(BufPtr[3]) << 8);
(static_cast<unsigned>(BufPtr[3]) << 8);
BufPtr += WordSize;
return false;
}
......@@ -245,9 +245,8 @@ bool NaClBitcodeHeader::Read(MemoryObject *Bytes) {
}
// Then read the rest, starting after the 2 * WordSize of the prefix.
uint8_t *Header = new uint8_t[NumBytes];
bool failed =
Bytes->readBytes(Header, NumBytes, 2 * WordSize) != NumBytes ||
ReadFields(Header, Header + NumBytes, NumFields, NumBytes);
bool failed = Bytes->readBytes(Header, NumBytes, 2 * WordSize) != NumBytes ||
ReadFields(Header, Header + NumBytes, NumFields, NumBytes);
delete[] Header;
if (failed)
return UnsupportedError("Bitcode read failure");
......
......@@ -14,19 +14,20 @@ using namespace llvm;
void NaClBitcodeRecordData::Print(raw_ostream &os) const {
os << "[" << Code;
for (NaClRecordVector::const_iterator
Iter = Values.begin(), IterEnd = Values.end();
for (NaClRecordVector::const_iterator Iter = Values.begin(),
IterEnd = Values.end();
Iter != IterEnd; ++Iter) {
os << ", " << *Iter;
}
os << "]";
}
void NaClBitcodeRecord::Print(raw_ostream& os) const {
void NaClBitcodeRecord::Print(raw_ostream &os) const {
Block.Print(os);
os << ", Code " << Data.Code << ", EntryID " << Entry.ID << ", <";
for (unsigned i = 0, e = Data.Values.size(); i != e; ++i) {
if (i > 0) os << " ";
if (i > 0)
os << " ";
os << Data.Values[i];
}
os << ">";
......@@ -34,11 +35,8 @@ void NaClBitcodeRecord::Print(raw_ostream& os) const {
NaClBitcodeBlock::NaClBitcodeBlock(unsigned BlockID,
const NaClBitcodeRecord &Record)
: NaClBitcodeData(Record),
BlockID(BlockID),
EnclosingBlock(&Record.GetBlock()),
LocalStartBit(Record.GetStartBit())
{}
: NaClBitcodeData(Record), BlockID(BlockID),
EnclosingBlock(&Record.GetBlock()), LocalStartBit(Record.GetStartBit()) {}
void NaClBitcodeBlock::Print(raw_ostream &os) const {
os << "Block " << BlockID;
......@@ -69,8 +67,8 @@ void NaClBitcodeParserListener::EndBlockInfoBlock() {
Parser->ExitBlock();
}
void NaClBitcodeParserListener::
ProcessAbbreviation(NaClBitCodeAbbrev *Abbrev, bool IsLocal) {
void NaClBitcodeParserListener::ProcessAbbreviation(NaClBitCodeAbbrev *Abbrev,
bool IsLocal) {
Parser->Record.SetStartBit(StartBit);
Parser->Record.Entry.Kind = NaClBitstreamEntry::Record;
Parser->Record.Entry.ID = naclbitc::DEFINE_ABBREV;
......@@ -86,9 +84,9 @@ NaClBitcodeParser::~NaClBitcodeParser() {
}
}
bool NaClBitcodeParser::ErrorAt(
naclbitc::ErrorLevel Level, uint64_t BitPosition,
const std::string &Message) {
bool NaClBitcodeParser::ErrorAt(naclbitc::ErrorLevel Level,
uint64_t BitPosition,
const std::string &Message) {
naclbitc::ErrorAt(*ErrStream, Level, BitPosition) << Message << "\n";
if (Level == naclbitc::Fatal)
report_fatal_error("Unable to continue");
......@@ -108,7 +106,8 @@ bool NaClBitcodeParser::ParseBlockInfoInternal() {
// BLOCKINFO is a special part of the stream. Let the bitstream
// reader process this block.
bool Result = Record.GetCursor().ReadBlockInfoBlock(Listener);
if (Result) return Error("Malformed BlockInfoBlock");
if (Result)
return Error("Malformed BlockInfoBlock");
return Result;
}
......@@ -136,7 +135,8 @@ bool NaClBitcodeParser::ParseBlockInternal() {
return false;
}
case NaClBitstreamEntry::SubBlock: {
if (ParseBlock(Record.GetEntryID())) return true;
if (ParseBlock(Record.GetEntryID()))
return true;
break;
}
case NaClBitstreamEntry::Record:
......@@ -145,7 +145,8 @@ bool NaClBitcodeParser::ParseBlockInternal() {
// Since this abbreviation is local, the listener doesn't
// have the start bit set (it is only set when processing
// the BlockInfo block). Fix this by setting it here.
if (Listener) Listener->StartBit = Record.GetStartBit();
if (Listener)
Listener->StartBit = Record.GetStartBit();
Record.GetCursor().ReadAbbrevRecord(true, Listener);
} else {
// Read in a record.
......
......@@ -17,14 +17,12 @@ namespace {
class RawMemoryObject : public MemoryObject {
public:
RawMemoryObject(const unsigned char *Start, const unsigned char *End) :
FirstChar(Start), LastChar(End) {
RawMemoryObject(const unsigned char *Start, const unsigned char *End)
: FirstChar(Start), LastChar(End) {
assert(LastChar >= FirstChar && "Invalid start/end range");
}
uint64_t getExtent() const override {
return LastChar - FirstChar;
}
uint64_t getExtent() const override { return LastChar - FirstChar; }
uint64_t readBytes(uint8_t *Buf, uint64_t Size,
uint64_t Address) const override;
const uint8_t *getPointer(uint64_t address, uint64_t size) const override;
......@@ -33,8 +31,8 @@ public:
}
private:
const uint8_t* const FirstChar;
const uint8_t* const LastChar;
const uint8_t *const FirstChar;
const uint8_t *const LastChar;
// These are implemented as inline functions here to avoid multiple virtual
// calls per public function
......@@ -42,8 +40,8 @@ private:
return static_cast<std::ptrdiff_t>(address) < LastChar - FirstChar;
}
RawMemoryObject(const RawMemoryObject&) = delete;
void operator=(const RawMemoryObject&) = delete;
RawMemoryObject(const RawMemoryObject &) = delete;
void operator=(const RawMemoryObject &) = delete;
};
uint64_t RawMemoryObject::readBytes(uint8_t *Buf, uint64_t Size,
......@@ -72,15 +70,18 @@ namespace llvm {
// If the bitcode has a header, then its size is known, and we don't have to
// block until we actually want to read it.
bool StreamingMemoryObject::isValidAddress(uint64_t address) const {
if (ObjectSize && address < ObjectSize) return true;
if (ObjectSize && address < ObjectSize)
return true;
return fetchToPos(address);
}
uint64_t StreamingMemoryObject::getExtent() const {
if (ObjectSize) return ObjectSize;
if (ObjectSize)
return ObjectSize;
size_t pos = BytesRead + kChunkSize;
// keep fetching until we run out of bytes
while (fetchToPos(pos)) pos += kChunkSize;
while (fetchToPos(pos))
pos += kChunkSize;
return ObjectSize;
}
......@@ -111,7 +112,8 @@ const uint8_t *StreamingMemoryObject::getPointer(uint64_t Address,
}
bool StreamingMemoryObject::dropLeadingBytes(size_t s) {
if (BytesRead < s) return true;
if (BytesRead < s)
return true;
BytesSkipped = s;
BytesRead -= s;
return false;
......@@ -135,4 +137,4 @@ StreamingMemoryObject::StreamingMemoryObject(
BytesSkipped(0), ObjectSize(0), EOFReached(false) {
BytesRead = this->Streamer->GetBytes(&Bytes[0], kChunkSize);
}
}
} // namespace llvm
//===- NaClBitcodeDecoders.h -------------------------------------*- C++ -*-===//
//===- NaClBitcodeDecoders.h -------------------------------------*- C++
//-*-===//
// Functions used to decode values in PNaCl bitcode files.
//
// The LLVM Compiler Infrastructure
......@@ -16,11 +17,11 @@
#ifndef LLVM_BITCODE_NACL_NACLBITCODEDECODERS_H
#define LLVM_BITCODE_NACL_NACLBITCODEDECODERS_H
#include "llvm/Bitcode/NaCl/NaClLLVMBitCodes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/Bitcode/NaCl/NaClLLVMBitCodes.h"
namespace llvm {
namespace naclbitc {
......@@ -29,8 +30,7 @@ namespace naclbitc {
/// LLVM cast opcode. Returns true if the conversion
/// succeeds. Otherwise sets LLVMOpcode to Instruction::BitCast and
/// returns false.
bool DecodeCastOpcode(uint64_t NaClOpcode,
Instruction::CastOps &LLVMOpcode);
bool DecodeCastOpcode(uint64_t NaClOpcode, Instruction::CastOps &LLVMOpcode);
/// Converts the NaCl (bitcode file) linkage type to the corresponding
/// LLVM linkage type. Returns true if the conversion
......@@ -68,7 +68,7 @@ bool DecodeFcmpPredicate(uint64_t NaClPredicate,
bool DecodeIcmpPredicate(uint64_t NaClPredicate,
CmpInst::Predicate &LLVMPredicate);
}
}
} // namespace naclbitc
} // namespace llvm
#endif
......@@ -25,7 +25,7 @@ namespace naclbitc {
// record codes for user-defined blocks.
enum SpecialBlockCodes {
BLK_CODE_ENTER = 65535,
BLK_CODE_EXIT = 65534,
BLK_CODE_EXIT = 65534,
BLK_CODE_DEFINE_ABBREV = 65533,
BLK_CODE_HEADER = 65532
};
......@@ -49,5 +49,4 @@ static const size_t MaxNaClGlobalVarInits =
} // end of namespace llvm
#endif // LLVM_BITCODE_NACL_NACLBITCODEDEFS_H
......@@ -88,15 +88,11 @@ public:
/// \brief Returns string describing ID of field.
static const char *IDName(Tag ID);
const char *IDName() const {
return IDName(ID);
}
const char *IDName() const { return IDName(ID); }
/// \brief Returns string describing type of field.
static const char *TypeName(FieldType FType);
const char *TypeName() const {
return TypeName(FType);
}
const char *TypeName() const { return TypeName(FType); }
/// \brief Returns string describing field.
std::string Contents() const;
......@@ -132,7 +128,8 @@ private:
ID = (PossibleID > kTag_MAX ? kInvalid : static_cast<Tag>(PossibleID));
FixedSubfield PossibleFType = Subfield & 0xF;
FType = (PossibleFType > kFieldType_MAX
? kUnknownType : static_cast<FieldType>(PossibleFType));
? kUnknownType
: static_cast<FieldType>(PossibleFType));
}
// Combined size of the fixed subfields
const static size_t kTagLenSize = 2 * sizeof(FixedSubfield);
......@@ -182,9 +179,7 @@ public:
/// \brief Adds a field to the list of fields in a header. Takes ownership
/// of fields added.
void push_back(NaClBitcodeHeaderField *Field) {
Fields.push_back(Field);
}
void push_back(NaClBitcodeHeaderField *Field) { Fields.push_back(Field); }
/// \brief Read the PNaCl bitcode header, The format of the header is:
///
......@@ -255,7 +250,6 @@ private:
UnsupportedMessage = Message.str();
return true;
}
};
} // namespace llvm
......
......@@ -13,7 +13,6 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_DATASTREAM_H
#define LLVM_SUPPORT_DATASTREAM_H
......@@ -33,6 +32,6 @@ public:
std::unique_ptr<DataStreamer> getDataFileStreamer(const std::string &Filename,
std::string *Err);
}
} // namespace llvm
#endif // LLVM_SUPPORT_DATASTREAM_H_
#endif // LLVM_SUPPORT_DATASTREAM_H_
......@@ -63,6 +63,6 @@ public:
virtual bool isValidAddress(uint64_t address) const = 0;
};
}
} // namespace llvm
#endif
......@@ -48,8 +48,8 @@ public:
private:
mutable std::vector<unsigned char> Bytes;
std::unique_ptr<DataStreamer> Streamer;
mutable size_t BytesRead; // Bytes read from stream
size_t BytesSkipped;// Bytes skipped at start of stream (e.g. wrapper/header)
mutable size_t BytesRead; // Bytes read from stream
size_t BytesSkipped; // Bytes skipped at start of stream (e.g. wrapper/header)
mutable size_t ObjectSize; // 0 if unknown, set if wrapper seen or EOF reached
mutable bool EOFReached;
......@@ -64,8 +64,8 @@ private:
if (EOFReached)
return false;
Bytes.resize(BytesRead + BytesSkipped + kChunkSize);
size_t bytes = Streamer->GetBytes(&Bytes[BytesRead + BytesSkipped],
kChunkSize);
size_t bytes =
Streamer->GetBytes(&Bytes[BytesRead + BytesSkipped], kChunkSize);
BytesRead += bytes;
if (bytes == 0) { // reached EOF/ran out of bytes
if (ObjectSize == 0)
......@@ -76,12 +76,12 @@ private:
return !ObjectSize || Pos < ObjectSize;
}
StreamingMemoryObject(const StreamingMemoryObject&) = delete;
void operator=(const StreamingMemoryObject&) = delete;
StreamingMemoryObject(const StreamingMemoryObject &) = delete;
void operator=(const StreamingMemoryObject &) = delete;
};
MemoryObject *getNonStreamedMemoryObject(
const unsigned char *Start, const unsigned char *End);
MemoryObject *getNonStreamedMemoryObject(const unsigned char *Start,
const unsigned char *End);
}
#endif // STREAMINGMEMORYOBJECT_H_
} // namespace llvm
#endif // STREAMINGMEMORYOBJECT_H_
......@@ -26,8 +26,8 @@
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
......
......@@ -6,8 +6,8 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "IceAssemblerX8632.h"
#include "AssemblerX8632/TestUtil.h"
#include "IceAssemblerX8632.h"
namespace Ice {
namespace X8632 {
......
......@@ -135,8 +135,8 @@ TEST_F(AssemblerX8632Test, Lea) {
AssemblerFixup::NoFixup)); \
AssembledTest test = assemble(); \
test.run(); \
ASSERT_EQ(test.Base() + (Disp), test.Dst()) << TestString << " with Disp " \
<< Disp; \
ASSERT_EQ(test.Base() + (Disp), test.Dst()) \
<< TestString << " with Disp " << Disp; \
reset(); \
} while (0)
......@@ -620,8 +620,8 @@ TEST_F(AssemblerX8632Test, Arith_most) {
do { \
TestImplOp(And, Dst, Value0, Src, Value1, int, Size, &); \
TestImplOp(And, Dst, Value0, Src, Value1, uint, Size, &); \
TestImplOp(Or, Dst, Value0, Src, Value1, int, Size, | ); \
TestImplOp(Or, Dst, Value0, Src, Value1, uint, Size, | ); \
TestImplOp(Or, Dst, Value0, Src, Value1, int, Size, |); \
TestImplOp(Or, Dst, Value0, Src, Value1, uint, Size, |); \
TestImplOp(Xor, Dst, Value0, Src, Value1, int, Size, ^); \
TestImplOp(Xor, Dst, Value0, Src, Value1, uint, Size, ^); \
TestImplOp(add, Dst, Value0, Src, Value1, int, Size, +); \
......@@ -699,9 +699,8 @@ TEST_F(AssemblerX8632Test, Arith_BorrowNCarry) {
AssembledTest test = assemble(); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Value1) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Value1) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.Dst0()) << TestString << ": 0"; \
......@@ -734,9 +733,8 @@ TEST_F(AssemblerX8632Test, Arith_BorrowNCarry) {
test.setDwordTo(T1, V1); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Value1) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Value1) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.Dst0()) << TestString << ": 0"; \
......@@ -763,9 +761,8 @@ TEST_F(AssemblerX8632Test, Arith_BorrowNCarry) {
AssembledTest test = assemble(); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Imm) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Imm) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.Dst0()) << TestString << ": 0"; \
......@@ -798,9 +795,8 @@ TEST_F(AssemblerX8632Test, Arith_BorrowNCarry) {
test.setDwordTo(T1, V1); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Value1) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Value1) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.contentsOfDword(T0)) << TestString << ": 0"; \
......@@ -829,9 +825,8 @@ TEST_F(AssemblerX8632Test, Arith_BorrowNCarry) {
test.setDwordTo(T1, V1); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Imm) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Imm) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.contentsOfDword(T0)) << TestString << ": 0"; \
......
......@@ -318,12 +318,12 @@ protected:
return *reinterpret_cast<Dqword *>(&Ret); \
}
DefinePackedComparisonOperator(< );
DefinePackedComparisonOperator(<= );
DefinePackedComparisonOperator(> );
DefinePackedComparisonOperator(>= );
DefinePackedComparisonOperator(== );
DefinePackedComparisonOperator(!= );
DefinePackedComparisonOperator(<);
DefinePackedComparisonOperator(<=);
DefinePackedComparisonOperator(>);
DefinePackedComparisonOperator(>=);
DefinePackedComparisonOperator(==);
DefinePackedComparisonOperator(!=);
#undef DefinePackedComparisonOperator
......@@ -387,7 +387,7 @@ protected:
DefinePackedArithOperator(/, true, false);
DefinePackedArithOperator(&, true, true);
DefinePackedArithOperator(|, true, true);
DefinePackedArithOperator (^, true, true);
DefinePackedArithOperator(^, true, true);
#undef DefinePackedArithOperator
......@@ -403,8 +403,8 @@ protected:
return *reinterpret_cast<Dqword *>(&Ret); \
}
DefinePackedArithShiftImm(>> );
DefinePackedArithShiftImm(<< );
DefinePackedArithShiftImm(>>);
DefinePackedArithShiftImm(<<);
#undef DefinePackedArithShiftImm
......@@ -693,8 +693,7 @@ protected:
Dqword contentsOfDqword(uint32_t InitialDword) const {
return *reinterpret_cast<Dqword *>(
static_cast<uint8_t *>(ExecutableData) +
dwordOffset(InitialDword));
static_cast<uint8_t *>(ExecutableData) + dwordOffset(InitialDword));
}
template <typename T = uint32_t, typename = typename std::enable_if<
......
......@@ -646,8 +646,8 @@ TEST_F(AssemblerX8664Test, Arith_most) {
do { \
TestImplOp(And, Dst, Value0, Src, Value1, int, Size, &); \
TestImplOp(And, Dst, Value0, Src, Value1, uint, Size, &); \
TestImplOp(Or, Dst, Value0, Src, Value1, int, Size, | ); \
TestImplOp(Or, Dst, Value0, Src, Value1, uint, Size, | ); \
TestImplOp(Or, Dst, Value0, Src, Value1, int, Size, |); \
TestImplOp(Or, Dst, Value0, Src, Value1, uint, Size, |); \
TestImplOp(Xor, Dst, Value0, Src, Value1, int, Size, ^); \
TestImplOp(Xor, Dst, Value0, Src, Value1, uint, Size, ^); \
TestImplOp(add, Dst, Value0, Src, Value1, int, Size, +); \
......@@ -728,9 +728,8 @@ TEST_F(AssemblerX8664Test, Arith_BorrowNCarry) {
AssembledTest test = assemble(); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Value1) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Value1) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.Dst0()) << TestString << ": 0"; \
......@@ -761,9 +760,8 @@ TEST_F(AssemblerX8664Test, Arith_BorrowNCarry) {
test.setDwordTo(T1, V1); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Value1) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Value1) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.Dst0()) << TestString << ": 0"; \
......@@ -790,9 +788,8 @@ TEST_F(AssemblerX8664Test, Arith_BorrowNCarry) {
AssembledTest test = assemble(); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Imm) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Imm) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.Dst0()) << TestString << ": 0"; \
......@@ -823,9 +820,8 @@ TEST_F(AssemblerX8664Test, Arith_BorrowNCarry) {
test.setDwordTo(T1, V1); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Value1) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Value1) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.contentsOfDword(T0)) << TestString << ": 0"; \
......@@ -854,9 +850,8 @@ TEST_F(AssemblerX8664Test, Arith_BorrowNCarry) {
test.setDwordTo(T1, V1); \
test.run(); \
\
static constexpr uint64_t Result = \
(uint64_t(Value0) & ResultMask##Size)Op(uint64_t(Imm) & \
ResultMask##Size); \
static constexpr uint64_t Result = (uint64_t(Value0) & ResultMask##Size) \
Op(uint64_t(Imm) & ResultMask##Size); \
static constexpr uint32_t Expected0 = Result & Mask##Size; \
static constexpr uint32_t Expected1 = (Result >> Size) & Mask##Size; \
ASSERT_EQ(Expected0, test.contentsOfDword(T0)) << TestString << ": 0"; \
......
......@@ -430,12 +430,12 @@ protected:
return *reinterpret_cast<Dqword *>(&Ret); \
}
DefinePackedComparisonOperator(< );
DefinePackedComparisonOperator(<= );
DefinePackedComparisonOperator(> );
DefinePackedComparisonOperator(>= );
DefinePackedComparisonOperator(== );
DefinePackedComparisonOperator(!= );
DefinePackedComparisonOperator(<);
DefinePackedComparisonOperator(<=);
DefinePackedComparisonOperator(>);
DefinePackedComparisonOperator(>=);
DefinePackedComparisonOperator(==);
DefinePackedComparisonOperator(!=);
#undef DefinePackedComparisonOperator
......@@ -499,7 +499,7 @@ protected:
DefinePackedArithOperator(/, true, false);
DefinePackedArithOperator(&, true, true);
DefinePackedArithOperator(|, true, true);
DefinePackedArithOperator (^, true, true);
DefinePackedArithOperator(^, true, true);
#undef DefinePackedArithOperator
......@@ -515,8 +515,8 @@ protected:
return *reinterpret_cast<Dqword *>(&Ret); \
}
DefinePackedArithShiftImm(>> );
DefinePackedArithShiftImm(<< );
DefinePackedArithShiftImm(>>);
DefinePackedArithShiftImm(<<);
#undef DefinePackedArithShiftImm
......@@ -879,8 +879,7 @@ protected:
Dqword contentsOfDqword(uint32_t InitialDword) const {
return *reinterpret_cast<Dqword *>(
static_cast<uint8_t *>(ExecutableData) +
dwordOffset(InitialDword));
static_cast<uint8_t *>(ExecutableData) + dwordOffset(InitialDword));
}
template <typename T = uint32_t, typename = typename std::enable_if<
......
......@@ -14,8 +14,8 @@
#include "BitcodeMunge.h"
#include "IceCfg.h"
#include "IceClFlags.h"
#include "PNaClTranslator.h"
#include "IceTypes.h"
#include "PNaClTranslator.h"
namespace IceTest {
......
......@@ -24,16 +24,33 @@ namespace {
static const unsigned NO_LOCAL_ABBREVS =
NaClBitsNeededForValue(naclbitc::DEFAULT_MAX_ABBREV);
const uint64_t BitcodeRecords[] = {
naclbitc::ENTER_SUBBLOCK, naclbitc::BLK_CODE_ENTER,
naclbitc::MODULE_BLOCK_ID, NO_LOCAL_ABBREVS, Terminator,
naclbitc::ENTER_SUBBLOCK, naclbitc::BLK_CODE_ENTER,
naclbitc::TYPE_BLOCK_ID_NEW, NO_LOCAL_ABBREVS, Terminator,
naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_NUMENTRY, 2, Terminator,
naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_FLOAT, Terminator,
naclbitc::END_BLOCK, naclbitc::BLK_CODE_EXIT, Terminator,
naclbitc::END_BLOCK, naclbitc::BLK_CODE_EXIT, Terminator};
const uint64_t BitcodeRecords[] = {naclbitc::ENTER_SUBBLOCK,
naclbitc::BLK_CODE_ENTER,
naclbitc::MODULE_BLOCK_ID,
NO_LOCAL_ABBREVS,
Terminator,
naclbitc::ENTER_SUBBLOCK,
naclbitc::BLK_CODE_ENTER,
naclbitc::TYPE_BLOCK_ID_NEW,
NO_LOCAL_ABBREVS,
Terminator,
naclbitc::UNABBREV_RECORD,
naclbitc::TYPE_CODE_NUMENTRY,
2,
Terminator,
naclbitc::UNABBREV_RECORD,
naclbitc::TYPE_CODE_INTEGER,
32,
Terminator,
naclbitc::UNABBREV_RECORD,
naclbitc::TYPE_CODE_FLOAT,
Terminator,
naclbitc::END_BLOCK,
naclbitc::BLK_CODE_EXIT,
Terminator,
naclbitc::END_BLOCK,
naclbitc::BLK_CODE_EXIT,
Terminator};
const char *ExpectedDump =
" 0:0|<65532, 80, 69, 88, 69, 1, 0,|Magic Number: 'PEXE' (80, 69, "
......@@ -75,8 +92,9 @@ TEST(NaClParseTypesTest, BadTypeCountRecord) {
// Index for "count 2;".
const uint64_t CountRecordIndex = 2;
const uint64_t Edit[] = {
CountRecordIndex, NaClMungedBitcode::Replace, naclbitc::UNABBREV_RECORD,
naclbitc::TYPE_CODE_NUMENTRY, 18446744073709547964ULL, Terminator};
CountRecordIndex, NaClMungedBitcode::Replace,
naclbitc::UNABBREV_RECORD, naclbitc::TYPE_CODE_NUMENTRY,
18446744073709547964ULL, Terminator};
SubzeroBitcodeMunger Munger(ARRAY_TERM(BitcodeRecords));
Munger.Flags.setGenerateUnitTestMessages(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment