This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch expand_builtin_memmove: optimize any rodata source, not just strings
> From: Richard Henderson <rth@redhat.com>
>
> On Wed, May 07, 2003 at 12:09:06AM -0400, Kaveh R. Ghazi wrote:
> > + if (IS_EXPR_CODE_CLASS(TREE_CODE_CLASS (TREE_CODE (exp))))
> > + switch (TREE_CODE (exp))
> > + {
> > + case ADDR_EXPR:
> > + return decl_readonly_section (TREE_OPERAND (exp, 0), 0);
>
> That seems like an awfully complicated way to say
>
> TREE_CODE (exp) == ADDR_EXPR
>
> The patch is otherwise ok.
> r~
Yeah. :-)
Originally I was looking to see if any other TREE_CODEs might appear
to be valid for the builtin opt. If so, I was going to add them one
by one to the switch as is done in e.g:
fold-const.c:tree_expr_nonnegative_p().
So far I haven't found any, so I checked it in the form you suggested.
--Kaveh
+/* Returns true is EXP represents data that would potentially reside
+ in a readonly section. */
+
+static bool
+readonly_data_expr (tree exp)
+{
+ STRIP_NOPS (exp);
+
+ if (TREE_CODE (exp) == ADDR_EXPR)
+ return decl_readonly_section (TREE_OPERAND (exp, 0), 0);
+ else
+ return false;
+}