@@ -469,21 +469,36 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
469
469
// set of options.
470
470
static bool ppcUserFeaturesCheck (DiagnosticsEngine &Diags,
471
471
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
+ }
477
478
return false ;
478
- }
479
+ };
479
480
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" );
486
499
}
500
+ if (Found)
501
+ return false ;
487
502
488
503
// Cannot allow VSX with no Altivec.
489
504
if (llvm::is_contained (FeaturesVec, " +vsx" ) &&
@@ -497,21 +512,14 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
497
512
if (!llvm::is_contained (FeaturesVec, " -vsx" ))
498
513
return true ;
499
514
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" );
515
523
516
524
// Return false if any vsx subfeatures was found.
517
525
return !Found;
@@ -693,7 +701,6 @@ bool PPCTargetInfo::initFeatureMap(
693
701
Diags.Report (diag::err_opt_not_valid_with_opt) << " -mprivileged" << CPU;
694
702
return false ;
695
703
}
696
-
697
704
return TargetInfo::initFeatureMap (Features, Diags, CPU, FeaturesVec);
698
705
}
699
706
@@ -783,13 +790,16 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
783
790
} else {
784
791
if (Name == " spe" )
785
792
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 ;
789
798
Features[" vsx" ] = Features[" direct-move" ] = Features[" power8-vector" ] =
790
799
Features[" float128" ] = Features[" power9-vector" ] =
791
800
Features[" paired-vector-memops" ] = Features[" mma" ] =
792
801
Features[" power10-vector" ] = false ;
802
+ }
793
803
if (Name == " power8-vector" )
794
804
Features[" power9-vector" ] = Features[" paired-vector-memops" ] =
795
805
Features[" mma" ] = Features[" power10-vector" ] = false ;
0 commit comments