emit_library_call help
Stephen Biggs
xyzzy@hotpop.com
Mon Jun 23 14:11:00 GMT 2003
On Sun, 2003-06-22 at 18:00, Stephen Biggs wrote:
> Greetings,
>
> I am trying to unravel the many varied puzzles of emitting custom insns
> and am making progress, but am stuck on an issue:
>
> I have an internal library function that I wish to generate an insn for
> which has the prototype:
> void bar(void *);
>
> ... and I have a function in <machine>.c thus:
>
> void
> foo(rtx val) /* val is possibly a pseudo-register */
> {
> rtx val_ptr = force_reg(Pmode,val);
> emit_library_call(gen_rtx_SYMBOL_REF(Pmode,"bar"),LCT_NORMAL,VOIDmode,1,val_ptr,Pmode);
> }
>
> The argument val_ptr is created in the recognized insn as an integer
> instead of a pointer, even though I think I am forcing it to be a
> pointer. What magic is needed here to have this argument be a pointer
> argument instead of an integer argument? Thanks for any help.
>
>
I also tried:
void
foo(rtx val) /* val is possibly a pseudo-register */
{
mark_reg_pointer(val,0);
emit_library_call(gen_rtx_SYMBOL_REF(Pmode,"bar"),LCT_NORMAL,VOIDmode,1,val,Pmode);
}
... but no soap. How do I force this register to be a pointer register?
I finally got it to work by copying code from emit_library_call_value_1
in gcc/calls.c since I can't define FUNCTION_ARG_PASS_BY_REFERENCE in my
port, thusly:
void
foo(rtx val) /* val is possibly a pseudo-register */
{
tree type = type_for_mode (Pmode, 0);
rtx val_ptr,slot = gen_rtx_MEM(Pmode,
expand_expr(build1(ADDR_EXPR,build_pointer_type(type),
make_tree(type, val)),NULL_RTX, VOIDmode, 0));
val_ptr = force_operand(XEXP(slot, 0),NULL_RTX);
emit_library_call(gen_rtx_SYMBOL_REF(Pmode,"bar"),
LCT_NORMAL,VOIDmode,1,val_ptr,Pmode);
}
... a gross, horrid, sleazy hack, overkill, IMHO, but I couldn't figure out any other way to do this... any suggestions?
More information about the Gcc
mailing list