GCC源代码分析,recog_memoized()函数

来源:互联网 发布:怎样登录淘宝网页版 编辑:程序博客网 时间:2024/05/24 07:24

定义在recog.c文件中

int

recog_memoized (insn)
     rtx insn;
{
  volatile_ok = 1;
  if (INSN_CODE (insn) < 0)
    INSN_CODE (insn) = recog (PATTERN (insn), insn);
  return INSN_CODE (insn);
}

recog()函数定义在insn_recog.c文件中



...
insn insn 13
insn call_insn 140
insn insn 14
insn jump_insn 137

(const_int 4)

(reg:SI 6)

(plus:SI (reg:SI 6)
   (const_int 4))

(mem:SI (plus:SI (reg:SI 6)
       (const_int 4)))

(reg:SI 6)

(reg:SI 6)

(plus:SI (reg:SI 6)
   (reg:SI 6))

(const_int 4)

(plus:SI (plus:SI (reg:SI 6)
       (reg:SI 6))
   (const_int 4))
insn insn 13
insn call_insn 140
insn insn 14
insn jump_insn 137

(mem (nil))
insn insn 13
insn insn 13
insn call_insn 140
insn call_insn 140
insn insn 14
insn insn 14
insn jump_insn 137
insn jump_insn 137


最终得到的号码是140


insn call_insn 140
i=0 reg
i=1 mem
i=2 const_int

operands[0]名字是reg,  operands[1]名字是mem,  operands[2]名字是const_int


static char *
output_140 (operands, insn)
     rtx *operands;
     rtx insn;
{

{
  if (GET_CODE (operands[1]) == MEM
      && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0)))
    {
      operands[1] = XEXP (operands[1], 0);
      output_asm_insn ("call %*%1", operands);
    }
  else
    output_asm_insn ("call %1", operands);

  if (GET_MODE (operands[0]) == DFmode
      || GET_MODE (operands[0]) == SFmode)
    {
/*      fp_pop_level++; */
      /* pop if reg dead */
      if (!FP_REG_P (operands[0]))
    abort ();
      if (top_dead_p (insn))
    {
      POP_ONE_FP;
    }
    }
  RET;
}

Out-i386.c (config):29
#define RET return ""

这里的RET的目的是第二次进入output_asm_insn()函数的时候直接返回,因为

  /* An insn may return a null string template
     in a case where no assembler code is needed.  */
  if (*template == 0)
    return;



Tm-i386.h (config):653
#define CONSTANT_ADDRESS_P(X)   CONSTANT_P (X)

rtl.h

#define CONSTANT_P(X)   \
  (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF        \
   || GET_CODE (X) == CONST_INT                        \
   || GET_CODE (X) == CONST)


0 0
原创粉丝点击