First-principles studies of diamond polytypes