summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2012-01-24 11:55:14 +0000
committerDave Airlie <[email protected]>2012-02-17 17:39:01 +0000
commit13e2e51f7058dff01281050db1b64639ad3b399e (patch)
treeebe8a1b8da89718fc7cfad014ff7bcd6281a4787 /src/gallium
parent9be0f9b0e470bb7bc8672d161615c16fe5b026fd (diff)
tgsi: add source/destination type from opcodes. (v2)
These two functions produce the src/dst types for an opcode. MOV is special since it can be used to mov float->float and int->int, so just return VOID. v2: use a new enum for the opcode type as per Jose's suggestion. Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c97
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.h15
2 files changed, 112 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 2407448c40d..a44f48ca881 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -243,3 +243,100 @@ tgsi_get_processor_name( uint processor )
return "unknown shader type!";
}
}
+
+/*
+ * infer the source type of a TGSI opcode.
+ * MOV is special so return VOID
+ */
+enum tgsi_opcode_type
+tgsi_opcode_infer_src_type( uint opcode )
+{
+ switch (opcode) {
+ case TGSI_OPCODE_MOV:
+ return TGSI_TYPE_UNTYPED;
+ case TGSI_OPCODE_AND:
+ case TGSI_OPCODE_OR:
+ case TGSI_OPCODE_XOR:
+ case TGSI_OPCODE_SAD:
+ case TGSI_OPCODE_U2F:
+ case TGSI_OPCODE_UADD:
+ case TGSI_OPCODE_UDIV:
+ case TGSI_OPCODE_UMOD:
+ case TGSI_OPCODE_UMAD:
+ case TGSI_OPCODE_UMUL:
+ case TGSI_OPCODE_UMAX:
+ case TGSI_OPCODE_UMIN:
+ case TGSI_OPCODE_USEQ:
+ case TGSI_OPCODE_USGE:
+ case TGSI_OPCODE_USLT:
+ case TGSI_OPCODE_USNE:
+ case TGSI_OPCODE_USHR:
+ case TGSI_OPCODE_SHL:
+ case TGSI_OPCODE_TXQ:
+ return TGSI_TYPE_UNSIGNED;
+ case TGSI_OPCODE_MOD:
+ case TGSI_OPCODE_I2F:
+ case TGSI_OPCODE_IDIV:
+ case TGSI_OPCODE_IMAX:
+ case TGSI_OPCODE_IMIN:
+ case TGSI_OPCODE_INEG:
+ case TGSI_OPCODE_ISGE:
+ case TGSI_OPCODE_ISHR:
+ case TGSI_OPCODE_ISLT:
+ case TGSI_OPCODE_IABS:
+ case TGSI_OPCODE_ISSG:
+ case TGSI_OPCODE_UARL:
+ return TGSI_TYPE_SIGNED;
+ default:
+ return TGSI_TYPE_FLOAT;
+ }
+}
+
+/*
+ * infer the destination type of a TGSI opcode.
+ * MOV is special so return VOID
+ */
+enum tgsi_opcode_type
+tgsi_opcode_infer_dst_type( uint opcode )
+{
+ switch (opcode) {
+ case TGSI_OPCODE_MOV:
+ return TGSI_TYPE_UNTYPED;
+ case TGSI_OPCODE_F2U:
+ case TGSI_OPCODE_AND:
+ case TGSI_OPCODE_OR:
+ case TGSI_OPCODE_XOR:
+ case TGSI_OPCODE_SAD:
+ case TGSI_OPCODE_UADD:
+ case TGSI_OPCODE_UDIV:
+ case TGSI_OPCODE_UMOD:
+ case TGSI_OPCODE_UMAD:
+ case TGSI_OPCODE_UMUL:
+ case TGSI_OPCODE_UMAX:
+ case TGSI_OPCODE_UMIN:
+ case TGSI_OPCODE_USEQ:
+ case TGSI_OPCODE_USGE:
+ case TGSI_OPCODE_USLT:
+ case TGSI_OPCODE_USNE:
+ case TGSI_OPCODE_USHR:
+ case TGSI_OPCODE_SHL:
+ case TGSI_OPCODE_TXQ:
+ return TGSI_TYPE_UNSIGNED;
+ case TGSI_OPCODE_F2I:
+ case TGSI_OPCODE_IDIV:
+ case TGSI_OPCODE_IMAX:
+ case TGSI_OPCODE_IMIN:
+ case TGSI_OPCODE_INEG:
+ case TGSI_OPCODE_ISGE:
+ case TGSI_OPCODE_ISHR:
+ case TGSI_OPCODE_ISLT:
+ case TGSI_OPCODE_MOD:
+ case TGSI_OPCODE_UARL:
+ case TGSI_OPCODE_ARL:
+ case TGSI_OPCODE_IABS:
+ case TGSI_OPCODE_ISSG:
+ return TGSI_TYPE_SIGNED;
+ default:
+ return TGSI_TYPE_FLOAT;
+ }
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h
index c0427fb61c9..541491645ec 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.h
@@ -30,6 +30,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_format.h"
#if defined __cplusplus
extern "C" {
@@ -90,6 +91,20 @@ tgsi_get_opcode_name( uint opcode );
const char *
tgsi_get_processor_name( uint processor );
+enum tgsi_opcode_type {
+ TGSI_TYPE_UNTYPED, /* for MOV */
+ TGSI_TYPE_VOID,
+ TGSI_TYPE_UNSIGNED,
+ TGSI_TYPE_SIGNED,
+ TGSI_TYPE_FLOAT,
+ TGSI_TYPE_DOUBLE,
+};
+
+enum tgsi_opcode_type
+tgsi_opcode_infer_src_type( uint opcode );
+
+enum tgsi_opcode_type
+tgsi_opcode_infer_dst_type( uint opcode );
#if defined __cplusplus
}