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

Re: __builtin_constant_p and inline assembly constraints


At Tue, 22 Aug 2006 15:27:14 +0100,
Andrew Haley wrote:
> I see this:
> 
> static inline int
> puts (const char *string)
> {
>   register unsigned long __v0 asm ("$2");
>   __asm__ volatile (".set  push\n.set  noreorder\n");
>   if (__builtin_constant_p (string))
>     {
>       __asm__ volatile (".long  0xfffd0000\n" ".long  %0\n"::"i,!r" (string));
>     }
>   else
>     {
>       __asm__ volatile (".short  0xfffe\n" ".short  %0\n"::"r" (string));
>     };
>   __asm__ volatile (".short 0xffff\t#" "puts" "\n\t"
> 		    ".short %1\n":"=&r" (__v0):"i" (1));
>   __asm__ volatile (".set\tpop\n");
>   return (int) __v0;
> };
> 
> and it's pretty clear that string is not a constant in the context of
> this function: it's a parameter.

I don't see why that would be a problem: the function is inlined after
all. Also, I've tried the same with exit (defined in the same way, but
takes an integer), that works as expected.

The funny thing is that GCC realizes that it can put the constant
address in the inline assembly with the "i,!r" constraint, but that
__builtin_constant_p still returns 0. This is what I think looks
inconsistent.

// Simon


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