compiler/types: Flip wrapping of base_type checks
authorCaio Oliveira <caio.oliveira@intel.com>
Sat, 2 Sep 2023 05:35:26 +0000 (22:35 -0700)
committerMarge Bot <emma+marge@anholt.net>
Sat, 7 Oct 2023 00:42:54 +0000 (00:42 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25470>

src/compiler/glsl_types.h
src/compiler/glsl_types_impl.h
src/compiler/nir_types.cpp

index f292b0d..da91a44 100644 (file)
@@ -1162,20 +1162,25 @@ glsl_get_bit_size(const struct glsl_type *t)
    return glsl_base_type_get_bit_size(glsl_get_base_type(t));
 }
 
-bool glsl_type_is_boolean(const struct glsl_type *t);
-bool glsl_type_is_sampler(const struct glsl_type *t);
-bool glsl_type_is_texture(const struct glsl_type *t);
-bool glsl_type_is_image(const struct glsl_type *t);
-bool glsl_type_is_atomic_uint(const struct glsl_type *t);
-bool glsl_type_is_struct(const struct glsl_type *t);
-bool glsl_type_is_interface(const struct glsl_type *t);
-bool glsl_type_is_array(const struct glsl_type *t);
-bool glsl_type_is_cmat(const struct glsl_type *t);
-bool glsl_type_is_void(const struct glsl_type *t);
-bool glsl_type_is_subroutine(const struct glsl_type *t);
-bool glsl_type_is_error(const struct glsl_type *t);
-
-bool glsl_type_is_struct_or_ifc(const struct glsl_type *t);
+static inline bool glsl_type_is_boolean(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_BOOL; }
+static inline bool glsl_type_is_sampler(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_SAMPLER; }
+static inline bool glsl_type_is_texture(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_TEXTURE; }
+static inline bool glsl_type_is_image(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_IMAGE; }
+static inline bool glsl_type_is_atomic_uint(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_ATOMIC_UINT; }
+static inline bool glsl_type_is_struct(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_STRUCT; }
+static inline bool glsl_type_is_interface(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_INTERFACE; }
+static inline bool glsl_type_is_array(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_ARRAY; }
+static inline bool glsl_type_is_cmat(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_COOPERATIVE_MATRIX; }
+static inline bool glsl_type_is_void(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_VOID; }
+static inline bool glsl_type_is_subroutine(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_SUBROUTINE; }
+static inline bool glsl_type_is_error(const struct glsl_type *t) { return t->base_type == GLSL_TYPE_ERROR; }
+
+static inline bool
+glsl_type_is_struct_or_ifc(const struct glsl_type *t)
+{
+   return glsl_type_is_struct(t) || glsl_type_is_interface(t);
+}
+
 bool glsl_type_is_packed(const struct glsl_type *t);
 bool glsl_type_is_16bit(const struct glsl_type *t);
 bool glsl_type_is_32bit(const struct glsl_type *t);
index bf4a429..b2ccac7 100644 (file)
 #include "compiler/builtin_types_cpp.h"
 #undef BUILTIN_TYPES_CPP_DEFINITIONS
 
