From c7b09e44f53896cf5f019f0808a7f6b6096c1973 Mon Sep 17 00:00:00 2001 From: Rebecca Heineman Date: Mon, 7 Oct 2024 15:24:51 -0500 Subject: [PATCH] Added more EnableIntrinsicFunctions, FavorSizeOrSpeed, InlineFunctionExpansion --- makeprojects/visual_studio.py | 167 +++++++++++++++++++++++----------- 1 file changed, 114 insertions(+), 53 deletions(-) diff --git a/makeprojects/visual_studio.py b/makeprojects/visual_studio.py index fc0552c..b1e1d70 100644 --- a/makeprojects/visual_studio.py +++ b/makeprojects/visual_studio.py @@ -808,9 +808,11 @@ def GlobalOptimizations(configuration, fallback=None): Note: Only available on Visual Studio 2003 + Args: configuration: Project configuration to scan for overrides. fallback: Default value to use + Returns: None or validators.VSBooleanProperty object. """ @@ -838,8 +840,8 @@ def InlineFunctionExpansion(configuration, fallback=None): Acceptable inputs are: * "Disable" - * "/Ob1", "Only __inline" - * "/Ob2", "Any Suitable" + * "/Ob1" / "Only __inline" + * "/Ob2" / "Any Suitable" * 0 through 2 Args: @@ -857,11 +859,113 @@ def InlineFunctionExpansion(configuration, fallback=None): # The settings are the same on 2003, 2005, and 2008 return VSEnumProperty( - "InlineFunctionExpansion", fallback, + "InlineFunctionExpansion", + fallback, ("Disable", ("/Ob1", "Only __inline"), ("/Ob2", "Any Suitable"))) +######################################## + + +def EnableIntrinsicFunctions(configuration, fallback=None): + """ + Create ``EnableIntrinsicFunctions`` property. + + Enables intrinsic functions. Using intrinsic functions generates faster, + but possibly larger, code. + + Compiler switch /Oi + + Can be overridden with configuration attribute + ``vs_EnableIntrinsicFunctions`` for the C compiler. + + Args: + configuration: Project configuration to scan for overrides. + fallback: Default value to use + + Returns: + validators.VSBooleanProperty object. + """ + + return VSBooleanProperty.vs_validate( + "EnableIntrinsicFunctions", configuration, + fallback=fallback) + +######################################## + + +def ImproveFloatingPointConsistency(configuration, fallback=None): + """ + Create ``ImproveFloatingPointConsistency`` property. + + Enables intrinsic functions. Using intrinsic functions generates faster, + but possibly larger, code. + + Compiler switch /Op + + Can be overridden with configuration attribute + ``vs_ImproveFloatingPointConsistency`` for the C compiler. + + Note: + Only available on Visual Studio 2003 + + Args: + configuration: Project configuration to scan for overrides. + fallback: Default value to use + + Returns: + None or validators.VSBooleanProperty object. + """ + if configuration.ide is IDETypes.vs2003: + return VSBooleanProperty.vs_validate( + "ImproveFloatingPointConsistency", + configuration, + fallback=fallback) + return None + +######################################## + + +def FavorSizeOrSpeed(configuration, fallback=None): + """ + Create ``FavorSizeOrSpeed`` property. + + Determine if optimizations should focus on saving space vs unrolling loops. + + Compiler switches /Ot, /Os + + Can be overridden with configuration attribute + ``vs_FavorSizeOrSpeed`` for the C compiler. + + Acceptable inputs are: + + * "Neither" + * "/Ot" / "Favor Fast Code" + * "/Os" / "Favor Small Code" + * 0 through 2 + + Args: + configuration: Project configuration to scan for overrides. + fallback: Default value to use + + Returns: + validators.VSEnumProperty object. + """ + + # Was there an override? + value = configuration.get_chained_value("vs_FavorSizeOrSpeed") + if value is not None: + fallback = value + + # The settings are the same on 2003, 2005, and 2008 + return VSEnumProperty( + "FavorSizeOrSpeed", + fallback, + ("Neither", + ("/Ot", "Favor Fast Code"), + ("/Os", "Favor Small Code"))) + # Boolean properties @@ -970,48 +1074,6 @@ def BoolATLMinimizesCRunTimeLibraryUsage(configuration): return None -def BoolEnableIntrinsicFunctions(configuration): - """ EnableIntrinsicFunctions - - Enables intrinsic functions. Using intrinsic functions generates faster, - but possibly larger, code. - - Compiler switch /Oi - - Args: - configuration: Project configuration to scan for overrides. - Returns: - None or VSBooleanProperty object. - """ - return VSBooleanProperty.vs_validate( - "EnableIntrinsicFunctions", configuration, - fallback=configuration.optimization, options_key="compiler_options", - options=(("/Oi", True),)) - - -def BoolImproveFloatingPointConsistency(configuration): - """ ImproveFloatingPointConsistency - - Enables intrinsic functions. Using intrinsic functions generates faster, - but possibly larger, code. - - Compiler switch /Op - - Note: - Only available on Visual Studio 2003 - Args: - configuration: Project configuration to scan for overrides. - Returns: - None or VSBooleanProperty object. - """ - if configuration.ide is IDETypes.vs2003: - return VSBooleanProperty.vs_validate( - "ImproveFloatingPointConsistency", configuration, - options_key="compiler_options", - options=(("/Op", True),)) - return None - - def BoolOmitFramePointers(configuration): """ OmitFramePointers @@ -2451,17 +2513,16 @@ def __init__(self, configuration): self.add_default(InlineFunctionExpansion(configuration, item)) # Enable intrinsics - self.add_default(BoolEnableIntrinsicFunctions(configuration)) + self.add_default( + EnableIntrinsicFunctions( + configuration, + configuration.optimization)) - # True if floating point consistency is important - self.add_default(BoolImproveFloatingPointConsistency(configuration)) + # True if floating point consistency is important (2003 only) + self.add_default(ImproveFloatingPointConsistency(configuration)) # Size or speed? - self.add_default( - VSEnumProperty( - "FavorSizeOrSpeed", "/Ot", - ("Neither", ("/Ot", "Favor Fast Code"), - ("/Os", "Favor Small Code")))) + self.add_default(FavorSizeOrSpeed(configuration, "Favor Fast Code")) # Get rid of stack frame pointers for speed self.add_default(BoolOmitFramePointers(configuration))