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]
Other format: [Raw text]

Re: [PATCH] Stage 2 projects - AltiVec rewrite


On Fri, Apr 29, 2005 at 01:24:51PM +0200, Paolo Bonzini wrote:
> 
> >>@@ -5999,8 +5999,12 @@ resolve_overloaded_builtin (tree functio
> >>      }
> >>
> >>    default:
> >>-      return NULL;
> >>+      if (targetm.resolve_overloaded_builtin
> >>+	  && DECL_BUILT_IN_CLASS (function) == BUILT_IN_MD)
> >>+	return targetm.resolve_overloaded_builtin (function, params);
> >>   
> >>
> >You've removed the BUILT_IN_NORMAL check and not replaced it.
> >This new code is in the wrong place, since this default should
> >be shadowed by the BUILT_IN_NORMAL check.
> > 
> >
> I don't understand why resolve_overloaded_builtin should only look at 
> BUILT_IN_NORMALs.  BUILT_IN_FRONTENDs will fail the if and go to the 
> "return NULL_TREE" just below; non-overloaded BUILT_IN_NORMALs will do 
> the same.  BUILT_IN_MDs will go to the target hook.

Yes, you don't understand.  You're testing number BUILT_IN_FETCH_AND_ADD_N
of type BUILT_IN_MD and try to interpret it as __sync_fetch_and_add.  The
code should be

	if (DECL_BUILT_IN_CLASS (function) == BUILT_IN_NORMAL)
	  switch (orig_code)
	    {
	    ...
	    default:
	      break;
	    }
	else if (DECL_BUILT_IN_CLASS (function) == BUILT_IN_MD)
	  {
	    if (targetm.resolve_overloaded_builtin)
	      return targetm.resolve_overloaded_builtin (function, params);
	  }

	return NULL;

> >>+      /* Remove the const from the pointers to simplify the overload
> >>+	 matching further down.  */
> >>+      if (POINTER_TYPE_P (decl_type)
> >>+	  && POINTER_TYPE_P (type)
> >>+	  && TYPE_QUALS (TREE_TYPE (type)) != 0)
> >>+	{
> >>+          if (TYPE_READONLY (TREE_TYPE (type))
> >>+	      && !TYPE_READONLY (TREE_TYPE (decl_type)))
> >>+	    warning ("removing const passing argument %d "
> >>+		     "to an Altivec intrinsic", n + 1);
> >>   
> >>
> >Why are you warning?
> > 
> >
> Because the code for warning about const-ness in c-typeck.c does not 
> fire.  The fold_converts in altivec_build_resolved_builtin remove consts 
> before the c-typeck.c code checks for dropped qualifiers.  And the 
> AltiVec testsuite does not want you to warn for dropped volatile 
> qualifiers, so you have to special case either one; I chose const.
> 
> By the way, an additional warning parameter is necessary now.

If you think you have to warn, you should use the same language as the
main compiler.  I.e. "passing arg N of 'func' discards qualifiers from
pointer target type".

And it should be guarded with warn_cast_qual, just like the main compiler.



r~


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