This is the mail archive of the gcc@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]

call_value problem: var = func() !?


Hello,

I'm working on a new gcc target and trying to implement call_value.
When compiling (-O0 -S) the following c code :

  int f1(int a, int b)
  {
    int tmp = a + b;
      return tmp;
  }

  void main()
  {
    int a = 10;
    int b = 20;
    int c;
   
    c = f1(a,b);
  }

I get the following error:

f1.c: In function 'f1':
f1.c:5:1: error: unrecognizable insn:
(insn 12 11 13 3 f1.c:4 
   (set (mem/c/i:SI (reg/f:SI 23 [ D.1964 ]) [0 <retval>+0 S4 A32])
         (mem/c/i:SI (plus:SI (reg/f:SI 19 virtual-stack-vars)
	                      (const_int -4 [0xfffffffffffffffc])) 
	                               [0 tmp+0 S4 A32])) -1 (nil))

    
I defined expanders and insns only for moving between registers, set
registers with immediate and moving from mem to register and vice versa.
Moving from mem to mem is not allowed. So shouldn't gcc try to force
one of the two mem addresses in a register? I don't even know if that's
what causing the error.


This is the call_value implementation in .md:
    
(define_expand "call_value"
  [(parallel [(set  (match_operand 0 "register_operand" "")
	            (call (match_operand 1 "general_operand" "")
		          (match_operand 2 "")))
              (clobber (reg:SI RETURN_ADDR_REGNUM))])]
  ""
 {
   rtx dest = XEXP(operands[1], 0);
   
   if(!call_operand(dest, Pmode))
     dest = force_reg(Pmode, dest);
   
   emit_call_insn(gen_call_value_internal(operands[0], dest, operands[2]));
   DONE;
  })

(define_insn "call_value_internal"
  [(parallel [(set  (match_operand 0 "register_operand" "")
	            (call (match_operand 1 "general_operand" "")
		          (match_operand 2 "")))
              (clobber (reg:SI RETURN_ADDR_REGNUM))])]

  ""
  "bal\t%1")


And this is my function_value:

rtx
function_value(const_tree valtype, const_tree func, enum machine_mode mode)
{
 /* first step is an integer-C compiler */ 
 /*G_RET return value reg num = %r1 .*/
  return gen_rtx_REG(SImode, G_RET);
}

I'd be grateful for any help.
Kind regards.
-- 
if [ $(uname) = "Linux" ];then echo "[q]sb[lv0=blv256%Plv256/svlcx]sc911084920508\
6363247337574050075032905184391195412274100697358608023133864165787933915045683\
432087129472907338347329339706073226139582008068077725378669120069632svlcxq"|dc;fi;


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