[Ada] Improve support for tuning branch probability heuristics
This adds a new GNAT.Branch_Prediction package to make it possible to tune the branch probability heuristics more finely. This package contains the equivalent of __builtin_expect in C/C++ plus a couple of specializations. The following program gives a summary of the usage: package Q is I : Integer; pragma Volatile (I); end Q; with GNAT.Branch_Prediction; use GNAT.Branch_Prediction; with Text_IO; use Text_IO; with Q; use Q; procedure P is begin if Unlikely (I = 0) then Put_Line ("Zero was passed"); return; end if; if Likely (I > 0) then Put_Line ("A positive number was passed"); else Put_Line ("A negative number was passed"); end if; if Expect ((I rem 2) = 0, False) then Put_Line ("An even number was passed"); else Put_Line ("An odd number was passed"); end if; end; 2019-07-10 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-brapre. * libgnat/g-brapre.ads: New package specification. * doc/gnat_rm/the_gnat_library.rst: Document it. * gnat_rm.texi: Regenerate. From-SVN: r273340
Showing
This diff is collapsed.
Click to expand it.
gcc/ada/libgnat/g-brapre.ads
0 → 100644
Please
register
or
sign in
to comment