Subzero: Fix and clean up some cross tests.
1. It turns out that the crosstest scripts mix different versions of
clang - build_pnacl_ir.py uses pnacl-clang from the NaCl SDK for the
tests, while crosstest.py uses clang/clang++ from LLVM_BIN_PATH for
the driver. The SDK has been updated to use a different version of
the standard library, and now there is a mismatch as to whether int8_t
is typedef'd to 'char' or 'signed char', leading to name mangling
mismatches. (char, signed char, and unsigned char are distinct
types.) We deal with this by using myint8_t which is explicitly
defined as signed char.
2. Some ugly function pointer casting in test_arith_main.cpp is fixed/removed.
3. std::endl is replaced with "\n".
4. License text is added to tests that were touched by the above items.
BUG= none
R=wala@chromium.org
Review URL: https://codereview.chromium.org/435353002
diff --git a/crosstest/test_arith.cpp b/crosstest/test_arith.cpp
index ed6c9d3..6f8aec4 100644
--- a/crosstest/test_arith.cpp
+++ b/crosstest/test_arith.cpp
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_arith.cpp - Arithmetic operator tests -------===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation for crosstesting arithmetic operations.
+//
+//===----------------------------------------------------------------------===//
+
// This aims to test all the arithmetic bitcode instructions across
// all PNaCl primitive data types.
@@ -19,7 +32,7 @@
#define X(inst, op, isdiv) \
bool test##inst(bool a, bool b) { return a op b; } \
- int8_t test##inst(int8_t a, int8_t b) { return a op b; } \
+ myint8_t test##inst(myint8_t a, myint8_t b) { return a op b; } \
int16_t test##inst(int16_t a, int16_t b) { return a op b; } \
int32_t test##inst(int32_t a, int32_t b) { return a op b; } \
int64_t test##inst(int64_t a, int64_t b) { return a op b; } \
diff --git a/crosstest/test_arith.def b/crosstest/test_arith.def
index 019eb77..9ebb4fd 100644
--- a/crosstest/test_arith.def
+++ b/crosstest/test_arith.def
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_arith.def - macros for tests ----*- C++ -*---===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines macros for crosstesting arithmetic operations.
+//
+//===----------------------------------------------------------------------===//
+
#ifndef TEST_ARITH_DEF
#define TEST_ARITH_DEF
diff --git a/crosstest/test_arith.h b/crosstest/test_arith.h
index 20591d5..c9cd965 100644
--- a/crosstest/test_arith.h
+++ b/crosstest/test_arith.h
@@ -31,7 +31,7 @@
#define X(inst, op, isdiv) \
bool test##inst(bool a, bool b); \
- int8_t test##inst(int8_t a, int8_t b); \
+ myint8_t test##inst(myint8_t a, myint8_t b); \
int16_t test##inst(int16_t a, int16_t b); \
int32_t test##inst(int32_t a, int32_t b); \
int64_t test##inst(int64_t a, int64_t b); \
diff --git a/crosstest/test_arith_main.cpp b/crosstest/test_arith_main.cpp
index 682fce8..b032a5f 100644
--- a/crosstest/test_arith_main.cpp
+++ b/crosstest/test_arith_main.cpp
@@ -50,24 +50,24 @@
volatile unsigned Values[] = INT_VALUE_ARRAY;
const static size_t NumValues = sizeof(Values) / sizeof(*Values);
static struct {
+ // For functions that operate on unsigned values, the
+ // FuncLlcSigned and FuncSzSigned fields are NULL. For functions
+ // that operate on signed values, the FuncLlcUnsigned and
+ // FuncSzUnsigned fields are NULL.
const char *Name;
- FuncTypeUnsigned FuncLlc;
- FuncTypeUnsigned FuncSz;
+ FuncTypeUnsigned FuncLlcUnsigned;
+ FuncTypeUnsigned FuncSzUnsigned;
+ FuncTypeSigned FuncLlcSigned;
+ FuncTypeSigned FuncSzSigned;
bool ExcludeDivExceptions; // for divide related tests
} Funcs[] = {
#define X(inst, op, isdiv) \
- { \
- STR(inst), (FuncTypeUnsigned)test##inst, \
- (FuncTypeUnsigned)Subzero_::test##inst, isdiv \
- } \
+ { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \
,
UINTOP_TABLE
#undef X
#define X(inst, op, isdiv) \
- { \
- STR(inst), (FuncTypeUnsigned)(FuncTypeSigned)test##inst, \
- (FuncTypeUnsigned)(FuncTypeSigned)Subzero_::test##inst, isdiv \
- } \
+ { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \
,
SINTOP_TABLE
#undef X
@@ -87,8 +87,14 @@
inputsMayTriggerException<TypeSigned>(Value1, Value2))
continue;
++TotalTests;
- TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2);
- TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
+ TypeUnsigned ResultSz, ResultLlc;
+ if (Funcs[f].FuncSzUnsigned) {
+ ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
+ ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
+ } else {
+ ResultSz = Funcs[f].FuncSzSigned(Value1, Value2);
+ ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2);
+ }
if (ResultSz == ResultLlc) {
++Passes;
} else {
@@ -96,7 +102,7 @@
std::cout << "test" << Funcs[f].Name
<< (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
<< ", " << Value2 << "): sz=" << (unsigned)ResultSz
- << " llc=" << (unsigned)ResultLlc << std::endl;
+ << " llc=" << (unsigned)ResultLlc << "\n";
}
}
}
@@ -117,8 +123,14 @@
inputsMayTriggerException<TypeSigned>(Value1, Value2))
continue;
++TotalTests;
- TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2);
- TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
+ TypeUnsigned ResultSz, ResultLlc;
+ if (Funcs[f].FuncSzUnsigned) {
+ ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
+ ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
+ } else {
+ ResultSz = Funcs[f].FuncSzSigned(Value1, Value2);
+ ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2);
+ }
if (ResultSz == ResultLlc) {
++Passes;
} else {
@@ -126,7 +138,7 @@
std::cout << "test" << Funcs[f].Name
<< (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
<< ", " << Value2 << "): sz=" << (unsigned)ResultSz
- << " llc=" << (unsigned)ResultLlc << std::endl;
+ << " llc=" << (unsigned)ResultLlc << "\n";
}
}
}
@@ -150,23 +162,27 @@
volatile unsigned Values[] = INT_VALUE_ARRAY;
const static size_t NumValues = sizeof(Values) / sizeof(*Values);
static struct {
+ // For functions that operate on unsigned values, the
+ // FuncLlcSigned and FuncSzSigned fields are NULL. For functions
+ // that operate on signed values, the FuncLlcUnsigned and
+ // FuncSzUnsigned fields are NULL.
const char *Name;
- FuncTypeUnsigned FuncLlc;
- FuncTypeUnsigned FuncSz;
+ FuncTypeUnsigned FuncLlcUnsigned;
+ FuncTypeUnsigned FuncSzUnsigned;
+ FuncTypeSigned FuncLlcSigned;
+ FuncTypeSigned FuncSzSigned;
bool ExcludeDivExceptions; // for divide related tests
} Funcs[] = {
#define X(inst, op, isdiv) \
{ \
- STR(inst), (FuncTypeUnsigned)test##inst, \
- (FuncTypeUnsigned)Subzero_::test##inst, isdiv \
+ STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv \
} \
,
UINTOP_TABLE
#undef X
#define X(inst, op, isdiv) \
{ \
- STR(inst), (FuncTypeUnsigned)(FuncTypeSigned)test##inst, \
- (FuncTypeUnsigned)(FuncTypeSigned)Subzero_::test##inst, isdiv \
+ STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv \
} \
,
SINTOP_TABLE
@@ -190,9 +206,15 @@
++j;
}
// Perform the test.
- TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2);
- TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
+ TypeUnsigned ResultSz, ResultLlc;
++TotalTests;
+ if (Funcs[f].FuncSzUnsigned) {
+ ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
+ ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
+ } else {
+ ResultSz = Funcs[f].FuncSzSigned(Value1, Value2);
+ ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2);
+ }
if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
++Passes;
} else {
@@ -203,7 +225,7 @@
<< vectAsString<TypeUnsignedLabel>(Value2)
<< "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz)
<< " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc)
- << std::endl;
+ << "\n";
}
}
}
@@ -247,7 +269,7 @@
std::cout << std::fixed << "test" << Funcs[f].Name
<< (CHAR_BIT * sizeof(Type)) << "(" << Value1 << ", "
<< Value2 << "): sz=" << ResultSz << " llc=" << ResultLlc
- << std::endl;
+ << "\n";
}
}
}
@@ -264,7 +286,7 @@
++Failures;
std::cout << std::fixed << "test_sqrt" << (CHAR_BIT * sizeof(Type)) << "("
<< Value << "): sz=" << ResultSz << " llc=" << ResultLlc
- << std::endl;
+ << "\n";
}
}
}
@@ -311,7 +333,7 @@
<< "(" << vectAsString<v4f32>(Value1) << ","
<< vectAsString<v4f32>(Value2)
<< "): sz=" << vectAsString<v4f32>(ResultSz) << " llc"
- << vectAsString<v4f32>(ResultLlc) << std::endl;
+ << vectAsString<v4f32>(ResultLlc) << "\n";
}
}
}
@@ -322,7 +344,7 @@
size_t Passes = 0;
size_t Failures = 0;
- testsInt<uint8_t, int8_t>(TotalTests, Passes, Failures);
+ testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures);
testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures);
testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures);
testsInt<uint64_t, int64_t>(TotalTests, Passes, Failures);
diff --git a/crosstest/test_cast.cpp b/crosstest/test_cast.cpp
index 1035109..6298320 100644
--- a/crosstest/test_cast.cpp
+++ b/crosstest/test_cast.cpp
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_cast.cpp - Cast operator tests --------------===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation for crosstesting cast operations.
+//
+//===----------------------------------------------------------------------===//
+
// This aims to test all the conversion bitcode instructions across
// all PNaCl primitive data types.
@@ -19,7 +32,7 @@
// all <A,B>, so that they can be called from the driver.
template <typename ToType> class Caster {
static ToType f(bool a) { return cast<bool, ToType>(a); }
- static ToType f(int8_t a) { return cast<int8_t, ToType>(a); }
+ static ToType f(myint8_t a) { return cast<myint8_t, ToType>(a); }
static ToType f(uint8_t a) { return cast<uint8_t, ToType>(a); }
static ToType f(int16_t a) { return cast<int16_t, ToType>(a); }
static ToType f(uint16_t a) { return cast<uint16_t, ToType>(a); }
@@ -37,7 +50,7 @@
// template class Caster<bool>;
-template class Caster<int8_t>;
+template class Caster<myint8_t>;
template class Caster<uint8_t>;
template class Caster<int16_t>;
template class Caster<uint16_t>;
diff --git a/crosstest/test_cast.h b/crosstest/test_cast.h
index bf59cd9..27d0dd0 100644
--- a/crosstest/test_cast.h
+++ b/crosstest/test_cast.h
@@ -1,2 +1,23 @@
+//===- subzero/crosstest/test_cast.h - Test prototypes ----------*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the function prototypes used for crosstesting cast
+// operations.
+//
+//===----------------------------------------------------------------------===//
+
+// The driver and the test program may be compiled by different
+// versions of clang, with different standard libraries that have
+// different definitions of int8_t. Specifically, int8_t may be
+// typedef'd as either 'char' or 'signed char', which mangle to
+// different strings. Avoid int8_t and use an explicit myint8_t.
+typedef signed char myint8_t;
+
template <typename FromType, typename ToType> ToType cast(FromType a);
template <typename FromType, typename ToType> ToType castBits(FromType a);
diff --git a/crosstest/test_cast_main.cpp b/crosstest/test_cast_main.cpp
index 330f984..414fcbb 100644
--- a/crosstest/test_cast_main.cpp
+++ b/crosstest/test_cast_main.cpp
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_cast_main.cpp - Driver for tests ------------===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Driver for crosstesting cast operations.
+//
+//===----------------------------------------------------------------------===//
+
/* crosstest.py --test=test_cast.cpp --test=test_cast_to_u1.ll \
--driver=test_cast_main.cpp --prefix=Subzero_ --output=test_cast */
@@ -36,7 +49,7 @@
size_t &Failures) {
COMPARE(cast, FromType, bool, Val);
COMPARE(cast, FromType, uint8_t, Val);
- COMPARE(cast, FromType, int8_t, Val);
+ COMPARE(cast, FromType, myint8_t, Val);
COMPARE(cast, FromType, uint16_t, Val);
COMPARE(cast, FromType, int16_t, Val);
COMPARE(cast, FromType, uint32_t, Val);
@@ -57,7 +70,7 @@
volatile uint8_t ValsUi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
static const size_t NumValsUi8 = sizeof(ValsUi8) / sizeof(*ValsUi8);
- volatile int8_t ValsSi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
+ volatile myint8_t ValsSi8[] = { 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff };
static const size_t NumValsSi8 = sizeof(ValsSi8) / sizeof(*ValsSi8);
volatile uint16_t ValsUi16[] = { 0, 1, 0x7e, 0x7f, 0x80,
@@ -151,8 +164,8 @@
testValue<uint8_t>(Val, TotalTests, Passes, Failures);
}
for (size_t i = 0; i < NumValsSi8; ++i) {
- int8_t Val = ValsSi8[i];
- testValue<int8_t>(Val, TotalTests, Passes, Failures);
+ myint8_t Val = ValsSi8[i];
+ testValue<myint8_t>(Val, TotalTests, Passes, Failures);
}
for (size_t i = 0; i < NumValsUi16; ++i) {
uint16_t Val = ValsUi16[i];
diff --git a/crosstest/test_fcmp.def b/crosstest/test_fcmp.def
index 9f498b4..c3d6387 100644
--- a/crosstest/test_fcmp.def
+++ b/crosstest/test_fcmp.def
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_fcmp.def - macros for tests -----*- C++ -*---===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines macros for crosstesting the fcmp instruction.
+//
+//===----------------------------------------------------------------------===//
+
#ifndef TEST_FCMP_DEF
#define TEST_FCMP_DEF
diff --git a/crosstest/test_global.cpp b/crosstest/test_global.cpp
index a5a2f61..a670ff2 100644
--- a/crosstest/test_global.cpp
+++ b/crosstest/test_global.cpp
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_global.cpp - Global variable access tests ---===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation for crosstesting global variable access operations.
+//
+//===----------------------------------------------------------------------===//
+
#include <stdint.h>
#include <cstdlib>
diff --git a/crosstest/test_global.h b/crosstest/test_global.h
index dc7ff75..be62b35 100644
--- a/crosstest/test_global.h
+++ b/crosstest/test_global.h
@@ -1,2 +1,23 @@
+//===- subzero/crosstest/test_global.h - Test prototypes --------*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the function prototypes used for crosstesting global
+// variable access operations.
+//
+//===----------------------------------------------------------------------===//
+
+// The driver and the test program may be compiled by different
+// versions of clang, with different standard libraries that have
+// different definitions of int8_t. Specifically, int8_t may be
+// typedef'd as either 'char' or 'signed char', which mangle to
+// different strings. Avoid int8_t and use an explicit myint8_t.
+typedef signed char myint8_t;
+
size_t getNumArrays();
const uint8_t *getArray(size_t WhichArray, size_t &Len);
diff --git a/crosstest/test_global_main.cpp b/crosstest/test_global_main.cpp
index e8ebbde..43f9609 100644
--- a/crosstest/test_global_main.cpp
+++ b/crosstest/test_global_main.cpp
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_global_main.cpp - Driver for tests ----------===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Driver for crosstesting global variable access operations.
+//
+//===----------------------------------------------------------------------===//
+
/* crosstest.py --test=test_global.cpp \
--driver=test_global_main.cpp --prefix=Subzero_ --output=test_global */
@@ -29,7 +42,7 @@
++Passes;
} else {
std::cout << i << ":LlcArrayLen=" << LlcArrayLen
- << ", SzArrayLen=" << SzArrayLen << std::endl;
+ << ", SzArrayLen=" << SzArrayLen << "\n";
++Failures;
}
@@ -41,7 +54,7 @@
++Failures;
std::cout << i << ":LlcArray[" << i << "] = " << (int)LlcArray[i]
<< ", SzArray[" << i << "] = " << (int)SzArray[i]
- << std::endl;
+ << "\n";
}
}
}
diff --git a/crosstest/test_icmp.cpp b/crosstest/test_icmp.cpp
index b74abce..5ca2c46 100644
--- a/crosstest/test_icmp.cpp
+++ b/crosstest/test_icmp.cpp
@@ -28,7 +28,7 @@
#undef X
#define X(cmp, op) \
- bool icmp##cmp(int8_t a, int8_t b) { return a op b; } \
+ bool icmp##cmp(myint8_t a, myint8_t b) { return a op b; } \
bool icmp##cmp(int16_t a, int16_t b) { return a op b; } \
bool icmp##cmp(int32_t a, int32_t b) { return a op b; } \
bool icmp##cmp(int64_t a, int64_t b) { return a op b; } \
diff --git a/crosstest/test_icmp.def b/crosstest/test_icmp.def
index c7cfc96..beb481c 100644
--- a/crosstest/test_icmp.def
+++ b/crosstest/test_icmp.def
@@ -1,3 +1,16 @@
+//===- subzero/crosstest/test_icmp.def - macros for tests -----*- C++ -*---===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines macros for crosstesting the icmp instruction.
+//
+//===----------------------------------------------------------------------===//
+
#ifndef TEST_ICMP_DEF
#define TEST_ICMP_DEF
diff --git a/crosstest/test_icmp.h b/crosstest/test_icmp.h
index 52a9f22..8a264d0 100644
--- a/crosstest/test_icmp.h
+++ b/crosstest/test_icmp.h
@@ -28,7 +28,7 @@
#undef X
#define X(cmp, op) \
- bool icmp##cmp(int8_t a, int8_t b); \
+ bool icmp##cmp(myint8_t a, myint8_t b); \
bool icmp##cmp(int16_t a, int16_t b); \
bool icmp##cmp(int32_t a, int32_t b); \
bool icmp##cmp(int64_t a, int64_t b); \
diff --git a/crosstest/test_icmp_main.cpp b/crosstest/test_icmp_main.cpp
index 53597e8..758b1ef 100644
--- a/crosstest/test_icmp_main.cpp
+++ b/crosstest/test_icmp_main.cpp
@@ -81,7 +81,7 @@
std::cout << "icmp" << Funcs[f].Name
<< (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
<< ", " << Value2 << "): sz=" << ResultSz
- << " llc=" << ResultLlc << std::endl;
+ << " llc=" << ResultLlc << "\n";
}
}
}
@@ -108,7 +108,7 @@
std::cout << "icmp" << Funcs[f].Name
<< (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
<< ", " << Value2 << "): sz=" << ResultSz
- << " llc=" << ResultLlc << std::endl;
+ << " llc=" << ResultLlc << "\n";
}
}
}
@@ -174,7 +174,7 @@
<< vectAsString<TypeUnsignedLabel>(Value2)
<< "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz)
<< " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc)
- << std::endl;
+ << "\n";
}
}
}
@@ -234,7 +234,7 @@
<< vectAsString<T>(Value1) << ","
<< vectAsString<T>(Value2)
<< "): sz=" << vectAsString<T>(ResultSz)
- << " llc=" << vectAsString<T>(ResultLlc) << std::endl;
+ << " llc=" << vectAsString<T>(ResultLlc) << "\n";
}
}
}
@@ -260,7 +260,7 @@
std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "("
<< vectAsString<T>(Value1) << "," << vectAsString<T>(Value2)
<< "): sz=" << vectAsString<T>(ResultSz)
- << " llc=" << vectAsString<T>(ResultLlc) << std::endl;
+ << " llc=" << vectAsString<T>(ResultLlc) << "\n";
}
}
}
@@ -272,7 +272,7 @@
size_t Passes = 0;
size_t Failures = 0;
- testsInt<uint8_t, int8_t>(TotalTests, Passes, Failures);
+ testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures);
testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures);
testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures);
testsInt<uint64_t, int64_t>(TotalTests, Passes, Failures);
diff --git a/crosstest/test_vector_ops.def b/crosstest/test_vector_ops.def
index 422ed54..3396d43 100644
--- a/crosstest/test_vector_ops.def
+++ b/crosstest/test_vector_ops.def
@@ -1,3 +1,17 @@
+//===- subzero/crosstest/test_vector_ops.def - test macros ----*- C++ -*---===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines macros for crosstesting the insertelement and
+// extractelement instruction.
+//
+//===----------------------------------------------------------------------===//
+
#ifndef TEST_VECTOR_OPS_DEF
#define VECTOR_TYPE_TABLE \
diff --git a/crosstest/test_vector_ops_main.cpp b/crosstest/test_vector_ops_main.cpp
index f48e099..ef7b450 100644
--- a/crosstest/test_vector_ops_main.cpp
+++ b/crosstest/test_vector_ops_main.cpp
@@ -53,7 +53,7 @@
const size_t VECTOR_ALIGNMENT = 16;
void *Dest;
if (posix_memalign(&Dest, VECTOR_ALIGNMENT, sizeof(TestVectors))) {
- std::cerr << "memory allocation error" << std::endl;
+ std::cerr << "memory allocation error\n";
abort();
}
@@ -89,9 +89,9 @@
std::cout << "insertelement<" << VectorOps<T>::TypeName << ">(Vect=";
std::cout << vectAsString<T>(Vect)
<< ", Element=" << (typename VectorOps<T>::CastTy)Elt
- << ", Pos=" << I << ")" << std::endl;
- std::cout << "llc=" << vectAsString<T>(ResultLlc) << std::endl;
- std::cout << "sz =" << vectAsString<T>(ResultSz) << std::endl;
+ << ", Pos=" << I << ")\n";
+ std::cout << "llc=" << vectAsString<T>(ResultLlc) << "\n";
+ std::cout << "sz =" << vectAsString<T>(ResultSz) << "\n";
}
}
}
@@ -120,9 +120,9 @@
} else {
++Failures;
std::cout << "extractelement<" << VectorOps<T>::TypeName << ">(Vect=";
- std::cout << vectAsString<T>(Vect) << ", Pos=" << I << ")" << std::endl;
- std::cout << "llc=" << ResultLlc << std::endl;
- std::cout << "sz =" << ResultSz << std::endl;
+ std::cout << vectAsString<T>(Vect) << ", Pos=" << I << ")\n";
+ std::cout << "llc=" << ResultLlc << "\n";
+ std::cout << "sz =" << ResultSz << "\n";
}
}
}
@@ -166,7 +166,7 @@
extern "C" {
void ice_unreachable(void) {
- std::cerr << "\"unreachable\" instruction encountered" << std::endl;
+ std::cerr << "\"unreachable\" instruction encountered\n";
abort();
}
}
diff --git a/crosstest/vectors.def b/crosstest/vectors.def
index ff797bf..b7c3739 100644
--- a/crosstest/vectors.def
+++ b/crosstest/vectors.def
@@ -16,7 +16,7 @@
#define VECTOR_TYPE_TABLE \
/* typename, element type, cast type */ \
-X(v16si8, int8_t, int64_t) \
+X(v16si8, myint8_t, int64_t) \
X(v16ui8, uint8_t, int64_t) \
X(v8si16, int16_t, int64_t) \
X(v8ui16, uint16_t, int64_t) \
diff --git a/crosstest/vectors.h b/crosstest/vectors.h
index 9924eb5..2fdb482 100644
--- a/crosstest/vectors.h
+++ b/crosstest/vectors.h
@@ -20,6 +20,13 @@
#include <string>
#include <sstream>
+// The driver and the test program may be compiled by different
+// versions of clang, with different standard libraries that have
+// different definitions of int8_t. Specifically, int8_t may be
+// typedef'd as either 'char' or 'signed char', which mangle to
+// different strings. Avoid int8_t and use an explicit myint8_t.
+typedef signed char myint8_t;
+
#include "vectors.def"
// PNaCl portable vector types