@@ -469,21 +469,36 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
469469// set of options.
470470static bool ppcUserFeaturesCheck (DiagnosticsEngine &Diags,
471471 const std::vector<std::string> &FeaturesVec) {
472- // Cannot allow soft-float with Altivec.
473- if (llvm::is_contained (FeaturesVec, " -hard-float" ) &&
474- llvm::is_contained (FeaturesVec, " +altivec" )) {
475- Diags.Report (diag::err_opt_not_valid_with_opt) << " -msoft-float"
476- << " -maltivec" ;
472+ auto FindVSXSubfeature = [&](StringRef Feature, StringRef SubOption,
473+ StringRef Option) {
474+ if (llvm::is_contained (FeaturesVec, Feature)) {
475+ Diags.Report (diag::err_opt_not_valid_with_opt) << SubOption << Option;
476+ return true ;
477+ }
477478 return false ;
478- }
479+ };
479480
480- // Cannot allow soft-float with VSX.
481- if (llvm::is_contained (FeaturesVec, " -hard-float" ) &&
482- llvm::is_contained (FeaturesVec, " +vsx" )) {
483- Diags.Report (diag::err_opt_not_valid_with_opt) << " -msoft-float"
484- << " -mvsx" ;
485- return false ;
481+ // Cannot allow soft-float with VSX, Altivec, or any
482+ // VSX subfeatures.
483+ bool Found = false ;
484+ if (llvm::is_contained (FeaturesVec, " -hard-float" )) {
485+ Found |= FindVSXSubfeature (" +vsx" , " -mvsx" , " -msoft-float" );
486+ Found |= FindVSXSubfeature (" +altivec" , " -maltivec" , " -msoft-float" );
487+ Found |=
488+ FindVSXSubfeature (" +power8-vector" , " -mpower8-vector" , " -msoft-float" );
489+ Found |= FindVSXSubfeature (" +direct-move" , " -mdirect-move" , " -msoft-float" );
490+ Found |= FindVSXSubfeature (" +float128" , " -mfloat128" , " -msoft-float" );
491+ Found |=
492+ FindVSXSubfeature (" +power9-vector" , " -mpower9-vector" , " -msoft-float" );
493+ Found |= FindVSXSubfeature (" +paired-vector-memops" ,
494+ " -mpaired-vector-memops" , " -msoft-float" );
495+ Found |= FindVSXSubfeature (" +mma" , " -mmma" , " -msoft-float" );
496+ Found |= FindVSXSubfeature (" +crypto" , " -mcrypto" , " -msoft-float" );
497+ Found |= FindVSXSubfeature (" +power10-vector" , " -mpower10-vector" ,
498+ " -msoft-float" );
486499 }
500+ if (Found)
501+ return false ;
487502
488503 // Cannot allow VSX with no Altivec.
489504 if (llvm::is_contained (FeaturesVec, " +vsx" ) &&
@@ -497,21 +512,14 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
497512 if (!llvm::is_contained (FeaturesVec, " -vsx" ))
498513 return true ;
499514
500- auto FindVSXSubfeature = [&](StringRef Feature, StringRef Option) {
501- if (llvm::is_contained (FeaturesVec, Feature)) {
502- Diags.Report (diag::err_opt_not_valid_with_opt) << Option << " -mno-vsx" ;
503- return true ;
504- }
505- return false ;
506- };
507-
508- bool Found = FindVSXSubfeature (" +power8-vector" , " -mpower8-vector" );
509- Found |= FindVSXSubfeature (" +direct-move" , " -mdirect-move" );
510- Found |= FindVSXSubfeature (" +float128" , " -mfloat128" );
511- Found |= FindVSXSubfeature (" +power9-vector" , " -mpower9-vector" );
512- Found |= FindVSXSubfeature (" +paired-vector-memops" , " -mpaired-vector-memops" );
513- Found |= FindVSXSubfeature (" +mma" , " -mmma" );
514- Found |= FindVSXSubfeature (" +power10-vector" , " -mpower10-vector" );
515+ Found = FindVSXSubfeature (" +power8-vector" , " -mpower8-vector" , " -mno-vsx" );
516+ Found |= FindVSXSubfeature (" +direct-move" , " -mdirect-move" , " -mno-vsx" );
517+ Found |= FindVSXSubfeature (" +float128" , " -mfloat128" , " -mno-vsx" );
518+ Found |= FindVSXSubfeature (" +power9-vector" , " -mpower9-vector" , " -mno-vsx" );
519+ Found |= FindVSXSubfeature (" +paired-vector-memops" , " -mpaired-vector-memops" ,
520+ " -mno-vsx" );
521+ Found |= FindVSXSubfeature (" +mma" , " -mmma" , " -mno-vsx" );
522+ Found |= FindVSXSubfeature (" +power10-vector" , " -mpower10-vector" , " -mno-vsx" );
515523
516524 // Return false if any vsx subfeatures was found.
517525 return !Found;
@@ -693,7 +701,6 @@ bool PPCTargetInfo::initFeatureMap(
693701 Diags.Report (diag::err_opt_not_valid_with_opt) << " -mprivileged" << CPU;
694702 return false ;
695703 }
696-
697704 return TargetInfo::initFeatureMap (Features, Diags, CPU, FeaturesVec);
698705}
699706
@@ -783,13 +790,16 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
783790 } else {
784791 if (Name == " spe" )
785792 Features[" efpu2" ] = false ;
786- // If we're disabling altivec or vsx go ahead and disable all of the vsx
787- // features.
788- if ((Name == " altivec" ) || (Name == " vsx" ))
793+ // If we're disabling altivec, hard-float, or vsx go ahead and disable all
794+ // of the vsx features.
795+ if ((Name == " altivec" ) || (Name == " vsx" ) || (Name == " hard-float" )) {
796+ if (Name != " vsx" )
797+ Features[" altivec" ] = Features[" crypto" ] = false ;
789798 Features[" vsx" ] = Features[" direct-move" ] = Features[" power8-vector" ] =
790799 Features[" float128" ] = Features[" power9-vector" ] =
791800 Features[" paired-vector-memops" ] = Features[" mma" ] =
792801 Features[" power10-vector" ] = false ;
802+ }
793803 if (Name == " power8-vector" )
794804 Features[" power9-vector" ] = Features[" paired-vector-memops" ] =
795805 Features[" mma" ] = Features[" power10-vector" ] = false ;
0 commit comments