home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gcc-2.3.3-src.lha
/
GNU
/
src
/
amiga
/
gcc-2.3.3
/
rtl.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-06
|
21KB
|
838 lines
/* 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 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, 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_INT
extern 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 * const 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 * const 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,
const 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,
const 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,
const 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,
const 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 *const 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. */
const 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 * const 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 * const 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. */
rtvec
rtvec_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. */
rtx
rtx_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. */
rtx
copy_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 (ori