This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Automatic "const" function detection.
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Automatic "const" function detection.
- From: Etienne LORRAIN <etienne_lorrain at yahoo dot fr>
- Date: Mon, 8 Nov 1999 16:34:06 +0100 (CET)
- Cc: etienne dot lorrain at ibm dot net
- Reply-To: etienne dot lorrain at ibm dot net
Hello again,
I have had problems with simple inline functions and asm(""),
sometime the optimiser removes the asm(""). I know that
we can use the "volatile" keyword to force the instruction
to be emited - but it is not clean and I feel, studying the
assembly, that the problem is elsewhere.
I know also (from reading the source) that with 2.95-2, an
input only asm("") is by default declared "volatile".
My question is: is there a place (in the source) where a
function (inlined or not) is "automagically detected" as a
constant function - i.e. __attribute__((const)).
I would like to check myself if one function containning
only one (non-const) asm("") would be correctly detected
as a NOT "__attribute__ ((const))" function.
unsigned char inb (unsigned short port) {
unsigned char result;
asm ("inb %1,%0" : "=a" (result) : "d" (port));
return result;
}
==> should not be optimised like a "const" function
==> when called 3 times, mostly when there is other
==> asm() in between. That is not so much different
==> from:
#define inb(data, port) asm ("inb %1,%0" : "=a" (data) : "d" (port));
I am not 100% sure of what I am saying here - so I
would like to check myself. The problems I had were
in deeply mixed outb() and inb()...
Maybe my problem were just that I can clobber "cc"
and "memory" but not "IOspace".
Thanks,
Etienne.
-- Note that I am sorry sending so much E-mail to this
-- newsgroup - but I have been unable to post here
-- for some weeks...
___________________________________________________________
Do You Yahoo!?
Votre e-mail @yahoo.fr gratuit sur http://courrier.yahoo.fr