⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v850.c

📁 linux下的gcc编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Subroutines for insn-output.c for NEC V850 series   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002   Free Software Foundation, Inc.   Contributed by Jeff Law (law@cygnus.com).   This file is part of GNU CC.   GNU CC is free software; you can redistribute it and/or modify it   under the terms of the GNU General Public License as published by   the 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 of MERCHANTABILITY or   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   for more details.   You should have received a copy of the GNU General Public License   along with GNU CC; see the file COPYING.  If not, write to the 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 "output.h"#include "insn-attr.h"#include "flags.h"#include "recog.h"#include "expr.h"#include "function.h"#include "toplev.h"#include "ggc.h"#include "integrate.h"#include "tm_p.h"#include "target.h"#include "target-def.h"#ifndef streq#define streq(a,b) (strcmp (a, b) == 0)#endif/* Function prototypes for stupid compilers:  */static void const_double_split       PARAMS ((rtx, HOST_WIDE_INT *, HOST_WIDE_INT *));static int  const_costs_int          PARAMS ((HOST_WIDE_INT, int));static void substitute_ep_register   PARAMS ((rtx, rtx, int, int, rtx *, rtx *));static int  ep_memory_offset         PARAMS ((enum machine_mode, int));static void v850_set_data_area       PARAMS ((tree, v850_data_area));const struct attribute_spec v850_attribute_table[];static tree v850_handle_interrupt_attribute PARAMS ((tree *, tree, tree, int, bool *));static tree v850_handle_data_area_attribute PARAMS ((tree *, tree, tree, int, bool *));static void v850_insert_attributes   PARAMS ((tree, tree *));static void v850_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT));static void v850_encode_data_area    PARAMS ((tree));static void v850_encode_section_info PARAMS ((tree, int));static const char *v850_strip_name_encoding PARAMS ((const char *));/* Information about the various small memory areas.  */struct small_memory_info small_memory[ (int)SMALL_MEMORY_max ] ={  /* name	value		max		physical max */  { "tda",	(char *)0,	0,		256 },  { "sda",	(char *)0,	0,		65536 },  { "zda",	(char *)0,	0,		32768 },};/* Names of the various data areas used on the v850.  */tree GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];tree GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];/* Track the current data area set by the data area pragma (which    can be nested).  Tested by check_default_data_area.  */data_area_stack_element * data_area_stack = NULL;/* True if we don't need to check any more if the current   function is an interrupt handler.  */static int v850_interrupt_cache_p = FALSE;/* Whether current function is an interrupt handler.  */static int v850_interrupt_p = FALSE;/* Initialize the GCC target structure.  */#undef TARGET_ASM_ALIGNED_HI_OP#define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"#undef TARGET_ATTRIBUTE_TABLE#define TARGET_ATTRIBUTE_TABLE v850_attribute_table#undef TARGET_INSERT_ATTRIBUTES#define TARGET_INSERT_ATTRIBUTES v850_insert_attributes#undef  TARGET_ASM_SELECT_SECTION#define TARGET_ASM_SELECT_SECTION  v850_select_section#undef TARGET_ENCODE_SECTION_INFO#define TARGET_ENCODE_SECTION_INFO v850_encode_section_info#undef TARGET_STRIP_NAME_ENCODING#define TARGET_STRIP_NAME_ENCODING v850_strip_name_encodingstruct gcc_target targetm = TARGET_INITIALIZER;/* Sometimes certain combinations of command options do not make   sense on a particular target machine.  You can define a macro   `OVERRIDE_OPTIONS' to take account of this.  This macro, if   defined, is executed once just after all the command options have   been parsed.   Don't use this macro to turn on various extra optimizations for   `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */voidoverride_options (){  int i;  extern int atoi PARAMS ((const char *));  /* Parse -m{s,t,z}da=nnn switches */  for (i = 0; i < (int)SMALL_MEMORY_max; i++)    {      if (small_memory[i].value)	{	  if (!ISDIGIT (*small_memory[i].value))	    error ("%s=%s is not numeric",		   small_memory[i].name,		   small_memory[i].value);	  else	    {	      small_memory[i].max = atoi (small_memory[i].value);	      if (small_memory[i].max > small_memory[i].physical_max)		error ("%s=%s is too large",		   small_memory[i].name,		   small_memory[i].value);	    }	}    }  /* Make sure that the US_BIT_SET mask has been correctly initialized.  */  if ((target_flags & MASK_US_MASK_SET) == 0)    {      target_flags |= MASK_US_MASK_SET;      target_flags &= ~MASK_US_BIT_SET;    }}/* Output assembly code for the start of the file.  */voidasm_file_start (file)     FILE *file;{  output_file_directive (file, main_input_filename);}/* Return an RTX to represent where a value with mode MODE will be returned   from a function.  If the result is 0, the argument is pushed.  */rtxfunction_arg (cum, mode, type, named)     CUMULATIVE_ARGS *cum;     enum machine_mode mode;     tree type;     int named;{  rtx result = 0;  int size, align;  if (TARGET_GHS && !named)    return NULL_RTX;  if (mode == BLKmode)    size = int_size_in_bytes (type);  else    size = GET_MODE_SIZE (mode);  if (size < 1)    return 0;  if (type)    align = TYPE_ALIGN (type) / BITS_PER_UNIT;  else    align = size;  cum->nbytes = (cum->nbytes + align - 1) &~(align - 1);  if (cum->nbytes > 4 * UNITS_PER_WORD)    return 0;  if (type == NULL_TREE      && cum->nbytes + size > 4 * UNITS_PER_WORD)    return 0;  switch (cum->nbytes / UNITS_PER_WORD)    {    case 0:      result = gen_rtx_REG (mode, 6);      break;    case 1:      result = gen_rtx_REG (mode, 7);      break;    case 2:      result = gen_rtx_REG (mode, 8);      break;    case 3:      result = gen_rtx_REG (mode, 9);      break;    default:      result = 0;    }  return result;}/* Return the number of words which must be put into registers   for values which are part in registers and part in memory.  */intfunction_arg_partial_nregs (cum, mode, type, named)     CUMULATIVE_ARGS *cum;     enum machine_mode mode;     tree type;     int named;{  int size, align;  if (TARGET_GHS && !named)    return 0;  if (mode == BLKmode)    size = int_size_in_bytes (type);  else    size = GET_MODE_SIZE (mode);  if (type)    align = TYPE_ALIGN (type) / BITS_PER_UNIT;  else    align = size;  cum->nbytes = (cum->nbytes + align - 1) &~(align - 1);  if (cum->nbytes > 4 * UNITS_PER_WORD)    return 0;  if (cum->nbytes + size <= 4 * UNITS_PER_WORD)    return 0;  if (type == NULL_TREE      && cum->nbytes + size > 4 * UNITS_PER_WORD)    return 0;  return (4 * UNITS_PER_WORD - cum->nbytes) / UNITS_PER_WORD;}/* Return the high and low words of a CONST_DOUBLE */static voidconst_double_split (x, p_high, p_low)     rtx x;     HOST_WIDE_INT *p_high;     HOST_WIDE_INT *p_low;{  if (GET_CODE (x) == CONST_DOUBLE)    {      long t[2];      REAL_VALUE_TYPE rv;      switch (GET_MODE (x))	{	case DFmode:	  REAL_VALUE_FROM_CONST_DOUBLE (rv, x);	  REAL_VALUE_TO_TARGET_DOUBLE (rv, t);	  *p_high = t[1];	/* since v850 is little endian */	  *p_low = t[0];	/* high is second word */	  return;	case SFmode:	  REAL_VALUE_FROM_CONST_DOUBLE (rv, x);	  REAL_VALUE_TO_TARGET_SINGLE (rv, *p_high);	  *p_low = 0;	  return;	case VOIDmode:	case DImode:	  *p_high = CONST_DOUBLE_HIGH (x);	  *p_low  = CONST_DOUBLE_LOW (x);	  return;	default:	  break;	}    }  fatal_insn ("const_double_split got a bad insn:", x);}/* Return the cost of the rtx R with code CODE.  */static intconst_costs_int (value, zero_cost)     HOST_WIDE_INT value;     int zero_cost;{  if (CONST_OK_FOR_I (value))      return zero_cost;  else if (CONST_OK_FOR_J (value))    return 1;  else if (CONST_OK_FOR_K (value))    return 2;  else    return 4;}intconst_costs (r, c)     rtx r;     enum rtx_code c;{  HOST_WIDE_INT high, low;  switch (c)    {    case CONST_INT:      return const_costs_int (INTVAL (r), 0);    case CONST_DOUBLE:      const_double_split (r, &high, &low);      if (GET_MODE (r) == SFmode)	return const_costs_int (high, 1);      else	return const_costs_int (high, 1) + const_costs_int (low, 1);    case SYMBOL_REF:    case LABEL_REF:    case CONST:      return 2;    case HIGH:      return 1;    default:      return 4;    }}/* Print operand X using operand code CODE to assembly language output file   FILE.  */voidprint_operand (file, x, code)     FILE *file;     rtx x;     int code;{  HOST_WIDE_INT high, low;  switch (code)    {    case 'c':      /* We use 'c' operands with symbols for .vtinherit */      if (GET_CODE (x) == SYMBOL_REF)        {          output_addr_const(file, x);          break;        }      /* fall through */    case 'b':    case 'B':    case 'C':      switch ((code == 'B' || code == 'C')	      ? reverse_condition (GET_CODE (x)) : GET_CODE (x))	{	  case NE:	    if (code == 'c' || code == 'C')	      fprintf (file, "nz");	    else	      fprintf (file, "ne");	    break;	  case EQ:	    if (code == 'c' || code == 'C')	      fprintf (file, "z");	    else	      fprintf (file, "e");	    break;	  case GE:	    fprintf (file, "ge");	    break;	  case GT:	    fprintf (file, "gt");	    break;	  case LE:	    fprintf (file, "le");	    break;	  case LT:	    fprintf (file, "lt");	    break;	  case GEU:	    fprintf (file, "nl");	    break;	  case GTU:	    fprintf (file, "h");	    break;	  case LEU:	    fprintf (file, "nh");	    break;	  case LTU:	    fprintf (file, "l");	    break;	  default:	    abort ();	}      break;    case 'F':			/* high word of CONST_DOUBLE */      if (GET_CODE (x) == CONST_INT)	fprintf (file, "%d", (INTVAL (x) >= 0) ? 0 : -1);      else if (GET_CODE (x) == CONST_DOUBLE)	{	  const_double_split (x, &high, &low);	  fprintf (file, "%ld", (long) high);	}      else	abort ();      break;    case 'G':			/* low word of CONST_DOUBLE */      if (GET_CODE (x) == CONST_INT)	fprintf (file, "%ld", (long) INTVAL (x));      else if (GET_CODE (x) == CONST_DOUBLE)	{	  const_double_split (x, &high, &low);	  fprintf (file, "%ld", (long) low);	}      else	abort ();      break;    case 'L':      fprintf (file, "%d\n", INTVAL (x) & 0xffff);      break;    case 'M':      fprintf (file, "%d", exact_log2 (INTVAL (x)));      break;    case 'O':      if (special_symbolref_operand (x, VOIDmode))        {          const char *name;	  if (GET_CODE (x) == SYMBOL_REF)	    name = XSTR (x, 0);	  else if (GET_CODE (x) == CONST)	    name = XSTR (XEXP (XEXP (x, 0), 0), 0);	  else	    abort ();          if (ZDA_NAME_P (name))            fprintf (file, "zdaoff");          else if (SDA_NAME_P (name))            fprintf (file, "sdaoff");          else if (TDA_NAME_P (name))            fprintf (file, "tdaoff");          else            abort ();        }      else        abort ();      break;    case 'P':      if (special_symbolref_operand (x, VOIDmode))        output_addr_const (file, x);      else        abort ();      break;    case 'Q':      if (special_symbolref_operand (x, VOIDmode))        {          const char *name;	  if (GET_CODE (x) == SYMBOL_REF)	    name = XSTR (x, 0);	  else if (GET_CODE (x) == CONST)	    name = XSTR (XEXP (XEXP (x, 0), 0), 0);	  else	    abort ();          if (ZDA_NAME_P (name))            fprintf (file, "r0");          else if (SDA_NAME_P (name))            fprintf (file, "gp");          else if (TDA_NAME_P (name))            fprintf (file, "ep");          else            abort ();        }      else        abort ();      break;    case 'R':		/* 2nd word of a double.  */      switch (GET_CODE (x))	{	case REG:	  fprintf (file, reg_names[REGNO (x) + 1]);	  break;	case MEM:	  x = XEXP (adjust_address (x, SImode, 4), 0);	  print_operand_address (file, x);	  if (GET_CODE (x) == CONST_INT)	    fprintf (file, "[r0]");	  break;	  	default:	  break;	}      break;

⌨️ 快捷键说明

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