diff mbox series

[Ada] Optimization of System.Value_N

Message ID 20210621110534.GA43003@adacore.com
State New
Headers show
Series [Ada] Optimization of System.Value_N | expand

Commit Message

Pierre-Marie de Rodat June 21, 2021, 11:05 a.m. UTC
Add Inline and Pure_Function aspects. With these changes, and additional
changes in gigi, we should be able to eliminate duplicate calls to
Value_Enumeration_Pos.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-valuen.ads (Value_Enumeration,
	Valid_Enumeration_Value): Inline.
	(Value_Enumeration_Pos): Add Pure_Function.
diff mbox series

Patch

diff --git a/gcc/ada/libgnat/s-valuen.ads b/gcc/ada/libgnat/s-valuen.ads
--- a/gcc/ada/libgnat/s-valuen.ads
+++ b/gcc/ada/libgnat/s-valuen.ads
@@ -48,7 +48,7 @@  package System.Value_N is
       Hash    : Hash_Function_Ptr;
       Num     : Natural;
       Str     : String)
-      return    Natural;
+      return    Natural with Inline;
    --  Used to compute Enum'Value (Str) where Enum is some enumeration type
    --  other than those defined in package Standard. Names is a string with
    --  a lower bound of 1 containing the characters of all the enumeration
@@ -73,7 +73,7 @@  package System.Value_N is
       Hash    : Hash_Function_Ptr;
       Num     : Natural;
       Str     : String)
-      return    Boolean;
+      return    Boolean with Inline;
    --  Returns True if Str is a valid Image of some enumeration literal, False
    --  otherwise. That is, returns False if and only if Value_Enumeration would
    --  raise Constraint_Error. The parameters have the same meaning as for
@@ -87,7 +87,7 @@  package System.Value_N is
       Hash    : Hash_Function_Ptr;
       Num     : Natural;
       Str     : String)
-      return    Integer;
+      return    Integer with Pure_Function;
    --  Same as Value_Enumeration, except returns Invalid if Value_Enumeration
    --  would raise Constraint_Error.