summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_opcodes.py
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2016-01-21 09:09:29 -0800
committerMatt Turner <mattst88@gmail.com>2016-02-01 10:43:57 -0800
commit68f8c5730bef7b93fd235ae2f3c87cc9403b5b4c (patch)
tree18d11b5509d0874a8ea698e5759faac552eba75d /src/compiler/nir/nir_opcodes.py
parent8709dc071323eb47be12f0929efe9e0741e9ef30 (diff)
downloadexternal_mesa3d-68f8c5730bef7b93fd235ae2f3c87cc9403b5b4c.zip
external_mesa3d-68f8c5730bef7b93fd235ae2f3c87cc9403b5b4c.tar.gz
external_mesa3d-68f8c5730bef7b93fd235ae2f3c87cc9403b5b4c.tar.bz2
nir: Add opcodes to extract bytes or words.
The uint versions zero extend while the int versions sign extend. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Diffstat (limited to 'src/compiler/nir/nir_opcodes.py')
-rw-r--r--src/compiler/nir/nir_opcodes.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index a8bbe1a..5f5a0ef 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -536,6 +536,15 @@ dst.x = src0.x;
dst.y = src1.x;
""")
+# Byte extraction
+binop("extract_u8", tuint, "", "(uint8_t)(src0 >> (src1 * 8))")
+binop("extract_i8", tint, "", "(int8_t)(src0 >> (src1 * 8))")
+
+# Word extraction
+binop("extract_u16", tuint, "", "(uint16_t)(src0 >> (src1 * 16))")
+binop("extract_i16", tint, "", "(int16_t)(src0 >> (src1 * 16))")
+
+
def triop(name, ty, const_expr):
opcode(name, 0, ty, [0, 0, 0], [ty, ty, ty], "", const_expr)
def triop_horiz(name, output_size, src1_size, src2_size, src3_size, const_expr):