//===- subzero/crosstest/vectors.h - Common SIMD vector utilies -*- C++ -*-===// // // The Subzero Code Generator // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file provides declarations for PNaCl portable SIMD vector types. In // addition, this file provides utilies that may be useful for crosstesting // vector code. // //===----------------------------------------------------------------------===// #ifndef VECTORS_H #define VECTORS_H #include #include #include // 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 // Types declared: v4si32, v4ui32, v8si16, v8ui16, v16si8, v16ui8, v4f32 #define X(ty, eltty, castty) typedef eltty ty __attribute__((vector_size(16))); VECTOR_TYPE_TABLE #undef X // i1 vector types are not native C++ SIMD vector types. Instead, for // testing, they are expanded by the test code into native 128 bit // SIMD vector types with the appropriate number of elements. // Representing the types in Vectors<> requires a unique label for each // type which this declaration provides. // Types declared: v4i1, v8i1, v16i1 #define X(ty, expandedty, numelements) class ty; I1_VECTOR_TYPE_TABLE #undef X namespace { template struct Vectors; // Vectors provides information about a vector type with label T: // * Vectors::Ty is the C++ vector type // * Vectors::ElementTy is the C++ element type // * Vectors::CastTy is a type that is safe to cast elements to and from // and is used for getting the representation of elements in ostreams // * Vectors::NumElements is the number of elements // * Vectors::TypeName is a string that names the type #define DECLARE_VECTOR_TYPE(LABEL, TY, ELTTY, CASTTY, NUM_ELEMENTS) \ template <> struct Vectors