dst.y = src1.x;
""")
+# Byte extraction
+binop("extract_ubyte", tuint, "", "(uint8_t)(src0 >> (src1 * 8))")
+binop("extract_ibyte", tint, "", "(int8_t)(src0 >> (src1 * 8))")
+
+# Word extraction
+binop("extract_uword", tuint, "", "(uint16_t)(src0 >> (src1 * 16))")
+binop("extract_iword", 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):
('bcsel', ('ult', 31, 'bits'), 'value',
('ubfe', 'value', 'offset', 'bits')),
'options->lower_bitfield_extract'),
+
+ (('extract_ibyte', a, b),
+ ('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 8),
+ 'options->lower_extract_byte'),
+
+ (('extract_ubyte', a, b),
+ ('iand', ('ushr', a, ('imul', b, 8)), 0xff),
+ 'options->lower_extract_byte'),
+
+ (('extract_iword', a, b),
+ ('ishr', ('ishl', a, ('imul', ('isub', 1, b), 16)), 16),
+ 'options->lower_extract_word'),
+
+ (('extract_uword', a, b),
+ ('iand', ('ushr', a, ('imul', b, 16)), 0xffff),
+ 'options->lower_extract_word'),
]
# Add optimizations to handle the case where the result of a ternary is