1 //===- subzero/crosstest/test_vector_ops.h - Test prototypes ----*- C++ -*-===// 2 // 3 // The Subzero Code Generator 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file declares the function prototypes for crosstesting insertelement 11 // and extractelement operations. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef TEST_VECTOR_OPS_H 16 #define TEST_VECTOR_OPS_H 17 18 #include "vectors.h" 19 20 // The VectorOps<> class acts like Vectors<> but also has insertelement, 21 // Subzero_insertelement, extractelement, Subzero_extractelement, 22 // shufflevector, Subzero_shufflevector, and shufflevector_count fields. 23 24 template <typename T> struct VectorOps; 25 #define FIELD(TYNAME, FIELDNAME) VectorOps<TYNAME>::FIELDNAME 26 #define TY(TYNAME) FIELD(TYNAME, Ty) 27 #define CASTTY(TYNAME) FIELD(TYNAME, CastTy) 28 #define DECLARE_VECTOR_OPS(NAME) \ 29 template <> struct VectorOps<NAME> : public Vectors<NAME> { \ 30 static Ty (*insertelement)(Ty, CastTy, int32_t); \ 31 static Ty (*shufflevector)(Ty, Ty, uint32_t); \ 32 static CastTy (*extractelement)(Ty, int32_t); \ 33 static Ty (*Subzero_insertelement)(Ty, CastTy, int32_t); \ 34 static Ty (*Subzero_shufflevector)(Ty, Ty, uint32_t); \ 35 static CastTy (*Subzero_extractelement)(Ty, int32_t); \ 36 static uint32_t (*shufflevector_count)(); \ 37 }; \ 38 extern "C" { \ 39 TY(NAME) insertelement_##NAME(TY(NAME), CASTTY(NAME), int32_t); \ 40 TY(NAME) Subzero_insertelement_##NAME(TY(NAME), CASTTY(NAME), int32_t); \ 41 CASTTY(NAME) extractelement_##NAME(TY(NAME), int32_t); \ 42 CASTTY(NAME) Subzero_extractelement_##NAME(TY(NAME), int32_t); \ 43 TY(NAME) shufflevector_##NAME(TY(NAME), TY(NAME), uint32_t); \ 44 TY(NAME) Subzero_shufflevector_##NAME(TY(NAME), TY(NAME), uint32_t); \ 45 uint32_t shufflevector_count_##NAME(); \ 46 } \ 47 TY(NAME) \ 48 (*FIELD(NAME, insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \ 49 &insertelement_##NAME; \ 50 TY(NAME) \ 51 (*FIELD(NAME, Subzero_insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \ 52 &Subzero_insertelement_##NAME; \ 53 CASTTY(NAME) \ 54 (*FIELD(NAME, extractelement))(TY(NAME), int32_t) = &extractelement_##NAME; \ 55 CASTTY(NAME) \ 56 (*FIELD(NAME, Subzero_extractelement))(TY(NAME), int32_t) = \ 57 &Subzero_extractelement_##NAME; \ 58 TY(NAME) \ 59 (*FIELD(NAME, shufflevector))(TY(NAME), TY(NAME), uint32_t) = \ 60 &shufflevector_##NAME; \ 61 TY(NAME) \ 62 (*FIELD(NAME, Subzero_shufflevector))(TY(NAME), TY(NAME), uint32_t) = \ 63 &Subzero_shufflevector_##NAME; \ 64 uint32_t (*FIELD(NAME, shufflevector_count))() = &shufflevector_count_##NAME; 65 66 #define X(ty, eltty, castty) DECLARE_VECTOR_OPS(ty) 67 VECTOR_TYPE_TABLE 68 #undef X 69 70 #define X(ty, eltty, numelements) DECLARE_VECTOR_OPS(ty) 71 I1_VECTOR_TYPE_TABLE 72 #undef X 73 74 #endif // TEST_VECTOR_OPS_H 75