Subzero: Use a "known" version of clang-format.
There are two problems with "make format" and "make format-diff" in
Makefile.standalone:
1. You have to make sure clang-format and clang-format-diff.py are
available in $PATH.
2. Different users may have different versions installed (even for the
same user on different machines), leading to whitespace wars. Can't we
all just get along?
Since the normal LLVM build that Subzero depends on also exposes and
builds clang-format and friends, we might as well use it. The
clang-format binary is found in $LLVM_BIN_PATH, and clang-format-diff.py
is found relative to $LLVM_SRC_PATH. As long as the user's LLVM build
is fairly up to date, whitespace wars are unlikely.
Given this, there's a much higher incentive to use "make format"
regularly instead of "make format-diff". In particular, inline comments
on variable/field declaration lists can get lined up more nicely by
looking at the entire context, rather than the small diff window.
BUG= none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/877003003
diff --git a/crosstest/mem_intrin.cpp b/crosstest/mem_intrin.cpp
index 4a65995..612edce 100644
--- a/crosstest/mem_intrin.cpp
+++ b/crosstest/mem_intrin.cpp
@@ -14,9 +14,8 @@
/*
* Reset buf to the sequence of bytes: n, n+1, n+2 ... length - 1
*/
-static void __attribute__((noinline)) reset_buf(uint8_t *buf,
- uint8_t init,
- size_t length) {
+static void __attribute__((noinline))
+reset_buf(uint8_t *buf, uint8_t init, size_t length) {
size_t i;
size_t v = init;
for (i = 0; i < length; ++i)
@@ -27,8 +26,8 @@
* (Not doing a fletcher-32 checksum, since we are working with
* smaller buffers, whose total won't approach 2**16).
*/
-static int __attribute__((noinline)) fletcher_checksum(uint8_t *buf,
- size_t length) {
+static int __attribute__((noinline))
+fletcher_checksum(uint8_t *buf, size_t length) {
size_t i;
int sum = 0;
int sum_of_sums = 0;
diff --git a/crosstest/mem_intrin_main.cpp b/crosstest/mem_intrin_main.cpp
index b529273..70e3a67 100644
--- a/crosstest/mem_intrin_main.cpp
+++ b/crosstest/mem_intrin_main.cpp
@@ -13,22 +13,22 @@
#define STR(s) #s
void testFixedLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
-#define do_test_fixed(test_func) \
- for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
- ++TotalTests; \
- int llc_result = test_func(init_val); \
- int sz_result = Subzero_::test_func(init_val); \
- if (llc_result == sz_result) { \
- ++Passes; \
- } else { \
- ++Failures; \
- printf("Failure (%s): init_val=%d, llc=%d, sz=%d\n", \
- STR(test_func), init_val, llc_result, sz_result); \
- } \
+#define do_test_fixed(test_func) \
+ for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
+ ++TotalTests; \
+ int llc_result = test_func(init_val); \
+ int sz_result = Subzero_::test_func(init_val); \
+ if (llc_result == sz_result) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ printf("Failure (%s): init_val=%d, llc=%d, sz=%d\n", STR(test_func), \
+ init_val, llc_result, sz_result); \
+ } \
}
- do_test_fixed(memcpy_test_fixed_len)
- do_test_fixed(memmove_test_fixed_len)
+ do_test_fixed(memcpy_test_fixed_len);
+ do_test_fixed(memmove_test_fixed_len);
do_test_fixed(memset_test_fixed_len)
#undef do_test_fixed
}
@@ -36,24 +36,24 @@
void testVariableLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
uint8_t buf[256];
uint8_t buf2[256];
-#define do_test_variable(test_func) \
- for (size_t len = 4; len < 128; ++len) { \
- for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
- ++TotalTests; \
- int llc_result = test_func(buf, buf2, init_val, len); \
- int sz_result = Subzero_::test_func(buf, buf2, init_val, len); \
- if (llc_result == sz_result) { \
- ++Passes; \
- } else { \
- ++Failures; \
- printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \
- STR(test_func), init_val, len, llc_result, sz_result); \
- } \
- } \
+#define do_test_variable(test_func) \
+ for (size_t len = 4; len < 128; ++len) { \
+ for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
+ ++TotalTests; \
+ int llc_result = test_func(buf, buf2, init_val, len); \
+ int sz_result = Subzero_::test_func(buf, buf2, init_val, len); \
+ if (llc_result == sz_result) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \
+ STR(test_func), init_val, len, llc_result, sz_result); \
+ } \
+ } \
}
- do_test_variable(memcpy_test)
- do_test_variable(memmove_test)
+ do_test_variable(memcpy_test);
+ do_test_variable(memmove_test);
do_test_variable(memset_test)
#undef do_test_variable
}
diff --git a/crosstest/test_arith_main.cpp b/crosstest/test_arith_main.cpp
index 16b2c5e..49aa662 100644
--- a/crosstest/test_arith_main.cpp
+++ b/crosstest/test_arith_main.cpp
@@ -64,14 +64,14 @@
#define X(inst, op, isdiv, isshift) \
{ STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \
,
- UINTOP_TABLE
+ UINTOP_TABLE
#undef X
#define X(inst, op, isdiv, isshift) \
{ STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \
,
- SINTOP_TABLE
+ SINTOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) {
@@ -175,20 +175,16 @@
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
+ SINTOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements;
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -251,9 +247,9 @@
#define X(inst, op, func) \
{ STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \
,
- FPOP_TABLE
+ FPOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -310,9 +306,9 @@
#define X(inst, op, func) \
{ STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \
,
- FPOP_TABLE
+ FPOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
const static size_t NumElementsInType = 4;
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -363,4 +359,3 @@
<< " Failures=" << Failures << "\n";
return Failures;
}
-
diff --git a/crosstest/test_bitmanip.h b/crosstest/test_bitmanip.h
index c24c679..274fb5b 100644
--- a/crosstest/test_bitmanip.h
+++ b/crosstest/test_bitmanip.h
@@ -14,10 +14,10 @@
#include "test_bitmanip.def"
-#define X(inst, type) \
- type test_##inst(type a); \
- type test_alloca_##inst(type a); \
- type test_const_##inst(type ignored); \
+#define X(inst, type) \
+ type test_##inst(type a); \
+ type test_alloca_##inst(type a); \
+ type test_const_##inst(type ignored); \
type my_##inst(type a);
FOR_ALL_BMI_OP_TYPES(X)
diff --git a/crosstest/test_bitmanip_main.cpp b/crosstest/test_bitmanip_main.cpp
index 592ad7e..4901462 100644
--- a/crosstest/test_bitmanip_main.cpp
+++ b/crosstest/test_bitmanip_main.cpp
@@ -64,19 +64,13 @@
FuncType FuncLlc;
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) "_const", test_const_##inst, Subzero_::test_const_##inst \
- },
- BMI_OPS
+#define X(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
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -89,12 +83,10 @@
++Passes;
} else {
++Failures;
- std::cout << "test_" << Funcs[f].Name
- << (CHAR_BIT * sizeof(Type)) << "("
- << static_cast<uint64_t>(Value)
+ std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
+ << "(" << static_cast<uint64_t>(Value)
<< "): sz=" << static_cast<uint64_t>(ResultSz)
- << " llc=" << static_cast<uint64_t>(ResultLlc)
- << "\n";
+ << " llc=" << static_cast<uint64_t>(ResultLlc) << "\n";
}
}
}
diff --git a/crosstest/test_calling_conv.cpp b/crosstest/test_calling_conv.cpp
index 57bfa6f..e7fa616 100644
--- a/crosstest/test_calling_conv.cpp
+++ b/crosstest/test_calling_conv.cpp
@@ -75,9 +75,9 @@
}
void __attribute__((noinline))
-callee_vlvlivfvdviv(v4f32 arg1, int64_t arg2, v4f32 arg3, int64_t arg4, int arg5,
- v4f32 arg6, float arg7, v4f32 arg8, double arg9, v4f32 arg10,
- int arg11, v4f32 arg12) {
+callee_vlvlivfvdviv(v4f32 arg1, int64_t arg2, v4f32 arg3, int64_t arg4,
+ int arg5, v4f32 arg6, float arg7, v4f32 arg8, double arg9,
+ v4f32 arg10, int arg11, v4f32 arg12) {
switch (ArgNum) {
HANDLE_ARG(1);
HANDLE_ARG(2);
diff --git a/crosstest/test_calling_conv.h b/crosstest/test_calling_conv.h
index cd4a9d9..6cff49b 100644
--- a/crosstest/test_calling_conv.h
+++ b/crosstest/test_calling_conv.h
@@ -27,10 +27,10 @@
callee_i_Ty callee_alloca_i;
void caller_vvvvv();
-typedef void (callee_vvvvv_Ty)(v4si32, v4si32, v4si32, v4si32, v4si32);
+typedef void(callee_vvvvv_Ty)(v4si32, v4si32, v4si32, v4si32, v4si32);
callee_vvvvv_Ty callee_vvvvv;
void caller_vlvlivfvdviv();
typedef void(callee_vlvlivfvdviv_Ty)(v4f32, int64_t, v4f32, int64_t, int, v4f32,
- float, v4f32, double, v4f32, int, v4f32);
+ float, v4f32, double, v4f32, int, v4f32);
callee_vlvlivfvdviv_Ty callee_vlvlivfvdviv;
diff --git a/crosstest/test_calling_conv_main.cpp b/crosstest/test_calling_conv_main.cpp
index 9a6c2f6..f319a49 100644
--- a/crosstest/test_calling_conv_main.cpp
+++ b/crosstest/test_calling_conv_main.cpp
@@ -56,7 +56,7 @@
for (size_t i = 0; i < BUF_SIZE; ++i) {
if (i > 0)
OS << " ";
- OS << (unsigned) Buf[i];
+ OS << (unsigned)Buf[i];
}
return OS.str();
}
@@ -75,9 +75,9 @@
reinterpret_cast<CalleePtrTy>(&callee), \
} \
,
- TEST_FUNC_TABLE
+ TEST_FUNC_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
@@ -125,9 +125,9 @@
reinterpret_cast<CalleePtrTy>(&Subzero_::callee) \
} \
,
- TEST_FUNC_TABLE
+ TEST_FUNC_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
diff --git a/crosstest/test_cast_main.cpp b/crosstest/test_cast_main.cpp
index fd50011..dbd93aa 100644
--- a/crosstest/test_cast_main.cpp
+++ b/crosstest/test_cast_main.cpp
@@ -115,66 +115,62 @@
size_t Passes = 0;
size_t Failures = 0;
- volatile bool ValsUi1[] = { false, true };
+ volatile bool ValsUi1[] = {false, true};
static const size_t NumValsUi1 = sizeof(ValsUi1) / sizeof(*ValsUi1);
- volatile uint8_t ValsUi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
+ volatile uint8_t ValsUi8[] = {0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff};
static const size_t NumValsUi8 = sizeof(ValsUi8) / sizeof(*ValsUi8);
- volatile myint8_t ValsSi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
+ volatile myint8_t ValsSi8[] = {0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff};
static const size_t NumValsSi8 = sizeof(ValsSi8) / sizeof(*ValsSi8);
- volatile uint16_t ValsUi16[] = { 0, 1, 0x7e, 0x7f, 0x80,
- 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
- 0x8000, 0x8001, 0xfffe, 0xffff };
+ volatile uint16_t ValsUi16[] = {0, 1, 0x7e, 0x7f, 0x80,
+ 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
+ 0x8000, 0x8001, 0xfffe, 0xffff};
static const size_t NumValsUi16 = sizeof(ValsUi16) / sizeof(*ValsUi16);
- volatile int16_t ValsSi16[] = { 0, 1, 0x7e, 0x7f, 0x80,
- 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
- 0x8000, 0x8001, 0xfffe, 0xffff };
+ volatile int16_t ValsSi16[] = {0, 1, 0x7e, 0x7f, 0x80,
+ 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
+ 0x8000, 0x8001, 0xfffe, 0xffff};
static const size_t NumValsSi16 = sizeof(ValsSi16) / sizeof(*ValsSi16);
- volatile size_t ValsUi32[] = {
- 0, 1, 0x7e, 0x7f, 0x80,
- 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
- 0x8000, 0x8001, 0xfffe, 0xffff, 0x7ffffffe,
- 0x7fffffff, 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff
- };
+ volatile size_t ValsUi32[] = {0, 1, 0x7e, 0x7f,
+ 0x80, 0x81, 0xfe, 0xff,
+ 0x7ffe, 0x7fff, 0x8000, 0x8001,
+ 0xfffe, 0xffff, 0x7ffffffe, 0x7fffffff,
+ 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff};
static const size_t NumValsUi32 = sizeof(ValsUi32) / sizeof(*ValsUi32);
- volatile size_t ValsSi32[] = {
- 0, 1, 0x7e, 0x7f, 0x80,
- 0x81, 0xfe, 0xff, 0x7ffe, 0x7fff,
- 0x8000, 0x8001, 0xfffe, 0xffff, 0x7ffffffe,
- 0x7fffffff, 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff
- };
+ volatile size_t ValsSi32[] = {0, 1, 0x7e, 0x7f,
+ 0x80, 0x81, 0xfe, 0xff,
+ 0x7ffe, 0x7fff, 0x8000, 0x8001,
+ 0xfffe, 0xffff, 0x7ffffffe, 0x7fffffff,
+ 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff};
static const size_t NumValsSi32 = sizeof(ValsSi32) / sizeof(*ValsSi32);
volatile uint64_t 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
- };
+ 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_t 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
- };
+ 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;
diff --git a/crosstest/test_fcmp_main.cpp b/crosstest/test_fcmp_main.cpp
index b15d91f..359ecc0 100644
--- a/crosstest/test_fcmp_main.cpp
+++ b/crosstest/test_fcmp_main.cpp
@@ -51,7 +51,7 @@
assert(NegInf < PosInf);
assert(Zero < PosInf);
static volatile double InitValues[] =
- FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
+ FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
NumValues = sizeof(InitValues) / sizeof(*InitValues);
Values = InitValues;
}
@@ -72,7 +72,7 @@
Subzero_fcmp##cmp##Double, fcmp##cmp##Double \
} \
,
- FCMP_TABLE
+ FCMP_TABLE
#undef X
};
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
diff --git a/crosstest/test_global.cpp b/crosstest/test_global.cpp
index f28afb8..b2f52b0 100644
--- a/crosstest/test_global.cpp
+++ b/crosstest/test_global.cpp
@@ -29,7 +29,7 @@
int ArrayInitPartial[10] = {60, 70, 80, 90, 100};
int ArrayInitFull[] = {10, 20, 30, 40, 50};
const int ArrayConst[] = {-10, -20, -30};
-static double ArrayDouble[10] = { 0.5, 1.5, 2.5, 3.5 };
+static double ArrayDouble[10] = {0.5, 1.5, 2.5, 3.5};
static struct {
int Array1[5];
@@ -43,12 +43,12 @@
} NestedStuff;
uint8_t *Pointer5;
} StructEx = {
- { 10, 20, 30, 40, 50 },
- ExternName1,
- { 0.5, 1.5, 2.5 },
- ExternName4,
- { ExternName3, {1000, 1010, 1020}, ExternName2 },
- ExternName5,
+ {10, 20, 30, 40, 50},
+ ExternName1,
+ {0.5, 1.5, 2.5},
+ ExternName4,
+ {ExternName3, {1000, 1010, 1020}, ExternName2},
+ ExternName5,
};
#define ARRAY(a) \
@@ -67,7 +67,7 @@
ARRAY(ArrayDouble),
{(uint8_t *)(ArrayInitPartial + 2),
sizeof(ArrayInitPartial) - 2 * sizeof(int)},
- { (uint8_t*)(&StructEx), sizeof(StructEx) },
+ {(uint8_t *)(&StructEx), sizeof(StructEx)},
};
size_t NumArraysElements = sizeof(Arrays) / sizeof(*Arrays);
diff --git a/crosstest/test_global_main.cpp b/crosstest/test_global_main.cpp
index f34b3c9..5383cb7 100644
--- a/crosstest/test_global_main.cpp
+++ b/crosstest/test_global_main.cpp
@@ -68,8 +68,7 @@
} else {
++Failures;
std::cout << i << ":LlcArray[" << i << "] = " << (int)LlcArray[i]
- << ", SzArray[" << i << "] = " << (int)SzArray[i]
- << "\n";
+ << ", SzArray[" << i << "] = " << (int)SzArray[i] << "\n";
}
}
}
diff --git a/crosstest/test_icmp_main.cpp b/crosstest/test_icmp_main.cpp
index fa2eebd..dbfe515 100644
--- a/crosstest/test_icmp_main.cpp
+++ b/crosstest/test_icmp_main.cpp
@@ -27,12 +27,12 @@
#include "test_icmp.h"
}
-volatile unsigned Values[] = { 0x0, 0x1, 0x7ffffffe, 0x7fffffff,
- 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff,
- 0x7e, 0x7f, 0x80, 0x81,
- 0xfe, 0xff, 0x100, 0x101,
- 0x7ffe, 0x7fff, 0x8000, 0x8001,
- 0xfffe, 0xffff, 0x10000, 0x10001, };
+volatile unsigned Values[] = {
+ 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001,
+ 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81,
+ 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff,
+ 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001,
+};
const static size_t NumValues = sizeof(Values) / sizeof(*Values);
template <typename TypeUnsigned, typename TypeSigned>
@@ -54,13 +54,13 @@
#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
+ ICMP_S_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) {
@@ -141,13 +141,13 @@
#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
+ ICMP_S_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements;
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -206,9 +206,7 @@
#define X(cmp, op) \
{ STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \
,
- ICMP_U_TABLE
- ICMP_S_TABLE
- };
+ ICMP_U_TABLE ICMP_S_TABLE};
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
const static size_t NumElements = Vectors<T>::NumElements;
const static size_t MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING = 8;
diff --git a/crosstest/test_select_main.cpp b/crosstest/test_select_main.cpp
index 36d6c7e..5ccdcfb 100644
--- a/crosstest/test_select_main.cpp
+++ b/crosstest/test_select_main.cpp
@@ -32,13 +32,10 @@
typedef typename Vectors<T>::Ty Ty;
typedef typename Vectors<TI1>::Ty TyI1;
volatile unsigned Values[] = {
- 0x0, 0x1, 0x7ffffffe, 0x7fffffff,
- 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff,
- 0x7e, 0x7f, 0x80, 0x81,
- 0xfe, 0xff, 0x100, 0x101,
- 0x7ffe, 0x7fff, 0x8000, 0x8001,
- 0xfffe, 0xffff, 0x10000, 0x10001
- };
+ 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001,
+ 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81,
+ 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff,
+ 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001};
static const size_t NumValues = sizeof(Values) / sizeof(*Values);
static const size_t NumElements = Vectors<T>::NumElements;
PRNG Index;
@@ -67,8 +64,9 @@
}
}
-template<> void
-testSelect<v4f32, v4i1>(size_t &TotalTests, size_t &Passes, size_t &Failures) {
+template <>
+void testSelect<v4f32, v4i1>(size_t &TotalTests, size_t &Passes,
+ size_t &Failures) {
static const float NegInf = -1.0 / 0.0;
static const float PosInf = 1.0 / 0.0;
static const float Nan = 0.0 / 0.0;
@@ -102,7 +100,7 @@
}
}
-template<typename T>
+template <typename T>
void testSelectI1(size_t &TotalTests, size_t &Passes, size_t &Failures) {
typedef typename Vectors<T>::Ty Ty;
static const size_t NumElements = Vectors<T>::NumElements;
diff --git a/crosstest/test_stacksave.c b/crosstest/test_stacksave.c
index b0e9b5e..6654880 100644
--- a/crosstest/test_stacksave.c
+++ b/crosstest/test_stacksave.c
@@ -29,9 +29,7 @@
return (vla[start] << 2) + (vla[mid] << 1) + vla[size - 1];
}
-static uint32_t __attribute__((noinline)) foo(uint32_t x) {
- return x * x;
-}
+static uint32_t __attribute__((noinline)) foo(uint32_t x) { return x * x; }
/* NOTE: This has 1 stacksave, because the vla is in a loop and should
* be freed before the next iteration.
diff --git a/crosstest/test_stacksave.h b/crosstest/test_stacksave.h
index 8d0af01..cb4684d 100644
--- a/crosstest/test_stacksave.h
+++ b/crosstest/test_stacksave.h
@@ -15,12 +15,12 @@
#ifndef TEST_STACKSAVE_H
#define TEST_STACKSAVE_H
-#define DECLARE_TESTS(PREFIX) \
- uint32_t PREFIX##test_basic_vla(uint32_t size, uint32_t start, \
- uint32_t inc); \
- uint32_t PREFIX##test_vla_in_loop(uint32_t size, uint32_t start, \
- uint32_t inc); \
- uint32_t PREFIX##test_two_vlas_in_loops(uint32_t size, uint32_t start, \
+#define DECLARE_TESTS(PREFIX) \
+ uint32_t PREFIX##test_basic_vla(uint32_t size, uint32_t start, \
+ uint32_t inc); \
+ uint32_t PREFIX##test_vla_in_loop(uint32_t size, uint32_t start, \
+ uint32_t inc); \
+ uint32_t PREFIX##test_two_vlas_in_loops(uint32_t size, uint32_t start, \
uint32_t inc);
#endif
diff --git a/crosstest/test_stacksave_main.c b/crosstest/test_stacksave_main.c
index a5ab248..0691025 100644
--- a/crosstest/test_stacksave_main.c
+++ b/crosstest/test_stacksave_main.c
@@ -31,12 +31,10 @@
const char *Name;
FuncType FuncLlc;
FuncType FuncSz;
- } Funcs[] = {
- { "test_basic_vla", test_basic_vla, Subzero_test_basic_vla },
- { "test_vla_in_loop", test_vla_in_loop, Subzero_test_vla_in_loop },
- { "test_two_vlas_in_loops", test_two_vlas_in_loops,
- Subzero_test_two_vlas_in_loops }
- };
+ } Funcs[] = {{"test_basic_vla", test_basic_vla, Subzero_test_basic_vla},
+ {"test_vla_in_loop", test_vla_in_loop, Subzero_test_vla_in_loop},
+ {"test_two_vlas_in_loops", test_two_vlas_in_loops,
+ Subzero_test_two_vlas_in_loops}};
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
const uint32_t size_to_test = 128;
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -55,7 +53,7 @@
}
}
}
- printf("TotalTests=%zu Passes=%zu Failures=%zu\n",
- TotalTests, Passes, Failures);
+ printf("TotalTests=%zu Passes=%zu Failures=%zu\n", TotalTests, Passes,
+ Failures);
return Failures;
}
diff --git a/crosstest/test_sync_atomic.cpp b/crosstest/test_sync_atomic.cpp
index 9cfb963..d1578eb 100644
--- a/crosstest/test_sync_atomic.cpp
+++ b/crosstest/test_sync_atomic.cpp
@@ -19,36 +19,36 @@
#include "test_sync_atomic.h"
-#define X(inst, type) \
- type test_##inst(bool fetch_first, volatile type *ptr, type a) { \
- if (fetch_first) { \
- return __sync_fetch_and_##inst(ptr, a); \
- } else { \
- return __sync_##inst##_and_fetch(ptr, a); \
- } \
- } \
- type test_alloca_##inst(bool fetch, volatile type *ptr, type a) { \
- const size_t buf_size = 8; \
- type buf[buf_size]; \
- for (size_t i = 0; i < buf_size; ++i) { \
- if (fetch) { \
- buf[i] = __sync_fetch_and_##inst(ptr, a); \
- } else { \
- buf[i] = __sync_##inst##_and_fetch(ptr, a); \
- } \
- } \
- type sum = 0; \
- for (size_t i = 0; i < buf_size; ++i) { \
- sum += buf[i]; \
- } \
- return sum; \
- } \
- type test_const_##inst(bool fetch, volatile type *ptr, type ign) { \
- if (fetch) { \
- return __sync_fetch_and_##inst(ptr, 42); \
- } else { \
- return __sync_##inst##_and_fetch(ptr, 99); \
- } \
+#define X(inst, type) \
+ type test_##inst(bool fetch_first, volatile type *ptr, type a) { \
+ if (fetch_first) { \
+ return __sync_fetch_and_##inst(ptr, a); \
+ } else { \
+ return __sync_##inst##_and_fetch(ptr, a); \
+ } \
+ } \
+ type test_alloca_##inst(bool fetch, volatile type *ptr, type a) { \
+ const size_t buf_size = 8; \
+ type buf[buf_size]; \
+ for (size_t i = 0; i < buf_size; ++i) { \
+ if (fetch) { \
+ buf[i] = __sync_fetch_and_##inst(ptr, a); \
+ } else { \
+ buf[i] = __sync_##inst##_and_fetch(ptr, a); \
+ } \
+ } \
+ type sum = 0; \
+ for (size_t i = 0; i < buf_size; ++i) { \
+ sum += buf[i]; \
+ } \
+ return sum; \
+ } \
+ type test_const_##inst(bool fetch, volatile type *ptr, type ign) { \
+ if (fetch) { \
+ return __sync_fetch_and_##inst(ptr, 42); \
+ } else { \
+ return __sync_##inst##_and_fetch(ptr, 99); \
+ } \
}
FOR_ALL_RMWOP_TYPES(X)
diff --git a/crosstest/test_sync_atomic.h b/crosstest/test_sync_atomic.h
index ce24a07..3db2c3d 100644
--- a/crosstest/test_sync_atomic.h
+++ b/crosstest/test_sync_atomic.h
@@ -14,9 +14,9 @@
#include "test_sync_atomic.def"
-#define X(inst, type) \
- type test_##inst(bool fetch_first, volatile type *ptr, type a); \
- type test_alloca_##inst(bool fetch, volatile type *ptr, type a); \
+#define X(inst, type) \
+ type test_##inst(bool fetch_first, volatile type *ptr, type a); \
+ type test_alloca_##inst(bool fetch, volatile type *ptr, type a); \
type test_const_##inst(bool fetch, volatile type *ptr, type ignored);
FOR_ALL_RMWOP_TYPES(X)
diff --git a/crosstest/test_sync_atomic_main.cpp b/crosstest/test_sync_atomic_main.cpp
index 6a00f31..c9bf579 100644
--- a/crosstest/test_sync_atomic_main.cpp
+++ b/crosstest/test_sync_atomic_main.cpp
@@ -33,27 +33,27 @@
}
volatile uint64_t 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 };
+ 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,27 +65,21 @@
} AtomicLocs;
template <typename Type>
-void testAtomicRMW(volatile Type *AtomicLoc,
- size_t &TotalTests, size_t &Passes, size_t &Failures) {
- typedef Type (*FuncType)(bool, volatile Type*, Type);
+void testAtomicRMW(volatile Type *AtomicLoc, size_t &TotalTests, size_t &Passes,
+ size_t &Failures) {
+ typedef Type (*FuncType)(bool, volatile Type *, Type);
static struct {
const char *Name;
FuncType FuncLlc;
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) "_const", test_const_##inst, Subzero_::test_const_##inst \
- },
- RMWOP_TABLE
+#define X(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
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -97,26 +91,22 @@
bool fetch_first = k;
++TotalTests;
*AtomicLoc = Value1;
- Type ResultSz1 = Funcs[f].FuncSz(
- fetch_first, AtomicLoc, Value2);
+ Type ResultSz1 = Funcs[f].FuncSz(fetch_first, AtomicLoc, Value2);
Type ResultSz2 = *AtomicLoc;
*AtomicLoc = Value1;
- Type ResultLlc1 = Funcs[f].FuncLlc(
- fetch_first, AtomicLoc, Value2);
+ Type ResultLlc1 = Funcs[f].FuncLlc(fetch_first, AtomicLoc, Value2);
Type ResultLlc2 = *AtomicLoc;
if (ResultSz1 == ResultLlc1 && ResultSz2 == ResultLlc2) {
++Passes;
} else {
++Failures;
- std::cout << "test_" << Funcs[f].Name
- << (CHAR_BIT * sizeof(Type)) << "("
- << static_cast<uint64_t>(Value1) << ", "
+ std::cout << "test_" << Funcs[f].Name << (CHAR_BIT * sizeof(Type))
+ << "(" << static_cast<uint64_t>(Value1) << ", "
<< static_cast<uint64_t>(Value2)
<< "): sz1=" << static_cast<uint64_t>(ResultSz1)
<< " llc1=" << static_cast<uint64_t>(ResultLlc1)
<< " sz2=" << static_cast<uint64_t>(ResultSz2)
- << " llc2=" << static_cast<uint64_t>(ResultLlc2)
- << "\n";
+ << " llc2=" << static_cast<uint64_t>(ResultLlc2) << "\n";
}
}
}
@@ -170,18 +160,16 @@
}
}
-template <typename Type>
-struct ThreadData {
- Type (*FuncPtr)(bool, volatile Type*, Type);
+template <typename Type> struct ThreadData {
+ Type (*FuncPtr)(bool, volatile Type *, Type);
bool Fetch;
volatile Type *Ptr;
Type Adjustment;
};
-template <typename Type>
-void *threadWrapper(void *Data) {
+template <typename Type> void *threadWrapper(void *Data) {
const size_t NumReps = 8000;
- ThreadData<Type> *TData = reinterpret_cast<ThreadData<Type>*>(Data);
+ ThreadData<Type> *TData = reinterpret_cast<ThreadData<Type> *>(Data);
for (size_t i = 0; i < NumReps; ++i) {
(void)TData->FuncPtr(TData->Fetch, TData->Ptr, TData->Adjustment);
}
@@ -191,26 +179,22 @@
template <typename Type>
void testAtomicRMWThreads(volatile Type *AtomicLoc, size_t &TotalTests,
size_t &Passes, size_t &Failures) {
- typedef Type (*FuncType)(bool, volatile Type*, Type);
+ typedef Type (*FuncType)(bool, volatile Type *, Type);
static struct {
const char *Name;
FuncType FuncLlc;
FuncType FuncSz;
} Funcs[] = {
-#define X(inst) \
- { \
- STR(inst), test_##inst, Subzero_::test_##inst \
- }, \
- { \
- STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst \
- },
- RMWOP_TABLE
+#define X(inst) \
+ { STR(inst), test_##inst, Subzero_::test_##inst } \
+ , {STR(inst) "_alloca", test_alloca_##inst, Subzero_::test_alloca_##inst},
+ RMWOP_TABLE
#undef X
- };
+ };
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
// Just test a few values, otherwise it takes a *really* long time.
- volatile uint64_t ValuesSubset[] = { 1, 0x7e, 0x000fffffffffffffffll };
+ volatile uint64_t ValuesSubset[] = {1, 0x7e, 0x000fffffffffffffffll};
const size_t NumValuesSubset = sizeof(ValuesSubset) / sizeof(*ValuesSubset);
for (size_t f = 0; f < NumFuncs; ++f) {
@@ -219,10 +203,10 @@
for (size_t j = 0; j < NumValuesSubset; ++j) {
Type Value2 = static_cast<Type>(ValuesSubset[j]);
bool fetch_first = true;
- ThreadData<Type> TDataSz = {
- Funcs[f].FuncSz, fetch_first, AtomicLoc, Value2 };
- ThreadData<Type> TDataLlc = {
- Funcs[f].FuncLlc, fetch_first, AtomicLoc, Value2 };
+ ThreadData<Type> TDataSz = {Funcs[f].FuncSz, fetch_first, AtomicLoc,
+ Value2};
+ ThreadData<Type> TDataLlc = {Funcs[f].FuncLlc, fetch_first, AtomicLoc,
+ Value2};
++TotalTests;
const size_t NumThreads = 4;
pthread_t t[NumThreads];
@@ -243,8 +227,8 @@
for (size_t m = 0; m < NumThreads; ++m) {
if (pthread_create(&t[m], NULL, &threadWrapper<Type>,
m % 2 == 0
- ? reinterpret_cast<void *>(&TDataLlc)
- : reinterpret_cast<void *>(&TDataSz)) != 0) {
+ ? reinterpret_cast<void *>(&TDataLlc)
+ : reinterpret_cast<void *>(&TDataSz)) != 0) {
++Failures;
std::cout << "pthread_create failed w/ " << strerror(errno) << "\n";
abort();
@@ -268,8 +252,7 @@
<< static_cast<uint64_t>(Value1) << ", "
<< static_cast<uint64_t>(Value2)
<< "): llc=" << static_cast<uint64_t>(ResultLlc)
- << " mixed=" << static_cast<uint64_t>(ResultMixed)
- << "\n";
+ << " mixed=" << static_cast<uint64_t>(ResultMixed) << "\n";
}
}
}
@@ -285,22 +268,17 @@
testAtomicRMW<uint16_t>(&AtomicLocs.l16, TotalTests, Passes, Failures);
testAtomicRMW<uint32_t>(&AtomicLocs.l32, TotalTests, Passes, Failures);
testAtomicRMW<uint64_t>(&AtomicLocs.l64, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint8_t>(
- &AtomicLocs.l8, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint16_t>(
- &AtomicLocs.l16, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint32_t>(
- &AtomicLocs.l32, TotalTests, Passes, Failures);
- testValCompareAndSwap<uint64_t>(
- &AtomicLocs.l64, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint8_t>(
- &AtomicLocs.l8, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint16_t>(
- &AtomicLocs.l16, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint32_t>(
- &AtomicLocs.l32, TotalTests, Passes, Failures);
- testAtomicRMWThreads<uint64_t>(
- &AtomicLocs.l64, TotalTests, Passes, Failures);
+ testValCompareAndSwap<uint8_t>(&AtomicLocs.l8, TotalTests, Passes, Failures);
+ testValCompareAndSwap<uint16_t>(&AtomicLocs.l16, TotalTests, Passes,
+ Failures);
+ testValCompareAndSwap<uint32_t>(&AtomicLocs.l32, TotalTests, Passes,
+ Failures);
+ testValCompareAndSwap<uint64_t>(&AtomicLocs.l64, TotalTests, Passes,
+ Failures);
+ testAtomicRMWThreads<uint8_t>(&AtomicLocs.l8, TotalTests, Passes, Failures);
+ testAtomicRMWThreads<uint16_t>(&AtomicLocs.l16, TotalTests, Passes, Failures);
+ testAtomicRMWThreads<uint32_t>(&AtomicLocs.l32, TotalTests, Passes, Failures);
+ testAtomicRMWThreads<uint64_t>(&AtomicLocs.l64, TotalTests, Passes, Failures);
std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
<< " Failures=" << Failures << "\n";