diff options
author | Matt Turner <[email protected]> | 2016-01-21 09:09:29 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2016-02-01 10:43:57 -0800 |
commit | 68f8c5730bef7b93fd235ae2f3c87cc9403b5b4c (patch) | |
tree | 18d11b5509d0874a8ea698e5759faac552eba75d /src/compiler/nir/nir_opcodes.py | |
parent | 8709dc071323eb47be12f0929efe9e0741e9ef30 (diff) |
nir: Add opcodes to extract bytes or words.
The uint versions zero extend while the int versions sign extend.
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_opcodes.py')
-rw-r--r-- | src/compiler/nir/nir_opcodes.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index a8bbe1a0b82..5f5a0efd2d6 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): |