Factor out some knowledge of immediate index encoding.