Targets.cpp (226951) | Targets.cpp (232894) |
---|---|
1//===--- Targets.cpp - Implement -arch option and targets -----------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 1569 unchanged lines hidden (view full) --- 1578 const std::string &Name, 1579 bool Enabled) const { 1580 // FIXME: This *really* should not be here. We need some way of translating 1581 // options into llvm subtarget features. 1582 if (!Features.count(Name) && 1583 (Name != "sse4" && Name != "sse4.2" && Name != "sse4.1")) 1584 return false; 1585 | 1//===--- Targets.cpp - Implement -arch option and targets -----------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 1569 unchanged lines hidden (view full) --- 1578 const std::string &Name, 1579 bool Enabled) const { 1580 // FIXME: This *really* should not be here. We need some way of translating 1581 // options into llvm subtarget features. 1582 if (!Features.count(Name) && 1583 (Name != "sse4" && Name != "sse4.2" && Name != "sse4.1")) 1584 return false; 1585 |
1586 // FIXME: this should probably use a switch with fall through. 1587 |
|
1586 if (Enabled) { 1587 if (Name == "mmx") 1588 Features["mmx"] = true; 1589 else if (Name == "sse") | 1588 if (Enabled) { 1589 if (Name == "mmx") 1590 Features["mmx"] = true; 1591 else if (Name == "sse") |
1590 Features["sse"] = true; | 1592 Features["mmx"] = Features["sse"] = true; |
1591 else if (Name == "sse2") | 1593 else if (Name == "sse2") |
1592 Features["sse"] = Features["sse2"] = true; | 1594 Features["mmx"] = Features["sse"] = Features["sse2"] = true; |
1593 else if (Name == "sse3") | 1595 else if (Name == "sse3") |
1594 Features["sse"] = Features["sse2"] = Features["sse3"] = true; | 1596 Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = 1597 true; |
1595 else if (Name == "ssse3") | 1598 else if (Name == "ssse3") |
1596 Features["sse"] = Features["sse2"] = Features["sse3"] = | 1599 Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
1597 Features["ssse3"] = true; 1598 else if (Name == "sse4" || Name == "sse4.2") | 1600 Features["ssse3"] = true; 1601 else if (Name == "sse4" || Name == "sse4.2") |
1599 Features["sse"] = Features["sse2"] = Features["sse3"] = | 1602 Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
1600 Features["ssse3"] = Features["sse41"] = Features["sse42"] = true; 1601 else if (Name == "sse4.1") | 1603 Features["ssse3"] = Features["sse41"] = Features["sse42"] = true; 1604 else if (Name == "sse4.1") |
1602 Features["sse"] = Features["sse2"] = Features["sse3"] = | 1605 Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = |
1603 Features["ssse3"] = Features["sse41"] = true; 1604 else if (Name == "3dnow") 1605 Features["mmx"] = Features["3dnow"] = true; 1606 else if (Name == "3dnowa") 1607 Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = true; 1608 else if (Name == "aes") 1609 Features["aes"] = true; 1610 else if (Name == "avx") | 1606 Features["ssse3"] = Features["sse41"] = true; 1607 else if (Name == "3dnow") 1608 Features["mmx"] = Features["3dnow"] = true; 1609 else if (Name == "3dnowa") 1610 Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = true; 1611 else if (Name == "aes") 1612 Features["aes"] = true; 1613 else if (Name == "avx") |
1611 Features["avx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = 1612 Features["ssse3"] = Features["sse41"] = Features["sse42"] = true; | 1614 Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] = 1615 Features["ssse3"] = Features["sse41"] = Features["sse42"] = 1616 Features["avx"] = true; |
1613 else if (Name == "sse4a") | 1617 else if (Name == "sse4a") |
1614 Features["sse4a"] = true; | 1618 Features["mmx"] = Features["sse4a"] = true; |
1615 } else { 1616 if (Name == "mmx") 1617 Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = false; 1618 else if (Name == "sse") 1619 Features["sse"] = Features["sse2"] = Features["sse3"] = 1620 Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; 1621 else if (Name == "sse2") 1622 Features["sse2"] = Features["sse3"] = Features["ssse3"] = --- 2151 unchanged lines hidden (view full) --- 3774 } 3775 3776 // Compute the default target features, we need the target to handle this 3777 // because features may have dependencies on one another. 3778 llvm::StringMap<bool> Features; 3779 Target->getDefaultFeatures(Features); 3780 3781 // Apply the user specified deltas. | 1619 } else { 1620 if (Name == "mmx") 1621 Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = false; 1622 else if (Name == "sse") 1623 Features["sse"] = Features["sse2"] = Features["sse3"] = 1624 Features["ssse3"] = Features["sse41"] = Features["sse42"] = false; 1625 else if (Name == "sse2") 1626 Features["sse2"] = Features["sse3"] = Features["ssse3"] = --- 2151 unchanged lines hidden (view full) --- 3778 } 3779 3780 // Compute the default target features, we need the target to handle this 3781 // because features may have dependencies on one another. 3782 llvm::StringMap<bool> Features; 3783 Target->getDefaultFeatures(Features); 3784 3785 // Apply the user specified deltas. |
3786 // First the enables. |
|
3782 for (std::vector<std::string>::const_iterator it = Opts.Features.begin(), 3783 ie = Opts.Features.end(); it != ie; ++it) { 3784 const char *Name = it->c_str(); 3785 | 3787 for (std::vector<std::string>::const_iterator it = Opts.Features.begin(), 3788 ie = Opts.Features.end(); it != ie; ++it) { 3789 const char *Name = it->c_str(); 3790 |
3791 if (Name[0] != '+') 3792 continue; 3793 |
|
3786 // Apply the feature via the target. | 3794 // Apply the feature via the target. |
3787 if ((Name[0] != '-' && Name[0] != '+') || 3788 !Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) { | 3795 if (!Target->setFeatureEnabled(Features, Name + 1, true)) { |
3789 Diags.Report(diag::err_target_invalid_feature) << Name; 3790 return 0; 3791 } 3792 } 3793 | 3796 Diags.Report(diag::err_target_invalid_feature) << Name; 3797 return 0; 3798 } 3799 } 3800 |
3801 // Then the disables. 3802 for (std::vector<std::string>::const_iterator it = Opts.Features.begin(), 3803 ie = Opts.Features.end(); it != ie; ++it) { 3804 const char *Name = it->c_str(); 3805 3806 if (Name[0] == '+') 3807 continue; 3808 3809 // Apply the feature via the target. 3810 if (Name[0] != '-' || 3811 !Target->setFeatureEnabled(Features, Name + 1, false)) { 3812 Diags.Report(diag::err_target_invalid_feature) << Name; 3813 return 0; 3814 } 3815 } 3816 |
|
3794 // Add the features to the compile options. 3795 // 3796 // FIXME: If we are completely confident that we have the right set, we only 3797 // need to pass the minuses. 3798 Opts.Features.clear(); 3799 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), 3800 ie = Features.end(); it != ie; ++it) 3801 Opts.Features.push_back(std::string(it->second ? "+" : "-") + 3802 it->first().str()); 3803 Target->HandleTargetFeatures(Opts.Features); 3804 3805 return Target.take(); 3806} | 3817 // Add the features to the compile options. 3818 // 3819 // FIXME: If we are completely confident that we have the right set, we only 3820 // need to pass the minuses. 3821 Opts.Features.clear(); 3822 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), 3823 ie = Features.end(); it != ie; ++it) 3824 Opts.Features.push_back(std::string(it->second ? "+" : "-") + 3825 it->first().str()); 3826 Target->HandleTargetFeatures(Opts.Features); 3827 3828 return Target.take(); 3829} |