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

Author: Nicolai Hähnle <[email protected]>
Date:   Tue Aug  1 23:09:48 2017 +0200

tgsi: store opcode mnemonics in a separate table

They are only used for debug info.

Together with making tgsi_opcode_info::opcode a bitfield, this reduces
the size of tgsi_opcode_info on 64-bit systems from 24 bytes to 4 bytes,
and makes the whole data structure a bit more linker friendly.

Reviewed-by: Marek Olšák <[email protected]>

---

 src/gallium/auxiliary/tgsi/tgsi_info.c | 19 +++++++++++++++----
 src/gallium/auxiliary/tgsi/tgsi_info.h |  3 +--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c 
b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 5112826aaf..08bce6380c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -36,11 +36,11 @@
 #define OTHR TGSI_OUTPUT_OTHER
 
 #define OPCODE(_num_dst, _num_src, _output_mode, name, ...) \
-   { .mnemonic = #name, .opcode = TGSI_OPCODE_ ## name, \
+   { .opcode = TGSI_OPCODE_ ## name, \
      .output_mode = _output_mode, .num_dst = _num_dst, .num_src = _num_src, \
      ##__VA_ARGS__ },
 
-#define OPCODE_GAP(opc) { .mnemonic = "", .opcode = opc },
+#define OPCODE_GAP(opc) { .opcode = opc },
 
 static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
 {
@@ -69,12 +69,23 @@ tgsi_get_opcode_info( uint opcode )
    return NULL;
 }
 
+#define OPCODE(_num_dst, _num_src, _output_mode, name, ...) #name,
+#define OPCODE_GAP(opc) "UNK" #opc,
+
+static const char * const opcode_names[TGSI_OPCODE_LAST] =
+{
+#include "tgsi_info_opcodes.h"
+};
+
+#undef OPCODE
+#undef OPCODE_GAP
 
 const char *
 tgsi_get_opcode_name( uint opcode )
 {
-   const struct tgsi_opcode_info *info = tgsi_get_opcode_info(opcode);
-   return info->mnemonic;
+   if (opcode >= ARRAY_SIZE(opcode_names))
+      return "UNK_OOB";
+   return opcode_names[opcode];
 }
 
 
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h 
b/src/gallium/auxiliary/tgsi/tgsi_info.h
index e65f7ac3b7..74bff18692 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.h
@@ -79,8 +79,7 @@ struct tgsi_opcode_info
    unsigned pre_dedent:1;
    unsigned post_indent:1;
    enum tgsi_output_mode output_mode:3;
-   const char *mnemonic;
-   uint opcode;
+   unsigned opcode:8;
 };
 
 const struct tgsi_opcode_info *

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to