util/u_format: move utility function from r600g