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/+/50169
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/third_party/subzero/crosstest/mem_intrin.cpp b/third_party/subzero/crosstest/mem_intrin.cpp
index b84cdb9..2dfd60f 100644
--- a/third_party/subzero/crosstest/mem_intrin.cpp
+++ b/third_party/subzero/crosstest/mem_intrin.cpp
@@ -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"
diff --git a/third_party/subzero/crosstest/mem_intrin_main.cpp b/third_party/subzero/crosstest/mem_intrin_main.cpp
index e20a9ab..f032cf9 100644
--- a/third_party/subzero/crosstest/mem_intrin_main.cpp
+++ b/third_party/subzero/crosstest/mem_intrin_main.cpp
@@ -1,8 +1,8 @@
/* 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"
diff --git a/third_party/subzero/crosstest/test_arith.h b/third_party/subzero/crosstest/test_arith.h
index 60d3bb1..88996ba 100644
--- a/third_party/subzero/crosstest/test_arith.h
+++ b/third_party/subzero/crosstest/test_arith.h
@@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//
-#include <stdint.h>
#include "test_arith.def"
#include "xdefs.h"
+#include <stdint.h>
#include "vectors.h"
diff --git a/third_party/subzero/crosstest/test_arith_main.cpp b/third_party/subzero/crosstest/test_arith_main.cpp
index 9eb4d75..88ae2a5 100644
--- a/third_party/subzero/crosstest/test_arith_main.cpp
+++ b/third_party/subzero/crosstest/test_arith_main.cpp
@@ -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 @@
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 @@
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 @@
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 @@
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
};
diff --git a/third_party/subzero/crosstest/test_bitmanip_main.cpp b/third_party/subzero/crosstest/test_bitmanip_main.cpp
index 9e643ff..827f0e7 100644
--- a/third_party/subzero/crosstest/test_bitmanip_main.cpp
+++ b/third_party/subzero/crosstest/test_bitmanip_main.cpp
@@ -29,19 +29,56 @@
#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 @@
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
diff --git a/third_party/subzero/crosstest/test_calling_conv.cpp b/third_party/subzero/crosstest/test_calling_conv.cpp
index d6a8b1d..bac49c8 100644
--- a/third_party/subzero/crosstest/test_calling_conv.cpp
+++ b/third_party/subzero/crosstest/test_calling_conv.cpp
@@ -50,9 +50,8 @@
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) \
diff --git a/third_party/subzero/crosstest/test_calling_conv_main.cpp b/third_party/subzero/crosstest/test_calling_conv_main.cpp
index 7564537..afae466 100644
--- a/third_party/subzero/crosstest/test_calling_conv_main.cpp
+++ b/third_party/subzero/crosstest/test_calling_conv_main.cpp
@@ -72,19 +72,21 @@
#ifdef MIPS32
#define X(caller, callee, argc) \
{ \
- STR(caller), STR(callee), argc, &caller, &Subzero_::caller, \
- reinterpret_cast<CalleePtrTy>(&Subzero_::callee), \
- } \
- ,
+ STR(caller), \
+ STR(callee), \
+ argc, \
+ &caller, \
+ &Subzero_::caller, \
+ reinterpret_cast<CalleePtrTy>(&Subzero_::callee), \
+ },
TEST_FUNC_TABLE
#undef X
#else
#define X(caller, callee, argc) \
{ \
- STR(caller), STR(callee), argc, &caller, &Subzero_::caller, \
- reinterpret_cast<CalleePtrTy>(&callee), \
- } \
- ,
+ STR(caller), STR(callee), argc, \
+ &caller, &Subzero_::caller, reinterpret_cast<CalleePtrTy>(&callee), \
+ },
TEST_FUNC_TABLE
#undef X
#endif
@@ -130,12 +132,12 @@
CalleePtrTy Callee, Subzero_Callee;
} Funcs[] = {
#define X(caller, callee, argc) \
- { \
- STR(caller), STR(callee), argc, &caller, \
- reinterpret_cast<CalleePtrTy>(&callee), \
- reinterpret_cast<CalleePtrTy>(&Subzero_::callee) \
- } \
- ,
+ {STR(caller), \
+ STR(callee), \
+ argc, \
+ &caller, \
+ reinterpret_cast<CalleePtrTy>(&callee), \
+ reinterpret_cast<CalleePtrTy>(&Subzero_::callee)},
TEST_FUNC_TABLE
#undef X
};
diff --git a/third_party/subzero/crosstest/test_cast.cpp b/third_party/subzero/crosstest/test_cast.cpp
index 0532973..a943699 100644
--- a/third_party/subzero/crosstest/test_cast.cpp
+++ b/third_party/subzero/crosstest/test_cast.cpp
@@ -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) {
diff --git a/third_party/subzero/crosstest/test_cast_main.cpp b/third_party/subzero/crosstest/test_cast_main.cpp
index 1104090..289956c 100644
--- a/third_party/subzero/crosstest/test_cast_main.cpp
+++ b/third_party/subzero/crosstest/test_cast_main.cpp
@@ -179,20 +179,64 @@
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;
diff --git a/third_party/subzero/crosstest/test_fcmp_main.cpp b/third_party/subzero/crosstest/test_fcmp_main.cpp
index 5d195ca..40fdbab 100644
--- a/third_party/subzero/crosstest/test_fcmp_main.cpp
+++ b/third_party/subzero/crosstest/test_fcmp_main.cpp
@@ -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 @@
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 @@
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
};
diff --git a/third_party/subzero/crosstest/test_global.cpp b/third_party/subzero/crosstest/test_global.cpp
index b5519a0..7b5d4c1 100644
--- a/third_party/subzero/crosstest/test_global.cpp
+++ b/third_party/subzero/crosstest/test_global.cpp
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#include <stdint.h>
#include <cstdlib>
+#include <stdint.h>
#include "test_global.h"
diff --git a/third_party/subzero/crosstest/test_global_main.cpp b/third_party/subzero/crosstest/test_global_main.cpp
index 6b4eec7..5993bd0 100644
--- a/third_party/subzero/crosstest/test_global_main.cpp
+++ b/third_party/subzero/crosstest/test_global_main.cpp
@@ -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_ {
diff --git a/third_party/subzero/crosstest/test_icmp_main.cpp b/third_party/subzero/crosstest/test_icmp_main.cpp
index 42177ff..1279f8d 100644
--- a/third_party/subzero/crosstest/test_icmp_main.cpp
+++ b/third_party/subzero/crosstest/test_icmp_main.cpp
@@ -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 @@
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 @@
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 @@
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 @@
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;
diff --git a/third_party/subzero/crosstest/test_sync_atomic_main.cpp b/third_party/subzero/crosstest/test_sync_atomic_main.cpp
index 187783e..39d5871 100644
--- a/third_party/subzero/crosstest/test_sync_atomic_main.cpp
+++ b/third_party/subzero/crosstest/test_sync_atomic_main.cpp
@@ -33,18 +33,48 @@
#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 @@
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 @@
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
};
diff --git a/third_party/subzero/crosstest/test_vector_ops.h b/third_party/subzero/crosstest/test_vector_ops.h
index e9e8737..b20168c 100644
--- a/third_party/subzero/crosstest/test_vector_ops.h
+++ b/third_party/subzero/crosstest/test_vector_ops.h
@@ -44,18 +44,23 @@
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)
diff --git a/third_party/subzero/crosstest/vectors.h b/third_party/subzero/crosstest/vectors.h
index e4c163e..4d37b90 100644
--- a/third_party/subzero/crosstest/vectors.h
+++ b/third_party/subzero/crosstest/vectors.h
@@ -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
diff --git a/third_party/subzero/pnacl-llvm/DataStream.cpp b/third_party/subzero/pnacl-llvm/DataStream.cpp
index 3b10fc5..1472935 100644
--- a/third_party/subzero/pnacl-llvm/DataStream.cpp
+++ b/third_party/subzero/pnacl-llvm/DataStream.cpp
@@ -15,8 +15,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/DataStream.h"
-#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
#include <string>
@@ -45,14 +45,15 @@
namespace llvm {
DataStreamer::~DataStreamer() {}
-}
+} // namespace llvm
namespace {
// Very simple stream backed by a file. Mostly useful for stdin and debugging;
// actual file access is probably still best done with mmap.
class DataFileStreamer : public DataStreamer {
- int Fd;
+ int Fd;
+
public:
DataFileStreamer() : Fd(0) {}
~DataFileStreamer() override { close(Fd); }
@@ -72,14 +73,14 @@
}
};
-}
+} // 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);
diff --git a/third_party/subzero/pnacl-llvm/MemoryObject.cpp b/third_party/subzero/pnacl-llvm/MemoryObject.cpp
index d796acf..dff3ed3 100644
--- a/third_party/subzero/pnacl-llvm/MemoryObject.cpp
+++ b/third_party/subzero/pnacl-llvm/MemoryObject.cpp
@@ -9,6 +9,5 @@
#include "llvm/Support/MemoryObject.h"
using namespace llvm;
-
-MemoryObject::~MemoryObject() {
-}
+
+MemoryObject::~MemoryObject() {}
diff --git a/third_party/subzero/pnacl-llvm/NaClBitCodes.cpp b/third_party/subzero/pnacl-llvm/NaClBitCodes.cpp
index 7267411..e20e961 100644
--- a/third_party/subzero/pnacl-llvm/NaClBitCodes.cpp
+++ b/third_party/subzero/pnacl-llvm/NaClBitCodes.cpp
@@ -13,30 +13,26 @@
//===----------------------------------------------------------------------===//
#include "llvm/Bitcode/NaCl/NaClBitCodes.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
const bool NaClBitCodeAbbrevOp::HasValueArray[] = {
- true, // Literal
- true, // Fixed
- true, // VBR
- false, // Array
- false // Char6
+ true, // Literal
+ true, // Fixed
+ true, // VBR
+ false, // Array
+ false // Char6
};
const char *NaClBitCodeAbbrevOp::EncodingNameArray[] = {
- "Literal",
- "Fixed",
- "VBR",
- "Array",
- "Char6"
-};
+ "Literal", "Fixed", "VBR", "Array", "Char6"};
NaClBitCodeAbbrevOp::NaClBitCodeAbbrevOp(Encoding E, uint64_t Data)
: Enc(E), Val(Data) {
- if (isValid(E, Data)) return;
+ if (isValid(E, Data))
+ return;
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Invalid NaClBitCodeAbbrevOp(" << E << ", " << Data << ")";
@@ -57,7 +53,7 @@
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 @@
}
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 @@
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 @@
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 @@
// 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 @@
// 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)
diff --git a/third_party/subzero/pnacl-llvm/NaClBitcodeDecoders.cpp b/third_party/subzero/pnacl-llvm/NaClBitcodeDecoders.cpp
index 450499a..d64d521 100644
--- a/third_party/subzero/pnacl-llvm/NaClBitcodeDecoders.cpp
+++ b/third_party/subzero/pnacl-llvm/NaClBitcodeDecoders.cpp
@@ -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 @@
}
}
-
-}
-}
+} // namespace naclbitc
+} // namespace llvm
diff --git a/third_party/subzero/pnacl-llvm/NaClBitcodeHeader.cpp b/third_party/subzero/pnacl-llvm/NaClBitcodeHeader.cpp
index 8a65f50..2833005 100644
--- a/third_party/subzero/pnacl-llvm/NaClBitcodeHeader.cpp
+++ b/third_party/subzero/pnacl-llvm/NaClBitcodeHeader.cpp
@@ -15,8 +15,8 @@
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/StreamingMemoryObject.h"
+#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <iomanip>
@@ -28,24 +28,24 @@
// The name for each ID tag.
static const char *TagName[] = {
- "Invalid", // kInvalid
- "PNaCl Version", // kPNaClVersion
- "Align bitcode records" // kAlignBitcodeRecords
+ "Invalid", // kInvalid
+ "PNaCl Version", // kPNaClVersion
+ "Align bitcode records" // kAlignBitcodeRecords
};
// The name for each field type.
static const char *FieldTypeName[] = {
- "uint8[]", // kBufferType
- "uint32", // kUInt32Type
- "flag", // kFlagType
- "unknown" // kUnknownType
+ "uint8[]", // kBufferType
+ "uint32", // kUInt32Type
+ "flag", // kFlagType
+ "unknown" // kUnknownType
};
// The type associated with each ID tag.
static const NaClBitcodeHeaderField::FieldType ExpectedType[] = {
- NaClBitcodeHeaderField::kUnknownType, // kInvalid
- NaClBitcodeHeaderField::kUInt32Type, // kPNaClVersion
- NaClBitcodeHeaderField::kFlagType // kAlignBitcodeRecords
+ NaClBitcodeHeaderField::kUnknownType, // kInvalid
+ NaClBitcodeHeaderField::kUInt32Type, // kPNaClVersion
+ NaClBitcodeHeaderField::kFlagType // kAlignBitcodeRecords
};
} // end of anonymous namespace
@@ -59,10 +59,10 @@
}
NaClBitcodeHeaderField::NaClBitcodeHeaderField()
- : ID(kInvalid), FType(kBufferType), Len(0), Data(0) {}
+ : ID(kInvalid), FType(kBufferType), Len(0), Data(0) {}
NaClBitcodeHeaderField::NaClBitcodeHeaderField(Tag MyID)
- : ID(MyID), FType(kFlagType), Len(0), Data(0) {
+ : ID(MyID), FType(kFlagType), Len(0), Data(0) {
assert(MyID <= kTag_MAX);
}
@@ -94,7 +94,7 @@
bool NaClBitcodeHeaderField::Write(uint8_t *Buf, size_t BufLen) const {
size_t FieldsLen = kTagLenSize + Len;
- size_t PadLen = (WordSize - (FieldsLen & (WordSize-1))) & (WordSize-1);
+ size_t PadLen = (WordSize - (FieldsLen & (WordSize - 1))) & (WordSize - 1);
// Ensure buffer is large enough and that length can be represented
// in 32 bits
if (BufLen < FieldsLen + PadLen ||
@@ -182,7 +182,7 @@
UnsupportedMessage = "Invalid PNaCl bitcode header";
if (isBitcode(BufPtr, BufEnd)) {
UnsupportedMessage += " (to run in Chrome, bitcode files must be "
- "finalized using pnacl-finalize)";
+ "finalized using pnacl-finalize)";
}
return true;
}
@@ -192,9 +192,9 @@
if (BufPtr + WordSize > BufEnd)
return UnsupportedError("Bitcode read failure");
NumFields = static_cast<unsigned>(BufPtr[0]) |
- (static_cast<unsigned>(BufPtr[1]) << 8);
+ (static_cast<unsigned>(BufPtr[1]) << 8);
NumBytes = static_cast<unsigned>(BufPtr[2]) |
- (static_cast<unsigned>(BufPtr[3]) << 8);
+ (static_cast<unsigned>(BufPtr[3]) << 8);
BufPtr += WordSize;
return false;
}
@@ -245,9 +245,8 @@
}
// Then read the rest, starting after the 2 * WordSize of the prefix.
uint8_t *Header = new uint8_t[NumBytes];
- bool failed =
- Bytes->readBytes(Header, NumBytes, 2 * WordSize) != NumBytes ||
- ReadFields(Header, Header + NumBytes, NumFields, NumBytes);
+ bool failed = Bytes->readBytes(Header, NumBytes, 2 * WordSize) != NumBytes ||
+ ReadFields(Header, Header + NumBytes, NumFields, NumBytes);
delete[] Header;
if (failed)
return UnsupportedError("Bitcode read failure");
diff --git a/third_party/subzero/pnacl-llvm/NaClBitcodeParser.cpp b/third_party/subzero/pnacl-llvm/NaClBitcodeParser.cpp
index 30744ec..c3295bb 100644
--- a/third_party/subzero/pnacl-llvm/NaClBitcodeParser.cpp
+++ b/third_party/subzero/pnacl-llvm/NaClBitcodeParser.cpp
@@ -14,19 +14,20 @@
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 @@
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 @@
Parser->ExitBlock();
}
-void NaClBitcodeParserListener::
-ProcessAbbreviation(NaClBitCodeAbbrev *Abbrev, bool IsLocal) {
+void NaClBitcodeParserListener::ProcessAbbreviation(NaClBitCodeAbbrev *Abbrev,
+ bool IsLocal) {
Parser->Record.SetStartBit(StartBit);
Parser->Record.Entry.Kind = NaClBitstreamEntry::Record;
Parser->Record.Entry.ID = naclbitc::DEFINE_ABBREV;
@@ -86,9 +84,9 @@
}
}
-bool NaClBitcodeParser::ErrorAt(
- naclbitc::ErrorLevel Level, uint64_t BitPosition,
- const std::string &Message) {
+bool NaClBitcodeParser::ErrorAt(naclbitc::ErrorLevel Level,
+ uint64_t BitPosition,
+ const std::string &Message) {
naclbitc::ErrorAt(*ErrStream, Level, BitPosition) << Message << "\n";
if (Level == naclbitc::Fatal)
report_fatal_error("Unable to continue");
@@ -108,7 +106,8 @@
// 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 @@
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 @@
// 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.
diff --git a/third_party/subzero/pnacl-llvm/NaClBitstreamReader.cpp b/third_party/subzero/pnacl-llvm/NaClBitstreamReader.cpp
index 0f1aa02..2f89dd6 100644
--- a/third_party/subzero/pnacl-llvm/NaClBitstreamReader.cpp
+++ b/third_party/subzero/pnacl-llvm/NaClBitstreamReader.cpp
@@ -8,8 +8,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/STLExtras.h"
#include "llvm/Bitcode/NaCl/NaClBitstreamReader.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
@@ -17,11 +17,7 @@
namespace {
-static const char *ErrorLevelName[] = {
- "Warning",
- "Error",
- "Fatal"
-};
+static const char *ErrorLevelName[] = {"Warning", "Error", "Fatal"};
} // End of anonymous namespace.
@@ -32,8 +28,8 @@
return Stream.str();
}
-raw_ostream &llvm::naclbitc::ErrorAt(
- raw_ostream &Out, ErrorLevel Level, uint64_t BitPosition) {
+raw_ostream &llvm::naclbitc::ErrorAt(raw_ostream &Out, ErrorLevel Level,
+ uint64_t BitPosition) {
assert(Level < array_lengthof(::ErrorLevelName));
return Out << ErrorLevelName[Level] << "("
<< naclbitc::getBitAddress(BitPosition) << "): ";
@@ -43,14 +39,15 @@
// NaClBitstreamCursor implementation
//===----------------------------------------------------------------------===//
-void NaClBitstreamCursor::ErrorHandler::
-Fatal(const std::string &ErrorMessage) const {
+void NaClBitstreamCursor::ErrorHandler::Fatal(
+ const std::string &ErrorMessage) const {
// Default implementation is simply print message, and the bit where
// the error occurred.
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
naclbitc::ErrorAt(StrBuf, naclbitc::Fatal,
- Cursor.getErrorBitNo(getCurrentBitNo())) << ErrorMessage;
+ Cursor.getErrorBitNo(getCurrentBitNo()))
+ << ErrorMessage;
report_fatal_error(StrBuf.str());
}
@@ -72,12 +69,13 @@
/// the block, and return true if the block has an error.
bool NaClBitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
const bool IsFixed = true;
- NaClBitcodeSelectorAbbrev
- CodeAbbrev(IsFixed, ReadVBR(naclbitc::CodeLenWidth));
+ NaClBitcodeSelectorAbbrev CodeAbbrev(IsFixed,
+ ReadVBR(naclbitc::CodeLenWidth));
BlockScope.push_back(Block(BitStream->getBlockInfo(BlockID), CodeAbbrev));
SkipToFourByteBoundary();
unsigned NumWords = Read(naclbitc::BlockSizeWidth);
- if (NumWordsP) *NumWordsP = NumWords;
+ if (NumWordsP)
+ *NumWordsP = NumWords;
// Validate that this block is sane.
if (BlockScope.back().getCodeAbbrev().NumBits == 0 || AtEndOfStream())
@@ -148,8 +146,8 @@
SkipToByteBoundaryIfAligned();
}
-bool NaClBitstreamCursor::readRecordAbbrevField(
- const NaClBitCodeAbbrevOp &Op, uint64_t &Value) {
+bool NaClBitstreamCursor::readRecordAbbrevField(const NaClBitCodeAbbrevOp &Op,
+ uint64_t &Value) {
switch (Op.getEncoding()) {
case NaClBitCodeAbbrevOp::Literal:
Value = Op.getValue();
@@ -171,8 +169,8 @@
return false;
}
-uint64_t NaClBitstreamCursor::readArrayAbbreviatedField(
- const NaClBitCodeAbbrevOp &Op) {
+uint64_t
+NaClBitstreamCursor::readArrayAbbreviatedField(const NaClBitCodeAbbrevOp &Op) {
// Decode the value as we are commanded.
switch (Op.getEncoding()) {
case NaClBitCodeAbbrevOp::Literal:
@@ -191,9 +189,9 @@
llvm_unreachable("Illegal abbreviation encoding for field!");
}
-void NaClBitstreamCursor::readArrayAbbrev(
- const NaClBitCodeAbbrevOp &Op, unsigned NumArrayElements,
- SmallVectorImpl<uint64_t> &Vals) {
+void NaClBitstreamCursor::readArrayAbbrev(const NaClBitCodeAbbrevOp &Op,
+ unsigned NumArrayElements,
+ SmallVectorImpl<uint64_t> &Vals) {
for (; NumArrayElements; --NumArrayElements) {
Vals.push_back(readArrayAbbreviatedField(Op));
}
@@ -241,9 +239,7 @@
return Code;
}
-
-NaClBitCodeAbbrevOp::Encoding NaClBitstreamCursor::
-getEncoding(uint64_t Value) {
+NaClBitCodeAbbrevOp::Encoding NaClBitstreamCursor::getEncoding(uint64_t Value) {
if (!NaClBitCodeAbbrevOp::isValidEncoding(Value)) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
@@ -258,28 +254,34 @@
NaClAbbrevListener *Listener) {
NaClBitCodeAbbrev *Abbv = BlockScope.back().appendLocalCreate();
unsigned NumOpInfo = ReadVBR(5);
- if (Listener) Listener->Values.push_back(NumOpInfo);
+ if (Listener)
+ Listener->Values.push_back(NumOpInfo);
for (unsigned i = 0; i != NumOpInfo; ++i) {
bool IsLiteral = Read(1) ? true : false;
- if (Listener) Listener->Values.push_back(IsLiteral);
+ if (Listener)
+ Listener->Values.push_back(IsLiteral);
if (IsLiteral) {
uint64_t Value = ReadVBR64(8);
- if (Listener) Listener->Values.push_back(Value);
+ if (Listener)
+ Listener->Values.push_back(Value);
Abbv->Add(NaClBitCodeAbbrevOp(Value));
continue;
}
NaClBitCodeAbbrevOp::Encoding E = getEncoding(Read(3));
- if (Listener) Listener->Values.push_back(E);
+ if (Listener)
+ Listener->Values.push_back(E);
if (NaClBitCodeAbbrevOp::hasValue(E)) {
unsigned Data = ReadVBR64(5);
- if (Listener) Listener->Values.push_back(Data);
+ if (Listener)
+ Listener->Values.push_back(Data);
// As a special case, handle fixed(0) (i.e., a fixed field with zero bits)
// and vbr(0) as a literal zero. This is decoded the same way, and avoids
// a slow path in Read() to have to handle reading zero bits.
if ((E == NaClBitCodeAbbrevOp::Fixed || E == NaClBitCodeAbbrevOp::VBR) &&
Data == 0) {
- if (Listener) Listener->Values.push_back(0);
+ if (Listener)
+ Listener->Values.push_back(0);
Abbv->Add(NaClBitCodeAbbrevOp(0));
continue;
}
@@ -287,8 +289,8 @@
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Invalid abbreviation encoding ("
- << NaClBitCodeAbbrevOp::getEncodingName(E)
- << ", " << Data << ")";
+ << NaClBitCodeAbbrevOp::getEncodingName(E) << ", " << Data
+ << ")";
ErrHandler->Fatal(StrBuf.str());
}
Abbv->Add(NaClBitCodeAbbrevOp(E, Data));
@@ -333,28 +335,24 @@
namespace {
unsigned ValidBlockIDs[] = {
- naclbitc::BLOCKINFO_BLOCK_ID,
- naclbitc::CONSTANTS_BLOCK_ID,
- naclbitc::FUNCTION_BLOCK_ID,
- naclbitc::GLOBALVAR_BLOCK_ID,
- naclbitc::MODULE_BLOCK_ID,
- naclbitc::TOP_LEVEL_BLOCKID,
- naclbitc::TYPE_BLOCK_ID_NEW,
- naclbitc::VALUE_SYMTAB_BLOCK_ID
-};
+ naclbitc::BLOCKINFO_BLOCK_ID, naclbitc::CONSTANTS_BLOCK_ID,
+ naclbitc::FUNCTION_BLOCK_ID, naclbitc::GLOBALVAR_BLOCK_ID,
+ naclbitc::MODULE_BLOCK_ID, naclbitc::TOP_LEVEL_BLOCKID,
+ naclbitc::TYPE_BLOCK_ID_NEW, naclbitc::VALUE_SYMTAB_BLOCK_ID};
} // end of anonymous namespace
-NaClBitstreamReader::BlockInfoRecordsMap::
-BlockInfoRecordsMap() : IsFrozen(false) {
+NaClBitstreamReader::BlockInfoRecordsMap::BlockInfoRecordsMap()
+ : IsFrozen(false) {
for (size_t BlockID : ValidBlockIDs) {
std::unique_ptr<BlockInfo> Info(new BlockInfo(BlockID));
KnownInfos.emplace(BlockID, std::move(Info));
}
}
-NaClBitstreamReader::BlockInfo * NaClBitstreamReader::BlockInfoRecordsMap::
-getOrCreateUnknownBlockInfo(unsigned BlockID) {
+NaClBitstreamReader::BlockInfo *
+NaClBitstreamReader::BlockInfoRecordsMap::getOrCreateUnknownBlockInfo(
+ unsigned BlockID) {
std::unique_lock<std::mutex> Lock(UnknownBlockInfoLock);
while (true) {
auto Pos = UnknownInfos.find(BlockID);
@@ -366,13 +364,12 @@
}
}
-NaClBitstreamReader::BlockInfoRecordsMap::UpdateLock::
-UpdateLock(BlockInfoRecordsMap &BlockInfoRecords)
+NaClBitstreamReader::BlockInfoRecordsMap::UpdateLock::UpdateLock(
+ BlockInfoRecordsMap &BlockInfoRecords)
: BlockInfoRecords(BlockInfoRecords),
Lock(BlockInfoRecords.UpdateRecordsLock) {}
-NaClBitstreamReader::BlockInfoRecordsMap::UpdateLock::
-~UpdateLock() {
+NaClBitstreamReader::BlockInfoRecordsMap::UpdateLock::~UpdateLock() {
if (BlockInfoRecords.freeze())
report_fatal_error("Global abbreviations block frozen while building.");
}
@@ -382,12 +379,14 @@
if (BitStream->BlockInfoRecords->isFrozen())
return SkipBlock();
- NaClBitstreamReader::BlockInfoRecordsMap::UpdateLock
- Lock(*BitStream->BlockInfoRecords);
+ NaClBitstreamReader::BlockInfoRecordsMap::UpdateLock Lock(
+ *BitStream->BlockInfoRecords);
unsigned NumWords;
- if (EnterSubBlock(naclbitc::BLOCKINFO_BLOCK_ID, &NumWords)) return true;
+ if (EnterSubBlock(naclbitc::BLOCKINFO_BLOCK_ID, &NumWords))
+ return true;
- if (Listener) Listener->BeginBlockInfoBlock(NumWords);
+ if (Listener)
+ Listener->BeginBlockInfoBlock(NumWords);
NaClBitcodeRecordVector Record;
Block &CurBlock = BlockScope.back();
@@ -397,15 +396,17 @@
// Read records of the BlockInfo block.
while (1) {
- if (Listener) Listener->StartBit = GetCurrentBitNo();
+ if (Listener)
+ Listener->StartBit = GetCurrentBitNo();
NaClBitstreamEntry Entry = advance(AF_DontAutoprocessAbbrevs, Listener);
switch (Entry.Kind) {
- case llvm::NaClBitstreamEntry::SubBlock: // PNaCl doesn't allow!
+ case llvm::NaClBitstreamEntry::SubBlock: // PNaCl doesn't allow!
case llvm::NaClBitstreamEntry::Error:
return true;
case llvm::NaClBitstreamEntry::EndBlock:
- if (Listener) Listener->EndBlockInfoBlock();
+ if (Listener)
+ Listener->EndBlockInfoBlock();
return false;
case llvm::NaClBitstreamEntry::Record:
// The interesting case.
@@ -427,19 +428,20 @@
// Read a record.
Record.clear();
switch (readRecord(Entry.ID, Record)) {
- default:
- // No other records should be found!
+ default:
+ // No other records should be found!
+ return true;
+ case naclbitc::BLOCKINFO_CODE_SETBID:
+ if (Record.size() < 1)
return true;
- case naclbitc::BLOCKINFO_CODE_SETBID:
- if (Record.size() < 1) return true;
- FoundSetBID = true;
- UpdateAbbrevs =
- &BitStream->getBlockInfo((unsigned)Record[0])->getAbbrevs();
- if (Listener) {
- Listener->Values = Record;
- Listener->SetBID();
- }
- break;
+ FoundSetBID = true;
+ UpdateAbbrevs =
+ &BitStream->getBlockInfo((unsigned)Record[0])->getAbbrevs();
+ if (Listener) {
+ Listener->Values = Record;
+ Listener->SetBID();
+ }
+ break;
}
}
}
diff --git a/third_party/subzero/pnacl-llvm/StreamingMemoryObject.cpp b/third_party/subzero/pnacl-llvm/StreamingMemoryObject.cpp
index fb56617..68874e2 100644
--- a/third_party/subzero/pnacl-llvm/StreamingMemoryObject.cpp
+++ b/third_party/subzero/pnacl-llvm/StreamingMemoryObject.cpp
@@ -17,14 +17,12 @@
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 @@
}
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 @@
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 @@
// 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 @@
}
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 @@
BytesSkipped(0), ObjectSize(0), EOFReached(false) {
BytesRead = this->Streamer->GetBytes(&Bytes[0], kChunkSize);
}
-}
+} // namespace llvm
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitCodes.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitCodes.h
index 44069a5..f914cc2 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitCodes.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitCodes.h
@@ -29,83 +29,83 @@
namespace naclbitc {
enum StandardWidths {
- BlockIDWidth = 8, // We use VBR-8 for block IDs.
- CodeLenWidth = 4, // Codelen are VBR-4.
- BlockSizeWidth = 32, // BlockSize up to 2^32 32-bit words = 16GB per block.
- MaxAbbrevWidth = 32, // Maximum value allowed for Fixed and VBR.
+ BlockIDWidth = 8, // We use VBR-8 for block IDs.
+ CodeLenWidth = 4, // Codelen are VBR-4.
+ BlockSizeWidth = 32, // BlockSize up to 2^32 32-bit words = 16GB per block.
+ MaxAbbrevWidth = 32, // Maximum value allowed for Fixed and VBR.
BitstreamWordSize = sizeof(uint32_t), // Number of bytes in bitstream word.
- MinRecordBitSize = 2 // Minimum number of bits needed to represent a record.
+ 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 {
- END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode.
- ENTER_SUBBLOCK = 1,
+// 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,
- /// DEFINE_ABBREV - Defines an abbrev for the current block. It consists
- /// of a vbr5 for # operand infos. Each operand info is emitted with a
- /// single bit to indicate if it is a literal encoding. If so, the value is
- /// emitted with a vbr8. If not, the encoding is emitted as 3 bits followed
- /// by the info value as a vbr5 if needed.
- DEFINE_ABBREV = 2,
+ /// DEFINE_ABBREV - Defines an abbrev for the current block. It consists
+ /// of a vbr5 for # operand infos. Each operand info is emitted with a
+ /// single bit to indicate if it is a literal encoding. If so, the value is
+ /// emitted with a vbr8. If not, the encoding is emitted as 3 bits followed
+ /// by the info value as a vbr5 if needed.
+ DEFINE_ABBREV = 2,
- // UNABBREV_RECORDs are emitted with a vbr6 for the record code, followed by
- // a vbr6 for the # operands, followed by vbr6's for each operand.
- UNABBREV_RECORD = 3,
+ // UNABBREV_RECORDs are emitted with a vbr6 for the record code, followed by
+ // a vbr6 for the # operands, followed by vbr6's for each operand.
+ UNABBREV_RECORD = 3,
- // This is not a code, this is a marker for the first abbrev assignment.
- // In addition, we assume up to two additional enumerated constants are
- // added for each extension. These constants are:
- //
- // PREFIX_MAX_FIXED_ABBREV
- // PREFIX_MAX_ABBREV
- //
- // PREFIX_MAX_ABBREV defines the maximal enumeration value used for
- // the code selector of a block. If Both PREFIX_MAX_FIXED_ABBREV
- // and PREFIX_MAX_ABBREV is defined, then PREFIX_MAX_FIXED_ABBREV
- // defines the last code selector of the block that must be read using
- // a single read (i.e. a FIXED read, or the first chunk of a VBR read.
- FIRST_APPLICATION_ABBREV = 4,
- // Defines default values for code length, if no additional selectors
- // are added.
- DEFAULT_MAX_ABBREV = FIRST_APPLICATION_ABBREV-1
- };
+ // This is not a code, this is a marker for the first abbrev assignment.
+ // In addition, we assume up to two additional enumerated constants are
+ // added for each extension. These constants are:
+ //
+ // PREFIX_MAX_FIXED_ABBREV
+ // PREFIX_MAX_ABBREV
+ //
+ // PREFIX_MAX_ABBREV defines the maximal enumeration value used for
+ // the code selector of a block. If Both PREFIX_MAX_FIXED_ABBREV
+ // and PREFIX_MAX_ABBREV is defined, then PREFIX_MAX_FIXED_ABBREV
+ // defines the last code selector of the block that must be read using
+ // a single read (i.e. a FIXED read, or the first chunk of a VBR read.
+ FIRST_APPLICATION_ABBREV = 4,
+ // Defines default values for code length, if no additional selectors
+ // are added.
+ 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 {
- /// BLOCKINFO_BLOCK is used to define metadata about blocks, for example,
- /// standard abbrevs that should be available to all blocks of a specified
- /// ID.
- BLOCKINFO_BLOCK_ID = 0,
- // Block IDs 1-6 are reserved for future expansion.
- // Dummy block added around all records in a bitcode file. Allows the code
- // to treat top-level records like all other records (i.e. all records
- // appear in a block).
- TOP_LEVEL_BLOCKID = 7,
- FIRST_APPLICATION_BLOCKID = 8
- };
+/// 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.
+ BLOCKINFO_BLOCK_ID = 0,
+ // Block IDs 1-6 are reserved for future expansion.
+ // Dummy block added around all records in a bitcode file. Allows the code
+ // to treat top-level records like all other records (i.e. all records
+ // appear in a block).
+ TOP_LEVEL_BLOCKID = 7,
+ FIRST_APPLICATION_BLOCKID = 8
+};
- /// 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.
+/// 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.
- BLOCKINFO_CODE_SETBID = 1, // SETBID: [blockid#]
- // The following two codes were removed
- // because the PNaCl reader could read
- // them, but couldn't be generated by
- // the writer.
- BLOCKINFO_CODE_BLOCKNAME = 2, // Not used in PNaCl.
- BLOCKINFO_CODE_SETRECORDNAME = 3 // Not used in PNaCl.
- };
+ BLOCKINFO_CODE_SETBID = 1, // SETBID: [blockid#]
+ // The following two codes were removed
+ // because the PNaCl reader could read
+ // them, but couldn't be generated by
+ // 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").
///
@@ -114,13 +114,13 @@
enum Encoding {
Literal = 0, // Value is literal value.
Fixed = 1, // A fixed width field, Val specifies number of bits.
- VBR = 2, // A VBR field where Val specifies the width of each chunk.
+ VBR = 2, // A VBR field where Val specifies the width of each chunk.
Array = 3, // A sequence of fields, next field species elt encoding.
Char6 = 4, // A 6-bit fixed field which maps to [a-zA-Z0-9._].
Encoding_MAX = Char6
};
- explicit NaClBitCodeAbbrevOp(uint64_t V) : Enc(Literal), Val(V) {}
+ explicit NaClBitCodeAbbrevOp(uint64_t V) : Enc(Literal), Val(V) {}
explicit NaClBitCodeAbbrevOp(Encoding E, uint64_t Data = 0);
Encoding getEncoding() const { return Enc; }
@@ -129,9 +129,7 @@
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 @@
/// 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 @@
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.
@@ -202,8 +215,8 @@
}
private:
- Encoding Enc; // The encoding to use.
- uint64_t Val; // Data associated with encoding (if any).
+ Encoding Enc; // The encoding to use.
+ uint64_t Val; // Data associated with encoding (if any).
int ValCompare(const NaClBitCodeAbbrevOp &Op) const {
if (Val < Op.Val)
@@ -218,7 +231,7 @@
};
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
// 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
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDecoders.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDecoders.h
index a3250e0..ff67634 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDecoders.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDecoders.h
@@ -1,4 +1,5 @@
-//===- 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 @@
/// 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 DecodeIcmpPredicate(uint64_t NaClPredicate,
CmpInst::Predicate &LLVMPredicate);
-}
-}
+} // namespace naclbitc
+} // namespace llvm
#endif
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDefs.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDefs.h
index bb1792f..e1e69ee 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDefs.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeDefs.h
@@ -25,7 +25,7 @@
// record codes for user-defined blocks.
enum SpecialBlockCodes {
BLK_CODE_ENTER = 65535,
- BLK_CODE_EXIT = 65534,
+ BLK_CODE_EXIT = 65534,
BLK_CODE_DEFINE_ABBREV = 65533,
BLK_CODE_HEADER = 65532
};
@@ -49,5 +49,4 @@
} // end of namespace llvm
-
#endif // LLVM_BITCODE_NACL_NACLBITCODEDEFS_H
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeHeader.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeHeader.h
index 50ca5aa..dd439a7 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeHeader.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeHeader.h
@@ -88,15 +88,11 @@
/// \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 @@
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 @@
/// \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 @@
UnsupportedMessage = Message.str();
return true;
}
-
};
} // namespace llvm
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
index e48aebd..1848b87 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
@@ -97,8 +97,8 @@
#ifndef LLVM_BITCODE_NACL_NACLBITCODEPARSER_H
#define LLVM_BITCODE_NACL_NACLBITCODEPARSER_H
-#include "llvm/Bitcode/NaCl/NaClBitstreamReader.h"
#include "llvm/Bitcode/NaCl/NaClBitcodeDefs.h"
+#include "llvm/Bitcode/NaCl/NaClBitstreamReader.h"
#include "llvm/Support/raw_ostream.h"
#include <vector>
@@ -111,18 +111,16 @@
// Defines the base class for data extracted from the input bitstream
// (i.e blocks and records).
class NaClBitcodeData {
- void operator=(const NaClBitcodeData&) = delete;
+ void operator=(const NaClBitcodeData &) = delete;
public:
/// Create data element to be read from input cursor.
explicit NaClBitcodeData(NaClBitstreamCursor &Cursor)
- : Cursor(Cursor), StartBit(Cursor.GetCurrentBitNo())
- {}
+ : Cursor(Cursor), StartBit(Cursor.GetCurrentBitNo()) {}
/// Create copy of the given data element.
explicit NaClBitcodeData(const NaClBitcodeData &Data)
- : Cursor(Data.Cursor), StartBit(Data.StartBit)
- {}
+ : Cursor(Data.Cursor), StartBit(Data.StartBit) {}
/// Returns the bitstream reader being used.
NaClBitstreamReader &GetReader() const {
@@ -130,9 +128,7 @@
}
/// Returns the cursor position within the bitstream.
- NaClBitstreamCursor &GetCursor() const {
- return Cursor;
- }
+ NaClBitstreamCursor &GetCursor() const { return Cursor; }
/// Returns the number of bits defined by the data.
uint64_t GetNumBits() const {
@@ -140,15 +136,11 @@
}
/// Returns the first bit of the stream data.
- uint64_t GetStartBit() const {
- return StartBit;
- }
+ uint64_t GetStartBit() const { return StartBit; }
protected:
/// Change the start bit for the data to the new value.
- void SetStartBit(uint64_t NewValue) {
- StartBit = NewValue;
- }
+ void SetStartBit(uint64_t NewValue) { StartBit = NewValue; }
private:
// The bitstream cursor defining location within the bitcode file.
@@ -171,25 +163,18 @@
/// Create block data for block BlockID, using the input cursor.
NaClBitcodeBlock(unsigned BlockID, NaClBitstreamCursor &Cursor)
- : NaClBitcodeData(Cursor),
- BlockID(BlockID),
- EnclosingBlock(0)
- {
+ : NaClBitcodeData(Cursor), BlockID(BlockID), EnclosingBlock(0) {
LocalStartBit = GetStartBit();
}
/// Print the contents out to the given stream.
- void Print(raw_ostream& os) const;
+ void Print(raw_ostream &os) const;
/// Returns pointer to the enclosing block.
- const NaClBitcodeBlock *GetEnclosingBlock() const {
- return EnclosingBlock;
- }
+ const NaClBitcodeBlock *GetEnclosingBlock() const { return EnclosingBlock; }
/// Returns the block ID of the block.
- unsigned GetBlockID() const {
- return BlockID;
- }
+ unsigned GetBlockID() const { return BlockID; }
/// Returns the number of bits in the block associated with the
/// bitcode parser parsing this block, excluding nested blocks.
@@ -214,6 +199,7 @@
class NaClBitcodeRecordData {
NaClBitcodeRecordData &operator=(const NaClBitcodeRecordData &) = delete;
+
public:
NaClBitcodeRecordData(unsigned Code, const NaClRecordVector &Values)
: Code(Code), Values(Values) {}
@@ -238,15 +224,12 @@
/// read record to a simpler form, only containing values.
struct NaClBitcodeValues {
public:
- NaClBitcodeValues(const NaClBitcodeRecordData &Record)
- : Record(Record) {}
+ NaClBitcodeValues(const NaClBitcodeRecordData &Record) : Record(Record) {}
- size_t size() const {
- return Record.Values.size()+1;
- }
+ size_t size() const { return Record.Values.size() + 1; }
uint64_t operator[](size_t index) const {
- return index == 0 ? Record.Code : Record.Values[index-1];
+ return index == 0 ? Record.Code : Record.Values[index - 1];
}
private:
@@ -263,69 +246,52 @@
/// Creates a bitcode record, starting at the position defined
/// by cursor.
explicit NaClBitcodeRecord(const NaClBitcodeBlock &Block)
- : NaClBitcodeData(Block.GetCursor()),
- Block(Block)
- {}
+ : NaClBitcodeData(Block.GetCursor()), Block(Block) {}
/// Print the contents out to the given stream.
- void Print(raw_ostream& os) const;
+ void Print(raw_ostream &os) const;
/// The block the record appears in.
- const NaClBitcodeBlock &GetBlock() const {
- return Block;
- }
+ const NaClBitcodeBlock &GetBlock() const { return Block; }
/// Returns the block ID associated with the record.
- unsigned GetBlockID() const {
- return Block.GetBlockID();
- }
+ unsigned GetBlockID() const { return Block.GetBlockID(); }
/// Returns the kind of entry read from the input stream.
- unsigned GetEntryKind() const {
- return Entry.Kind;
- }
+ unsigned GetEntryKind() const { return Entry.Kind; }
/// Returns the code value (i.e. selector) associated with the
/// record.
- unsigned GetCode() const {
- return Data.Code;
- }
+ unsigned GetCode() const { return Data.Code; }
/// Returns the EntryID (e.g. abbreviation if !=
/// naclbitc::UNABBREV_RECORD) associated with the record. Note:
/// for block-enter, block-exit, and define-abbreviation, EntryID is
/// not the corresponding abbreviation.
- unsigned GetEntryID() const {
- return Entry.ID;
- }
+ unsigned GetEntryID() const { return Entry.ID; }
/// Returns the (value) record associated with the read record.
- const RecordVector &GetValues() const {
- return Data.Values;
- }
+ const RecordVector &GetValues() const { return Data.Values; }
/// Allows lower level access to data representing record.
- const NaClBitcodeRecordData &GetRecordData() const {
- return Data;
- }
+ const NaClBitcodeRecordData &GetRecordData() const { return Data; }
/// Returns true if the record was read using an abbreviation.
bool UsedAnAbbreviation() const {
return GetEntryKind() == NaClBitstreamEntry::Record &&
- GetEntryID() != naclbitc::UNABBREV_RECORD;
+ GetEntryID() != naclbitc::UNABBREV_RECORD;
}
/// Returns the abbrevation index used to read the record.
/// Returns naclbitc::UNABBREV_RECORD if not applicable.
unsigned GetAbbreviationIndex() const {
return UsedAnAbbreviation()
- ? GetEntryID() : static_cast<unsigned>(naclbitc::UNABBREV_RECORD);
+ ? GetEntryID()
+ : static_cast<unsigned>(naclbitc::UNABBREV_RECORD);
}
/// Destructively change the abbreviation ID to the given value.
- void SetAbbreviationIndex(unsigned Index) {
- Entry.ID = Index;
- }
+ void SetAbbreviationIndex(unsigned Index) { Entry.ID = Index; }
protected:
// The block associated with the record.
@@ -346,8 +312,8 @@
/// bitstream.
void ReadEntry() {
SetStartBit(GetCursor().GetCurrentBitNo());
- Entry = GetCursor().
- advance(NaClBitstreamCursor::AF_DontAutoprocessAbbrevs, 0);
+ Entry =
+ GetCursor().advance(NaClBitstreamCursor::AF_DontAutoprocessAbbrevs, 0);
}
/// Reads in a record's values, if the entry defines a record (Must
@@ -373,12 +339,12 @@
/// ProcessAbbreviation and SetBID.
class NaClBitcodeParserListener : public NaClAbbrevListener {
friend class NaClBitcodeParser;
+
public:
// Constructs a listener for the given parser. Note: All nested
// parsers automatically inherit this listener.
NaClBitcodeParserListener(NaClBitcodeParser *Parser)
- : Parser(Parser), GlobalBlockID(naclbitc::BLOCKINFO_BLOCK_ID) {
- }
+ : Parser(Parser), GlobalBlockID(naclbitc::BLOCKINFO_BLOCK_ID) {}
virtual ~NaClBitcodeParserListener() {}
@@ -389,8 +355,7 @@
virtual void EndBlockInfoBlock();
- virtual void ProcessAbbreviation(NaClBitCodeAbbrev *Abbrev,
- bool IsLocal);
+ virtual void ProcessAbbreviation(NaClBitCodeAbbrev *Abbrev, bool IsLocal);
/// The block parser currently being listened to.
NaClBitcodeParser *Parser;
@@ -411,10 +376,10 @@
// reporting function.
class ErrorHandler : public NaClBitstreamCursor::ErrorHandler {
NaClBitcodeParser *Parser;
+
public:
- ErrorHandler(NaClBitcodeParser *Parser,
- NaClBitstreamCursor &Cursor):
- NaClBitstreamCursor::ErrorHandler(Cursor), Parser(Parser) {}
+ ErrorHandler(NaClBitcodeParser *Parser, NaClBitstreamCursor &Cursor)
+ : NaClBitstreamCursor::ErrorHandler(Cursor), Parser(Parser) {}
LLVM_ATTRIBUTE_NORETURN
void Fatal(const std::string &ErrorMessage) const final {
Parser->FatalAt(getCurrentBitNo(), ErrorMessage);
@@ -428,13 +393,10 @@
// the PNaCl bitcode stream. This instance is a "dummy" instance
// that starts the parser.
explicit NaClBitcodeParser(NaClBitstreamCursor &Cursor)
- : EnclosingParser(0),
- Block(ILLEGAL_BLOCK_ID, Cursor),
- Record(Block),
- Listener(0),
- ErrStream(&errs()) {
- std::unique_ptr<NaClBitstreamCursor::ErrorHandler>
- ErrHandler(new ErrorHandler(this, Cursor));
+ : EnclosingParser(0), Block(ILLEGAL_BLOCK_ID, Cursor), Record(Block),
+ Listener(0), ErrStream(&errs()) {
+ std::unique_ptr<NaClBitstreamCursor::ErrorHandler> ErrHandler(
+ new ErrorHandler(this, Cursor));
Cursor.setErrorHandler(ErrHandler);
}
@@ -525,28 +487,18 @@
// Generates fatal generic error message.
LLVM_ATTRIBUTE_NORETURN
- void Fatal() {
- Fatal("Fatal error occurred!");
- }
+ void Fatal() { Fatal("Fatal error occurred!"); }
// Returns the number of bits in this block, including nested blocks.
- unsigned GetBlockNumBits() const {
- return Block.GetNumBits();
- }
+ unsigned GetBlockNumBits() const { return Block.GetNumBits(); }
// Returns the number of bits in this block, excluding nested blocks.
- unsigned GetBlockLocalNumBits() const {
- return Block.GetLocalNumBits();
- }
+ unsigned GetBlockLocalNumBits() const { return Block.GetLocalNumBits(); }
/// Returns the block ID associated with the Parser.
- unsigned GetBlockID() const {
- return Block.GetBlockID();
- }
+ unsigned GetBlockID() const { return Block.GetBlockID(); }
- NaClBitcodeBlock &GetBlock() {
- return Block;
- }
+ NaClBitcodeBlock &GetBlock() { return Block; }
/// Returns the enclosing parser of this block.
NaClBitcodeParser *GetEnclosingParser() const {
@@ -603,11 +555,9 @@
// EnclosingParser.
NaClBitcodeParser(unsigned BlockID, NaClBitcodeParser *EnclosingParser)
: EnclosingParser(EnclosingParser),
- Block(BlockID, EnclosingParser->Record),
- Record(Block),
+ Block(BlockID, EnclosingParser->Record), Record(Block),
Listener(EnclosingParser->Listener),
- ErrStream(EnclosingParser->ErrStream)
- {}
+ ErrStream(EnclosingParser->ErrStream) {}
// Same as above, but use the supplied bitstream cursor (instead of
// inheriting from the enclosing parser). This constructor allows
@@ -615,16 +565,13 @@
// a different Cursor for each block to be parsed in parallel.
NaClBitcodeParser(unsigned BlockID, NaClBitcodeParser *EnclosingParser,
NaClBitstreamCursor &Cursor)
- : EnclosingParser(EnclosingParser),
- Block(BlockID, Cursor),
- Record(Block),
+ : EnclosingParser(EnclosingParser), Block(BlockID, Cursor), Record(Block),
Listener(EnclosingParser->Listener),
- ErrStream(EnclosingParser->ErrStream)
- {}
+ ErrStream(EnclosingParser->ErrStream) {}
/// Defines the listener for this block, and all enclosing blocks,
/// to be the given listener. Should be set in the constructor.
- void SetListener(NaClBitcodeParserListener* UseListener) {
+ void SetListener(NaClBitcodeParserListener *UseListener) {
Listener = UseListener;
}
@@ -655,9 +602,8 @@
void operator=(const NaClBitcodeParser &Parser) = delete;
NaClBitcodeParser(const NaClBitcodeParser &Parser) = delete;
-
};
-} // namespace llvm
+} // namespace llvm
#endif
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
index 6e4da3c..5d1fbb7 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
@@ -38,17 +38,12 @@
std::string getBitAddress(uint64_t Bit);
/// Severity levels for reporting errors.
-enum ErrorLevel {
- Warning,
- Error,
- Fatal
-};
+enum ErrorLevel { Warning, Error, Fatal };
// Basic printing routine to generate the beginning of an error
// message. BitPosition is the bit position the error was found.
// Level is the severity of the error.
-raw_ostream &ErrorAt(raw_ostream &Out, ErrorLevel Level,
- uint64_t BitPosition);
+raw_ostream &ErrorAt(raw_ostream &Out, ErrorLevel Level, uint64_t BitPosition);
} // End namespace naclbitc.
@@ -61,8 +56,8 @@
public:
// Models a raw list of abbreviations.
static const size_t DefaultAbbrevListSize = 12;
- using AbbrevListVector = SmallVector<NaClBitCodeAbbrev *,
- DefaultAbbrevListSize>;
+ using AbbrevListVector =
+ SmallVector<NaClBitCodeAbbrev *, DefaultAbbrevListSize>;
// Models and maintains a list of abbreviations. In particular, it maintains
// updating reference counts of abbreviation operators within the abbreviation
@@ -104,12 +99,13 @@
}
// Empties abbreviation list.
void clear() {
- while(!Abbrevs.empty())
+ while (!Abbrevs.empty())
popLast();
}
// Allow read access to vector defining list.
const AbbrevListVector &getVector() const { return Abbrevs; }
~AbbrevList() { clear(); }
+
private:
AbbrevListVector Abbrevs;
};
@@ -118,16 +114,17 @@
/// BLOCKINFO_BLOCK block. These describe global abbreviations that apply to
/// all succeeding blocks of the specified ID.
class BlockInfo {
- BlockInfo &operator=(const BlockInfo&) = delete;
+ BlockInfo &operator=(const BlockInfo &) = delete;
+
public:
BlockInfo() = default;
- explicit BlockInfo(unsigned BlockID)
- : BlockID(BlockID), Abbrevs() {}
- BlockInfo(const BlockInfo&) = default;
+ explicit BlockInfo(unsigned BlockID) : BlockID(BlockID), Abbrevs() {}
+ BlockInfo(const BlockInfo &) = default;
unsigned getBlockID() const { return BlockID; }
void setBlockID(unsigned ID) { BlockID = ID; }
AbbrevList &getAbbrevs() { return Abbrevs; }
~BlockInfo() {}
+
private:
unsigned BlockID;
AbbrevList Abbrevs;
@@ -147,11 +144,12 @@
//
// In practice, this means that only function blocks can be parsed in
// parallel.
- class BlockInfoRecordsMap :
- public std::enable_shared_from_this<BlockInfoRecordsMap> {
+ class BlockInfoRecordsMap
+ : public std::enable_shared_from_this<BlockInfoRecordsMap> {
friend class NaClBitstreamReader;
- BlockInfoRecordsMap(const BlockInfoRecordsMap&) = delete;
- BlockInfoRecordsMap &operator=(const BlockInfoRecordsMap&) = delete;
+ BlockInfoRecordsMap(const BlockInfoRecordsMap &) = delete;
+ BlockInfoRecordsMap &operator=(const BlockInfoRecordsMap &) = delete;
+
public:
using InfosMap = std::unordered_map<unsigned, std::unique_ptr<BlockInfo>>;
@@ -160,14 +158,10 @@
}
~BlockInfoRecordsMap() = default;
- bool isFrozen() const {
- return IsFrozen.load();
- }
+ bool isFrozen() const { return IsFrozen.load(); }
// Returns true if already frozen.
- bool freeze() {
- return IsFrozen.exchange(true);
- }
+ bool freeze() { return IsFrozen.exchange(true); }
BlockInfo *getBlockInfo(unsigned BlockID) {
auto Pos = KnownInfos.find(BlockID);
@@ -186,11 +180,13 @@
// global abbreviations are defined.
class UpdateLock {
UpdateLock() = delete;
- UpdateLock(const UpdateLock&) = delete;
- UpdateLock &operator=(const UpdateLock&) = delete;
+ UpdateLock(const UpdateLock &) = delete;
+ UpdateLock &operator=(const UpdateLock &) = delete;
+
public:
explicit UpdateLock(BlockInfoRecordsMap &BlockInfoRecords);
~UpdateLock();
+
private:
// The BlockInfoRecordsMap to update.
BlockInfoRecordsMap &BlockInfoRecords;
@@ -235,9 +231,8 @@
// True if filler should be added to byte align records.
bool AlignBitcodeRecords = false;
- NaClBitstreamReader(const NaClBitstreamReader&) = delete;
- void operator=(const NaClBitstreamReader&) = delete;
-
+ NaClBitstreamReader(const NaClBitstreamReader &) = delete;
+ void operator=(const NaClBitstreamReader &) = delete;
void initFromHeader(NaClBitcodeHeader &Header) {
InitialAddress = Header.getHeaderSize();
@@ -256,8 +251,9 @@
/// Read stream from Bytes, after parsing the given bitcode header.
NaClBitstreamReader(MemoryObject *Bytes, NaClBitcodeHeader &Header)
- : BitcodeBytes(Bytes), BlockInfoRecords(BlockInfoRecordsMap::create())
- { initFromHeader(Header); }
+ : BitcodeBytes(Bytes), BlockInfoRecords(BlockInfoRecordsMap::create()) {
+ initFromHeader(Header);
+ }
/// Read stream from bytes, starting at the given initial address.
/// Provides simple API for unit testing.
@@ -272,7 +268,9 @@
const unsigned char *End, NaClBitstreamReader *Reader)
: BitcodeBytes(getNonStreamedMemoryObject(Start, End)),
BlockInfoRecords(Reader->BlockInfoRecords), InitialAddress(0),
- ErrorOffset(StartAddress) { BlockInfoRecords->freeze(); }
+ ErrorOffset(StartAddress) {
+ BlockInfoRecords->freeze();
+ }
// Returns the memory object that is being read.
MemoryObject &getBitcodeBytes() { return *BitcodeBytes; }
@@ -280,9 +278,7 @@
~NaClBitstreamReader() {}
/// \brief Returns the initial address (after the header) of the input stream.
- size_t getInitialAddress() const {
- return InitialAddress;
- }
+ size_t getInitialAddress() const { return InitialAddress; }
/// Returns the byte address of the first byte in the bitstream. Used
/// for error reporting.
@@ -311,16 +307,26 @@
unsigned ID;
static NaClBitstreamEntry getError() {
- NaClBitstreamEntry E; E.Kind = Error; return E;
+ NaClBitstreamEntry E;
+ E.Kind = Error;
+ return E;
}
static NaClBitstreamEntry getEndBlock() {
- NaClBitstreamEntry E; E.Kind = EndBlock; return E;
+ NaClBitstreamEntry E;
+ E.Kind = EndBlock;
+ return E;
}
static NaClBitstreamEntry getSubBlock(unsigned ID) {
- NaClBitstreamEntry E; E.Kind = SubBlock; E.ID = ID; return E;
+ NaClBitstreamEntry E;
+ E.Kind = SubBlock;
+ E.ID = ID;
+ return E;
}
static NaClBitstreamEntry getRecord(unsigned AbbrevID) {
- NaClBitstreamEntry E; E.Kind = Record; E.ID = AbbrevID; return E;
+ NaClBitstreamEntry E;
+ E.Kind = Record;
+ E.ID = AbbrevID;
+ return E;
}
};
@@ -338,15 +344,15 @@
/// to allow the readers to update internals of the bit stream reader
/// appropriately.
class NaClAbbrevListener {
- NaClAbbrevListener(const NaClAbbrevListener&) = delete;
- void operator=(const NaClAbbrevListener&) = delete;
+ NaClAbbrevListener(const NaClAbbrevListener &) = delete;
+ void operator=(const NaClAbbrevListener &) = delete;
+
public:
NaClAbbrevListener() {}
virtual ~NaClAbbrevListener() {}
/// Called to process the read abbreviation.
- virtual void ProcessAbbreviation(NaClBitCodeAbbrev *Abbrv,
- bool IsLocal) = 0;
+ virtual void ProcessAbbreviation(NaClBitCodeAbbrev *Abbrv, bool IsLocal) = 0;
/// Called after entering block. NumWords is the number of words
/// in the block.
@@ -382,14 +388,14 @@
class ErrorHandler {
ErrorHandler(const ErrorHandler &) = delete;
ErrorHandler &operator=(const ErrorHandler &) = delete;
+
public:
explicit ErrorHandler(NaClBitstreamCursor &Cursor) : Cursor(Cursor) {}
LLVM_ATTRIBUTE_NORETURN
virtual void Fatal(const std::string &ErrorMessage) const;
virtual ~ErrorHandler() {}
- uint64_t getCurrentBitNo() const {
- return Cursor.GetCurrentBitNo();
- }
+ uint64_t getCurrentBitNo() const { return Cursor.GetCurrentBitNo(); }
+
private:
NaClBitstreamCursor &Cursor;
};
@@ -428,7 +434,7 @@
return *this;
}
Block(NaClBitstreamReader::BlockInfo *GlobalAbbrevs,
- NaClBitcodeSelectorAbbrev& CodeAbbrev)
+ NaClBitcodeSelectorAbbrev &CodeAbbrev)
: GlobalAbbrevs(GlobalAbbrevs),
NumGlobalAbbrevs(GlobalAbbrevs->getAbbrevs().getVector().size()),
LocalAbbrevs(), CodeAbbrev(CodeAbbrev) {}
@@ -460,6 +466,7 @@
LocalAbbrevs.popLast();
}
}
+
private:
friend class NaClBitstreamCursor;
// The global abbreviations associated with this scope.
@@ -481,12 +488,12 @@
NaClBitstreamCursor &operator=(const NaClBitstreamCursor &) = delete;
public:
- NaClBitstreamCursor() : ErrHandler(new ErrorHandler(*this)) {
- init(nullptr);
- }
+ NaClBitstreamCursor() : ErrHandler(new ErrorHandler(*this)) { init(nullptr); }
explicit NaClBitstreamCursor(NaClBitstreamReader &R)
- : ErrHandler(new ErrorHandler(*this)) { init(&R); }
+ : ErrHandler(new ErrorHandler(*this)) {
+ init(&R);
+ }
void init(NaClBitstreamReader *R) {
freeState();
@@ -500,9 +507,7 @@
}
}
- ~NaClBitstreamCursor() {
- freeState();
- }
+ ~NaClBitstreamCursor() { freeState(); }
void freeState() {
while (!BlockScope.empty())
@@ -519,7 +524,7 @@
bool canSkipToPos(size_t pos) const {
// pos can be skipped to if it is a valid address or one byte past the end.
return pos == 0 || BitStream->getBitcodeBytes().isValidAddress(
- static_cast<uint64_t>(pos - 1));
+ static_cast<uint64_t>(pos - 1));
}
bool AtEndOfStream() {
@@ -538,7 +543,7 @@
/// Return the bit # of the bit we are reading.
uint64_t GetCurrentBitNo() const {
- return NextChar*CHAR_BIT - BitsInCurWord;
+ return NextChar * CHAR_BIT - BitsInCurWord;
}
/// Converts the given position into the corresponding Error position.
@@ -547,16 +552,10 @@
}
/// Returns the current bit address for reporting errors.
- uint64_t getErrorBitNo() const {
- return getErrorBitNo(GetCurrentBitNo());
- }
+ uint64_t getErrorBitNo() const { return getErrorBitNo(GetCurrentBitNo()); }
- NaClBitstreamReader *getBitStreamReader() {
- return BitStream;
- }
- const NaClBitstreamReader *getBitStreamReader() const {
- return BitStream;
- }
+ NaClBitstreamReader *getBitStreamReader() { return BitStream; }
+ const NaClBitstreamReader *getBitStreamReader() const { return BitStream; }
/// Returns the current bit address (string) of the bit cursor.
std::string getCurrentBitAddress() const {
@@ -618,20 +617,18 @@
/// Returns the starting byte of the word containing BitNo.
uintptr_t getStartWordByteForBit(uint64_t BitNo) const {
- return uintptr_t(BitNo/CHAR_BIT) & ~(sizeof(word_t)-1);
+ return uintptr_t(BitNo / CHAR_BIT) & ~(sizeof(word_t) - 1);
}
/// Returns the index of BitNo within the word it appears in.
unsigned getWordBitNo(uint64_t BitNo) const {
- return unsigned(BitNo & (sizeof(word_t)*CHAR_BIT-1));
+ return unsigned(BitNo & (sizeof(word_t) * CHAR_BIT - 1));
}
/// Returns the ending byte of the word containing BitNo.
uintptr_t getEndWordByteForBit(uint64_t BitNo) const {
return getStartWordByteForBit(BitNo) +
- (getWordBitNo(BitNo)
- ? sizeof(word_t)
- : 0);
+ (getWordBitNo(BitNo) ? sizeof(word_t) : 0);
}
/// Fills Buffer[Size] using bytes at Address (in the memory object being
@@ -720,18 +717,18 @@
uint32_t ReadVBR(unsigned NumBits) {
uint32_t Piece = Read(NumBits);
- if ((Piece & (1U << (NumBits-1))) == 0)
+ if ((Piece & (1U << (NumBits - 1))) == 0)
return Piece;
uint32_t Result = 0;
unsigned NextBit = 0;
while (1) {
- Result |= (Piece & ((1U << (NumBits-1))-1)) << NextBit;
+ Result |= (Piece & ((1U << (NumBits - 1)) - 1)) << NextBit;
- if ((Piece & (1U << (NumBits-1))) == 0)
+ if ((Piece & (1U << (NumBits - 1))) == 0)
return Result;
- NextBit += NumBits-1;
+ NextBit += NumBits - 1;
Piece = Read(NumBits);
}
}
@@ -740,18 +737,18 @@
// the VBR must still be <= 32 bits though.
uint64_t ReadVBR64(unsigned NumBits) {
uint32_t Piece = Read(NumBits);
- if ((Piece & (1U << (NumBits-1))) == 0)
+ if ((Piece & (1U << (NumBits - 1))) == 0)
return uint64_t(Piece);
uint64_t Result = 0;
unsigned NextBit = 0;
while (1) {
- Result |= uint64_t(Piece & ((1U << (NumBits-1))-1)) << NextBit;
+ Result |= uint64_t(Piece & ((1U << (NumBits - 1)) - 1)) << NextBit;
- if ((Piece & (1U << (NumBits-1))) == 0)
+ if ((Piece & (1U << (NumBits - 1))) == 0)
return Result;
- NextBit += NumBits-1;
+ NextBit += NumBits - 1;
Piece = Read(NumBits);
}
}
@@ -773,32 +770,28 @@
void SkipToFourByteBoundary() {
// If word_t is 64-bits and if we've read less than 32 bits, just dump
// the bits we have up to the next 32-bit boundary.
- if (sizeof(word_t) > 4 &&
- BitsInCurWord >= 32) {
- CurWord >>= BitsInCurWord-32;
+ if (sizeof(word_t) > 4 && BitsInCurWord >= 32) {
+ CurWord >>= BitsInCurWord - 32;
BitsInCurWord = 32;
return;
}
BitsInCurWord = 0;
}
-public:
+public:
unsigned ReadCode() {
const NaClBitcodeSelectorAbbrev &CodeAbbrev =
BlockScope.back().getCodeAbbrev();
- return CodeAbbrev.IsFixed
- ? Read(CodeAbbrev.NumBits)
- : ReadVBR(CodeAbbrev.NumBits);
+ return CodeAbbrev.IsFixed ? Read(CodeAbbrev.NumBits)
+ : ReadVBR(CodeAbbrev.NumBits);
}
// Block header:
// [ENTER_SUBBLOCK, blockid, newcodelen, <align4bytes>, blocklen]
/// Having read the ENTER_SUBBLOCK code, read the BlockID for the block.
- unsigned ReadSubBlockID() {
- return ReadVBR(naclbitc::BlockIDWidth);
- }
+ unsigned ReadSubBlockID() { return ReadVBR(naclbitc::BlockIDWidth); }
/// Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body
/// of this block. If the block record is malformed, return true.
@@ -811,8 +804,8 @@
// Check that the block wasn't partially defined, and that the offset isn't
// bogus.
- size_t SkipTo = GetCurrentBitNo() + NumFourBytes*4*CHAR_BIT;
- if (AtEndOfStream() || !canSkipToPos(SkipTo/CHAR_BIT))
+ size_t SkipTo = GetCurrentBitNo() + NumFourBytes * 4 * CHAR_BIT;
+ if (AtEndOfStream() || !canSkipToPos(SkipTo / CHAR_BIT))
return true;
JumpToBit(SkipTo);
@@ -824,7 +817,8 @@
bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = nullptr);
bool ReadBlockEnd() {
- if (BlockScope.empty()) return true;
+ if (BlockScope.empty())
+ return true;
// Block tail:
// [END_BLOCK, <align4bytes>]
@@ -835,7 +829,6 @@
}
private:
-
//===--------------------------------------------------------------------===//
// Record Processing
//===--------------------------------------------------------------------===//
@@ -869,17 +862,16 @@
void reportInvalidJumpToBit(uint64_t Bit) const;
public:
-
/// Return the abbreviation for the specified AbbrevId.
const NaClBitCodeAbbrev *getAbbrev(unsigned AbbrevID) const {
- unsigned AbbrevNo = AbbrevID-naclbitc::FIRST_APPLICATION_ABBREV;
+ unsigned AbbrevNo = AbbrevID - naclbitc::FIRST_APPLICATION_ABBREV;
const Block &CurBlock = BlockScope.back();
const unsigned NumGlobalAbbrevs = CurBlock.getNumGlobalAbbrevs();
if (AbbrevNo < NumGlobalAbbrevs)
return CurBlock.getGlobalAbbrevs().getVector()[AbbrevNo];
unsigned LocalAbbrevNo = AbbrevNo - NumGlobalAbbrevs;
- NaClBitstreamReader::AbbrevListVector
- LocalAbbrevs = CurBlock.getLocalAbbrevs().getVector();
+ NaClBitstreamReader::AbbrevListVector LocalAbbrevs =
+ CurBlock.getLocalAbbrevs().getVector();
if (LocalAbbrevNo >= LocalAbbrevs.size())
reportInvalidAbbrevNumber(AbbrevID);
return LocalAbbrevs[LocalAbbrevNo];
@@ -887,7 +879,7 @@
/// Read the current record and discard it.
void skipRecord(unsigned AbbrevID);
-
+
unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals);
//===--------------------------------------------------------------------===//
@@ -896,16 +888,15 @@
// IsLocal indicates where the abbreviation occurs. If it is in the
// BlockInfo block, IsLocal is false. In all other cases, IsLocal is
// true.
- void ReadAbbrevRecord(bool IsLocal,
- NaClAbbrevListener *Listener);
+ void ReadAbbrevRecord(bool IsLocal, NaClAbbrevListener *Listener);
// Skips over an abbreviation record. Duplicates code of ReadAbbrevRecord,
// except that no abbreviation is built.
void SkipAbbrevRecord();
-
+
bool ReadBlockInfoBlock(NaClAbbrevListener *Listener);
};
-} // End llvm namespace
+} // namespace llvm
#endif
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
index adc554c..662260a 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h
@@ -26,349 +26,341 @@
namespace llvm {
namespace naclbitc {
- // The only top-level block type defined is for a module.
- enum NaClBlockIDs {
- // Blocks
- MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID,
+// The only top-level block type defined is for a module.
+enum NaClBlockIDs {
+ // Blocks
+ MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID,
- // Module sub-block id's.
- PARAMATTR_BLOCK_ID, // Not used in PNaCl.
- PARAMATTR_GROUP_BLOCK_ID, // Not used in PNaCl.
+ // Module sub-block id's.
+ PARAMATTR_BLOCK_ID, // Not used in PNaCl.
+ PARAMATTR_GROUP_BLOCK_ID, // Not used in PNaCl.
- CONSTANTS_BLOCK_ID,
- FUNCTION_BLOCK_ID,
+ CONSTANTS_BLOCK_ID,
+ FUNCTION_BLOCK_ID,
- UNUSED_ID1,
+ UNUSED_ID1,
- VALUE_SYMTAB_BLOCK_ID,
- METADATA_BLOCK_ID, // Not used in PNaCl.
- METADATA_ATTACHMENT_ID, // Not used in PNaCl.
+ VALUE_SYMTAB_BLOCK_ID,
+ METADATA_BLOCK_ID, // Not used in PNaCl.
+ METADATA_ATTACHMENT_ID, // Not used in PNaCl.
- TYPE_BLOCK_ID_NEW,
+ TYPE_BLOCK_ID_NEW,
- USELIST_BLOCK_ID, // Not used in PNaCl.
- GLOBALVAR_BLOCK_ID
- };
+ USELIST_BLOCK_ID, // Not used in PNaCl.
+ GLOBALVAR_BLOCK_ID
+};
+/// MODULE blocks have a number of optional fields and subblocks.
+enum NaClModuleCodes {
+ MODULE_CODE_VERSION = 1, // VERSION: [version#]
+ MODULE_CODE_TRIPLE = 2, // Not used in PNaCl
+ MODULE_CODE_DATALAYOUT = 3, // Not used in PNaCl
+ MODULE_CODE_ASM = 4, // Not used in PNaCl
+ MODULE_CODE_SECTIONNAME = 5, // Not used in PNaCl
+ MODULE_CODE_DEPLIB = 6, // Not used in PNaCl
+ MODULE_CODE_GLOBALVAR = 7, // Not used in PNaCl
+ // FUNCTION: [type, callingconv, isproto, linkage]
+ MODULE_CODE_FUNCTION = 8,
+ MODULE_CODE_ALIAS = 9, // Not used in PNaCl
+ MODULE_CODE_PURGEVALS = 10, // Not used in PNaCl
+ MODULE_CODE_GCNAME = 11 // Not used in PNaCl
+};
- /// MODULE blocks have a number of optional fields and subblocks.
- enum NaClModuleCodes {
- MODULE_CODE_VERSION = 1, // VERSION: [version#]
- MODULE_CODE_TRIPLE = 2, // Not used in PNaCl
- MODULE_CODE_DATALAYOUT = 3, // Not used in PNaCl
- MODULE_CODE_ASM = 4, // Not used in PNaCl
- MODULE_CODE_SECTIONNAME = 5, // Not used in PNaCl
- MODULE_CODE_DEPLIB = 6, // Not used in PNaCl
- MODULE_CODE_GLOBALVAR = 7, // Not used in PNaCl
- // FUNCTION: [type, callingconv, isproto, linkage]
- MODULE_CODE_FUNCTION = 8,
- MODULE_CODE_ALIAS = 9, // Not used in PNaCl
- MODULE_CODE_PURGEVALS = 10, // Not used in PNaCl
- MODULE_CODE_GCNAME = 11 // Not used in PNaCl
- };
+/// PARAMATTR blocks have code for defining a parameter attribute set.
+enum NaClAttributeCodes {
+ // FIXME: Remove `PARAMATTR_CODE_ENTRY_OLD' in 4.0
+ PARAMATTR_CODE_ENTRY_OLD = 1, // ENTRY: [paramidx0, attr0,
+ // paramidx1, attr1...]
+ PARAMATTR_CODE_ENTRY = 2, // ENTRY: [paramidx0, attrgrp0,
+ // paramidx1, attrgrp1, ...]
+ PARAMATTR_GRP_CODE_ENTRY = 3 // ENTRY: [id, attr0, att1, ...]
+};
- /// PARAMATTR blocks have code for defining a parameter attribute set.
- enum NaClAttributeCodes {
- // FIXME: Remove `PARAMATTR_CODE_ENTRY_OLD' in 4.0
- PARAMATTR_CODE_ENTRY_OLD = 1, // ENTRY: [paramidx0, attr0,
- // paramidx1, attr1...]
- PARAMATTR_CODE_ENTRY = 2, // ENTRY: [paramidx0, attrgrp0,
- // paramidx1, attrgrp1, ...]
- PARAMATTR_GRP_CODE_ENTRY = 3 // ENTRY: [id, attr0, att1, ...]
- };
+/// TYPE blocks have codes for each type primitive they use.
+enum NaClTypeCodes {
+ TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries]
- /// TYPE blocks have codes for each type primitive they use.
- enum NaClTypeCodes {
- TYPE_CODE_NUMENTRY = 1, // NUMENTRY: [numentries]
+ // Type Codes
+ TYPE_CODE_VOID = 2, // VOID
+ TYPE_CODE_FLOAT = 3, // FLOAT
+ TYPE_CODE_DOUBLE = 4, // DOUBLE
+ // TODO(mseaborn): Remove LABEL when we drop support for v1 of the
+ // PNaCl bitcode format. The writer no longer generates it.
+ TYPE_CODE_LABEL = 5, // LABEL
+ TYPE_CODE_OPAQUE = 6, // Not used in PNaCl.
+ TYPE_CODE_INTEGER = 7, // INTEGER: [width]
+ TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
- // Type Codes
- TYPE_CODE_VOID = 2, // VOID
- TYPE_CODE_FLOAT = 3, // FLOAT
- TYPE_CODE_DOUBLE = 4, // DOUBLE
- // TODO(mseaborn): Remove LABEL when we drop support for v1 of the
- // PNaCl bitcode format. The writer no longer generates it.
- TYPE_CODE_LABEL = 5, // LABEL
- TYPE_CODE_OPAQUE = 6, // Not used in PNaCl.
- TYPE_CODE_INTEGER = 7, // INTEGER: [width]
- TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
+ TYPE_CODE_FUNCTION_OLD = 9, // Not used in PNaCl.
- TYPE_CODE_FUNCTION_OLD = 9, // Not used in PNaCl.
+ TYPE_CODE_HALF = 10, // Not used in PNaCl.
- TYPE_CODE_HALF = 10, // Not used in PNaCl.
+ TYPE_CODE_ARRAY = 11, // Not used in PNaCl.
+ TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty]
- TYPE_CODE_ARRAY = 11, // Not used in PNaCl.
- TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty]
+ // These are not with the other floating point types because they're
+ // a late addition, and putting them in the right place breaks
+ // binary compatibility.
+ TYPE_CODE_X86_FP80 = 13, // Not used in PNaCl.
+ TYPE_CODE_FP128 = 14, // Not used in PNaCl.
+ TYPE_CODE_PPC_FP128 = 15, // Not used in PNaCl.
- // These are not with the other floating point types because they're
- // a late addition, and putting them in the right place breaks
- // binary compatibility.
- TYPE_CODE_X86_FP80 = 13, // Not used in PNaCl.
- TYPE_CODE_FP128 = 14, // Not used in PNaCl.
- TYPE_CODE_PPC_FP128= 15, // Not used in PNaCl.
+ TYPE_CODE_METADATA = 16, // Not used in PNaCl.
- TYPE_CODE_METADATA = 16, // Not used in PNaCl.
+ TYPE_CODE_X86_MMX = 17, // Not used in PNaCl.
- TYPE_CODE_X86_MMX = 17, // Not used in PNaCl.
+ TYPE_CODE_STRUCT_ANON = 18, // Not used in PNaCl.
+ TYPE_CODE_STRUCT_NAME = 19, // Not used in PNaCl.
+ TYPE_CODE_STRUCT_NAMED = 20, // Not used in PNaCl.
- TYPE_CODE_STRUCT_ANON = 18, // Not used in PNaCl.
- TYPE_CODE_STRUCT_NAME = 19, // Not used in PNaCl.
- TYPE_CODE_STRUCT_NAMED = 20,// Not used in PNaCl.
+ TYPE_CODE_FUNCTION = 21 // FUNCTION: [vararg, retty, paramty x N]
+};
- TYPE_CODE_FUNCTION = 21 // FUNCTION: [vararg, retty, paramty x N]
- };
+// The type symbol table only has one code (TST_ENTRY_CODE).
+enum NaClTypeSymtabCodes {
+ TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namechar x N]
+};
- // The type symbol table only has one code (TST_ENTRY_CODE).
- enum NaClTypeSymtabCodes {
- TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namechar x N]
- };
+// The value symbol table only has one code (VST_ENTRY_CODE).
+enum NaClValueSymtabCodes {
+ VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
+ VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N]
+};
- // The value symbol table only has one code (VST_ENTRY_CODE).
- enum NaClValueSymtabCodes {
- VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
- VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N]
- };
+// Not used in PNaCl.
+enum NaClMetadataCodes {
+ METADATA_STRING = 1, // MDSTRING: [values]
+ // 2 is unused.
+ // 3 is unused.
+ METADATA_NAME = 4, // STRING: [values]
+ // 5 is unused.
+ METADATA_KIND = 6, // [n x [id, name]]
+ // 7 is unused.
+ METADATA_NODE = 8, // NODE: [n x (type num, value num)]
+ METADATA_FN_NODE = 9, // FN_NODE: [n x (type num, value num)]
+ METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes]
+ METADATA_ATTACHMENT = 11 // [m x [value, [n x [id, mdnode]]]
+};
- // Not used in PNaCl.
- enum NaClMetadataCodes {
- METADATA_STRING = 1, // MDSTRING: [values]
- // 2 is unused.
- // 3 is unused.
- METADATA_NAME = 4, // STRING: [values]
- // 5 is unused.
- METADATA_KIND = 6, // [n x [id, name]]
- // 7 is unused.
- METADATA_NODE = 8, // NODE: [n x (type num, value num)]
- METADATA_FN_NODE = 9, // FN_NODE: [n x (type num, value num)]
- METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes]
- METADATA_ATTACHMENT = 11 // [m x [value, [n x [id, mdnode]]]
- };
+// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
+// constant and maintains an implicit current type value.
+enum NaClConstantsCodes {
+ CST_CODE_SETTYPE = 1, // SETTYPE: [typeid]
+ CST_CODE_NULL = 2, // Not used in PNaCl.
+ CST_CODE_UNDEF = 3, // UNDEF
+ CST_CODE_INTEGER = 4, // INTEGER: [intval]
+ CST_CODE_WIDE_INTEGER = 5, // Not used in PNaCl.
+ CST_CODE_FLOAT = 6, // FLOAT: [fpval]
+ CST_CODE_AGGREGATE = 7, // Not used in PNaCl.
+ CST_CODE_STRING = 8, // Not used in PNaCl.
+ CST_CODE_CSTRING = 9, // Not used in PNaCl.
+ CST_CODE_CE_BINOP = 10, // Not used in PNaCl.
+ CST_CODE_CE_CAST = 11, // Not used in PNaCl.
+ CST_CODE_CE_GEP = 12, // Not used in PNaCl.
+ CST_CODE_CE_SELECT = 13, // Not used in PNaCl.
+ CST_CODE_CE_EXTRACTELT = 14, // Not used in PNaCl.
+ CST_CODE_CE_INSERTELT = 15, // Not used in PNaCl.
+ CST_CODE_CE_SHUFFLEVEC = 16, // Not used in PNaCl.
+ CST_CODE_CE_CMP = 17, // Not used in PNaCl.
+ CST_CODE_INLINEASM_OLD = 18, // No longer used.
+ CST_CODE_CE_SHUFVEC_EX = 19, // Not used in PNaCl.
+ CST_CODE_CE_INBOUNDS_GEP = 20, // Not used in PNaCl.
+ CST_CODE_BLOCKADDRESS = 21, // Not used in PNaCl.
+ CST_CODE_DATA = 22, // Not used in PNaCl.
+ CST_CODE_INLINEASM = 23 // Not used in PNaCl.
+};
- // The constants block (CONSTANTS_BLOCK_ID) describes emission for each
- // constant and maintains an implicit current type value.
- enum NaClConstantsCodes {
- CST_CODE_SETTYPE = 1, // SETTYPE: [typeid]
- CST_CODE_NULL = 2, // Not used in PNaCl.
- CST_CODE_UNDEF = 3, // UNDEF
- CST_CODE_INTEGER = 4, // INTEGER: [intval]
- CST_CODE_WIDE_INTEGER = 5, // Not used in PNaCl.
- CST_CODE_FLOAT = 6, // FLOAT: [fpval]
- CST_CODE_AGGREGATE = 7, // Not used in PNaCl.
- CST_CODE_STRING = 8, // Not used in PNaCl.
- CST_CODE_CSTRING = 9, // Not used in PNaCl.
- CST_CODE_CE_BINOP = 10, // Not used in PNaCl.
- CST_CODE_CE_CAST = 11, // Not used in PNaCl.
- CST_CODE_CE_GEP = 12, // Not used in PNaCl.
- CST_CODE_CE_SELECT = 13, // Not used in PNaCl.
- CST_CODE_CE_EXTRACTELT = 14, // Not used in PNaCl.
- CST_CODE_CE_INSERTELT = 15, // Not used in PNaCl.
- CST_CODE_CE_SHUFFLEVEC = 16, // Not used in PNaCl.
- CST_CODE_CE_CMP = 17, // Not used in PNaCl.
- CST_CODE_INLINEASM_OLD = 18, // No longer used.
- CST_CODE_CE_SHUFVEC_EX = 19, // Not used in PNaCl.
- CST_CODE_CE_INBOUNDS_GEP = 20,// Not used in PNaCl.
- CST_CODE_BLOCKADDRESS = 21, // Not used in PNaCl.
- CST_CODE_DATA = 22, // Not used in PNaCl.
- CST_CODE_INLINEASM = 23 // Not used in PNaCl.
- };
+/// GlobalVarOpcodes - These are values used in the bitcode files to
+/// encode records defining global variables.
+///
+/// The structure of global variables can be summarized as follows:
+///
+/// The global variable block begins with a GLOBALVAR_COUNT, defining
+/// the number of global variables in the bitcode file. After that,
+/// each global variable is defined.
+///
+/// Global variables are defined by a GLOBALVAR_VAR record, followed
+/// by 1 or more records defining its initial value. Simple
+/// variables have a single initializer. Structured variables are
+/// defined by an initial GLOBALVAR_COMPOUND record defining the
+/// number of fields in the structure, followed by an initializer
+/// for each of its fields. In this context, a field is either data,
+/// or a relocation. A data field is defined by a
+/// GLOBALVAR_ZEROFILL or GLOBALVAR_DATA record. A relocation field
+/// is defined by a GLOBALVAR_RELOC record.
+enum NaClGlobalVarOpcodes {
+ GLOBALVAR_VAR = 0, // VAR: [align, isconst]
+ GLOBALVAR_COMPOUND = 1, // COMPOUND: [size]
+ GLOBALVAR_ZEROFILL = 2, // ZEROFILL: [size]
+ GLOBALVAR_DATA = 3, // DATA: [b0, b1, ...]
+ GLOBALVAR_RELOC = 4, // RELOC: [val, [addend]]
+ GLOBALVAR_COUNT = 5 // COUNT: [n]
+};
- /// GlobalVarOpcodes - These are values used in the bitcode files to
- /// encode records defining global variables.
- ///
- /// The structure of global variables can be summarized as follows:
- ///
- /// The global variable block begins with a GLOBALVAR_COUNT, defining
- /// the number of global variables in the bitcode file. After that,
- /// each global variable is defined.
- ///
- /// Global variables are defined by a GLOBALVAR_VAR record, followed
- /// by 1 or more records defining its initial value. Simple
- /// variables have a single initializer. Structured variables are
- /// defined by an initial GLOBALVAR_COMPOUND record defining the
- /// number of fields in the structure, followed by an initializer
- /// for each of its fields. In this context, a field is either data,
- /// or a relocation. A data field is defined by a
- /// GLOBALVAR_ZEROFILL or GLOBALVAR_DATA record. A relocation field
- /// is defined by a GLOBALVAR_RELOC record.
- enum NaClGlobalVarOpcodes {
- GLOBALVAR_VAR = 0, // VAR: [align, isconst]
- GLOBALVAR_COMPOUND = 1, // COMPOUND: [size]
- GLOBALVAR_ZEROFILL = 2, // ZEROFILL: [size]
- GLOBALVAR_DATA = 3, // DATA: [b0, b1, ...]
- GLOBALVAR_RELOC = 4, // RELOC: [val, [addend]]
- GLOBALVAR_COUNT = 5 // COUNT: [n]
- };
+/// CastOpcodes - These are values used in the bitcode files to encode which
+/// cast a CST_CODE_CE_CAST or a XXX refers to. The values of these enums
+/// have no fixed relation to the LLVM IR enum values. Changing these will
+/// break compatibility with old files.
+enum NaClCastOpcodes {
+ CAST_TRUNC = 0,
+ CAST_ZEXT = 1,
+ CAST_SEXT = 2,
+ CAST_FPTOUI = 3,
+ CAST_FPTOSI = 4,
+ CAST_UITOFP = 5,
+ CAST_SITOFP = 6,
+ CAST_FPTRUNC = 7,
+ CAST_FPEXT = 8,
+ // 9 was CAST_PTRTOINT; not used in PNaCl.
+ // 10 was CAST_INTTOPTR; not used in PNaCl.
+ CAST_BITCAST = 11
+};
- /// CastOpcodes - These are values used in the bitcode files to encode which
- /// cast a CST_CODE_CE_CAST or a XXX refers to. The values of these enums
- /// have no fixed relation to the LLVM IR enum values. Changing these will
- /// break compatibility with old files.
- enum NaClCastOpcodes {
- CAST_TRUNC = 0,
- CAST_ZEXT = 1,
- CAST_SEXT = 2,
- CAST_FPTOUI = 3,
- CAST_FPTOSI = 4,
- CAST_UITOFP = 5,
- CAST_SITOFP = 6,
- CAST_FPTRUNC = 7,
- CAST_FPEXT = 8,
- // 9 was CAST_PTRTOINT; not used in PNaCl.
- // 10 was CAST_INTTOPTR; not used in PNaCl.
- CAST_BITCAST = 11
- };
+/// BinaryOpcodes - These are values used in the bitcode files to encode which
+/// binop a CST_CODE_CE_BINOP or a XXX refers to. The values of these enums
+/// have no fixed relation to the LLVM IR enum values. Changing these will
+/// break compatibility with old files.
+enum NaClBinaryOpcodes {
+ BINOP_ADD = 0,
+ BINOP_SUB = 1,
+ BINOP_MUL = 2,
+ BINOP_UDIV = 3,
+ BINOP_SDIV = 4, // overloaded for FP
+ BINOP_UREM = 5,
+ BINOP_SREM = 6, // overloaded for FP
+ BINOP_SHL = 7,
+ BINOP_LSHR = 8,
+ BINOP_ASHR = 9,
+ BINOP_AND = 10,
+ BINOP_OR = 11,
+ BINOP_XOR = 12
+};
- /// BinaryOpcodes - These are values used in the bitcode files to encode which
- /// binop a CST_CODE_CE_BINOP or a XXX refers to. The values of these enums
- /// have no fixed relation to the LLVM IR enum values. Changing these will
- /// break compatibility with old files.
- enum NaClBinaryOpcodes {
- BINOP_ADD = 0,
- BINOP_SUB = 1,
- BINOP_MUL = 2,
- BINOP_UDIV = 3,
- BINOP_SDIV = 4, // overloaded for FP
- BINOP_UREM = 5,
- BINOP_SREM = 6, // overloaded for FP
- BINOP_SHL = 7,
- BINOP_LSHR = 8,
- BINOP_ASHR = 9,
- BINOP_AND = 10,
- BINOP_OR = 11,
- BINOP_XOR = 12
- };
+/// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
+/// OverflowingBinaryOperator's SubclassOptionalData contents.
+/// Note: This enum is no longer used in PNaCl, because these
+/// flags can't exist in files that meet the PNaCl ABI.
+enum NaClOverflowingBinaryOperatorOptionalFlags {
+ OBO_NO_UNSIGNED_WRAP = 0,
+ OBO_NO_SIGNED_WRAP = 1
+};
- /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
- /// OverflowingBinaryOperator's SubclassOptionalData contents.
- /// Note: This enum is no longer used in PNaCl, because these
- /// flags can't exist in files that meet the PNaCl ABI.
- enum NaClOverflowingBinaryOperatorOptionalFlags {
- OBO_NO_UNSIGNED_WRAP = 0,
- OBO_NO_SIGNED_WRAP = 1
- };
+/// PossiblyExactOperatorOptionalFlags - Flags for serializing
+/// PossiblyExactOperator's SubclassOptionalData contents.
+/// Note: This enum is no longer used in PNaCl, because these
+/// flags can't exist in files that meet the PNaCl ABI.
+enum NaClPossiblyExactOperatorOptionalFlags { PEO_EXACT = 0 };
- /// PossiblyExactOperatorOptionalFlags - Flags for serializing
- /// PossiblyExactOperator's SubclassOptionalData contents.
- /// Note: This enum is no longer used in PNaCl, because these
- /// flags can't exist in files that meet the PNaCl ABI.
- enum NaClPossiblyExactOperatorOptionalFlags {
- PEO_EXACT = 0
- };
+/// \brief Flags for serializing floating point binary operators's
+/// SubclassOptionalData contents.
+/// Note: This enum is no longer used in PNaCl, because these
+/// flags shouldn't exist in files that meet the PNaCl ABI, unless
+/// they are old. In the latter case, they are ignored by the reader.
+enum NaClFloatingPointBinaryOperatorOptionalFlags {
+ FPO_UNSAFE_ALGEBRA = 0,
+ FPO_NO_NANS = 1,
+ FPO_NO_INFS = 2,
+ FPO_NO_SIGNED_ZEROS = 3,
+ FPO_ALLOW_RECIPROCAL = 4
+};
- /// \brief Flags for serializing floating point binary operators's
- /// SubclassOptionalData contents.
- /// Note: This enum is no longer used in PNaCl, because these
- /// flags shouldn't exist in files that meet the PNaCl ABI, unless
- /// they are old. In the latter case, they are ignored by the reader.
- enum NaClFloatingPointBinaryOperatorOptionalFlags {
- FPO_UNSAFE_ALGEBRA = 0,
- FPO_NO_NANS = 1,
- FPO_NO_INFS = 2,
- FPO_NO_SIGNED_ZEROS = 3,
- FPO_ALLOW_RECIPROCAL = 4
- };
+/// Encoded function calling conventions.
+enum NaClCallingConventions { C_CallingConv = 0 };
- /// Encoded function calling conventions.
- enum NaClCallingConventions {
- C_CallingConv = 0
- };
+/// Encoded comparison predicates.
+enum NaClComparisonPredicates {
+ // Opcode U L G E Intuitive operation
+ FCMP_FALSE = 0, ///< 0 0 0 0 Always false (always folded)
+ FCMP_OEQ = 1, ///< 0 0 0 1 True if ordered and equal
+ FCMP_OGT = 2, ///< 0 0 1 0 True if ordered and greater than
+ FCMP_OGE = 3, ///< 0 0 1 1 True if ordered and greater than or equal
+ FCMP_OLT = 4, ///< 0 1 0 0 True if ordered and less than
+ FCMP_OLE = 5, ///< 0 1 0 1 True if ordered and less than or equal
+ FCMP_ONE = 6, ///< 0 1 1 0 True if ordered and operands are unequal
+ FCMP_ORD = 7, ///< 0 1 1 1 True if ordered (no nans)
+ FCMP_UNO = 8, ///< 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
+ FCMP_UEQ = 9, ///< 1 0 0 1 True if unordered or equal
+ FCMP_UGT = 10, ///< 1 0 1 0 True if unordered or greater than
+ FCMP_UGE = 11, ///< 1 0 1 1 True if unordered, greater than, or equal
+ FCMP_ULT = 12, ///< 1 1 0 0 True if unordered or less than
+ FCMP_ULE = 13, ///< 1 1 0 1 True if unordered, less than, or equal
+ FCMP_UNE = 14, ///< 1 1 1 0 True if unordered or not equal
+ FCMP_TRUE = 15, ///< 1 1 1 1 Always true (always folded)
+ ICMP_EQ = 32, ///< equal
+ ICMP_NE = 33, ///< not equal
+ ICMP_UGT = 34, ///< unsigned greater than
+ ICMP_UGE = 35, ///< unsigned greater or equal
+ ICMP_ULT = 36, ///< unsigned less than
+ ICMP_ULE = 37, ///< unsigned less or equal
+ ICMP_SGT = 38, ///< signed greater than
+ ICMP_SGE = 39, ///< signed greater or equal
+ ICMP_SLT = 40, ///< signed less than
+ ICMP_SLE = 41 ///< signed less or equal
+};
- /// Encoded comparison predicates.
- enum NaClComparisonPredicates {
- // Opcode U L G E Intuitive operation
- FCMP_FALSE = 0, ///< 0 0 0 0 Always false (always folded)
- FCMP_OEQ = 1, ///< 0 0 0 1 True if ordered and equal
- FCMP_OGT = 2, ///< 0 0 1 0 True if ordered and greater than
- FCMP_OGE = 3, ///< 0 0 1 1 True if ordered and greater than or equal
- FCMP_OLT = 4, ///< 0 1 0 0 True if ordered and less than
- FCMP_OLE = 5, ///< 0 1 0 1 True if ordered and less than or equal
- FCMP_ONE = 6, ///< 0 1 1 0 True if ordered and operands are unequal
- FCMP_ORD = 7, ///< 0 1 1 1 True if ordered (no nans)
- FCMP_UNO = 8, ///< 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
- FCMP_UEQ = 9, ///< 1 0 0 1 True if unordered or equal
- FCMP_UGT = 10, ///< 1 0 1 0 True if unordered or greater than
- FCMP_UGE = 11, ///< 1 0 1 1 True if unordered, greater than, or equal
- FCMP_ULT = 12, ///< 1 1 0 0 True if unordered or less than
- FCMP_ULE = 13, ///< 1 1 0 1 True if unordered, less than, or equal
- FCMP_UNE = 14, ///< 1 1 1 0 True if unordered or not equal
- FCMP_TRUE = 15, ///< 1 1 1 1 Always true (always folded)
- ICMP_EQ = 32, ///< equal
- ICMP_NE = 33, ///< not equal
- ICMP_UGT = 34, ///< unsigned greater than
- ICMP_UGE = 35, ///< unsigned greater or equal
- ICMP_ULT = 36, ///< unsigned less than
- ICMP_ULE = 37, ///< unsigned less or equal
- ICMP_SGT = 38, ///< signed greater than
- ICMP_SGE = 39, ///< signed greater or equal
- ICMP_SLT = 40, ///< signed less than
- ICMP_SLE = 41 ///< signed less or equal
- };
+enum NaClLinkageTypes { LINKAGE_EXTERNAL = 0, LINKAGE_INTERNAL = 3 };
- enum NaClLinkageTypes {
- LINKAGE_EXTERNAL = 0,
- LINKAGE_INTERNAL = 3
- };
+// The function body block (FUNCTION_BLOCK_ID) describes function bodies. It
+// can contain a constant block (CONSTANTS_BLOCK_ID).
+enum NaClFunctionCodes {
+ FUNC_CODE_DECLAREBLOCKS = 1, // DECLAREBLOCKS: [n]
- // The function body block (FUNCTION_BLOCK_ID) describes function bodies. It
- // can contain a constant block (CONSTANTS_BLOCK_ID).
- enum NaClFunctionCodes {
- FUNC_CODE_DECLAREBLOCKS = 1, // DECLAREBLOCKS: [n]
+ FUNC_CODE_INST_BINOP = 2, // BINOP: [opval, opval, opcode]
+ // Note: because old PNaCl bitcode files
+ // may contain flags (which we now ignore),
+ // the reader must also support:
+ // BINOP: [opval, opval, opcode, flags]
+ FUNC_CODE_INST_CAST = 3, // CAST: [opval, destty, castopc]
+ FUNC_CODE_INST_GEP = 4, // Not used in PNaCl.
+ FUNC_CODE_INST_SELECT = 5, // Not used in PNaCl. Replaced by VSELECT.
+ FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opval, opval]
+ FUNC_CODE_INST_INSERTELT = 7, // INSERTELT: [opval, opval, opval]
+ FUNC_CODE_INST_SHUFFLEVEC = 8, // Not used in PNaCl.
+ FUNC_CODE_INST_CMP = 9, // Not used in PNaCl. Replaced by CMP2.
+ FUNC_CODE_INST_RET = 10, // RET: [opval<optional>]
+ FUNC_CODE_INST_BR = 11, // BR: [bb#, bb#, cond] or [bb#]
+ FUNC_CODE_INST_SWITCH = 12, // SWITCH: [opty, op0, op1, ...]
+ FUNC_CODE_INST_INVOKE = 13, // Not used in PNaCl.
+ // 14 is unused.
+ FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
- FUNC_CODE_INST_BINOP = 2, // BINOP: [opval, opval, opcode]
- // Note: because old PNaCl bitcode files
- // may contain flags (which we now ignore),
- // the reader must also support:
- // BINOP: [opval, opval, opcode, flags]
- FUNC_CODE_INST_CAST = 3, // CAST: [opval, destty, castopc]
- FUNC_CODE_INST_GEP = 4, // Not used in PNaCl.
- FUNC_CODE_INST_SELECT = 5, // Not used in PNaCl. Replaced by VSELECT.
- FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opval, opval]
- FUNC_CODE_INST_INSERTELT = 7, // INSERTELT: [opval, opval, opval]
- FUNC_CODE_INST_SHUFFLEVEC = 8, // Not used in PNaCl.
- FUNC_CODE_INST_CMP = 9, // Not used in PNaCl. Replaced by CMP2.
- FUNC_CODE_INST_RET = 10, // RET: [opval<optional>]
- FUNC_CODE_INST_BR = 11, // BR: [bb#, bb#, cond] or [bb#]
- FUNC_CODE_INST_SWITCH = 12, // SWITCH: [opty, op0, op1, ...]
- FUNC_CODE_INST_INVOKE = 13, // Not used in PNaCl.
- // 14 is unused.
- FUNC_CODE_INST_UNREACHABLE = 15, // UNREACHABLE
+ FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...]
+ // 17 is unused.
+ // 18 is unused.
+ FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [op, align]
+ FUNC_CODE_INST_LOAD = 20, // LOAD: [op, align, ty]
+ // 21 is unused.
+ // 22 is unused.
+ FUNC_CODE_INST_VAARG = 23, // Not used in PNaCl.
+ FUNC_CODE_INST_STORE = 24, // STORE: [ptr, val, align]
+ // 25 is unused.
+ FUNC_CODE_INST_EXTRACTVAL = 26, // Not used in PNaCl.
+ FUNC_CODE_INST_INSERTVAL = 27, // Not used in PNaCl.
+ // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to
+ // support legacy vicmp/vfcmp instructions.
+ FUNC_CODE_INST_CMP2 = 28, // CMP2: [opval, opval, pred]
+ // new select on i1 or [N x i1]
+ FUNC_CODE_INST_VSELECT = 29, // VSELECT: [opval, opval, pred]
+ FUNC_CODE_INST_INBOUNDS_GEP = 30, // Not used in PNaCl.
+ FUNC_CODE_INST_INDIRECTBR = 31, // Not used in PNaCl.
+ // 32 is unused.
+ FUNC_CODE_DEBUG_LOC_AGAIN = 33, // Not used in PNaCl.
- FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...]
- // 17 is unused.
- // 18 is unused.
- FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [op, align]
- FUNC_CODE_INST_LOAD = 20, // LOAD: [op, align, ty]
- // 21 is unused.
- // 22 is unused.
- FUNC_CODE_INST_VAARG = 23, // Not used in PNaCl.
- FUNC_CODE_INST_STORE = 24, // STORE: [ptr, val, align]
- // 25 is unused.
- FUNC_CODE_INST_EXTRACTVAL = 26, // Not used in PNaCl.
- FUNC_CODE_INST_INSERTVAL = 27, // Not used in PNaCl.
- // fcmp/icmp returning Int1TY or vector of Int1Ty. Same as CMP, exists to
- // support legacy vicmp/vfcmp instructions.
- FUNC_CODE_INST_CMP2 = 28, // CMP2: [opval, opval, pred]
- // new select on i1 or [N x i1]
- FUNC_CODE_INST_VSELECT = 29, // VSELECT: [opval, opval, pred]
- FUNC_CODE_INST_INBOUNDS_GEP= 30, // Not used in PNaCl.
- FUNC_CODE_INST_INDIRECTBR = 31, // Not used in PNaCl.
- // 32 is unused.
- FUNC_CODE_DEBUG_LOC_AGAIN = 33, // Not used in PNaCl.
-
- FUNC_CODE_INST_CALL = 34, // CALL: [cc, fnid, args...]
- // See FUNC_CODE_INST_CALL_INDIRECT below.
- FUNC_CODE_DEBUG_LOC = 35, // Not used in PNaCl.
- FUNC_CODE_INST_FENCE = 36, // Not used in PNaCl.
- FUNC_CODE_INST_CMPXCHG = 37, // Not used in PNaCl.
- FUNC_CODE_INST_ATOMICRMW = 38, // Not used in PNaCl.
- FUNC_CODE_INST_RESUME = 39, // Not used in PNaCl.
- FUNC_CODE_INST_LANDINGPAD = 40, // Not used in PNaCl.
- FUNC_CODE_INST_LOADATOMIC = 41, // Not used in PNaCl.
- FUNC_CODE_INST_STOREATOMIC = 42, // Not used in PNaCl.
- FUNC_CODE_INST_FORWARDTYPEREF = 43, // TYPE: [opval, ty]
- // CALL_INDIRECT: [cc, fnid, returnty, args...]
- FUNC_CODE_INST_CALL_INDIRECT = 44
- };
-} // End naclbitc namespace
-} // End llvm namespace
+ FUNC_CODE_INST_CALL = 34, // CALL: [cc, fnid, args...]
+ // See FUNC_CODE_INST_CALL_INDIRECT below.
+ FUNC_CODE_DEBUG_LOC = 35, // Not used in PNaCl.
+ FUNC_CODE_INST_FENCE = 36, // Not used in PNaCl.
+ FUNC_CODE_INST_CMPXCHG = 37, // Not used in PNaCl.
+ FUNC_CODE_INST_ATOMICRMW = 38, // Not used in PNaCl.
+ FUNC_CODE_INST_RESUME = 39, // Not used in PNaCl.
+ FUNC_CODE_INST_LANDINGPAD = 40, // Not used in PNaCl.
+ FUNC_CODE_INST_LOADATOMIC = 41, // Not used in PNaCl.
+ FUNC_CODE_INST_STOREATOMIC = 42, // Not used in PNaCl.
+ FUNC_CODE_INST_FORWARDTYPEREF = 43, // TYPE: [opval, ty]
+ // CALL_INDIRECT: [cc, fnid, returnty, args...]
+ FUNC_CODE_INST_CALL_INDIRECT = 44
+};
+} // namespace naclbitc
+} // namespace llvm
#endif
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClReaderWriter.h b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClReaderWriter.h
index 762e51b..0e59ae8 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClReaderWriter.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Bitcode/NaCl/NaClReaderWriter.h
@@ -24,120 +24,117 @@
#include <string>
namespace llvm {
- class LLVMContext;
- class Module;
- class NaClBitcodeHeader;
- class NaClBitstreamWriter;
- class StreamingMemoryObject;
- class raw_ostream;
+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;
+/// 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;
+/// 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;
+/// \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);
+/// 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 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(
- const std::string &name, StreamingMemoryObject *streamer,
- LLVMContext &Context,
- DiagnosticHandlerFunction DiagnosticHandler = nullptr,
- std::string *ErrMsg = 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(
+ const std::string &name, StreamingMemoryObject *streamer,
+ 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,
- DiagnosticHandlerFunction DiagnosticHandler = 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,
+ 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,
- LLVMContext &Context,
- raw_ostream *Verbose = nullptr);
+/// 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,
- bool AcceptSupportedOnly = true);
+/// 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,
- const unsigned char *BufEnd) {
- return BufPtr+4 <= BufEnd &&
- BufPtr[0] == 'P' &&
- BufPtr[1] == 'E' &&
- BufPtr[2] == 'X' &&
- BufPtr[3] == 'E';
- }
+/// 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 - 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);
+// 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
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Support/DataStream.h b/third_party/subzero/pnacl-llvm/include/llvm/Support/DataStream.h
index a544316..a3a7932 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Support/DataStream.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Support/DataStream.h
@@ -13,7 +13,6 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef LLVM_SUPPORT_DATASTREAM_H
#define LLVM_SUPPORT_DATASTREAM_H
@@ -33,6 +32,6 @@
std::unique_ptr<DataStreamer> getDataFileStreamer(const std::string &Filename,
std::string *Err);
-}
+} // namespace llvm
-#endif // LLVM_SUPPORT_DATASTREAM_H_
+#endif // LLVM_SUPPORT_DATASTREAM_H_
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Support/MemoryObject.h b/third_party/subzero/pnacl-llvm/include/llvm/Support/MemoryObject.h
index e0c8749..deff6c1 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Support/MemoryObject.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Support/MemoryObject.h
@@ -63,6 +63,6 @@
virtual bool isValidAddress(uint64_t address) const = 0;
};
-}
+} // namespace llvm
#endif
diff --git a/third_party/subzero/pnacl-llvm/include/llvm/Support/StreamingMemoryObject.h b/third_party/subzero/pnacl-llvm/include/llvm/Support/StreamingMemoryObject.h
index 1ab8537..f54fc28 100644
--- a/third_party/subzero/pnacl-llvm/include/llvm/Support/StreamingMemoryObject.h
+++ b/third_party/subzero/pnacl-llvm/include/llvm/Support/StreamingMemoryObject.h
@@ -48,8 +48,8 @@
private:
mutable std::vector<unsigned char> Bytes;
std::unique_ptr<DataStreamer> Streamer;
- mutable size_t BytesRead; // Bytes read from stream
- size_t BytesSkipped;// Bytes skipped at start of stream (e.g. wrapper/header)
+ mutable size_t BytesRead; // Bytes read from stream
+ size_t BytesSkipped; // Bytes skipped at start of stream (e.g. wrapper/header)
mutable size_t ObjectSize; // 0 if unknown, set if wrapper seen or EOF reached
mutable bool EOFReached;
@@ -64,8 +64,8 @@
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 @@
return !ObjectSize || Pos < ObjectSize;
}
- StreamingMemoryObject(const StreamingMemoryObject&) = delete;
- void operator=(const StreamingMemoryObject&) = delete;
+ StreamingMemoryObject(const StreamingMemoryObject &) = delete;
+ void operator=(const StreamingMemoryObject &) = delete;
};
-MemoryObject *getNonStreamedMemoryObject(
- const unsigned char *Start, const unsigned char *End);
+MemoryObject *getNonStreamedMemoryObject(const unsigned char *Start,
+ const unsigned char *End);
-}
-#endif // STREAMINGMEMORYOBJECT_H_
+} // namespace llvm
+#endif // STREAMINGMEMORYOBJECT_H_
diff --git a/third_party/subzero/runtime/wasm-runtime.cpp b/third_party/subzero/runtime/wasm-runtime.cpp
index 7ff3859..b2d40a1 100644
--- a/third_party/subzero/runtime/wasm-runtime.cpp
+++ b/third_party/subzero/runtime/wasm-runtime.cpp
@@ -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>
diff --git a/third_party/subzero/unittest/AssemblerX8632/ControlFlow.cpp b/third_party/subzero/unittest/AssemblerX8632/ControlFlow.cpp
index 10df5ac..102a5bc 100644
--- a/third_party/subzero/unittest/AssemblerX8632/ControlFlow.cpp
+++ b/third_party/subzero/unittest/AssemblerX8632/ControlFlow.cpp
@@ -6,8 +6,8 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#include "IceAssemblerX8632.h"
#include "AssemblerX8632/TestUtil.h"
+#include "IceAssemblerX8632.h"
namespace Ice {
namespace X8632 {
diff --git a/third_party/subzero/unittest/AssemblerX8632/DataMov.cpp b/third_party/subzero/unittest/AssemblerX8632/DataMov.cpp
index 22ce0b2..7cbac23 100644
--- a/third_party/subzero/unittest/AssemblerX8632/DataMov.cpp
+++ b/third_party/subzero/unittest/AssemblerX8632/DataMov.cpp
@@ -386,8 +386,8 @@
test.setDwordTo(T0, static_cast<float>(V0)); \
} \
test.run(); \
- ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) << TestString << " value is " \
- << Value; \
+ ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -441,8 +441,8 @@
test.setDwordTo(T1, static_cast<float>(V1)); \
} \
test.run(); \
- ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) << TestString << " value is " \
- << Value; \
+ ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -501,8 +501,8 @@
test.setDwordTo(T1, static_cast<float>(V1)); \
} \
test.run(); \
- ASSERT_DOUBLE_EQ(Value, test.Dst<Type>()) << TestString << " value is " \
- << Value; \
+ ASSERT_DOUBLE_EQ(Value, test.Dst<Type>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -546,8 +546,8 @@
test.setQwordTo(T0, V0); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -569,8 +569,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -618,8 +618,8 @@
test.setDwordTo(T0, V0); \
test.run(); \
\
- ASSERT_EQ(Value, test.contentsOfDword(T0)) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.contentsOfDword(T0)) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -641,8 +641,8 @@
test.setDwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.contentsOfDword(T1)) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.contentsOfDword(T1)) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -691,8 +691,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -728,8 +728,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -766,8 +766,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -945,10 +945,12 @@
#define TestImpl(Dst, Src) \
do { \
- TestImplSingle(Dst, Src, movhlps, (uint64_t(0x9999999988888888ull), \
- uint64_t(0xCCCCCCCCDDDDDDDDull))); \
- TestImplSingle(Dst, Src, movlhps, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xEEEEEEEEFFFFFFFFull))); \
+ TestImplSingle( \
+ Dst, Src, movhlps, \
+ (uint64_t(0x9999999988888888ull), uint64_t(0xCCCCCCCCDDDDDDDDull))); \
+ TestImplSingle( \
+ Dst, Src, movlhps, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xEEEEEEEEFFFFFFFFull))); \
} while (0)
TestImpl(xmm0, xmm1);
@@ -1028,14 +1030,18 @@
#define TestPmovsxdq(Dst, Src) \
do { \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x700000007FFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x800000007FFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x70000000FFFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x80000000FFFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x700000007FFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x800000007FFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x70000000FFFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x80000000FFFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
} while (0)
TestPmovsxdq(xmm0, xmm1);
diff --git a/third_party/subzero/unittest/AssemblerX8632/GPRArith.cpp b/third_party/subzero/unittest/AssemblerX8632/GPRArith.cpp
index e6ef73a..2960f4f 100644
--- a/third_party/subzero/unittest/AssemblerX8632/GPRArith.cpp
+++ b/third_party/subzero/unittest/AssemblerX8632/GPRArith.cpp
@@ -135,8 +135,8 @@
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 @@
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 @@
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.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 @@
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.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.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"; \
diff --git a/third_party/subzero/unittest/AssemblerX8632/TestUtil.h b/third_party/subzero/unittest/AssemblerX8632/TestUtil.h
index 983a89a..fc9abae 100644
--- a/third_party/subzero/unittest/AssemblerX8632/TestUtil.h
+++ b/third_party/subzero/unittest/AssemblerX8632/TestUtil.h
@@ -318,12 +318,12 @@
return *reinterpret_cast<Dqword *>(&Ret); \
}
- DefinePackedComparisonOperator(< );
- DefinePackedComparisonOperator(<= );
- DefinePackedComparisonOperator(> );
- DefinePackedComparisonOperator(>= );
- DefinePackedComparisonOperator(== );
- DefinePackedComparisonOperator(!= );
+ DefinePackedComparisonOperator(<);
+ DefinePackedComparisonOperator(<=);
+ DefinePackedComparisonOperator(>);
+ DefinePackedComparisonOperator(>=);
+ DefinePackedComparisonOperator(==);
+ DefinePackedComparisonOperator(!=);
#undef DefinePackedComparisonOperator
@@ -387,7 +387,7 @@
DefinePackedArithOperator(/, true, false);
DefinePackedArithOperator(&, true, true);
DefinePackedArithOperator(|, true, true);
- DefinePackedArithOperator (^, true, true);
+ DefinePackedArithOperator(^, true, true);
#undef DefinePackedArithOperator
@@ -403,8 +403,8 @@
return *reinterpret_cast<Dqword *>(&Ret); \
}
- DefinePackedArithShiftImm(>> );
- DefinePackedArithShiftImm(<< );
+ DefinePackedArithShiftImm(>>);
+ DefinePackedArithShiftImm(<<);
#undef DefinePackedArithShiftImm
@@ -693,8 +693,7 @@
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<
diff --git a/third_party/subzero/unittest/AssemblerX8632/XmmArith.cpp b/third_party/subzero/unittest/AssemblerX8632/XmmArith.cpp
index da2ad72..d85126f 100644
--- a/third_party/subzero/unittest/AssemblerX8632/XmmArith.cpp
+++ b/third_party/subzero/unittest/AssemblerX8632/XmmArith.cpp
@@ -92,8 +92,8 @@
TestArithSSXmmAddr(FloatSize, 4.0, Dst1, 40.0, subss, -); \
TestArithSSXmmXmm(FloatSize, Src, 5.0, Dst0, 50.0, mulss, *); \
TestArithSSXmmAddr(FloatSize, 6.0, Dst1, 60.0, mulss, *); \
- TestArithSSXmmXmm(FloatSize, Src, 7.0, Dst0, 70.0, divss, / ); \
- TestArithSSXmmAddr(FloatSize, 8.0, Dst1, 80.0, divss, / ); \
+ TestArithSSXmmXmm(FloatSize, Src, 7.0, Dst0, 70.0, divss, /); \
+ TestArithSSXmmAddr(FloatSize, 8.0, Dst1, 80.0, divss, /); \
} while (0)
TestArithSS(32, xmm0, xmm1, xmm2);
@@ -250,113 +250,129 @@
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
Src, (uint64_t(3u), uint64_t(0u)), psra, >>, int, Size); \
- TestPArithXmmAddr(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- (uint64_t(3u), uint64_t(0u)), psra, >>, int, Size); \
- TestPArithXmmImm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- 3u, psra, >>, int, Size); \
+ TestPArithXmmAddr( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ (uint64_t(3u), uint64_t(0u)), psra, >>, int, Size); \
+ TestPArithXmmImm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ 3u, psra, >>, int, Size); \
TestPArithXmmXmm( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
Src, (uint64_t(3u), uint64_t(0u)), psrl, >>, uint, Size); \
- TestPArithXmmAddr(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- (uint64_t(3u), uint64_t(0u)), psrl, >>, uint, Size); \
- TestPArithXmmImm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- 3u, psrl, >>, uint, Size); \
+ TestPArithXmmAddr( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ (uint64_t(3u), uint64_t(0u)), psrl, >>, uint, Size); \
+ TestPArithXmmImm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ 3u, psrl, >>, uint, Size); \
TestPArithXmmXmm( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
Src, (uint64_t(3u), uint64_t(0u)), psll, <<, uint, Size); \
- TestPArithXmmAddr(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- (uint64_t(3u), uint64_t(0u)), psll, <<, uint, Size); \
- TestPArithXmmImm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- 3u, psll, <<, uint, Size); \
+ TestPArithXmmAddr( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ (uint64_t(3u), uint64_t(0u)), psll, <<, uint, Size); \
+ TestPArithXmmImm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ 3u, psll, <<, uint, Size); \
\
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pmull, *, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pmull, *, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
pmull, *, int, Size); \
if (Size != 16) { \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pmuludq, *, uint, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), \
+ uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pmuludq, *, uint, Size); \
TestPArithXmmAddr( \
- Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), \
+ uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
pmuludq, *, uint, Size); \
} \
} \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- padd, +, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ padd, +, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
padd, +, int, Size); \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- psub, -, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ psub, -, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
psub, -, int, Size); \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pand, &, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pand, &, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
pand, &, int, Size); \
\
- TestPAndnXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- int, Size); \
+ TestPAndnXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ int, Size); \
TestPAndnXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
int, Size); \
\
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- por, |, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ por, |, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
por, |, int, Size); \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pxor, ^, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pxor, ^, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
@@ -789,24 +805,27 @@
TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \
TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \
if (FloatSize == 32) { \
- TestCmppsOrdUnordXmmXmm( \
- 32, Dst, (1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \
- std::numeric_limits<float>::quiet_NaN()), \
- Src, (1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \
- std::numeric_limits<float>::quiet_NaN()), \
- unord, Type); \
- TestCmppsOrdUnordXmmAddr( \
- 32, Dst, (1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \
- std::numeric_limits<float>::quiet_NaN()), \
- (1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \
- std::numeric_limits<float>::quiet_NaN()), \
- unord, Type); \
- } else { \
- TestCmppsOrdUnordXmmXmm(64, Dst, \
- (1.0, std::numeric_limits<double>::quiet_NaN()), \
- Src, (std::numeric_limits<double>::quiet_NaN(), \
- std::numeric_limits<double>::quiet_NaN()), \
+ TestCmppsOrdUnordXmmXmm(32, Dst, \
+ (1.0, 1.0, \
+ std::numeric_limits<float>::quiet_NaN(), \
+ std::numeric_limits<float>::quiet_NaN()), \
+ Src, \
+ (1.0, std::numeric_limits<float>::quiet_NaN(), \
+ 1.0, std::numeric_limits<float>::quiet_NaN()), \
unord, Type); \
+ TestCmppsOrdUnordXmmAddr(32, Dst, \
+ (1.0, 1.0, \
+ std::numeric_limits<float>::quiet_NaN(), \
+ std::numeric_limits<float>::quiet_NaN()), \
+ (1.0, std::numeric_limits<float>::quiet_NaN(), \
+ 1.0, std::numeric_limits<float>::quiet_NaN()), \
+ unord, Type); \
+ } else { \
+ TestCmppsOrdUnordXmmXmm( \
+ 64, Dst, (1.0, std::numeric_limits<double>::quiet_NaN()), Src, \
+ (std::numeric_limits<double>::quiet_NaN(), \
+ std::numeric_limits<double>::quiet_NaN()), \
+ unord, Type); \
TestCmppsOrdUnordXmmXmm(64, Dst, (1.0, 1.0), Src, \
(1.0, std::numeric_limits<double>::quiet_NaN()), \
unord, Type); \
@@ -863,15 +882,19 @@
#define TestImpl(Dst) \
do { \
- TestImplSingle(Dst, sqrtps, (uint64_t(0x400000003F800000ull), \
- uint64_t(0x3FE2D10B408F1BBDull))); \
- TestImplSingle(Dst, rsqrtps, (uint64_t(0x3EFFF0003F7FF000ull), \
- uint64_t(0x3F1078003E64F000ull))); \
- TestImplSingle(Dst, reciprocalps, (uint64_t(0x3E7FF0003F7FF000ull), \
- uint64_t(0x3EA310003D4CC000ull))); \
+ TestImplSingle( \
+ Dst, sqrtps, \
+ (uint64_t(0x400000003F800000ull), uint64_t(0x3FE2D10B408F1BBDull))); \
+ TestImplSingle( \
+ Dst, rsqrtps, \
+ (uint64_t(0x3EFFF0003F7FF000ull), uint64_t(0x3F1078003E64F000ull))); \
+ TestImplSingle( \
+ Dst, reciprocalps, \
+ (uint64_t(0x3E7FF0003F7FF000ull), uint64_t(0x3EA310003D4CC000ull))); \
\
- TestImplSingle(Dst, sqrtpd, (uint64_t(0x4036A09E9365F5F3ull), \
- uint64_t(0x401C42FAE40282A8ull))); \
+ TestImplSingle( \
+ Dst, sqrtpd, \
+ (uint64_t(0x4036A09E9365F5F3ull), uint64_t(0x401C42FAE40282A8ull))); \
} while (0)
TestImpl(xmm0);
@@ -1871,12 +1894,14 @@
#define TestPinsrSize(Dst, GPR, Value1, Imm, Size) \
do { \
- TestPinsrXmmGPRImm(Dst, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xFFFFFFFFDDDDDDDDull)), \
- GPR, Value1, Imm, Size); \
- TestPinsrXmmAddrImm(Dst, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xFFFFFFFFDDDDDDDDull)), \
- Value1, Imm, Size); \
+ TestPinsrXmmGPRImm( \
+ Dst, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xFFFFFFFFDDDDDDDDull)), \
+ GPR, Value1, Imm, Size); \
+ TestPinsrXmmAddrImm( \
+ Dst, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xFFFFFFFFDDDDDDDDull)), \
+ Value1, Imm, Size); \
} while (0)
#define TestPinsr(Src, Dst) \
@@ -1928,9 +1953,10 @@
#define TestPextrSize(GPR, Src, Value1, Imm, Size) \
do { \
- TestPextrGPRXmmImm(GPR, Src, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xFFFFFFFFDDDDDDDDull)), \
- Imm, Size); \
+ TestPextrGPRXmmImm( \
+ GPR, Src, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xFFFFFFFFDDDDDDDDull)), \
+ Imm, Size); \
} while (0)
#define TestPextr(Src, Dst) \
@@ -2014,24 +2040,26 @@
#define TestPcmpValues(Dst, Value0, Src, Value1, Size) \
do { \
- TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpeq, == ); \
- TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpeq, == ); \
- TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpgt, < ); \
- TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpgt, < ); \
+ TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpeq, ==); \
+ TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpeq, ==); \
+ TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpgt, <); \
+ TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpgt, <); \
} while (0)
#define TestPcmpSize(Dst, Src, Size) \
do { \
- TestPcmpValues(Dst, (uint64_t(0x8888888888888888ull), \
- uint64_t(0x0000000000000000ull)), \
- Src, (uint64_t(0x0000008800008800ull), \
- uint64_t(0xFFFFFFFFFFFFFFFFull)), \
- Size); \
- TestPcmpValues(Dst, (uint64_t(0x123567ABAB55DE01ull), \
- uint64_t(0x12345abcde12345Aull)), \
- Src, (uint64_t(0x0000008800008800ull), \
- uint64_t(0xAABBCCDD1234321Aull)), \
- Size); \
+ TestPcmpValues( \
+ Dst, \
+ (uint64_t(0x8888888888888888ull), uint64_t(0x0000000000000000ull)), \
+ Src, \
+ (uint64_t(0x0000008800008800ull), uint64_t(0xFFFFFFFFFFFFFFFFull)), \
+ Size); \
+ TestPcmpValues( \
+ Dst, \
+ (uint64_t(0x123567ABAB55DE01ull), uint64_t(0x12345abcde12345Aull)), \
+ Src, \
+ (uint64_t(0x0000008800008800ull), uint64_t(0xAABBCCDD1234321Aull)), \
+ Size); \
} while (0)
#define TestPcmp(Dst, Src) \
diff --git a/third_party/subzero/unittest/AssemblerX8664/DataMov.cpp b/third_party/subzero/unittest/AssemblerX8664/DataMov.cpp
index 3771d64..1b5d487 100644
--- a/third_party/subzero/unittest/AssemblerX8664/DataMov.cpp
+++ b/third_party/subzero/unittest/AssemblerX8664/DataMov.cpp
@@ -539,8 +539,8 @@
test.setDwordTo(T0, static_cast<float>(V0)); \
} \
test.run(); \
- ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) << TestString << " value is " \
- << Value; \
+ ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -601,8 +601,8 @@
test.setDwordTo(T1, static_cast<float>(V1)); \
} \
test.run(); \
- ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) << TestString << " value is " \
- << Value; \
+ ASSERT_DOUBLE_EQ(Value, test.Xmm<Type>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -667,8 +667,8 @@
test.setDwordTo(T1, static_cast<float>(V1)); \
} \
test.run(); \
- ASSERT_DOUBLE_EQ(Value, test.Dst<Type>()) << TestString << " value is " \
- << Value; \
+ ASSERT_DOUBLE_EQ(Value, test.Dst<Type>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -719,8 +719,8 @@
test.setQwordTo(T0, V0); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -741,8 +741,8 @@
test.setQwordTo(T0, V0); \
test.run(); \
\
- ASSERT_EQ(Expected, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Expected, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -770,8 +770,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -793,8 +793,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -867,8 +867,8 @@
test.setDwordTo(T0, V0); \
test.run(); \
\
- ASSERT_EQ(Value, test.contentsOfDword(T0)) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.contentsOfDword(T0)) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -887,8 +887,8 @@
test.setQwordTo(T0, V0); \
test.run(); \
\
- ASSERT_EQ(V0, test.contentsOfQword(T0)) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(V0, test.contentsOfQword(T0)) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -916,8 +916,8 @@
test.setDwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.contentsOfDword(T1)) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.contentsOfDword(T1)) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -939,8 +939,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(V0, test.contentsOfQword(T1)) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(V0, test.contentsOfQword(T1)) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -1015,8 +1015,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -1060,8 +1060,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -1106,8 +1106,8 @@
test.setQwordTo(T1, V1); \
test.run(); \
\
- ASSERT_EQ(Value, test.Dst<uint64_t>()) << TestString << " value is " \
- << Value; \
+ ASSERT_EQ(Value, test.Dst<uint64_t>()) \
+ << TestString << " value is " << Value; \
reset(); \
} while (0)
@@ -1325,10 +1325,12 @@
#define TestImpl(Dst, Src) \
do { \
- TestImplSingle(Dst, Src, movhlps, (uint64_t(0x9999999988888888ull), \
- uint64_t(0xCCCCCCCCDDDDDDDDull))); \
- TestImplSingle(Dst, Src, movlhps, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xEEEEEEEEFFFFFFFFull))); \
+ TestImplSingle( \
+ Dst, Src, movhlps, \
+ (uint64_t(0x9999999988888888ull), uint64_t(0xCCCCCCCCDDDDDDDDull))); \
+ TestImplSingle( \
+ Dst, Src, movlhps, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xEEEEEEEEFFFFFFFFull))); \
} while (0)
TestImpl(xmm0, xmm1);
@@ -1422,14 +1424,18 @@
#define TestPmovsxdq(Dst, Src) \
do { \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x700000007FFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x800000007FFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x70000000FFFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
- TestPmovsxdqXmmXmm(Dst, Src, (uint64_t(0x80000000FFFFFFFFull), \
- uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x700000007FFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x800000007FFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x70000000FFFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
+ TestPmovsxdqXmmXmm( \
+ Dst, Src, \
+ (uint64_t(0x80000000FFFFFFFFull), uint64_t(0xAAAAAAAAEEEEEEEEull))); \
} while (0)
TestPmovsxdq(xmm0, xmm1);
diff --git a/third_party/subzero/unittest/AssemblerX8664/GPRArith.cpp b/third_party/subzero/unittest/AssemblerX8664/GPRArith.cpp
index b3d03b5..b50f8db 100644
--- a/third_party/subzero/unittest/AssemblerX8664/GPRArith.cpp
+++ b/third_party/subzero/unittest/AssemblerX8664/GPRArith.cpp
@@ -646,8 +646,8 @@
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 @@
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.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 @@
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.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.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"; \
diff --git a/third_party/subzero/unittest/AssemblerX8664/TestUtil.h b/third_party/subzero/unittest/AssemblerX8664/TestUtil.h
index 5041a08..459385c 100644
--- a/third_party/subzero/unittest/AssemblerX8664/TestUtil.h
+++ b/third_party/subzero/unittest/AssemblerX8664/TestUtil.h
@@ -430,12 +430,12 @@
return *reinterpret_cast<Dqword *>(&Ret); \
}
- DefinePackedComparisonOperator(< );
- DefinePackedComparisonOperator(<= );
- DefinePackedComparisonOperator(> );
- DefinePackedComparisonOperator(>= );
- DefinePackedComparisonOperator(== );
- DefinePackedComparisonOperator(!= );
+ DefinePackedComparisonOperator(<);
+ DefinePackedComparisonOperator(<=);
+ DefinePackedComparisonOperator(>);
+ DefinePackedComparisonOperator(>=);
+ DefinePackedComparisonOperator(==);
+ DefinePackedComparisonOperator(!=);
#undef DefinePackedComparisonOperator
@@ -499,7 +499,7 @@
DefinePackedArithOperator(/, true, false);
DefinePackedArithOperator(&, true, true);
DefinePackedArithOperator(|, true, true);
- DefinePackedArithOperator (^, true, true);
+ DefinePackedArithOperator(^, true, true);
#undef DefinePackedArithOperator
@@ -515,8 +515,8 @@
return *reinterpret_cast<Dqword *>(&Ret); \
}
- DefinePackedArithShiftImm(>> );
- DefinePackedArithShiftImm(<< );
+ DefinePackedArithShiftImm(>>);
+ DefinePackedArithShiftImm(<<);
#undef DefinePackedArithShiftImm
@@ -879,8 +879,7 @@
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<
diff --git a/third_party/subzero/unittest/AssemblerX8664/XmmArith.cpp b/third_party/subzero/unittest/AssemblerX8664/XmmArith.cpp
index 25dedfa..51280c0 100644
--- a/third_party/subzero/unittest/AssemblerX8664/XmmArith.cpp
+++ b/third_party/subzero/unittest/AssemblerX8664/XmmArith.cpp
@@ -87,8 +87,8 @@
TestArithSSXmmAddr(FloatSize, 4.0, Dst1, 40.0, subss, -); \
TestArithSSXmmXmm(FloatSize, Src, 5.0, Dst0, 50.0, mulss, *); \
TestArithSSXmmAddr(FloatSize, 6.0, Dst1, 60.0, mulss, *); \
- TestArithSSXmmXmm(FloatSize, Src, 7.0, Dst0, 70.0, divss, / ); \
- TestArithSSXmmAddr(FloatSize, 8.0, Dst1, 80.0, divss, / ); \
+ TestArithSSXmmXmm(FloatSize, Src, 7.0, Dst0, 70.0, divss, /); \
+ TestArithSSXmmAddr(FloatSize, 8.0, Dst1, 80.0, divss, /); \
} while (0)
#define TestImpl(Src, Dst0, Dst1) \
@@ -247,113 +247,129 @@
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
Src, (uint64_t(3u), uint64_t(0u)), psra, >>, int, Size); \
- TestPArithXmmAddr(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- (uint64_t(3u), uint64_t(0u)), psra, >>, int, Size); \
- TestPArithXmmImm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- 3u, psra, >>, int, Size); \
+ TestPArithXmmAddr( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ (uint64_t(3u), uint64_t(0u)), psra, >>, int, Size); \
+ TestPArithXmmImm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ 3u, psra, >>, int, Size); \
TestPArithXmmXmm( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
Src, (uint64_t(3u), uint64_t(0u)), psrl, >>, uint, Size); \
- TestPArithXmmAddr(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- (uint64_t(3u), uint64_t(0u)), psrl, >>, uint, Size); \
- TestPArithXmmImm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- 3u, psrl, >>, uint, Size); \
+ TestPArithXmmAddr( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ (uint64_t(3u), uint64_t(0u)), psrl, >>, uint, Size); \
+ TestPArithXmmImm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ 3u, psrl, >>, uint, Size); \
TestPArithXmmXmm( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
Src, (uint64_t(3u), uint64_t(0u)), psll, <<, uint, Size); \
- TestPArithXmmAddr(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- (uint64_t(3u), uint64_t(0u)), psll, <<, uint, Size); \
- TestPArithXmmImm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- 3u, psll, <<, uint, Size); \
+ TestPArithXmmAddr( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ (uint64_t(3u), uint64_t(0u)), psll, <<, uint, Size); \
+ TestPArithXmmImm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ 3u, psll, <<, uint, Size); \
\
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pmull, *, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pmull, *, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
pmull, *, int, Size); \
if (Size != 16) { \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pmuludq, *, uint, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), \
+ uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pmuludq, *, uint, Size); \
TestPArithXmmAddr( \
- Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), \
+ uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
pmuludq, *, uint, Size); \
} \
} \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- padd, +, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ padd, +, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
padd, +, int, Size); \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- psub, -, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ psub, -, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
psub, -, int, Size); \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pand, &, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pand, &, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
pand, &, int, Size); \
\
- TestPAndnXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- int, Size); \
+ TestPAndnXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ int, Size); \
TestPAndnXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
int, Size); \
\
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- por, |, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ por, |, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
(uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
por, |, int, Size); \
- TestPArithXmmXmm(Dst, (uint64_t(0x8040201008040201ull), \
- uint64_t(0x8080404002020101ull)), \
- Src, (uint64_t(0xFFFFFFFF00000000ull), \
- uint64_t(0x0123456789ABCDEull)), \
- pxor, ^, int, Size); \
+ TestPArithXmmXmm( \
+ Dst, \
+ (uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
+ Src, \
+ (uint64_t(0xFFFFFFFF00000000ull), uint64_t(0x0123456789ABCDEull)), \
+ pxor, ^, int, Size); \
TestPArithXmmAddr( \
Dst, \
(uint64_t(0x8040201008040201ull), uint64_t(0x8080404002020101ull)), \
@@ -802,24 +818,27 @@
TestCmppsXmmXmm(FloatSize, Dst, Value0, Src, Value1, eq, ==, Type); \
TestCmppsXmmAddr(FloatSize, Dst, Value0, Value1, eq, ==, Type); \
if (FloatSize == 32) { \
- TestCmppsOrdUnordXmmXmm( \
- 32, Dst, (1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \
- std::numeric_limits<float>::quiet_NaN()), \
- Src, (1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \
- std::numeric_limits<float>::quiet_NaN()), \
- unord, Type); \
- TestCmppsOrdUnordXmmAddr( \
- 32, Dst, (1.0, 1.0, std::numeric_limits<float>::quiet_NaN(), \
- std::numeric_limits<float>::quiet_NaN()), \
- (1.0, std::numeric_limits<float>::quiet_NaN(), 1.0, \
- std::numeric_limits<float>::quiet_NaN()), \
- unord, Type); \
- } else { \
- TestCmppsOrdUnordXmmXmm(64, Dst, \
- (1.0, std::numeric_limits<double>::quiet_NaN()), \
- Src, (std::numeric_limits<double>::quiet_NaN(), \
- std::numeric_limits<double>::quiet_NaN()), \
+ TestCmppsOrdUnordXmmXmm(32, Dst, \
+ (1.0, 1.0, \
+ std::numeric_limits<float>::quiet_NaN(), \
+ std::numeric_limits<float>::quiet_NaN()), \
+ Src, \
+ (1.0, std::numeric_limits<float>::quiet_NaN(), \
+ 1.0, std::numeric_limits<float>::quiet_NaN()), \
unord, Type); \
+ TestCmppsOrdUnordXmmAddr(32, Dst, \
+ (1.0, 1.0, \
+ std::numeric_limits<float>::quiet_NaN(), \
+ std::numeric_limits<float>::quiet_NaN()), \
+ (1.0, std::numeric_limits<float>::quiet_NaN(), \
+ 1.0, std::numeric_limits<float>::quiet_NaN()), \
+ unord, Type); \
+ } else { \
+ TestCmppsOrdUnordXmmXmm( \
+ 64, Dst, (1.0, std::numeric_limits<double>::quiet_NaN()), Src, \
+ (std::numeric_limits<double>::quiet_NaN(), \
+ std::numeric_limits<double>::quiet_NaN()), \
+ unord, Type); \
TestCmppsOrdUnordXmmXmm(64, Dst, (1.0, 1.0), Src, \
(1.0, std::numeric_limits<double>::quiet_NaN()), \
unord, Type); \
@@ -884,15 +903,19 @@
#define TestImpl(Dst) \
do { \
- TestImplSingle(Dst, sqrtps, (uint64_t(0x400000003F800000ull), \
- uint64_t(0x3FE2D10B408F1BBDull))); \
- TestImplSingle(Dst, rsqrtps, (uint64_t(0x3EFFF0003F7FF000ull), \
- uint64_t(0x3F1078003E64F000ull))); \
- TestImplSingle(Dst, reciprocalps, (uint64_t(0x3E7FF0003F7FF000ull), \
- uint64_t(0x3EA310003D4CC000ull))); \
+ TestImplSingle( \
+ Dst, sqrtps, \
+ (uint64_t(0x400000003F800000ull), uint64_t(0x3FE2D10B408F1BBDull))); \
+ TestImplSingle( \
+ Dst, rsqrtps, \
+ (uint64_t(0x3EFFF0003F7FF000ull), uint64_t(0x3F1078003E64F000ull))); \
+ TestImplSingle( \
+ Dst, reciprocalps, \
+ (uint64_t(0x3E7FF0003F7FF000ull), uint64_t(0x3EA310003D4CC000ull))); \
\
- TestImplSingle(Dst, sqrtpd, (uint64_t(0x4036A09E9365F5F3ull), \
- uint64_t(0x401C42FAE40282A8ull))); \
+ TestImplSingle( \
+ Dst, sqrtpd, \
+ (uint64_t(0x4036A09E9365F5F3ull), uint64_t(0x401C42FAE40282A8ull))); \
} while (0)
TestImpl(xmm0);
@@ -1974,12 +1997,14 @@
#define TestPinsrSize(Dst, GPR, Value1, Imm, Size) \
do { \
- TestPinsrXmmGPRImm(Dst, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xFFFFFFFFDDDDDDDDull)), \
- GPR, Value1, Imm, Size); \
- TestPinsrXmmAddrImm(Dst, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xFFFFFFFFDDDDDDDDull)), \
- Value1, Imm, Size); \
+ TestPinsrXmmGPRImm( \
+ Dst, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xFFFFFFFFDDDDDDDDull)), \
+ GPR, Value1, Imm, Size); \
+ TestPinsrXmmAddrImm( \
+ Dst, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xFFFFFFFFDDDDDDDDull)), \
+ Value1, Imm, Size); \
} while (0)
#define TestPinsr(Src, Dst) \
@@ -2039,9 +2064,10 @@
#define TestPextrSize(GPR, Src, Value1, Imm, Size) \
do { \
- TestPextrGPRXmmImm(GPR, Src, (uint64_t(0xAAAAAAAABBBBBBBBull), \
- uint64_t(0xFFFFFFFFDDDDDDDDull)), \
- Imm, Size); \
+ TestPextrGPRXmmImm( \
+ GPR, Src, \
+ (uint64_t(0xAAAAAAAABBBBBBBBull), uint64_t(0xFFFFFFFFDDDDDDDDull)), \
+ Imm, Size); \
} while (0)
#define TestPextr(Src, Dst) \
@@ -2131,24 +2157,26 @@
#define TestPcmpValues(Dst, Value0, Src, Value1, Size) \
do { \
- TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpeq, == ); \
- TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpeq, == ); \
- TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpgt, < ); \
- TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpgt, < ); \
+ TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpeq, ==); \
+ TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpeq, ==); \
+ TestPcmpXmmXmm(Dst, Value0, Src, Value1, Size, pcmpgt, <); \
+ TestPcmpXmmAddr(Dst, Value0, Value1, Size, pcmpgt, <); \
} while (0)
#define TestPcmpSize(Dst, Src, Size) \
do { \
- TestPcmpValues(Dst, (uint64_t(0x8888888888888888ull), \
- uint64_t(0x0000000000000000ull)), \
- Src, (uint64_t(0x0000008800008800ull), \
- uint64_t(0xFFFFFFFFFFFFFFFFull)), \
- Size); \
- TestPcmpValues(Dst, (uint64_t(0x123567ABAB55DE01ull), \
- uint64_t(0x12345abcde12345Aull)), \
- Src, (uint64_t(0x0000008800008800ull), \
- uint64_t(0xAABBCCDD1234321Aull)), \
- Size); \
+ TestPcmpValues( \
+ Dst, \
+ (uint64_t(0x8888888888888888ull), uint64_t(0x0000000000000000ull)), \
+ Src, \
+ (uint64_t(0x0000008800008800ull), uint64_t(0xFFFFFFFFFFFFFFFFull)), \
+ Size); \
+ TestPcmpValues( \
+ Dst, \
+ (uint64_t(0x123567ABAB55DE01ull), uint64_t(0x12345abcde12345Aull)), \
+ Src, \
+ (uint64_t(0x0000008800008800ull), uint64_t(0xAABBCCDD1234321Aull)), \
+ Size); \
} while (0)
#define TestPcmp(Dst, Src) \
diff --git a/third_party/subzero/unittest/BitcodeMunge.cpp b/third_party/subzero/unittest/BitcodeMunge.cpp
index 3da21ec..7b3ecd0 100644
--- a/third_party/subzero/unittest/BitcodeMunge.cpp
+++ b/third_party/subzero/unittest/BitcodeMunge.cpp
@@ -14,8 +14,8 @@
#include "BitcodeMunge.h"
#include "IceCfg.h"
#include "IceClFlags.h"
-#include "PNaClTranslator.h"
#include "IceTypes.h"
+#include "PNaClTranslator.h"
namespace IceTest {
diff --git a/third_party/subzero/unittest/IceParseInstsTest.cpp b/third_party/subzero/unittest/IceParseInstsTest.cpp
index 25a2799..47136cf 100644
--- a/third_party/subzero/unittest/IceParseInstsTest.cpp
+++ b/third_party/subzero/unittest/IceParseInstsTest.cpp
@@ -29,31 +29,25 @@
constexpr bool ParseError = true;
// Note: alignment stored as 0 or log2(Alignment)+1.
-uint64_t getEncAlignPower(unsigned Power) {
- return Power + 1;
-}
+uint64_t getEncAlignPower(unsigned Power) { return Power + 1; }
uint64_t getEncAlignZero() { return 0; }
/// Test how we report a call arg that refers to nonexistent call argument
TEST(IceParseInstsTest, NonexistentCallArg) {
const uint64_t BitcodeRecords[] = {
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator,
- 3, naclbitc::TYPE_CODE_NUMENTRY, 3, Terminator,
- 3, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
- 3, naclbitc::TYPE_CODE_VOID, Terminator,
- 3, naclbitc::TYPE_CODE_FUNCTION, 0, 1, 0, 0, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 1, 3, Terminator,
- 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 0, 3, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2, Terminator,
- 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
+ 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator, 1,
+ naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator, 3,
+ naclbitc::TYPE_CODE_NUMENTRY, 3, Terminator, 3,
+ naclbitc::TYPE_CODE_INTEGER, 32, Terminator, 3, naclbitc::TYPE_CODE_VOID,
+ Terminator, 3, naclbitc::TYPE_CODE_FUNCTION, 0, 1, 0, 0, Terminator, 0,
+ naclbitc::BLK_CODE_EXIT, Terminator, 3, naclbitc::MODULE_CODE_FUNCTION, 2,
+ 0, 1, 3, Terminator, 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 0, 3,
+ Terminator, 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2,
+ Terminator, 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
// Note: 100 is a bad value index in next line.
- 3, naclbitc::FUNC_CODE_INST_CALL, 0, 4, 2, 100, Terminator,
- 3, naclbitc::FUNC_CODE_INST_RET, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator
- };
+ 3, naclbitc::FUNC_CODE_INST_CALL, 0, 4, 2, 100, Terminator, 3,
+ naclbitc::FUNC_CODE_INST_RET, Terminator, 0, naclbitc::BLK_CODE_EXIT,
+ Terminator, 0, naclbitc::BLK_CODE_EXIT, Terminator};
// Show bitcode objdump for BitcodeRecords.
NaClObjDumpMunger DumpMunger(ARRAY_TERM(BitcodeRecords));
@@ -76,22 +70,70 @@
/// Test how we recognize alignments in alloca instructions.
TEST(IceParseInstsTests, AllocaAlignment) {
- const uint64_t BitcodeRecords[] = {
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator,
- 3, naclbitc::TYPE_CODE_NUMENTRY, 4, Terminator,
- 3, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
- 3, naclbitc::TYPE_CODE_VOID, Terminator,
- 3, naclbitc::TYPE_CODE_FUNCTION, 0, 1, 0, Terminator,
- 3, naclbitc::TYPE_CODE_INTEGER, 8, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 0, 3, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2, Terminator,
- 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
- 3, naclbitc::FUNC_CODE_INST_ALLOCA, 1, getEncAlignPower(0), Terminator,
- 3, naclbitc::FUNC_CODE_INST_RET, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator};
+ const uint64_t BitcodeRecords[] = {1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::MODULE_BLOCK_ID,
+ 2,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::TYPE_BLOCK_ID_NEW,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_NUMENTRY,
+ 4,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_INTEGER,
+ 32,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_VOID,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_FUNCTION,
+ 0,
+ 1,
+ 0,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_INTEGER,
+ 8,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 3,
+ naclbitc::MODULE_CODE_FUNCTION,
+ 2,
+ 0,
+ 0,
+ 3,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::FUNCTION_BLOCK_ID,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_DECLAREBLOCKS,
+ 1,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_ALLOCA,
+ 1,
+ getEncAlignPower(0),
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_RET,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator};
const uint64_t ReplaceIndex = 11; // index for FUNC_CODE_INST_ALLOCA
@@ -108,8 +150,13 @@
// Show what happens when changing alignment to 0.
const uint64_t Align0[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_ALLOCA, 1, getEncAlignZero(), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_ALLOCA,
+ 1,
+ getEncAlignZero(),
+ Terminator,
};
EXPECT_TRUE(Munger.runTest(ARRAY(Align0)));
EXPECT_TRUE(DumpMunger.runTestForAssembly(ARRAY(Align0)));
@@ -118,8 +165,13 @@
// Show what happens when changing alignment to 2**30.
const uint64_t Align30[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_ALLOCA, 1, getEncAlignPower(30), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_ALLOCA,
+ 1,
+ getEncAlignPower(30),
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align30), ParseError));
EXPECT_EQ("Error(62:4): Invalid function record: <19 1 31>\n",
@@ -134,8 +186,13 @@
// Show what happens when changing alignment to 2**29.
const uint64_t Align29[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_ALLOCA, 1, getEncAlignPower(29), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_ALLOCA,
+ 1,
+ getEncAlignPower(29),
+ Terminator,
};
EXPECT_TRUE(Munger.runTest(ARRAY(Align29)));
EXPECT_TRUE(DumpMunger.runTestForAssembly(ARRAY(Align29)));
@@ -145,20 +202,65 @@
// Test how we recognize alignments in load i32 instructions.
TEST(IceParseInstsTests, LoadI32Alignment) {
- const uint64_t BitcodeRecords[] = {
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator,
- 3, naclbitc::TYPE_CODE_NUMENTRY, 2, Terminator,
- 3, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
- 3, naclbitc::TYPE_CODE_FUNCTION, 0, 0, 0, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 3, naclbitc::MODULE_CODE_FUNCTION, 1, 0, 0, 3, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2, Terminator,
- 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(0), 0, Terminator,
- 3, naclbitc::FUNC_CODE_INST_RET, 1, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator};
+ const uint64_t BitcodeRecords[] = {1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::MODULE_BLOCK_ID,
+ 2,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::TYPE_BLOCK_ID_NEW,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_NUMENTRY,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_INTEGER,
+ 32,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_FUNCTION,
+ 0,
+ 0,
+ 0,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 3,
+ naclbitc::MODULE_CODE_FUNCTION,
+ 1,
+ 0,
+ 0,
+ 3,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::FUNCTION_BLOCK_ID,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_DECLAREBLOCKS,
+ 1,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(0),
+ 0,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_RET,
+ 1,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator};
const uint64_t ReplaceIndex = 9; // index for FUNC_CODE_INST_LOAD
@@ -173,8 +275,14 @@
// Show what happens when changing alignment to 0.
const uint64_t Align0[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignZero(), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignZero(),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align0), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 0 0>\n",
@@ -186,8 +294,14 @@
// Show what happens when changing alignment to 4.
const uint64_t Align4[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(2), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(2),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align4), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 3 0>\n",
@@ -199,8 +313,14 @@
// Show what happens when changing alignment to 2**29.
const uint64_t Align29[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(29), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(29),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align29), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 30 0>\n",
@@ -212,8 +332,14 @@
// Show what happens when changing alignment to 2**30.
const uint64_t Align30[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(30), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(30),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align30), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 31 0>\n",
@@ -226,21 +352,68 @@
// Test how we recognize alignments in load float instructions.
TEST(IceParseInstsTests, LoadFloatAlignment) {
- const uint64_t BitcodeRecords[] = {
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator,
- 3, naclbitc::TYPE_CODE_NUMENTRY, 3, Terminator,
- 3, naclbitc::TYPE_CODE_FLOAT, Terminator,
- 3, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
- 3, naclbitc::TYPE_CODE_FUNCTION, 0, 0, 1, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 0, 3, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2, Terminator,
- 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(0), 0, Terminator,
- 3, naclbitc::FUNC_CODE_INST_RET, 1, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator};
+ const uint64_t BitcodeRecords[] = {1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::MODULE_BLOCK_ID,
+ 2,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::TYPE_BLOCK_ID_NEW,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_NUMENTRY,
+ 3,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_FLOAT,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_INTEGER,
+ 32,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_FUNCTION,
+ 0,
+ 0,
+ 1,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 3,
+ naclbitc::MODULE_CODE_FUNCTION,
+ 2,
+ 0,
+ 0,
+ 3,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::FUNCTION_BLOCK_ID,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_DECLAREBLOCKS,
+ 1,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(0),
+ 0,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_RET,
+ 1,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator};
const uint64_t ReplaceIndex = 10; // index for FUNC_CODE_INST_LOAD
@@ -255,22 +428,33 @@
// Show what happens when changing alignment to 0.
const uint64_t Align0[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignZero(), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignZero(),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align0), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 0 0>\n",
Munger.getTestResults());
EXPECT_FALSE(DumpMunger.runTestForAssembly(ARRAY(Align0)));
- EXPECT_EQ(
- " %v0 = load float* %p0, align 0;\n"
+ EXPECT_EQ(" %v0 = load float* %p0, align 0;\n"
"Error(58:4): load: Illegal alignment for float. Expects: 1 or 4\n",
DumpMunger.getLinesWithSubstring("load"));
// Show what happens when changing alignment to 4.
const uint64_t Align4[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(2), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(2),
+ 0,
+ Terminator,
};
EXPECT_TRUE(Munger.runTest(ARRAY(Align4)));
EXPECT_TRUE(DumpMunger.runTestForAssembly(ARRAY(Align4)));
@@ -278,50 +462,108 @@
DumpMunger.getLinesWithSubstring("load"));
const uint64_t Align29[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(29), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(29),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align29), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 30 0>\n",
Munger.getTestResults());
EXPECT_FALSE(DumpMunger.runTestForAssembly(ARRAY(Align29)));
- EXPECT_EQ(
- " %v0 = load float* %p0, align 536870912;\n"
+ EXPECT_EQ(" %v0 = load float* %p0, align 536870912;\n"
"Error(58:4): load: Illegal alignment for float. Expects: 1 or 4\n",
DumpMunger.getLinesWithSubstring("load"));
// Show what happens when changing alignment to 2**30.
const uint64_t Align30[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_LOAD, 1, getEncAlignPower(30), 0, Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_LOAD,
+ 1,
+ getEncAlignPower(30),
+ 0,
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align30), ParseError));
EXPECT_EQ("Error(58:4): Invalid function record: <20 1 31 0>\n",
Munger.getTestResults());
EXPECT_FALSE(DumpMunger.runTestForAssembly(ARRAY(Align30)));
- EXPECT_EQ(
- " %v0 = load float* %p0, align 0;\n"
+ EXPECT_EQ(" %v0 = load float* %p0, align 0;\n"
"Error(58:4): load: Illegal alignment for float. Expects: 1 or 4\n",
DumpMunger.getLinesWithSubstring("load"));
}
// Test how we recognize alignments in store instructions.
TEST(NaClParseInstsTests, StoreAlignment) {
- const uint64_t BitcodeRecords[] = {
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::MODULE_BLOCK_ID, 2, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::TYPE_BLOCK_ID_NEW, 2, Terminator,
- 3, naclbitc::TYPE_CODE_NUMENTRY, 3, Terminator,
- 3, naclbitc::TYPE_CODE_FLOAT, Terminator,
- 3, naclbitc::TYPE_CODE_INTEGER, 32, Terminator,
- 3, naclbitc::TYPE_CODE_FUNCTION, 0, 0, 1, 0, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 3, naclbitc::MODULE_CODE_FUNCTION, 2, 0, 0, 3, Terminator,
- 1, naclbitc::BLK_CODE_ENTER, naclbitc::FUNCTION_BLOCK_ID, 2, Terminator,
- 3, naclbitc::FUNC_CODE_DECLAREBLOCKS, 1, Terminator,
- 3, naclbitc::FUNC_CODE_INST_STORE, 2, 1, getEncAlignPower(0), Terminator,
- 3, naclbitc::FUNC_CODE_INST_RET, 1, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator,
- 0, naclbitc::BLK_CODE_EXIT, Terminator};
+ const uint64_t BitcodeRecords[] = {1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::MODULE_BLOCK_ID,
+ 2,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::TYPE_BLOCK_ID_NEW,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_NUMENTRY,
+ 3,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_FLOAT,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_INTEGER,
+ 32,
+ Terminator,
+ 3,
+ naclbitc::TYPE_CODE_FUNCTION,
+ 0,
+ 0,
+ 1,
+ 0,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 3,
+ naclbitc::MODULE_CODE_FUNCTION,
+ 2,
+ 0,
+ 0,
+ 3,
+ Terminator,
+ 1,
+ naclbitc::BLK_CODE_ENTER,
+ naclbitc::FUNCTION_BLOCK_ID,
+ 2,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_DECLAREBLOCKS,
+ 1,
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_STORE,
+ 2,
+ 1,
+ getEncAlignPower(0),
+ Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_RET,
+ 1,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator,
+ 0,
+ naclbitc::BLK_CODE_EXIT,
+ Terminator};
const uint64_t ReplaceIndex = 10; // index for FUNC_CODE_INST_STORE
@@ -338,8 +580,14 @@
// Show what happens when changing alignment to 0.
const uint64_t Align0[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_STORE, 2, 1, getEncAlignZero(), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_STORE,
+ 2,
+ 1,
+ getEncAlignZero(),
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align0), ParseError));
EXPECT_EQ("Error(62:4): Invalid function record: <24 2 1 0>\n",
@@ -352,16 +600,28 @@
// Show what happens when changing alignment to 4.
const uint64_t Align4[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_STORE, 2, 1, getEncAlignPower(2), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_STORE,
+ 2,
+ 1,
+ getEncAlignPower(2),
+ Terminator,
};
EXPECT_TRUE(Munger.runTest(ARRAY(Align4)));
EXPECT_TRUE(DumpMunger.runTestForAssembly(ARRAY(Align4)));
// Show what happens when changing alignment to 8.
const uint64_t Align8[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_STORE, 2, 1, getEncAlignPower(3), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_STORE,
+ 2,
+ 1,
+ getEncAlignPower(3),
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align8), ParseError));
EXPECT_EQ("Error(62:4): Invalid function record: <24 2 1 4>\n",
@@ -374,8 +634,14 @@
// Show what happens when changing alignment to 2**29.
const uint64_t Align29[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
- 3, naclbitc::FUNC_CODE_INST_STORE, 2, 1, getEncAlignPower(29), Terminator,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
+ 3,
+ naclbitc::FUNC_CODE_INST_STORE,
+ 2,
+ 1,
+ getEncAlignPower(29),
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align29), ParseError));
EXPECT_EQ("Error(62:4): Invalid function record: <24 2 1 30>\n",
@@ -387,9 +653,15 @@
DumpMunger.getLinesWithSubstring("store"));
const uint64_t Align30[] = {
- ReplaceIndex, NaClMungedBitcode::Replace,
+ ReplaceIndex,
+ NaClMungedBitcode::Replace,
// Note: alignment stored as 0 or log2(Alignment)+1.
- 3, naclbitc::FUNC_CODE_INST_STORE, 2, 1, getEncAlignPower(30), Terminator,
+ 3,
+ naclbitc::FUNC_CODE_INST_STORE,
+ 2,
+ 1,
+ getEncAlignPower(30),
+ Terminator,
};
EXPECT_FALSE(Munger.runTest(ARRAY(Align30), ParseError));
EXPECT_EQ("Error(62:4): Invalid function record: <24 2 1 31>\n",
diff --git a/third_party/subzero/unittest/IceParseTypesTest.cpp b/third_party/subzero/unittest/IceParseTypesTest.cpp
index 6449697..6657d32 100644
--- a/third_party/subzero/unittest/IceParseTypesTest.cpp
+++ b/third_party/subzero/unittest/IceParseTypesTest.cpp
@@ -24,16 +24,33 @@
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 @@
// 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);