Factor out common compiler code