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]

Re: volatile asm fix



> > Consider an asm that changes the rounding mode[1], or a page table entry
> > in the MMU[2], or one that switches to/from shadow register sets[3].  We
> > can't cache any kind of value across such an asm.

> Number 1 is the only remotely tricky case, though it is in fact possible. 
> You just have to fiddle with the values dependant on the mode change.
> Ideally we'd support ISO C9X's pragmas for changing the rounding mode, so
> I don't think the awkwardness of the current situation warrents thought.

Yes, the first is the tricky one.

But that's OK.  egcs gets this wrong in lots of other cases, too.

For instance, if you write

fesetround(FE_ROUND_ZERO);   /* I've probably got the wrong constant name */
x = 0.1 + 1.0;
fesetround(FE_ROUND_NEAREST);
...

'x' will have the wrong value because it will be computed at
compile-time.

I think the way this should work is that the C9X #pragma should be
used and supported:


#pragma STDC STRICT_FLOAT ON     /* probably this is the wrong name too */
fesetround(FE_ROUND_ZERO);
x = 0.1 + 1.0;
fesetround(FE_ROUND_NEAREST);


which suppresses run-time constant evaluation and lots of other stuff
that's difficult to suppress in egcs :-); and then egcs needs to have
the idea of a 'FP state', which is written by fesetround(), and is
read and written by every FP operation.

> Nr 2 is easily handled by clobbering "memory", and nr 3 by clobering the
> registers involved.

Indeed so.

-- 
Geoffrey Keating <geoffk@ozemail.com.au>


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