blob: 32903a987198628af5ab53e699049e8f2615090a [file] [log] [blame]
Matt Wala89a7c2b2014-07-22 10:55:30 -07001//===- 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, and Subzero_extractelement
22// fields.
23
24template <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 CastTy (*extractelement)(Ty, int32_t); \
32 static Ty (*Subzero_insertelement)(Ty, CastTy, int32_t); \
33 static CastTy (*Subzero_extractelement)(Ty, int32_t); \
34 }; \
35 extern "C" { \
36 TY(NAME) insertelement_##NAME(TY(NAME), CASTTY(NAME), int32_t); \
37 TY(NAME) Subzero_insertelement_##NAME(TY(NAME), CASTTY(NAME), int32_t); \
38 CASTTY(NAME) extractelement_##NAME(TY(NAME), int32_t); \
39 CASTTY(NAME) Subzero_extractelement_##NAME(TY(NAME), int32_t); \
40 } \
41 TY(NAME) (*FIELD(NAME, insertelement))(TY(NAME), CASTTY(NAME), int32_t) = \
42 &insertelement_##NAME; \
43 TY(NAME) (*FIELD(NAME, Subzero_insertelement))( \
44 TY(NAME), CASTTY(NAME), int32_t) = &Subzero_insertelement_##NAME; \
45 CASTTY(NAME) (*FIELD(NAME, extractelement))(TY(NAME), int32_t) = \
46 &extractelement_##NAME; \
47 CASTTY(NAME) (*FIELD(NAME, Subzero_extractelement))(TY(NAME), int32_t) = \
48 &Subzero_extractelement_##NAME;
49
50#define X(ty, eltty, castty) DECLARE_VECTOR_OPS(ty)
51VECTOR_TYPE_TABLE
52#undef X
53
54#define X(ty, eltty, numelements) DECLARE_VECTOR_OPS(ty)
55I1_VECTOR_TYPE_TABLE
56#undef X
57
58#endif // TEST_VECTOR_OPS_H