Skip to content

Commit 079f31a

Browse files
Change fpga_reg to use a deprecation warning for old APIs
1 parent ccca3ba commit 079f31a

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

sycl/include/CL/sycl/INTEL/fpga_reg.hpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,22 @@ namespace INTEL {
1818
// Returns a registered copy of the input
1919
// This function is intended for FPGA users to instruct the compiler to insert
2020
// at least one register stage between the input and the return value.
21-
template <typename _T> _T fpga_reg(_T t) {
22-
static_assert(std::is_trivially_copyable<_T>::value,
23-
"Type is not trivially_copyable.");
21+
template <typename _T>
22+
typename std::enable_if<std::is_trivially_copyable<_T>::value, _T>::type
23+
fpga_reg(_T t) {
24+
#if __has_builtin(__builtin_intel_fpga_reg)
25+
return __builtin_intel_fpga_reg(t);
26+
#else
27+
return t;
28+
#endif
29+
}
30+
31+
template <typename _T>
32+
[[deprecated("INTEL::fpga_reg will only support trivially_copyable types in a "
33+
"future release. The type used here will be disallowed.")]]
34+
typename std::enable_if<std::is_trivially_copyable<_T>::value == false,
35+
_T>::type
36+
fpga_reg(_T t) {
2437
#if __has_builtin(__builtin_intel_fpga_reg)
2538
return __builtin_intel_fpga_reg(t);
2639
#else
@@ -31,3 +44,13 @@ template <typename _T> _T fpga_reg(_T t) {
3144
} // namespace INTEL
3245
} // namespace sycl
3346
} // __SYCL_INLINE_NAMESPACE(cl)
47+
48+
// Keep it consistent with FPGA attributes like intelfpga::memory()
49+
// Currently clang does not support nested namespace for attributes
50+
namespace intelfpga {
51+
template <typename _T>
52+
[[deprecated("intelfpga::fpga_reg will be removed in a future release.")]] _T
53+
fpga_reg(const _T &t) {
54+
return cl::sycl::INTEL::fpga_reg(t);
55+
}
56+
} // namespace intelfpga

0 commit comments

Comments
 (0)