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

📄 rtl.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Allocate and read RTL for GNU C Compiler.   Copyright (C) 1987, 1988, 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */#include "config.h"#include <ctype.h>#include <stdio.h>#include "rtl.h"#include "obstack.h"#define	obstack_chunk_alloc	xmalloc#define	obstack_chunk_free	free/* Obstack used for allocating RTL objects.   Between functions, this is the permanent_obstack.   While parsing and expanding a function, this is maybepermanent_obstack   so we can save it if it is an inline function.   During optimization and output, this is function_obstack.  */extern struct obstack *rtl_obstack;#if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INTextern long atol();#endif/* Indexed by rtx code, gives number of operands for an rtx with that code.   Does NOT include rtx header data (code and links).   This array is initialized in init_rtl.  */int rtx_length[NUM_RTX_CODE + 1];/* Indexed by rtx code, gives the name of that kind of rtx, as a C string.  */#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   NAME ,char *rtx_name[] = {#include "rtl.def"		/* rtl expressions are documented here */};#undef DEF_RTL_EXPR/* Indexed by machine mode, gives the name of that machine mode.   This name does not include the letters "mode".  */#define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER)  NAME,char *mode_name[(int) MAX_MACHINE_MODE] = {#include "machmode.def"#ifdef EXTRA_CC_MODES  EXTRA_CC_NAMES#endif};#undef DEF_MACHMODE/* Indexed by machine mode, gives the length of the mode, in bytes.   GET_MODE_CLASS uses this.  */#define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER)  CLASS,enum mode_class mode_class[(int) MAX_MACHINE_MODE] = {#include "machmode.def"};#undef DEF_MACHMODE/* Indexed by machine mode, gives the length of the mode, in bytes.   GET_MODE_SIZE uses this.  */#define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER)  SIZE,int mode_size[(int) MAX_MACHINE_MODE] = {#include "machmode.def"};#undef DEF_MACHMODE/* Indexed by machine mode, gives the length of the mode's subunit.   GET_MODE_UNIT_SIZE uses this.  */#define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER)  UNIT,int mode_unit_size[(int) MAX_MACHINE_MODE] = {#include "machmode.def"		/* machine modes are documented here */};#undef DEF_MACHMODE/* Indexed by machine mode, gives next wider natural mode   (QI -> HI -> SI -> DI, etc.)  Widening multiply instructions   use this.  */#define DEF_MACHMODE(SYM, NAME, CLASS, SIZE, UNIT, WIDER)  \  (enum machine_mode) WIDER,enum machine_mode mode_wider_mode[(int) MAX_MACHINE_MODE] = {#include "machmode.def"		/* machine modes are documented here */};#undef DEF_MACHMODE/* Indexed by mode class, gives the narrowest mode for each class.  */enum machine_mode class_narrowest_mode[(int) MAX_MODE_CLASS];/* Commonly used modes.  */enum machine_mode byte_mode;	/* Mode whose width is BITS_PER_UNIT */enum machine_mode word_mode;	/* Mode whose width is BITS_PER_WORD *//* Indexed by rtx code, gives a sequence of operand-types for   rtx's of that code.  The sequence is a C string in which   each character describes one operand.  */char *rtx_format[] = {  /* "*" undefined.         can cause a warning message     "0" field is unused (or used in a phase-dependent manner)         prints nothing     "i" an integer         prints the integer     "n" like "i", but prints entries from `note_insn_name'     "w" an integer of width HOST_BITS_PER_WIDE_INT         prints the integer     "s" a pointer to a string         prints the string     "S" like "s", but optional:	 the containing rtx may end before this operand     "e" a pointer to an rtl expression         prints the expression     "E" a pointer to a vector that points to a number of rtl expressions         prints a list of the rtl expressions     "V" like "E", but optional:	 the containing rtx may end before this operand     "u" a pointer to another insn         prints the uid of the insn.  */#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   FORMAT ,#include "rtl.def"		/* rtl expressions are defined here */#undef DEF_RTL_EXPR};/* Indexed by rtx code, gives a character representing the "class" of   that rtx code.  See rtl.def for documentation on the defined classes.  */char rtx_class[] = {#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   CLASS, #include "rtl.def"		/* rtl expressions are defined here */#undef DEF_RTL_EXPR};/* Names for kinds of NOTEs and REG_NOTEs.  */char *note_insn_name[] = { "NOTE_INSN_FUNCTION_BEG", "NOTE_INSN_DELETED",			   "NOTE_INSN_BLOCK_BEG", "NOTE_INSN_BLOCK_END",			   "NOTE_INSN_LOOP_BEG", "NOTE_INSN_LOOP_END",			   "NOTE_INSN_FUNCTION_END", "NOTE_INSN_SETJMP",			   "NOTE_INSN_LOOP_CONT", "NOTE_INSN_LOOP_VTOP",			   "NOTE_INSN_PROLOGUE_END", "NOTE_INSN_EPILOGUE_BEG",			   "NOTE_INSN_DELETED_LABEL"};char *reg_note_name[] = { "", "REG_DEAD", "REG_INC", "REG_EQUIV", "REG_WAS_0",			  "REG_EQUAL", "REG_RETVAL", "REG_LIBCALL",			  "REG_NONNEG", "REG_NO_CONFLICT", "REG_UNUSED",			  "REG_CC_SETTER", "REG_CC_USER", "REG_LABEL",			  "REG_DEP_ANTI", "REG_DEP_OUTPUT" };/* Allocate an rtx vector of N elements.   Store the length, and initialize all elements to zero.  */rtvecrtvec_alloc (n)     int n;{  rtvec rt;  int i;  rt = (rtvec) obstack_alloc (rtl_obstack,			      sizeof (struct rtvec_def)			      + (( n - 1) * sizeof (rtunion)));  /* clear out the vector */  PUT_NUM_ELEM(rt, n);  for (i=0; i < n; i++)    rt->elem[i].rtvec = NULL;	/* @@ not portable due to rtunion */  return rt;}/* Allocate an rtx of code CODE.  The CODE is stored in the rtx;   all the rest is initialized to zero.  */rtxrtx_alloc (code)  RTX_CODE code;{  rtx rt;  register struct obstack *ob = rtl_obstack;  register int nelts = GET_RTX_LENGTH (code);  register int length = sizeof (struct rtx_def)    + (nelts - 1) * sizeof (rtunion);  /* This function is called more than any other in GCC,     so we manipulate the obstack directly.     Even though rtx objects are word aligned, we may be sharing an obstack     with tree nodes, which may have to be double-word aligned.  So align     our length to the alignment mask in the obstack.  */  length = (length + ob->alignment_mask) & ~ ob->alignment_mask;  if (ob->chunk_limit - ob->next_free < length)    _obstack_newchunk (ob, length);  rt = (rtx)ob->object_base;  ob->next_free += length;  ob->object_base = ob->next_free;  * (int *) rt = 0;  PUT_CODE (rt, code);  return rt;}/* Create a new copy of an rtx.   Recursively copies the operands of the rtx,   except for those few rtx codes that are sharable.  */rtxcopy_rtx (orig)     register rtx orig;{  register rtx copy;  register int i, j;  register RTX_CODE code;  register char *format_ptr;  code = GET_CODE (orig);  switch (code)    {    case REG:    case QUEUED:    case CONST_INT:    case CONST_DOUBLE:    case SYMBOL_REF:    case CODE_LABEL:    case PC:    case CC0:      return orig;    }  copy = rtx_alloc (code);  PUT_MODE (copy, GET_MODE (orig));  copy->in_struct = orig->in_struct;  copy->volatil = orig->volatil;  copy->unchanging = orig->unchanging;  copy->integrated = orig->integrated;    format_ptr = GET_RTX_FORMAT (GET_CODE (copy));  for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)    {      switch (*format_ptr++)	{	case 'e':	  XEXP (copy, i) = XEXP (orig, i);	  if (XEXP (orig, i) != NULL)	    XEXP (copy, i) = copy_rtx (XEXP (orig, i));	  break;	case '0':	case 'u':	  XEXP (copy, i) = XEXP (orig, i);	  break;	case 'E':	case 'V':	  XVEC (copy, i) = XVEC (orig, i);	  if (XVEC (orig, i) != NULL)	    {	      XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));	      for (j = 0; j < XVECLEN (copy, i); j++)		XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));	    }	  break;	case 'w':	  XWINT (copy, i) = XWINT (orig, i);	  break;	case 'i':	  XINT (copy, i) = XINT (orig, i);	  break;	case 's':	case 'S':	  XSTR (copy, i) = XSTR (orig, i);	  break;	default:	  abort ();	}    }  return copy;}/* Similar to `copy_rtx' except that if MAY_SHARE is present, it is   placed in the result directly, rather than being copied.  */rtxcopy_most_rtx (orig, may_share)     register rtx orig;     register rtx may_share;{  register rtx copy;  register int i, j;  register RTX_CODE code;  register char *format_ptr;  if (orig == may_share)    return orig;  code = GET_CODE (orig);  switch (code)    {    case REG:    case QUEUED:    case CONST_INT:    case CONST_DOUBLE:    case SYMBOL_REF:    case CODE_LABEL:    case PC:    case CC0:      return orig;    }  copy = rtx_alloc (code);  PUT_MODE (copy, GET_MODE (orig));  copy->in_struct = orig->in_struct;  copy->volatil = orig->volatil;  copy->unchanging = orig->unchanging;  copy->integrated = orig->integrated;    format_ptr = GET_RTX_FORMAT (GET_CODE (copy));  for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)    {      switch (*format_ptr++)	{	case 'e':	  XEXP (copy, i) = XEXP (orig, i);	  if (XEXP (orig, i) != NULL && XEXP (orig, i) != may_share)	    XEXP (copy, i) = copy_most_rtx (XEXP (orig, i), may_share);	  break;	case '0':	case 'u':	  XEXP (copy, i) = XEXP (orig, i);	  break;	case 'E':	case 'V':	  XVEC (copy, i) = XVEC (orig, i);	  if (XVEC (orig, i) != NULL)	    {	      XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));	      for (j = 0; j < XVECLEN (copy, i); j++)		XVECEXP (copy, i, j)		  = copy_most_rtx (XVECEXP (orig, i, j), may_share);	    }	  break;	case 'w':	  XWINT (copy, i) = XWINT (orig, i);	  break;	case 'n':	case 'i':	  XINT (copy, i) = XINT (orig, i);	  break;	case 's':	case 'S':	  XSTR (copy, i) = XSTR (orig, i);	  break;	default:	  abort ();	}    }  return copy;}/* Subroutines of read_rtx.  *//* Dump code after printing a message.  Used when read_rtx finds   invalid data.  */static void

⌨️ 快捷键说明

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