Mesa (master): intel/compiler: Add a INVALID_{,HW_}REG_TYPE macros

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 22 00:51:23 UTC 2020


Module: Mesa
Branch: master
Commit: 0b70d46f7a614888e999bfda443636c9bc1d8d97
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b70d46f7a614888e999bfda443636c9bc1d8d97

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Jan  6 13:17:49 2020 -0800

intel/compiler: Add a INVALID_{,HW_}REG_TYPE macros

Since the enum brw_reg_type is packed, comparisons with -1 don't work
directly, necessitating the cast. Add a macro to avoid this confusion.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2635>

---

 src/intel/compiler/brw_eu_compact.c | 4 ++--
 src/intel/compiler/brw_reg_type.c   | 6 +++---
 src/intel/compiler/brw_reg_type.h   | 3 +++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/intel/compiler/brw_eu_compact.c b/src/intel/compiler/brw_eu_compact.c
index 4d2e617b3ed..7c42aeec3dd 100644
--- a/src/intel/compiler/brw_eu_compact.c
+++ b/src/intel/compiler/brw_eu_compact.c
@@ -1512,10 +1512,10 @@ has_immediate(const struct gen_device_info *devinfo, const brw_inst *inst,
 {
    if (brw_inst_src0_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE) {
       *type = brw_inst_src0_type(devinfo, inst);
-      return *type != (enum brw_reg_type)-1;
+      return *type != INVALID_REG_TYPE;
    } else if (brw_inst_src1_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE) {
       *type = brw_inst_src1_type(devinfo, inst);
-      return *type != (enum brw_reg_type)-1;
+      return *type != INVALID_REG_TYPE;
    }
 
    return false;
diff --git a/src/intel/compiler/brw_reg_type.c b/src/intel/compiler/brw_reg_type.c
index e3fff5d2d1a..f4d435b647e 100644
--- a/src/intel/compiler/brw_reg_type.c
+++ b/src/intel/compiler/brw_reg_type.c
@@ -289,7 +289,7 @@ brw_hw_type_to_reg_type(const struct gen_device_info *devinfo,
          }
       }
    }
-   return (enum brw_reg_type)-1;
+   return INVALID_REG_TYPE;
 }
 
 /**
@@ -339,7 +339,7 @@ brw_a16_hw_3src_type_to_reg_type(const struct gen_device_info *devinfo,
          return i;
       }
    }
-   return (enum brw_reg_type)-1;
+   return INVALID_REG_TYPE;
 }
 
 /**
@@ -359,7 +359,7 @@ brw_a1_hw_3src_type_to_reg_type(const struct gen_device_info *devinfo,
          return i;
       }
    }
-   return (enum brw_reg_type)-1;
+   return INVALID_REG_TYPE;
 }
 
 /**
diff --git a/src/intel/compiler/brw_reg_type.h b/src/intel/compiler/brw_reg_type.h
index 086770d2e03..a17c93ee90e 100644
--- a/src/intel/compiler/brw_reg_type.h
+++ b/src/intel/compiler/brw_reg_type.h
@@ -100,6 +100,9 @@ brw_reg_type_is_integer(enum brw_reg_type type)
    }
 }
 
+#define INVALID_REG_TYPE    ((enum brw_reg_type)-1)
+#define INVALID_HW_REG_TYPE ((unsigned)-1)
+
 unsigned
 brw_reg_type_to_hw_type(const struct gen_device_info *devinfo,
                         enum brw_reg_file file, enum brw_reg_type type);



More information about the mesa-commit mailing list