This is the mail archive of the gcc-bugs@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]

Automatic "const" function detection.


  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


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