[Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations

Emil Velikov emil.l.velikov at gmail.com
Sat Nov 8 10:13:39 PST 2014


On 08/11/14 11:12, Timothy Arceri wrote:
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
As long as it fixes odd combinations such as this the following I'm all
in favour of using such an approach. It will save us quite a few
"lovely" details - split the file, configure checks etc...

https://bugs.freedesktop.org/show_bug.cgi?id=71547

Just a small nit below :)

Thanks
Emil
> ---
>  src/mesa/x86/x86_function_opt.h | 42 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
>  create mode 100644 src/mesa/x86/x86_function_opt.h
> 
>  Using a macro like this means we can easily enable runtime support in clang
>  once it also supports it. Also its less of an impact for those compiling
>  with the optimisations enabled.
>  Finally I'm assuming its also better for lto.
> 
> diff --git a/src/mesa/x86/x86_function_opt.h b/src/mesa/x86/x86_function_opt.h
> new file mode 100644
> index 0000000..c1ffb19
> --- /dev/null
> +++ b/src/mesa/x86/x86_function_opt.h
> @@ -0,0 +1,42 @@
> +/*
> + * Copyright (C) Timothy Arceri
> + * All Rights Reserved.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included
> + * in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + *
> + * Author:
> + *    Timothy Arceri <t_arceri at yahoo.com.au>
> + *
> + */
> +
> +/*
> + * Helper macros to enable per function optimisations
> + *
> + */
> +
> +#ifdef __SSSE3__
> +   #define SSSE3_FUNC_OPT_START
> +   #define SSSE3_FUNC_OPT_END
> +#else
> +   #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3))
Normally I've preferred to have
#if defined(__GNUC__) && (__GNUC__ > 4 ....


> +      #define SSSE3_FUNC_OPT_START _Pragma("GCC push_options") \
> +         _Pragma("GCC target(\"ssse3\")")
> +      #define SSSE3_FUNC_OPT_END _Pragma("GCC pop_options")
> +   #endif
> +#endif
> 



More information about the mesa-dev mailing list