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] m68k: Add constraints.md.


Hi Andreas and Richard,

>> +(define_constraint "Q"
>> +  "means address register indirect addressing mode."
>> +  (and (match_code "mem")
>> +       (match_test "m68k_matches_q_p (op)")))
>
> I think this should use define_memory_constraint.

Thank you for reviewing my patch.

Upon trying your suggestion, I may have found a latent bug in the
middle end.

Consider compiling the following testcase with -O0:

/* min.c */
int *g;

void
foo (void)
{
  int *p;
  p = g;
}

I get:

min.c:8: internal compiler error: in assemble_variable, at varasm.c:2091

Here is my analysis, and I have a question.

min.c.161r.lreg contains:

(insn 7 3 0 2 (set (mem/f/c/i:SI (plus:SI (reg/f:SI 14 %a6)
                (const_int -4 [0xfffffffc])) [0 p+0 S4 A16])
        (mem/f/c/i:SI (symbol_ref:SI ("g") <var_decl 0xf7f7f000 g>) [0 g+0 S\
4 A16])) 34 {*movsi_cf} (nil)
    (nil))

This insn isn't recognizable.  reload makes it recognizable by
changing

(mem/f/c/i:SI (symbol_ref:SI ("g") <var_decl 0xf7f7f000 g>)

to

(mem/f/c/i:SI (reg:SI 8 %a0))

The problem is that this replacement is done in place, causing
DECL_RTL ("g") to point

(mem/f/c/i:SI (reg:SI 8 %a0))

after reload even though DECL_RTL ("g") should keep pointing to

(mem/f/c/i:SI (symbol_ref:SI ("g") <var_decl 0xf7f7f000 g>)

This change upsets assemble_variable because the function expects

(mem:xx (symbol_ref:xx))

around varasm.c:2090 like so:

  gcc_assert (MEM_P (decl_rtl));
  gcc_assert (GET_CODE (XEXP (decl_rtl, 0)) == SYMBOL_REF);

Attached patch fixes the problem, but I have no idea whether that is
the correct approach.  Should I fix the expander, reload, or something
else?

Thanks,

Kazu Hirata

Index: expr.c
===================================================================
--- expr.c	(revision 124044)
+++ expr.c	(working copy)
@@ -6968,6 +6968,7 @@ expand_expr_real_1 (tree exp, rtx target
     case RESULT_DECL:
       decl_rtl = DECL_RTL (exp);
       gcc_assert (decl_rtl);
+      decl_rtl = copy_rtx (decl_rtl);

       /* Ensure variable marked as used even if it doesn't go through
 	 a parser.  If it hasn't be used yet, write out an external


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