intel/fs: Index scheduler mode string table by mode enum
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 15 Aug 2023 02:35:32 +0000 (19:35 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 23 Aug 2023 21:34:38 +0000 (21:34 +0000)
pre_modes[] is an array with the modes ordered in our desired
preference.  scheduler_mode_name[] was also in that order, and the two
had to be kept in sync.  This is a little silly; we should just have
a mode enum -> string table and look it up via the enum.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24707>

src/intel/compiler/brw_fs.cpp

index ad3f6ff..54d0093 100644 (file)
@@ -6749,10 +6749,11 @@ fs_visitor::allocate_registers(bool allow_spilling)
    };
 
    static const char *scheduler_mode_name[] = {
-      "top-down",
-      "non-lifo",
-      "none",
-      "lifo"
+      [SCHEDULE_PRE] = "top-down",
+      [SCHEDULE_PRE_NON_LIFO] = "non-lifo",
+      [SCHEDULE_PRE_LIFO] = "lifo",
+      [SCHEDULE_POST] = "post",
+      [SCHEDULE_NONE] = "none",
    };
 
    compact_virtual_grfs();
@@ -6783,6 +6784,8 @@ fs_visitor::allocate_registers(bool allow_spilling)
     * performance but increasing likelihood of allocating.
     */
    for (unsigned i = 0; i < ARRAY_SIZE(pre_modes); i++) {
+      enum instruction_scheduler_mode sched_mode = pre_modes[i];
+
       if (i > 0) {
          /* Unless we're the first pass, reset back to the original order */
          ip = 0;
@@ -6798,8 +6801,8 @@ fs_visitor::allocate_registers(bool allow_spilling)
          invalidate_analysis(DEPENDENCY_INSTRUCTIONS);
       }
 
-      schedule_instructions(pre_modes[i]);
-      this->shader_stats.scheduler_mode = scheduler_mode_name[i];
+      schedule_instructions(sched_mode);
+      this->shader_stats.scheduler_mode = scheduler_mode_name[sched_mode];
 
       if (0) {
          assign_regs_trivial();