1 // vector signal argument wrappers
2 // Copyright (C) 2010 Tim Blechmann
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; see the file COPYING. If not, write to
16 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 // Boston, MA 02111-1307, USA.
19 #ifndef NOVA_SIMD_DETAIL_WRAP_ARGUMENT_VECTOR_HPP
20 #define NOVA_SIMD_DETAIL_WRAP_ARGUMENT_VECTOR_HPP
24 #include "wrap_arguments.hpp"
26 #if defined(__GNUC__) && defined(NDEBUG)
27 #define always_inline inline __attribute__((always_inline))
29 #define always_inline inline
36 template <typename FloatType
>
37 struct vector_pointer_argument
39 always_inline
explicit vector_pointer_argument(const FloatType
* arg
):
43 always_inline
void increment(void)
45 data
+= vec
<FloatType
>::size
;
48 always_inline vec
<FloatType
> get(void) const
51 ret
.load_aligned(data
);
55 always_inline vec
<FloatType
> consume(void)
58 ret
.load_aligned(data
);
63 const FloatType
* data
;
66 template <typename FloatType
>
67 struct vector_scalar_argument
69 always_inline
explicit vector_scalar_argument(FloatType
const & arg
):
73 always_inline
void increment(void)
76 always_inline vec
<FloatType
> get(void) const
78 return vec
<FloatType
>(data
);
81 always_inline vec
<FloatType
> consume(void)
83 return vec
<FloatType
>(data
);
89 template <typename FloatType
>
90 struct vector_ramp_argument
92 always_inline
vector_ramp_argument(FloatType
const & base
, FloatType
const & slope
)
94 float vSlope
= data
.set_slope(base
, slope
);
95 slope_
.set_vec(vSlope
);
98 always_inline
void increment(void)
103 always_inline vec
<FloatType
> get(void) const
108 always_inline vec
<FloatType
> consume(void)
110 vec
<FloatType
> ret(data
);
116 vec
<FloatType
> slope_
;
119 /* convert scalar args to vector args */
120 template <typename FloatType
>
121 always_inline
detail::vector_scalar_argument
<FloatType
>
122 wrap_vector_arg(detail::scalar_scalar_argument
<FloatType
> const & arg
)
124 return detail::vector_scalar_argument
<FloatType
>(arg
.data
);
127 template <typename FloatType
>
128 always_inline
detail::vector_pointer_argument
<FloatType
>
129 wrap_vector_arg(detail::scalar_pointer_argument
<FloatType
> const & arg
)
131 return detail::vector_pointer_argument
<FloatType
>(arg
.data
);
134 template <typename FloatType
>
135 always_inline
detail::vector_ramp_argument
<FloatType
>
136 wrap_vector_arg(detail::scalar_ramp_argument
<FloatType
> const & arg
)
138 return detail::vector_ramp_argument
<FloatType
>(arg
.data
, arg
.slope_
);
141 } /* namespace detail */
142 } /* namespace nova */
147 #endif /* NOVA_SIMD_DETAIL_WRAP_ARGUMENT_VECTOR_HPP */