comp.lang.ada
 help / color / mirror / Atom feed
From: "Wayne Bullaughey" <wayneb@cacdsp.com>
Subject: volatile with gnat
Date: Wed, 10 Jan 2001 02:32:36 GMT
Date: 2001-01-10T02:32:36+00:00	[thread overview]
Message-ID: <8RP66.4566$Gf6.42244@news3.voicenet.com> (raw)

The volatile pragma seems to be ignored by gnat version 3.13p when
optimization O2 is set unless I am missing something. All the versions of
gnat I have tried including Linux Intel native, NT Intel native, Solaris
Sparc native, Linux Intel X MIPS cross generate similar code. The following
source exhibits the problem:
procedure vol is

x : integer;


pragma Volatile (x);


begin

x := 0;

while x = 0 loop

null;

end loop;

end vol;

The NT Intel code generated is:

vol.o:     file format pe-i386

Disassembly of section .text:

00000000 <__ada_vol>:
   0: 55              pushl  %ebp
   1: 89 e5           movl   %esp,%ebp
   3: 83 ec 04        subl   $0x4,%esp
   6: c7 45 fc 00 00  movl   $0x0,0xfffffffc(%ebp)
   b: 00 00
   d: 8b 45 fc        movl   0xfffffffc(%ebp),%eax
  10: 85 c0           testl  %eax,%eax
  12: 75 08           jne    1c <__ada_vol+1c>
  14: 8b 45 fc        movl   0xfffffffc(%ebp),%eax
  17: 90              nop
  18: 85 c0           testl  %eax,%eax
  1a: 74 fc           je     18 <__ada_vol+18>
  1c: 89 ec           movl   %ebp,%esp
  1e: 5d              popl   %ebp
  1f: c3              ret


The generated code loads x into a register and then tests the register value
in the loop. My understanding of the volatile pragma is that the register
must be reloaded from the memory location. Version 3.11p generated correct
code.  I have not tried 3.12p. In my actual application I use a for
x'address use statement to map x to special hardware address that I need to
test.  Having this type of clause does not seem to affect the generated
code.

My apologies if this is the wrong forum for discussing gnat specific issues.
Is there a more appropriate place? I will also submit this to Act.

Wayne Bullaughey





             reply	other threads:[~2001-01-10  2:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-10  2:32 Wayne Bullaughey [this message]
2001-01-10 22:00 ` volatile with gnat Robert Dewar
2001-01-11  0:59   ` wayne
2001-01-11  2:22     ` Robert Dewar
2001-01-11 18:13       ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox