nir: move brw_nir_rewrite_image_intrinsic into common code