@@ -701,9 +701,21 @@ void ARMAsmPrinter::emitAttributes() {
701
701
ARMBuildAttrs::AddressDirect);
702
702
}
703
703
704
+ Metadata *MDEx = nullptr ;
705
+ Metadata *MDDM = nullptr ;
706
+ Metadata *MDNM = nullptr ;
707
+ if (const Module *M = MMI->getModule ()) {
708
+ MDEx = M->getModuleFlag (" arm-eabi-fp-exceptions" );
709
+ MDDM = M->getModuleFlag (" arm-eabi-fp-denormal" );
710
+ MDNM = M->getModuleFlag (" arm-eabi-fp-number-model" );
711
+ }
712
+
704
713
// Set FP Denormals.
705
- if (checkDenormalAttributeConsistency (*MMI->getModule (), " denormal-fp-math" ,
706
- DenormalMode::getPreserveSign ()))
714
+ if (auto *DM = mdconst::extract_or_null<ConstantInt>(MDDM))
715
+ ATS.emitAttribute (ARMBuildAttrs::ABI_FP_denormal, DM->getZExtValue ());
716
+ else if (checkDenormalAttributeConsistency (*MMI->getModule (),
717
+ " denormal-fp-math" ,
718
+ DenormalMode::getPreserveSign ()))
707
719
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_denormal,
708
720
ARMBuildAttrs::PreserveFPSign);
709
721
else if (checkDenormalAttributeConsistency (*MMI->getModule (),
@@ -743,9 +755,11 @@ void ARMAsmPrinter::emitAttributes() {
743
755
}
744
756
745
757
// Set FP exceptions and rounding
746
- if (checkFunctionsAttributeConsistency (*MMI->getModule (),
747
- " no-trapping-math" , " true" ) ||
748
- TM.Options .NoTrappingFPMath )
758
+ if (auto *Ex = mdconst::extract_or_null<ConstantInt>(MDEx))
759
+ ATS.emitAttribute (ARMBuildAttrs::ABI_FP_exceptions, Ex->getZExtValue ());
760
+ else if (checkFunctionsAttributeConsistency (*MMI->getModule (),
761
+ " no-trapping-math" , " true" ) ||
762
+ TM.Options .NoTrappingFPMath )
749
763
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_exceptions,
750
764
ARMBuildAttrs::Not_Allowed);
751
765
else {
@@ -759,7 +773,9 @@ void ARMAsmPrinter::emitAttributes() {
759
773
760
774
// TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath is the
761
775
// equivalent of GCC's -ffinite-math-only flag.
762
- if (TM.Options .NoInfsFPMath && TM.Options .NoNaNsFPMath )
776
+ if (auto *NM = mdconst::extract_or_null<ConstantInt>(MDNM))
777
+ ATS.emitAttribute (ARMBuildAttrs::ABI_FP_number_model, NM->getZExtValue ());
778
+ else if (TM.Options .NoInfsFPMath && TM.Options .NoNaNsFPMath )
763
779
ATS.emitAttribute (ARMBuildAttrs::ABI_FP_number_model,
764
780
ARMBuildAttrs::Allowed);
765
781
else
0 commit comments