This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Implement new pragma/aspect Volatile_Full_Access


A new pragma (and equivalent aspect) Volatile_Full_Access is implemented. This
is similar to Volatile except that there is a guarantee that every read and
write access to an object with this aspect will always use a single instruction
which reads or writes all the bits of the object. Note that this differs from
Atomic in that there is no such guarantee for Atomic (the compiler can for
instance read part of the object), and in addition there is no resulting
atomic synchronization for this new volatile aspect.

The following test compiled with -gnatdt:

     1. with System; use System;
     2. procedure NonAtomC (G : Short_Integer; A : Address) is
     3.    type R is array (0 .. 31) of Boolean;
     4.    pragma Pack (R);
     5.    pragma Volatile_Full_Access (R);
     6.    RV : R;
     7.    for RV'Address use A;
     8.    type B is record
     9.       X, Y : Short_Integer;
    10.    end record  with Alignment => 4, Volatile_Full_Access;
    11.    BV : B := (G,G);
    12.    for BV'Address use A;
    13. begin
    14.    RV (3) := True;
    15.    BV.X := BV.Y;
    16. end;

generates a file with three occurrences of Has_Volatile_Full_Access:

      |    Has_Volatile_Full_Access = True
    |  Has_Volatile_Full_Access = True
    |  Has_Volatile_Full_Access = True

Note the corresponding gigi work will follow separately.

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

2015-05-12  Robert Dewar  <dewar@adacore.com>

	* aspects.ads, aspects.adb: Add entries for aspect Volatile_Full_Access
	* einfo.adb (Has_Volatile_Full_Access): New flag.
	(Has_Volatile_Full_Access): New flag.
	* einfo.ads (Has_Volatile_Full_Access): New flag.
	* par-prag.adb: Add dummy entry for Volatile_Full_Access.
	* sem_prag.adb (Analyze_Pragma, case Volatile_Full_Access):
	Implement new pragma.
	* snames.ads-tmpl: Add entries for pragma Volatile_Full_Access.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]