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, \
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, \
{STR(caller), \
STR(callee), \
argc, \
&caller, \
reinterpret_cast<CalleePtrTy>(&callee), \
reinterpret_cast<CalleePtrTy>(&Subzero_::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,7 +45,7 @@ STATISTIC(NumStreamFetches, "Number of calls to Data stream fetch");
namespace llvm {
DataStreamer::~DataStreamer() {}
}
} // namespace llvm
namespace {
......@@ -53,6 +53,7 @@ namespace {
// actual file access is probably still best done with mmap.
class DataFileStreamer : public DataStreamer {
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);
......
......@@ -10,5 +10,4 @@
#include "llvm/Support/MemoryObject.h"
using namespace llvm;
MemoryObject::~MemoryObject() {
}
MemoryObject::~MemoryObject() {}
......@@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===//
#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;
......@@ -27,16 +27,12 @@ const bool NaClBitCodeAbbrevOp::HasValueArray[] = {
};
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>
......@@ -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 ||
......@@ -245,8 +245,7 @@ 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 ||
bool failed = Bytes->readBytes(Header, NumBytes, 2 * WordSize) != NumBytes ||
ReadFields(Header, Header + NumBytes, NumFields, NumBytes);
delete[] Header;
if (failed)
......
......@@ -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,8 +84,8 @@ NaClBitcodeParser::~NaClBitcodeParser() {
}
}
bool NaClBitcodeParser::ErrorAt(
naclbitc::ErrorLevel Level, uint64_t BitPosition,
bool NaClBitcodeParser::ErrorAt(naclbitc::ErrorLevel Level,
uint64_t BitPosition,
const std::string &Message) {
naclbitc::ErrorAt(*ErrStream, Level, BitPosition) << Message << "\n";
if (Level == naclbitc::Fatal)
......@@ -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
......@@ -37,9 +37,9 @@ enum StandardWidths {
MinRecordBitSize = 2 // Minimum number of bits needed to represent a record.
};
// The standard abbrev namespace always has a way to exit a block, enter a
// nested block, define abbrevs, and define an unabbreviated record.
enum FixedAbbrevIDs {
// The standard abbrev namespace always has a way to exit a block, enter a
// nested block, define abbrevs, and define an unabbreviated record.
enum FixedAbbrevIDs {
END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode.
ENTER_SUBBLOCK = 1,
......@@ -69,12 +69,12 @@ enum StandardWidths {
FIRST_APPLICATION_ABBREV = 4,
// Defines default values for code length, if no additional selectors
// are added.
DEFAULT_MAX_ABBREV = FIRST_APPLICATION_ABBREV-1
};
DEFAULT_MAX_ABBREV = FIRST_APPLICATION_ABBREV - 1
};
/// StandardBlockIDs - All bitcode files can optionally include a BLOCKINFO
/// block, which contains metadata about other blocks in the file.
enum StandardBlockIDs {
/// StandardBlockIDs - All bitcode files can optionally include a BLOCKINFO
/// block, which contains metadata about other blocks in the file.
enum StandardBlockIDs {
/// BLOCKINFO_BLOCK is used to define metadata about blocks, for example,
/// standard abbrevs that should be available to all blocks of a specified
/// ID.
......@@ -85,11 +85,11 @@ enum StandardWidths {
// appear in a block).
TOP_LEVEL_BLOCKID = 7,
FIRST_APPLICATION_BLOCKID = 8
};
};
/// BlockInfoCodes - The blockinfo block contains metadata about user-defined
/// blocks.
enum BlockInfoCodes {
/// BlockInfoCodes - The blockinfo block contains metadata about user-defined
/// blocks.
enum BlockInfoCodes {
// DEFINE_ABBREV has magic semantics here, applying to the current SETBID'd
// block, instead of the BlockInfo block.
......@@ -100,12 +100,12 @@ enum StandardWidths {
// the writer.
BLOCKINFO_CODE_BLOCKNAME = 2, // Not used in PNaCl.
BLOCKINFO_CODE_SETRECORDNAME = 3 // Not used in PNaCl.
};
};
} // End naclbitc namespace
} // namespace naclbitc
/// NaClBitCodeAbbrevOp - This describes one or more operands in an abbreviation.
/// This is actually a union of two different things:
/// NaClBitCodeAbbrevOp - This describes one or more operands in an
/// abbreviation. This is actually a union of two different things:
/// 1. It could be a literal integer value ("the operand is always 17").
/// 2. It could be an encoding specification ("this operand encoded like so").
///
......@@ -129,9 +129,7 @@ public:
uint64_t getValue() const { return Val; }
bool hasValue() const {
return hasValue(Enc);
}
bool hasValue() const { return hasValue(Enc); }
static bool hasValue(Encoding E) {
return E <= Encoding_MAX && HasValueArray[E];
}
......@@ -164,28 +162,42 @@ public:
/// isChar6 - Return true if this character is legal in the Char6 encoding.
static bool isChar6(char C) {
if (C >= 'a' && C <= 'z') return true;
if (C >= 'A' && C <= 'Z') return true;
if (C >= '0' && C <= '9') return true;
if (C == '.' || C == '_') return true;
if (C >= 'a' && C <= 'z')
return true;
if (C >= 'A' && C <= 'Z')
return true;
if (C >= '0' && C <= '9')
return true;
if (C == '.' || C == '_')
return true;
return false;
}
static unsigned EncodeChar6(char C) {
if (C >= 'a' && C <= 'z') return C-'a';
if (C >= 'A' && C <= 'Z') return C-'A'+26;
if (C >= '0' && C <= '9') return C-'0'+26+26;
if (C == '.') return 62;
if (C == '_') return 63;
if (C >= 'a' && C <= 'z')
return C - 'a';
if (C >= 'A' && C <= 'Z')
return C - 'A' + 26;
if (C >= '0' && C <= '9')
return C - '0' + 26 + 26;
if (C == '.')
return 62;
if (C == '_')
return 63;
llvm_unreachable("Not a value Char6 character!");
}
static char DecodeChar6(unsigned V) {
assert((V & ~63) == 0 && "Not a Char6 encoded character!");
if (V < 26) return V+'a';
if (V < 26+26) return V-26+'A';
if (V < 26+26+10) return V-26-26+'0';
if (V == 62) return '.';
if (V == 63) return '_';
if (V < 26)
return V + 'a';
if (V < 26 + 26)
return V - 26 + 'A';
if (V < 26 + 26 + 10)
return V - 26 - 26 + '0';
if (V == 62)
return '.';
if (V == 63)
return '_';
llvm_unreachable("Not a value Char6 character!");
}
......@@ -194,7 +206,8 @@ public:
int Compare(const NaClBitCodeAbbrevOp &Op) const {
// Compare encoding values.
int EncodingDiff = static_cast<int>(Enc) - static_cast<int>(Op.Enc);
if (EncodingDiff != 0) return EncodingDiff;
if (EncodingDiff != 0)
return EncodingDiff;
// Encodings don't differ, so now base on data associated with the
// encoding.
......@@ -218,7 +231,7 @@ private:
};
template <> struct isPodLike<NaClBitCodeAbbrevOp> {
static const bool value=true;
static const bool value = true;
};
static inline bool operator<(const NaClBitCodeAbbrevOp &Op1,
......@@ -258,11 +271,15 @@ class NaClBitCodeAbbrev {
SmallVector<NaClBitCodeAbbrevOp, 8> OperandList;
unsigned char RefCount; // Number of things using this.
~NaClBitCodeAbbrev() {}
public:
NaClBitCodeAbbrev() : RefCount(1) {}
void addRef() { ++RefCount; }
void dropRef() { if (--RefCount == 0) delete this; }
void dropRef() {
if (--RefCount == 0)
delete this;
}
unsigned getNumOperandInfos() const {
return static_cast<unsigned>(OperandList.size());
......@@ -271,9 +288,7 @@ public:
return OperandList[N];
}
void Add(const NaClBitCodeAbbrevOp &OpInfo) {
OperandList.push_back(OpInfo);
}
void Add(const NaClBitCodeAbbrevOp &OpInfo) { OperandList.push_back(OpInfo); }
// Returns a simplified version of the abbreviation. Used
// to recognize equivalent abbrevations.
......@@ -303,24 +318,25 @@ public:
// of fixed length.
bool IsFixedSize() const {
unsigned Size = getNumOperandInfos();
if (Size < 2) return true;
return !OperandList[Size-2].isArrayOp();
if (Size < 2)
return true;
return !OperandList[Size - 2].isArrayOp();
}
// Returns the smallest record size that will match this
// abbreviation.
size_t GetMinRecordSize() const {
size_t Min = getNumOperandInfos();
if (!IsFixedSize()) Min -= 2;
if (!IsFixedSize())
Min -= 2;
return Min;
}
void Print(raw_ostream &Stream, bool AddNewline=true) const;
void Print(raw_ostream &Stream, bool AddNewline = true) const;
NaClBitCodeAbbrev *Copy() const {
NaClBitCodeAbbrev *AbbrevCopy = new NaClBitCodeAbbrev();
for (unsigned I = 0, IEnd = getNumOperandInfos();
I != IEnd; ++I) {
for (unsigned I = 0, IEnd = getNumOperandInfos(); I != IEnd; ++I) {
AbbrevCopy->Add(NaClBitCodeAbbrevOp(getOperandInfo(I)));
}
return AbbrevCopy;
......@@ -360,8 +376,9 @@ static inline bool operator>(const NaClBitCodeAbbrev &A1,
inline unsigned NaClBitsNeededForValue(unsigned Value) {
// Note: Need to handle case where Value=0xFFFFFFFF as special case,
// since we can't add 1 to it.
if (Value >= 0x80000000) return 32;
return Log2_32_Ceil(Value+1);
if (Value >= 0x80000000)
return 32;
return Log2_32_Ceil(Value + 1);
}
/// \brief Encode a signed value by moving the sign to the LSB for dense
......@@ -393,8 +410,7 @@ public:
unsigned NumBits;
// Creates a selector range for the given values.
NaClBitcodeSelectorAbbrev(bool IF, unsigned NB)
: IsFixed(IF), NumBits(NB) {}
NaClBitcodeSelectorAbbrev(bool IF, unsigned NB) : IsFixed(IF), NumBits(NB) {}
// Creates a selector range when no abbreviations are defined.
NaClBitcodeSelectorAbbrev()
......@@ -404,9 +420,8 @@ public:
// Creates a selector range to handle fixed abbrevations up to
// the specified value.
explicit NaClBitcodeSelectorAbbrev(unsigned MaxAbbrev)
: IsFixed(true),
NumBits(NaClBitsNeededForValue(MaxAbbrev)) {}
: IsFixed(true), NumBits(NaClBitsNeededForValue(MaxAbbrev)) {}
};
} // End llvm namespace
} // namespace llvm
#endif
//===- 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
......@@ -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
......
......@@ -24,120 +24,117 @@
#include <string>
namespace llvm {
class LLVMContext;
class Module;
class NaClBitcodeHeader;
class NaClBitstreamWriter;
class StreamingMemoryObject;
class raw_ostream;
/// Defines the data layout used for PNaCl bitcode files. We set the
/// data layout of the module in the bitcode readers rather than in
/// pnacl-llc so that 'opt' will also use the correct data layout if
/// it is run on a pexe.
extern const char *PNaClDataLayout;
/// Allows (function) local symbol tables (unsupported) in PNaCl bitcode
/// files.
extern cl::opt<bool> PNaClAllowLocalSymbolTables;
/// \brief Defines the integer bit size used to model pointers in PNaCl.
static const unsigned PNaClIntPtrTypeBitSize = 32;
/// Diagnostic handler that redirects error diagnostics to the given stream.
DiagnosticHandlerFunction redirectNaClDiagnosticToStream(raw_ostream &Out);
/// Read the header of the specified bitcode buffer and prepare for lazy
/// deserialization of function bodies. If successful, this takes ownership
/// of 'Buffer' (extending its lifetime). On error, this returns an error
/// code and deletes Buffer.
///
/// The AcceptSupportedOnly argument is used to decide which PNaCl versions
/// of the PNaCl bitcode to accept. There are three forms:
/// 1) Readable and supported.
/// 2) Readable and unsupported. Allows testing of code before becoming
/// supported, as well as running experiments on the bitcode format.
/// 3) Unreadable.
/// When AcceptSupportedOnly is true, only form 1 is allowed. When
/// AcceptSupportedOnly is false, forms 1 and 2 are allowed.
ErrorOr<Module *> getNaClLazyBitcodeModule(
std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context,
class LLVMContext;
class Module;
class NaClBitcodeHeader;
class NaClBitstreamWriter;
class StreamingMemoryObject;
class raw_ostream;
/// Defines the data layout used for PNaCl bitcode files. We set the
/// data layout of the module in the bitcode readers rather than in
/// pnacl-llc so that 'opt' will also use the correct data layout if
/// it is run on a pexe.
extern const char *PNaClDataLayout;
/// Allows (function) local symbol tables (unsupported) in PNaCl bitcode
/// files.
extern cl::opt<bool> PNaClAllowLocalSymbolTables;
/// \brief Defines the integer bit size used to model pointers in PNaCl.
static const unsigned PNaClIntPtrTypeBitSize = 32;
/// Diagnostic handler that redirects error diagnostics to the given stream.
DiagnosticHandlerFunction redirectNaClDiagnosticToStream(raw_ostream &Out);
/// Read the header of the specified bitcode buffer and prepare for lazy
/// deserialization of function bodies. If successful, this takes ownership
/// of 'Buffer' (extending its lifetime). On error, this returns an error
/// code and deletes Buffer.
///
/// The AcceptSupportedOnly argument is used to decide which PNaCl versions
/// of the PNaCl bitcode to accept. There are three forms:
/// 1) Readable and supported.
/// 2) Readable and unsupported. Allows testing of code before becoming
/// supported, as well as running experiments on the bitcode format.
/// 3) Unreadable.
/// When AcceptSupportedOnly is true, only form 1 is allowed. When
/// AcceptSupportedOnly is false, forms 1 and 2 are allowed.
ErrorOr<Module *>
getNaClLazyBitcodeModule(std::unique_ptr<MemoryBuffer> &&Buffer,
LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler = nullptr,
bool AcceptSupportedOnly = true);
/// Read the header of the specified stream and prepare for lazy
/// deserialization and streaming of function bodies. On error,
/// this returns null, and fills in *ErrMsg with an error description
/// if ErrMsg is non-null.
///
/// See getNaClLazyBitcodeModule for an explanation of argument
/// AcceptSupportedOnly.
/// TODO(kschimpf): Refactor this and getStreamedBitcodeModule to use
/// ErrorOr<Module *> API so that all methods have the same interface.
Module *getNaClStreamedBitcodeModule(
/// Read the header of the specified stream and prepare for lazy
/// deserialization and streaming of function bodies. On error,
/// this returns null, and fills in *ErrMsg with an error description
/// if ErrMsg is non-null.
///
/// See getNaClLazyBitcodeModule for an explanation of argument
/// AcceptSupportedOnly.
/// TODO(kschimpf): Refactor this and getStreamedBitcodeModule to use
/// ErrorOr<Module *> API so that all methods have the same interface.
Module *getNaClStreamedBitcodeModule(
const std::string &name, StreamingMemoryObject *streamer,
LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler = nullptr,
LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler = nullptr,
std::string *ErrMsg = nullptr, bool AcceptSupportedOnly = true);
/// Read the bitcode file from a buffer, returning the module.
///
/// See getNaClLazyBitcodeModule for an explanation of argument
/// AcceptSupportedOnly.
ErrorOr<Module *>
NaClParseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
/// Read the bitcode file from a buffer, returning the module.
///
/// See getNaClLazyBitcodeModule for an explanation of argument
/// AcceptSupportedOnly.
ErrorOr<Module *>
NaClParseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler = nullptr,
bool AcceptSupportedOnly = true);
/// Read the textual bitcode records in Filename, returning the module.
/// Note: If Filename is "-", stdin will be read.
///
/// TODO(kschimpf) Replace Verbose argument with a DiagnosticHandlerFunction.
ErrorOr<Module *> parseNaClBitcodeText(const std::string &Filename,
/// Read the textual bitcode records in Filename, returning the module.
/// Note: If Filename is "-", stdin will be read.
///
/// TODO(kschimpf) Replace Verbose argument with a DiagnosticHandlerFunction.
ErrorOr<Module *> parseNaClBitcodeText(const std::string &Filename,
LLVMContext &Context,
raw_ostream *Verbose = nullptr);
/// Write the specified module to the specified raw output stream, using
/// PNaCl wire format. For streams where it matters, the given stream
/// should be in "binary" mode.
///
/// The AcceptSupportedOnly argument is used to decide which PNaCl versions
/// of the PNaCl bitcode to generate. There are two forms:
/// 1) Writable and supported.
/// 2) Writable and unsupported. Allows testing of code before becoming
/// supported, as well as running experiments on the bitcode format.
/// When AcceptSupportedOnly is true, only form 1 is allowed. When
/// AcceptSupportedOnly is false, forms 1 and 2 are allowed.
void NaClWriteBitcodeToFile(const Module *M, raw_ostream &Out,
/// Write the specified module to the specified raw output stream, using
/// PNaCl wire format. For streams where it matters, the given stream
/// should be in "binary" mode.
///
/// The AcceptSupportedOnly argument is used to decide which PNaCl versions
/// of the PNaCl bitcode to generate. There are two forms:
/// 1) Writable and supported.
/// 2) Writable and unsupported. Allows testing of code before becoming
/// supported, as well as running experiments on the bitcode format.
/// When AcceptSupportedOnly is true, only form 1 is allowed. When
/// AcceptSupportedOnly is false, forms 1 and 2 are allowed.
void NaClWriteBitcodeToFile(const Module *M, raw_ostream &Out,
bool AcceptSupportedOnly = true);
/// isNaClBitcode - Return true if the given bytes are the magic bytes for
/// PNaCl bitcode wire format.
///
inline bool isNaClBitcode(const unsigned char *BufPtr,
/// isNaClBitcode - Return true if the given bytes are the magic bytes for
/// PNaCl bitcode wire format.
///
inline bool isNaClBitcode(const unsigned char *BufPtr,
const unsigned char *BufEnd) {
return BufPtr+4 <= BufEnd &&
BufPtr[0] == 'P' &&
BufPtr[1] == 'E' &&
BufPtr[2] == 'X' &&
BufPtr[3] == 'E';
}
/// NaClWriteHeader - Generate a default header (using the version
/// number defined by kPNaClVersion) and write to the corresponding
/// bitcode stream.
void NaClWriteHeader(NaClBitstreamWriter &Stream, bool AcceptSupportedOnly);
// NaClWriteHeader - Write the contents of the bitcode header to the
// corresponding bitcode stream.
void NaClWriteHeader(const NaClBitcodeHeader &Header,
return BufPtr + 4 <= BufEnd && BufPtr[0] == 'P' && BufPtr[1] == 'E' &&
BufPtr[2] == 'X' && BufPtr[3] == 'E';
}
/// NaClWriteHeader - Generate a default header (using the version
/// number defined by kPNaClVersion) and write to the corresponding
/// bitcode stream.
void NaClWriteHeader(NaClBitstreamWriter &Stream, bool AcceptSupportedOnly);
// NaClWriteHeader - Write the contents of the bitcode header to the
// corresponding bitcode stream.
void NaClWriteHeader(const NaClBitcodeHeader &Header,
NaClBitstreamWriter &Stream);
/// NaClObjDump - Read PNaCl bitcode file from input, and print a
/// textual representation of its contents. NoRecords and NoAssembly
/// define what should not be included in the dump.
bool NaClObjDump(MemoryBufferRef Input, raw_ostream &output,
bool NoRecords, bool NoAssembly);
/// NaClObjDump - Read PNaCl bitcode file from input, and print a
/// textual representation of its contents. NoRecords and NoAssembly
/// define what should not be included in the dump.
bool NaClObjDump(MemoryBufferRef Input, raw_ostream &output, bool NoRecords,
bool NoAssembly);
} // end llvm namespace
} // namespace llvm
#endif
......@@ -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_
......@@ -63,6 +63,6 @@ public:
virtual bool isValidAddress(uint64_t address) const = 0;
};
}
} // namespace llvm
#endif
......@@ -49,7 +49,7 @@ 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)
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);
}
} // 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