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]

Re: Inlining bug on MIPS - both 2.95.3 and 3.0 branches


On Sat, Mar 10, 2001 at 01:49:30PM -0800, Geoff Keating wrote:
> > Date: Fri, 9 Mar 2001 23:46:42 -0500
> > From: Daniel Jacobowitz <dmj+@andrew.cmu.edu>
> > Cc: gcc-bugs@gcc.gnu.org
> 
> > Right.  Is there any way to define an inline asm in an inline function
> > with an "i" constraint for an argument of the function, though?  I get
> > (obviously) constraint violation errors.  I'm assuming this needs to
> > become a macro.
> 
> It's possible that you need to try "i#*X", as in this example:
> 
> # define feraiseexcept(__excepts) \
>   ((__builtin_constant_p (__excepts)					      \
>     && ((__excepts) & ((__excepts)-1)) == 0				      \
>     && (__excepts) != FE_INVALID)					      \
>    ? ((__excepts) != 0							      \
>       ? (__extension__ ({ __asm__ __volatile__				      \
> 			  ("mtfsb1 %s0"					      \
> 			   : : "i#*X"(__builtin_ffs (__excepts)));	      \
> 			  (void)0; }))					      \
>       : (void)0)							      \
>    : (feraiseexcept) (__excepts))
> 
> I think that inline functions make the problem more likely to happen
> but it can happen anyway.  (The problem being that just because the
> code is guarded by '__builtin_constant_p' doesn't mean that it doesn't
> get compiled, at least up to some point in the compiler, and
> constraints are checked early.)

I see, thanks.  Although I'm mystified by how the # and * don't cancel
out - according to the documentation, # means "only used for register
preferences" and * means "ignored for register preferences".

These do still require that I use a macro rather than an inline
function, from what I can see, though.  If I use the "i#*X" constraint
inside the inline function, the compiler seems to first decide to
prefer a register (before inlining?), and then attempt to satisfy the
constraints when inlining.  This fails, obviously:

mips-vgacon.c: In function `vga_pal_blank':
mips-vgacon.c:10: inconsistent operand constraints in an `asm'

So unless there's something I'm missing about constraints, there is no
way to say what I want to say here, and I need to use a macro.

-- 
Daniel Jacobowitz                           Debian GNU/Linux Developer
Monta Vista Software                              Debian Security Team
                         "I am croutons!"


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