aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat/s-bituti.ads
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-03-30 07:15:39 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-21 06:45:14 -0400
commit9418d3d41f581edd9acfdc4f359d37f948c1671e (patch)
tree482346fcb7b87707e2e6f69fc1c235601292a911 /gcc/ada/libgnat/s-bituti.ads
parentc3681eba728a487f042de72e90c29b1cfca4e2e7 (diff)
downloadgcc-9418d3d41f581edd9acfdc4f359d37f948c1671e.zip
gcc-9418d3d41f581edd9acfdc4f359d37f948c1671e.tar.gz
gcc-9418d3d41f581edd9acfdc4f359d37f948c1671e.tar.bz2
[Ada] Improve efficiency of small slice assignments of packed arrays
gcc/ada/ * rtsfind.ads, libgnat/s-bitfie.ads, libgnat/s-bituti.adb, libgnat/s-bituti.ads (Fast_Copy_Bitfield): New run-time library function to copy bit fields faster than Copy_Bitfield. Cannot be called with zero-size bit fields. Remove obsolete ??? comments from s-bituti.adb; we already do "avoid calling this if Forwards_OK is False". * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield, Expand_Assign_Array_Bitfield_Fast): Generate calls to Fast_Copy_Bitfield when appropriate. * sem_util.adb, sem_util.ads (Get_Index_Bounds): Two new functions for getting the index bounds. These are more convenient than the procedure of the same name, because they can be used to initialize constants.
Diffstat (limited to 'gcc/ada/libgnat/s-bituti.ads')
-rw-r--r--gcc/ada/libgnat/s-bituti.ads16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ada/libgnat/s-bituti.ads b/gcc/ada/libgnat/s-bituti.ads
index c9c4b91..8afee24 100644
--- a/gcc/ada/libgnat/s-bituti.ads
+++ b/gcc/ada/libgnat/s-bituti.ads
@@ -54,7 +54,7 @@ package System.Bitfield_Utils is
-- generic formal, or on a type derived from a generic formal, so they have
-- to be passed in.
--
- -- Endian indicates whether we're on little-endian or big-endian machine.
+ -- Endian indicates whether we're on a little- or big-endian machine.
pragma Elaborate_Body;
@@ -127,6 +127,20 @@ package System.Bitfield_Utils is
-- D (D_First)'Address, D (D_First)'Bit,
-- Size);
+ function Fast_Copy_Bitfield
+ (Src : Val_2;
+ Src_Offset : Bit_Offset;
+ Dest : Val_2;
+ Dest_Offset : Bit_Offset;
+ Size : Small_Size)
+ return Val_2 with Inline;
+ -- Faster version of Copy_Bitfield, with a different calling convention.
+ -- In particular, we pass by copy rather than passing Addresses. The bit
+ -- field must fit in Val_Bits. Src and Dest must be properly aligned.
+ -- The result is supposed to be assigned back into Dest, as in:
+ --
+ -- Dest := Fast_Copy_Bitfield (Src, ..., Dest, ..., ...);
+
end G;
end System.Bitfield_Utils;