[Mesa-dev] [PATCH] glsl: rename _restrict to restrict_flag

Ian Romanick idr at freedesktop.org
Wed Feb 12 12:35:53 PST 2014


On 02/12/2014 12:25 PM, Brian Paul wrote:
> To fix MSVC compile breakage.  Evidently, _restrict is an MSVC keyword,
> though the docs only mention __restrict (with two underscores).

Clear violation of the C standard.  Strong work.  This is almost as bad
as the "near" and "far" rubbish.  I'm waiting for the version of MSVC
that has "i" as a reserved word...

> Note: we may want to also rename _volatile to volatile_flag to be
> consistent.

Yeah, but I think that's safe as a follow-on patch.  This gets you guys
unblocked, and that seems good.

> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74900

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>  src/glsl/ast.h                 |    2 +-
>  src/glsl/ast_function.cpp      |    2 +-
>  src/glsl/ast_to_hir.cpp        |    2 +-
>  src/glsl/builtin_functions.cpp |    2 +-
>  src/glsl/glsl_parser.yy        |    2 +-
>  src/glsl/ir.cpp                |    4 ++--
>  src/glsl/ir.h                  |    2 +-
>  7 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/glsl/ast.h b/src/glsl/ast.h
> index cd913ab..9140ca1 100644
> --- a/src/glsl/ast.h
> +++ b/src/glsl/ast.h
> @@ -473,7 +473,7 @@ struct ast_type_qualifier {
>  	 unsigned explicit_image_format:1;
>  	 unsigned coherent:1;
>  	 unsigned _volatile:1;
> -	 unsigned _restrict:1;
> +	 unsigned restrict_flag:1;
>  	 unsigned read_only:1; /**< "readonly" qualifier. */
>  	 unsigned write_only:1; /**< "writeonly" qualifier. */
>  	 /** \} */
> diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
> index 8fa03dc..4b84470 100644
> --- a/src/glsl/ast_function.cpp
> +++ b/src/glsl/ast_function.cpp
> @@ -120,7 +120,7 @@ verify_image_parameter(YYLTYPE *loc, _mesa_glsl_parse_state *state,
>        return false;
>     }
>  
> -   if (actual->data.image._restrict && !formal->data.image._restrict) {
> +   if (actual->data.image.restrict_flag && !formal->data.image.restrict_flag) {
>        _mesa_glsl_error(loc, state,
>                         "function call parameter `%s' drops "
>                         "`restrict' qualifier", formal->name);
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 3931768..6de73f4 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -2232,7 +2232,7 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
>        var->data.image.write_only |= qual->flags.q.write_only;
>        var->data.image.coherent |= qual->flags.q.coherent;
>        var->data.image._volatile |= qual->flags.q._volatile;
> -      var->data.image._restrict |= qual->flags.q._restrict;
> +      var->data.image.restrict_flag |= qual->flags.q.restrict_flag;
>        var->data.read_only = true;
>  
>        if (qual->flags.q.explicit_image_format) {
> diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
> index 2905a35..b9dc959 100644
> --- a/src/glsl/builtin_functions.cpp
> +++ b/src/glsl/builtin_functions.cpp
> @@ -4293,7 +4293,7 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
>     image->data.image.write_only = flags & IMAGE_FUNCTION_WRITE_ONLY;
>     image->data.image.coherent = true;
>     image->data.image._volatile = true;
> -   image->data.image._restrict = true;
> +   image->data.image.restrict_flag = true;
>  
>     return sig;
>  }
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index 6aed254..369da50 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -1655,7 +1655,7 @@ storage_qualifier:
>     {
>        STATIC_ASSERT(sizeof($$.flags.q) <= sizeof($$.flags.i));
>        memset(& $$, 0, sizeof($$));
> -      $$.flags.q._restrict = 1;
> +      $$.flags.q.restrict_flag = 1;
>     }
>     | READONLY
>     {
> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
> index 338f61b..a41eddf 100644
> --- a/src/glsl/ir.cpp
> +++ b/src/glsl/ir.cpp
> @@ -1558,7 +1558,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
>     this->data.image.write_only = false;
>     this->data.image.coherent = false;
>     this->data.image._volatile = false;
> -   this->data.image._restrict = false;
> +   this->data.image.restrict_flag = false;
>  
>     if (type != NULL) {
>        if (type->base_type == GLSL_TYPE_SAMPLER)
> @@ -1668,7 +1668,7 @@ ir_function_signature::qualifiers_match(exec_list *params)
>            a->data.image.write_only != b->data.image.write_only ||
>            a->data.image.coherent != b->data.image.coherent ||
>            a->data.image._volatile != b->data.image._volatile ||
> -          a->data.image._restrict != b->data.image._restrict) {
> +          a->data.image.restrict_flag != b->data.image.restrict_flag) {
>  
>  	 /* parameter a's qualifiers don't match */
>  	 return a->name;
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index 3958573..e27e30a 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -698,7 +698,7 @@ public:
>           bool write_only; /**< "writeonly" qualifier. */
>           bool coherent;
>           bool _volatile;
> -         bool _restrict;
> +         bool restrict_flag;
>  
>           /** Image internal format if specified explicitly, otherwise GL_NONE. */
>           GLenum format;
> 



More information about the mesa-dev mailing list