Hoist function creation from FromCore into a middleend transformation.