-inline bool glsl_type::is_boolean() const { return base_type == GLSL_TYPE_BOOL; }
-inline bool glsl_type::is_sampler() const { return base_type == GLSL_TYPE_SAMPLER; }
-inline bool glsl_type::is_texture() const { return base_type == GLSL_TYPE_TEXTURE; }
-inline bool glsl_type::is_image() const { return base_type == GLSL_TYPE_IMAGE; }
-inline bool glsl_type::is_array() const { return base_type == GLSL_TYPE_ARRAY; }
-inline bool glsl_type::is_struct() const { return base_type == GLSL_TYPE_STRUCT; }
-inline bool glsl_type::is_interface() const { return base_type == GLSL_TYPE_INTERFACE; }
-inline bool glsl_type::is_cmat() const { return base_type == GLSL_TYPE_COOPERATIVE_MATRIX; }
-inline bool glsl_type::is_void() const { return base_type == GLSL_TYPE_VOID; }
-inline bool glsl_type::is_error() const { return base_type == GLSL_TYPE_ERROR; }
-inline bool glsl_type::is_subroutine() const { return base_type == GLSL_TYPE_SUBROUTINE; }
-inline bool glsl_type::is_atomic_uint() const { return base_type == GLSL_TYPE_ATOMIC_UINT; }
-
+inline bool glsl_type::is_boolean() const { return glsl_type_is_boolean(this); }
+inline bool glsl_type::is_sampler() const { return glsl_type_is_sampler(this); }
+inline bool glsl_type::is_texture() const { return glsl_type_is_texture(this); }
+inline bool glsl_type::is_image() const { return glsl_type_is_image(this); }
+inline bool glsl_type::is_array() const { return glsl_type_is_array(this); }
+inline bool glsl_type::is_struct() const { return glsl_type_is_struct(this); }
+inline bool glsl_type::is_interface() const { return glsl_type_is_interface(this); }
+inline bool glsl_type::is_cmat() const { return glsl_type_is_cmat(this); }
+inline bool glsl_type::is_void() const { return glsl_type_is_void(this); }
+inline bool glsl_type::is_error() const { return glsl_type_is_error(this); }
+inline bool glsl_type::is_subroutine() const { return glsl_type_is_subroutine(this); }
+inline bool glsl_type::is_atomic_uint() const { return glsl_type_is_atomic_uint(this); }
 
 inline bool
 glsl_type::is_scalar() const
index 59064c4..1c603e6 100644 (file)
@@ -269,18 +269,6 @@ glsl_type_is_64bit(const struct glsl_type *type)
 }
 
 bool
-glsl_type_is_void(const struct glsl_type *type)
-{
-   return type->is_void();
-}
-
-bool
-glsl_type_is_error(const struct glsl_type *type)
-{
-   return type->is_error();
-}
-
-bool
 glsl_type_is_vector(const struct glsl_type *type)
 {
    return type->is_vector();
@@ -312,12 +300,6 @@ glsl_matrix_type_is_row_major(const struct glsl_type *type)
 }
 
 bool
-glsl_type_is_array(const struct glsl_type *type)
-{
-   return type->is_array();
-}
-
-bool
 glsl_type_is_unsized_array(const struct glsl_type *type)
 {
    return type->is_unsized_array();
@@ -336,54 +318,12 @@ glsl_type_is_array_or_matrix(const struct glsl_type *type)
 }
 
 bool
-glsl_type_is_cmat(const struct glsl_type *type)
-{
-   return type->is_cmat();
-}
-
-bool
-glsl_type_is_struct(const struct glsl_type *type)
-{
-   return type->is_struct();
-}
-
-bool
-glsl_type_is_interface(const struct glsl_type *type)
-{
-   return type->is_interface();
-}
-
-bool
-glsl_type_is_struct_or_ifc(const struct glsl_type *type)
-{
-   return type->is_struct() || type->is_interface();
-}
-
-bool
-glsl_type_is_sampler(const struct glsl_type *type)
-{
-   return type->is_sampler();
-}
-
-bool
 glsl_type_is_bare_sampler(const struct glsl_type *type)
 {
    return type->is_sampler() && type->sampled_type == GLSL_TYPE_VOID;
 }
 
 bool
-glsl_type_is_texture(const struct glsl_type *type)
-{
-   return type->is_texture();
-}
-
-bool
-glsl_type_is_image(const struct glsl_type *type)
-{
-   return type->is_image();
-}
-
-bool
 glsl_sampler_type_is_shadow(const struct glsl_type *type)
 {
    assert(glsl_type_is_sampler(type));
@@ -419,11 +359,6 @@ glsl_type_is_numeric(const struct glsl_type *type)
 }
 
 bool
-glsl_type_is_boolean(const struct glsl_type *type)
-{
-   return type->is_boolean();
-}
-bool
 glsl_type_is_integer(const struct glsl_type *type)
 {
    return type->is_integer();