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) (*FIELD(NAME, insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \ 48 &insertelement_##NAME; \ 49 TY(NAME) (*FIELD(NAME, Subzero_insertelement))( \ 50 TY(NAME), CASTTY(NAME), int32_t) = &Subzero_insertelement_##NAME; \ 51 CASTTY(NAME) (*FIELD(NAME, extractelement))(TY(NAME), int32_t) = \ 52 &extractelement_##NAME; \ 53 CASTTY(NAME) (*FIELD(NAME, Subzero_extractelement))(TY(NAME), int32_t) = \ 54 &Subzero_extractelement_##NAME; \ 55 TY(NAME) (*FIELD(NAME, shufflevector))(TY(NAME), TY(NAME), uint32_t) = \ 56 &shufflevector_##NAME; \ 57 TY(NAME) (*FIELD(NAME, Subzero_shufflevector))( \ 58 TY(NAME), TY(NAME), uint32_t) = &Subzero_shufflevector_##NAME; \ 59 uint32_t (*FIELD(NAME, shufflevector_count))() = &shufflevector_count_##NAME; 60 61 #define X(ty, eltty, castty) DECLARE_VECTOR_OPS(ty) 62 VECTOR_TYPE_TABLE 63 #undef X 64 65 #define X(ty, eltty, numelements) DECLARE_VECTOR_OPS(ty) 66 I1_VECTOR_TYPE_TABLE 67 #undef X 68 69 #endif // TEST_VECTOR_OPS_H 70