convex.c

来自「gcc3.2.1源代码」· C语言 代码 · 共 795 行 · 第 1/2 页

C
795
字号
/* Subroutines for insn-output.c for Convex.   Copyright (C) 1988, 1993, 1994, 1997, 1998, 1999, 2000, 2001   Free Software Foundation, Inc.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.  */#include "config.h"#include "system.h"#include "tree.h"#include "rtl.h"#include "regs.h"#include "hard-reg-set.h"#include "real.h"#include "insn-config.h"#include "conditions.h"#include "insn-attr.h"#include "output.h"#include "function.h"#include "expr.h"#include "tm_p.h"#include "target.h"#include "target-def.h"/* Tables used in convex.h */char regno_ok_for_index_p_base[1 + LAST_VIRTUAL_REGISTER + 1];enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];enum reg_class reg_class_from_letter[256];/* Target cpu index.  */int target_cpu;/* Boolean to keep track of whether the current section is .text or not.   Used by .align handler in convex.h.  */int current_section_is_text;/* Communication between output_compare and output_condjump.  */static rtx cmp_operand0, cmp_operand1;static char cmp_modech;/* Forwards */#if 0static rtx frame_argblock;static int frame_argblock_size;static rtx convert_arg_pushes ();#endifstatic void expand_movstr_call PARAMS ((rtx *));static void convex_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));static void convex_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));static int convex_adjust_cost PARAMS ((rtx, rtx, rtx, int));/* Initialize the GCC target structure.  */#undef TARGET_ASM_BYTE_OP#define TARGET_ASM_BYTE_OP "\tds.b\t"#undef TARGET_ASM_ALIGNED_HI_OP#define TARGET_ASM_ALIGNED_HI_OP "\tds.h\t"#undef TARGET_ASM_ALIGNED_SI_OP#define TARGET_ASM_ALIGNED_SI_OP "\tds.w\t"#undef TARGET_ASM_FUNCTION_PROLOGUE#define TARGET_ASM_FUNCTION_PROLOGUE convex_output_function_prologue#undef TARGET_ASM_FUNCTION_EPILOGUE#define TARGET_ASM_FUNCTION_EPILOGUE convex_output_function_epilogue#undef TARGET_SCHED_ADJUST_COST#define TARGET_SCHED_ADJUST_COST convex_adjust_coststruct gcc_target targetm = TARGET_INITIALIZER;/* Generate the assembly code for function entry.  FILE is a stdio   stream to output the code to.  SIZE is an int: how many units of   temporary storage to allocate.   Refer to the array `regs_ever_live' to determine which registers to   save; `regs_ever_live[I]' is nonzero if register number I is ever   used in the function.  This function is responsible for knowing   which registers should not be saved even if used.  */static voidconvex_output_function_prologue (file, size)     FILE *file;     HOST_WIDE_INT size;{  size = ((size) + 7) & -8;  if (size)    {      fprintf (file, "\tsub.w #");      fprintf (file, HOST_WIDE_INT_PRINT_DEC, size);      fprintf (file, ",sp\n");    }}/* This function generates the assembly code for function exit.   Args are as for output_function_prologue ().   The function epilogue should not depend on the current stack   pointer!  It should use the frame pointer only.  This is mandatory   because of alloca; we also take advantage of it to omit stack   adjustments before returning.  */static voidconvex_output_function_epilogue (file, size)     FILE *file;     HOST_WIDE_INT size ATTRIBUTE_UNUSED;{  /* Follow function with a zero to stop c34 icache prefetching.  */  fprintf (file, "\tds.h 0\n");}/* Adjust the cost of dependences.  */static intconvex_adjust_cost (insn, link, dep, cost)     rtx insn;     rtx link;     rtx dep;     int cost;{  /* Antidependencies don't block issue.  */  if (REG_NOTE_KIND (link) != 0)    cost = 0;  /* C38 situations where delay depends on context */  else if (TARGET_C38	   && GET_CODE (PATTERN (insn)) == SET	   && GET_CODE (PATTERN (dep)) == SET)    {      enum attr_type insn_type = get_attr_type (insn);      enum attr_type dep_type = get_attr_type (dep);      /* index register must be ready one cycle early */      if (insn_type == TYPE_MLDW || insn_type == TYPE_MLDL          || (insn_type == TYPE_MST	      && reg_mentioned_p (SET_DEST (PATTERN (dep)),				  SET_SRC (PATTERN (insn)))))	cost += 1;      /* alu forwarding off alu takes two */      if (dep_type == TYPE_ALU	  && insn_type != TYPE_ALU	  && ! (insn_type == TYPE_MST		&& SET_DEST (PATTERN (dep)) == SET_SRC (PATTERN (insn))))	cost += 1;    }  return cost;}/* Here from OVERRIDE_OPTIONS at startup.  Initialize constant tables.  */voidinit_convex (){  int regno;  /* Set A and S reg classes.  */  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)    if (A_REGNO_P (regno))      {	regno_ok_for_index_p[regno] = 1;	regno_reg_class[regno] = INDEX_REGS;      }    else      {	regno_ok_for_index_p[regno] = 0;	regno_reg_class[regno] = S_REGS;      }  /* Can't index off the stack pointer, register 0.  */  regno_ok_for_index_p[STACK_POINTER_REGNUM] = 0;  regno_reg_class[STACK_POINTER_REGNUM] = SP_REGS;  /* Can't index off aliases of the stack pointer.  */  regno_ok_for_index_p[VIRTUAL_INCOMING_ARGS_REGNUM] = 1;  regno_ok_for_index_p[VIRTUAL_STACK_VARS_REGNUM] = 1;  regno_ok_for_index_p[VIRTUAL_STACK_DYNAMIC_REGNUM] = 0;  regno_ok_for_index_p[VIRTUAL_OUTGOING_ARGS_REGNUM] = 0;  /* Can't index off hard reg -1 == pseudos not assigned */  regno_ok_for_index_p[-1] = 0;  /* Set reg class letters */  reg_class_from_letter['a'] = A_REGS;  reg_class_from_letter['A'] = INDEX_REGS;  reg_class_from_letter['d'] = S_REGS;  /* Turn off floating point exception enables in the psw.  */  psw_disable_float ();}voidpsw_disable_float (){#if __convex__ && __GNUC__  register int *p;  asm ("mov fp,%0" : "=a" (p));  while (p)    {      p[1] &= ~0x1000c400;      p = (int *) p[2];    }#endif  }/* Here to output code for a compare insn.  Output nothing, just   record the operands and their mode.  */const char *output_cmp (operand0, operand1, modech)     rtx operand0, operand1;     int modech;{  cmp_operand0 = operand0;  cmp_operand1 = operand1;  cmp_modech = modech;  return "";}/* Output code for a conditional jump.  The preceding instruction   is necessarily a compare.  Output two instructions, for example       eq.w a1,a2       jbra.t L5   for       (cmpsi a1 a2)       (beq L5) */const char *output_condjump (label, cond, jbr_sense)     rtx label;     const char *cond;     int jbr_sense;{  rtx operands[3];  char cmp_op[4];  char buf[80];  char jbr_regch;  strcpy (cmp_op, cond);  /* [BL] mean the value is being compared against immediate 0.     Use neg.x, which produces the same carry that eq.x #0 would if it     existed.  In this case operands[1] is a scratch register, not a     compare operand.  */  if (cmp_modech == 'B' || cmp_modech == 'L')    {      cmp_modech = cmp_modech - 'A' + 'a';      strcpy (cmp_op, "neg");    }  /* [WH] mean the value being compared resulted from "add.[wh] #-1,rk"     when rk was nonnegative -- we can omit equality compares against -1     or inequality compares against 0.  */  else if (cmp_modech == 'W' || cmp_modech == 'H')    {      if (! strcmp (cmp_op, "eq") && cmp_operand1 == constm1_rtx)	jbr_sense ^= 't' ^ 'f';      else if (! strcmp (cmp_op, "lt") && cmp_operand1 == const0_rtx)	;      else	cmp_modech = cmp_modech - 'A' + 'a';    }  /* Constant must be first; swap operands if necessary.     If lt, le, ltu, leu are swapped, change to le, lt, leu, ltu     and reverse the sense of the jump.  */  if (! REG_P (cmp_operand1))    {      operands[0] = cmp_operand1;      operands[1] = cmp_operand0;      if (cmp_op[0] == 'l')	{	  cmp_op[1] ^= 'e' ^ 't';	  jbr_sense ^= 't' ^ 'f';	}    }  else    {      operands[0] = cmp_operand0;      operands[1] = cmp_operand1;    }  operands[2] = label;  if (S_REG_P (operands[1]))    jbr_regch = 's';  else if (A_REG_P (operands[1]))    jbr_regch = 'a';  else    abort ();  if (cmp_modech == 'W' || cmp_modech == 'H')    sprintf (buf, "jbr%c.%c %%l2", jbr_regch, jbr_sense);  else    sprintf (buf, "%s.%c %%0,%%1\n\tjbr%c.%c %%l2",	     cmp_op, cmp_modech, jbr_regch, jbr_sense);  output_asm_insn (buf, operands);  return "";}/* Return 1 if OP is valid for cmpsf.   In IEEE mode, +/- zero compares are not handled by      the immediate versions of eq.s and on some machines, lt.s, and le.s.     So disallow 0.0 as the immediate operand of xx.s compares in IEEE mode.  */intnonmemory_cmpsf_operand (op, mode)     rtx op;     enum machine_mode mode;{#if _IEEE_FLOAT_  if (op == CONST0_RTX (SFmode))    return 0;#endif  return nonmemory_operand (op, mode);}/* Convex /bin/as does not like unary minus in some contexts.   Simplify CONST addresses to remove it.  */rtxsimplify_for_convex (x)     rtx x;{  switch (GET_CODE (x))    {    case MINUS:      if (GET_CODE (XEXP (x, 1)) == CONST_INT	  && INTVAL (XEXP (x, 1)) < 0)	{	  PUT_CODE (x, PLUS);	  XEXP (x, 1) = GEN_INT (- INTVAL (XEXP (x, 1)));	}      break;    case CONST:      return simplify_for_convex (XEXP (x, 0));    default:      break;    }  return x;}/* Routines to separate CONST_DOUBLEs into component parts.  */intconst_double_high_int (x)     rtx x;{  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)    return CONST_DOUBLE_LOW (x);  else    return CONST_DOUBLE_HIGH (x);}intconst_double_low_int (x)     rtx x;{  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)    return CONST_DOUBLE_HIGH (x);  else    return CONST_DOUBLE_LOW (x);}/* Inline block copy.  */voidexpand_movstr (operands)     rtx *operands;{  rtx dest = operands[0];  rtx src = operands[1];  int align = INTVAL (operands[3]);  int nregs, maxsize;  unsigned len;  enum machine_mode mode;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?