1/* Copyright (C) 2017 Povilas Kanapickas <povilas@radix.lt>
2
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8#ifndef LIBSIMDPP_SIMDPP_DEPRETATIONS_H
9#define LIBSIMDPP_SIMDPP_DEPRETATIONS_H
10
11// Compatibility macro introduced in 2.1 development cycle, but never released
12// Will be removed in the future
13#ifdef SIMDPP_DEFINE_IMPLICIT_CONVERSION_OPERATOR_TO_NATIVE_TYPES
14 #if SIMDPP_DEFINE_IMPLICIT_CONVERSION_OPERATOR_TO_NATIVE_TYPES
15 #define SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES 0
16 #else
17 #define SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES 1
18 #endif
19#endif
20
21// Disables all APIs deprecated in 2.1 and older releases
22#ifndef SIMDPP_DISABLE_DEPRECATED_IN_2_1_AND_OLDER
23#define SIMDPP_DISABLE_DEPRECATED_IN_2_1_AND_OLDER 0
24#endif
25
26#if SIMDPP_DISABLE_DEPRECATED_IN_2_1_AND_OLDER
27 #ifndef SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES
28 #define SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES 1
29 #endif
30#endif
31
32/* Clang supports a native vector extension that defines operators between
33 vector types. SSE types such as __m128 and __m128i are implemented on top
34 of this extension, which causes code like this being possible:
35
36__m128i a, b; a = a + b;
37
38 Previously, all libsimdpp types had an implicit conversion operator to
39 native vector type. For example, both uint8<16> and uint16<8> could be
40 implicitly converted to __m128i. This leads to code like this being
41 accepted on clang.
42
43uint8<16> a;
44uint16<8> b;
45a = a + b;
46
47 Here, both a and b are implicitly converted to __m128i values and they are
48 added using an operator provided by the clang vector extension.
49 Unexpectedly, the result is paddq instruction (64-bit integer addition).
50
51 Because of this, the implicit native vector type conversion operators are
52 deprecated and a native() method is provided as a replacement in libsimdpp
53 vector types. This change only affects code that interacts with native
54 intrinsics. Altivec/VSX and MSA are affected only slightly, because
55 intrinsics of those instruction sets never accepted implicit conversions
56 from libsimdpp types.
57*/
58#ifndef SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES
59 #define SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES 0
60#endif
61#if !SIMDPP_DISABLE_DEPRECATED_CONVERSION_OPERATOR_TO_NATIVE_TYPES
62 #define SIMDPP_IMPLICIT_CONVERSION_DEPRECATION_MSG \
63 SIMDPP_DEPRECATED( \
64 "Implicit conversion operators may lead to wrong code being " \
65 "accepted without a compile error on Clang. Use the native() " \
66 "method as a replacement.")
67#endif
68
69#endif
70