This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
inserting insn's into insn chain
- From: Per Fransson <per dot fransson dot 768 at student dot lu dot se>
- To: gcc <gcc at gcc dot gnu dot org>
- Date: Sun, 19 May 2002 19:48:43 +0200
- Subject: inserting insn's into insn chain
Hi,
I'm been trying to insert code into the insn chain during compilation (the
target is sparc-sun-solaris2.8). I've successfully inserted a call
instruction and now I'm trying to insert code fore storing and restoring
some hard registers in a pseudo register before and after the call
respectively.
The store/restore code gets inserted into the RTL-code without problems.
Unfortunately it somehow gets removed before the assembler code is
generated.
Is there something fundamentally wrong with doing it this way?
My code looks like this ('insn' is the insn-rtx I'm want my own instructions
to precede):
tmp_reg_rtx = gen_reg_rtx (SImode);
new_insn = emit_insn_before (
gen_rtx (SET, VOIDmode,
tmp_reg_rtx,
gen_rtx
(REG, SImode,
8
)
)
, insn);
// Construct PARALLEL rtx from rtvec and use it to put call insn in
chain
new_insn = emit_insn_before (
gen_rtx (PARALLEL,
VOIDmode,
gen_rtvec (2,
gen_rtx (SET, VOIDmode,
gen_rtx (REG, SImode,
0
),
gen_rtx (CALL, VOIDmode,
gen_rtx (MEM, SImode,
gen_rtx (SYMBOL_REF, SImode,
func_name
),
0
),
gen_rtx (CONST_INT, VOIDmode,
0
)
)
),
gen_rtx (CLOBBER, VOIDmode,
gen_rtx (REG, SImode,
15
)
)
))
, insn);
new_insn = emit_insn_before (
gen_rtx (SET, VOIDmode,
gen_rtx
(REG, SImode,
8
),
copy_rtx
(tmp_reg_rtx)
)
, insn);
Those of you who've been paying attention to this list might recognise my
question since I've posted it before. I'm sorry for repeating myself but
I've really been struggling with this and I *need* to get it working.
Any help would be *greatly* appreciated.
/Per