m68k call_value insn
Bernardo Innocenti
bernie@develer.com
Mon Sep 15 02:34:00 GMT 2003
Hello,
it seems the call_value insn in the m68k back-end isn't
really doing what its specification says:
`call_value'
Subroutine call instruction returning a value. Operand 0 is the
hard register in which the value is returned. There are three more
operands, the same as the three operands of the `call' instruction
(but with numbers increased by one).
Subroutines that return `BLKmode' objects use the `call' insn.
The code in m68k.md seems to be ignoring operand 0, thus leaving the
return value in %d0 (or %fp0 for floats), which is apparently invalid:
;; Call subroutine, returning value in operand 0
;; (which must be a hard register).
;; See comments before "call" regarding PIC calls.
(define_expand "call_value"
[(set (match_operand 0 "" "")
(call (match_operand:QI 1 "memory_operand" "")
(match_operand:SI 2 "general_operand" "")))]
;; Operand 2 not really used on the m68000.
""
"
{
if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
}")
;; This is a normal call_value
(define_insn ""
[(set (match_operand 0 "" "=rf")
(call (match_operand:QI 1 "memory_operand" "o")
(match_operand:SI 2 "general_operand" "g")))]
;; Operand 2 not really used on the m68000.
"! flag_pic"
"*
#if defined (MOTOROLA) && !defined (USE_GAS)
return \"jsr %1\";
#else
return \"jbsr %1\";
#endif
")
;; This is a PIC call_value
(define_insn ""
[(set (match_operand 0 "" "=rf")
(call (match_operand:QI 1 "memory_operand" "o")
(match_operand:SI 2 "general_operand" "g")))]
;; Operand 2 not really used on the m68000.
"flag_pic"
"*
if (GET_CODE (operands[1]) == MEM
&& GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
{
if (TARGET_PCREL) return \"bsr.l %o1\";
#ifdef MOTOROLA
#ifdef HPUX_ASM
return \"bsr.l %1\";
#else
#ifdef USE_GAS
return \"bsr.l %1@PLTPC\";
#else
return \"bsr %1@PLTPC\";
#endif
#endif
#else
#ifdef USE_GAS
return \"bsr.l %1\";
#else
/* The ',a1' is a dummy argument telling the Sun assembler we want PIC
GAS just plain ignores it. FIXME: Not anymore, gas doesn't! */
return \"jbsr %1,a1\";
#endif
#endif
}
return \"jsr %1\";
")
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/
Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html
More information about the Gcc
mailing list