This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Why it crash? (How to use emit_move_insn?)
- To: <gcc at gcc dot gnu dot org>, <gcc-help at gcc dot gnu dot org>
- Subject: Why it crash? (How to use emit_move_insn?)
- From: "Peng-Sheng Chen" <pschen at puma dot cs dot nthu dot edu dot tw>
- Date: Thu, 9 Mar 2000 22:17:05 +0800
Hello :
I have a question about using function emit_move_insn.
original source is (in m68k.c)
------------------------------------------------------------------------------------------
rtx
legitimize_pic_address (orig, mode, reg)
rtx orig, reg;
enum machine_mode mode ATTRIBUTE_UNUSED;
{
rtx pic_ref = orig;
/* First handle a simple SYMBOL_REF or LABEL_REF */
if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
{
if (reg == 0)
abort ();
pic_ref = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, pic_offset_table_rtx, orig));
current_function_uses_pic_offset_table = 1;
RTX_UNCHANGING_P (pic_ref) = 1;
emit_move_insn (reg, pic_ref);
return reg;
}
else if (GET_CODE (orig) == CONST)
......
}
----------------------------------------------------------------------------------------
I want to move SYMBOL_REF to register first, and then add register and bas-register.
I modify it as following :
----------------------------------------------------------------------------------------
if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
{
if (reg == 0)
abort ();
if (XXX) {
rtx tmp = gen_reg_rtx (Pmode); <== Added
emit_move_insn (tmp, orig); <== Added
pic_ref = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, pic_offset_table_rtx, tmp));
} else {
pic_ref = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, pic_offset_table_rtx, orig));
}
current_function_uses_pic_offset_table = 1;
RTX_UNCHANGING_P (pic_ref) = 1;
emit_move_insn (reg, pic_ref);
return reg;
}
-------------------------------------------------------------------------------------------
It crash! Why??? I don't know.
Who can tell me why and how to use emit_move_insn not to crash GCC?
Thanks very much.
Ps. Chen