I hadn't thought in those terms, but the (Southern) Baptist Press quotes a Princeton University law professor, Robert P. George, as saying that where same-sex marriage becomes legal, churches may have to perform these ceremonies or risk losing their tax-exempt status. Doubtful, very, very doubtful... Every legal indication is that freedom of religion trumps this, much as churches can still discriminate in hiring and keep their tax exemptions.
Of course, in Massachusetts, there is still a clear distinction between religious and civil ceremonies, as there has been from colonial times. This is clearer and cleaner in Massachusetts, but implicit elsewhere. U.S. clerics have never had to perform any marriages they oppose.