Commit ec54107b authored by James Willis's avatar James Willis
Browse files

Added macro to assign a restrict pointer to an array and inform compiler that is aligned.

parent 8b0c7e5d
......@@ -58,6 +58,30 @@
#define swift_align_information(array, alignment) ;
#endif
/**
* @brief Macro to create a restrict pointer to an array and tell the compiler that the given array has the specified
* alignment.
*
* Note that this turns into a no-op but gives information to the compiler.
*
* @param array The array.
* @param ptr Pointer to array
* @param type Type of array
* @param alignment The alignment in bytes of the array.
*/
#if defined(__ICC)
#define swift_align_and_restrict_information(array, ptr, type, alignment) \
type *restrict array = ptr; \
__assume_aligned(array, alignment);
#elif defined(__GNUC__)
#define swift_align_and_restrict_information(array, ptr, type, alignment) \
type *restrict array = ptr; \
array = __builtin_assume_aligned(array, alignment);
#else
#define swift_align_and_restrict_information(array, ptr, type, alignment) \
type *restrict array = ptr;
#endif
/**
* @brief Macro to tell the compiler that a given number is 0 modulo a given
* size.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment