OSDN Git Service
(root)
/
pf3gnuchains
/
gcc-fork.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(legitimate_address_p): Reject address whose index is itself the sum of two
[pf3gnuchains/gcc-fork.git]
/
gcc
/
genextract.c
diff --git
a/gcc/genextract.c
b/gcc/genextract.c
index
76cde0e
..
b600605
100644
(file)
--- a/
gcc/genextract.c
+++ b/
gcc/genextract.c
@@
-1,27
+1,29
@@
/* Generate code from machine description to extract operands from insn as rtl.
/* Generate code from machine description to extract operands from insn as rtl.
- Copyright (C) 1987, 1991, 1992, 1993, 1997, 1998,
-
1999, 2000
Free Software Foundation, Inc.
+ Copyright (C) 1987, 1991, 1992, 1993, 1997, 1998,
1999, 2000, 2003, 2004
+ Free Software Foundation, Inc.
-This file is part of G
NU
CC.
+This file is part of GCC.
-G
NU 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.
+G
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.
-G
NU 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 th
e
-
GNU General Public License
for more details.
+G
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 Licens
e
+for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
-along with G
NU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-
Boston, MA
02111-1307, USA. */
+along with G
CC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
-#include "
h
config.h"
+#include "
b
config.h"
#include "system.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "rtl.h"
#include "errors.h"
#include "insn-config.h"
#include "rtl.h"
#include "errors.h"
#include "insn-config.h"
@@
-29,7
+31,7
@@
Boston, MA 02111-1307, USA. */
/* This structure contains all the information needed to describe one
/* This structure contains all the information needed to describe one
- set of extractions methods. Each method may be used by more than
+ set of extractions methods. Each method may be used by more than
one pattern if the operands are in the same place.
The string for each operand describes that path to the operand and
one pattern if the operands are in the same place.
The string for each operand describes that path to the operand and
@@
-93,18
+95,17
@@
static int dupnums[MAX_DUP_OPERANDS];
static struct code_ptr *peepholes;
static struct code_ptr *peepholes;
-static void gen_insn
PARAMS ((rtx)
);
-static void walk_rtx
PARAMS ((rtx, const char *)
);
-static void print_path
PARAMS ((const char *)
);
-static void record_insn_name
PARAMS ((int, const char *)
);
+static void gen_insn
(rtx
);
+static void walk_rtx
(rtx, const char *
);
+static void print_path
(const char *
);
+static void record_insn_name
(int, const char *
);
static void
static void
-gen_insn (insn)
- rtx insn;
+gen_insn (rtx insn)
{
{
-
register
int i;
-
register
struct extraction *p;
-
register
struct code_ptr *link;
+ int i;
+ struct extraction *p;
+ struct code_ptr *link;
op_count = 0;
dup_count = 0;
op_count = 0;
dup_count = 0;
@@
-120,7
+121,7
@@
gen_insn (insn)
else
for (i = XVECLEN (insn, 1) - 1; i >= 0; i--)
{
else
for (i = XVECLEN (insn, 1) - 1; i >= 0; i--)
{
- char
*path = (char *) alloca (2)
;
+ char
path[2]
;
path[0] = 'a' + i;
path[1] = 0;
path[0] = 'a' + i;
path[1] = 0;
@@
-128,7
+129,7
@@
gen_insn (insn)
walk_rtx (XVECEXP (insn, 1, i), path);
}
walk_rtx (XVECEXP (insn, 1, i), path);
}
- link =
(struct code_ptr *)
xmalloc (sizeof (struct code_ptr));
+ link = xmalloc (sizeof (struct code_ptr));
link->insn_code = insn_code_number;
/* See if we find something that already had this extraction method. */
link->insn_code = insn_code_number;
/* See if we find something that already had this extraction method. */
@@
-163,7
+164,7
@@
gen_insn (insn)
/* Otherwise, make a new extraction method. */
/* Otherwise, make a new extraction method. */
- p =
(struct extraction *)
xmalloc (sizeof (struct extraction));
+ p = xmalloc (sizeof (struct extraction));
p->op_count = op_count;
p->dup_count = dup_count;
p->next = extractions;
p->op_count = op_count;
p->dup_count = dup_count;
p->next = extractions;
@@
-179,14
+180,12
@@
gen_insn (insn)
}
\f
static void
}
\f
static void
-walk_rtx (x, path)
- rtx x;
- const char *path;
+walk_rtx (rtx x, const char *path)
{
{
-
register
RTX_CODE code;
-
register
int i;
-
register
int len;
-
register
const char *fmt;
+ RTX_CODE code;
+ int i;
+ int len;
+ const char *fmt;
int depth = strlen (path);
char *newpath;
int depth = strlen (path);
char *newpath;
@@
-210,33
+209,34
@@
walk_rtx (x, path)
break;
case MATCH_DUP:
break;
case MATCH_DUP:
- case MATCH_PAR_DUP:
duplocs[dup_count] = xstrdup (path);
dupnums[dup_count] = XINT (x, 0);
dup_count++;
break;
duplocs[dup_count] = xstrdup (path);
dupnums[dup_count] = XINT (x, 0);
dup_count++;
break;
+ case MATCH_PAR_DUP:
case MATCH_OP_DUP:
duplocs[dup_count] = xstrdup (path);
dupnums[dup_count] = XINT (x, 0);
dup_count++;
case MATCH_OP_DUP:
duplocs[dup_count] = xstrdup (path);
dupnums[dup_count] = XINT (x, 0);
dup_count++;
-
- newpath =
(char *) alloca
(depth + 2);
+
+ newpath =
xmalloc
(depth + 2);
strcpy (newpath, path);
newpath[depth + 1] = 0;
strcpy (newpath, path);
newpath[depth + 1] = 0;
-
+
for (i = XVECLEN (x, 1) - 1; i >= 0; i--)
{
for (i = XVECLEN (x, 1) - 1; i >= 0; i--)
{
- newpath[depth] =
'0'
+ i;
+ newpath[depth] =
(code == MATCH_OP_DUP ? '0' : 'a')
+ i;
walk_rtx (XVECEXP (x, 1, i), newpath);
}
walk_rtx (XVECEXP (x, 1, i), newpath);
}
+ free (newpath);
return;
return;
-
+
case MATCH_OPERATOR:
oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
case MATCH_OPERATOR:
oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
- newpath =
(char *) alloca
(depth + 2);
+ newpath =
xmalloc
(depth + 2);
strcpy (newpath, path);
newpath[depth + 1] = 0;
strcpy (newpath, path);
newpath[depth + 1] = 0;
@@
-245,13
+245,14
@@
walk_rtx (x, path)
newpath[depth] = '0' + i;
walk_rtx (XVECEXP (x, 2, i), newpath);
}
newpath[depth] = '0' + i;
walk_rtx (XVECEXP (x, 2, i), newpath);
}
+ free (newpath);
return;
case MATCH_PARALLEL:
oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
return;
case MATCH_PARALLEL:
oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
- newpath =
(char *) alloca
(depth + 2);
+ newpath =
xmalloc
(depth + 2);
strcpy (newpath, path);
newpath[depth + 1] = 0;
strcpy (newpath, path);
newpath[depth + 1] = 0;
@@
-260,6
+261,7
@@
walk_rtx (x, path)
newpath[depth] = 'a' + i;
walk_rtx (XVECEXP (x, 2, i), newpath);
}
newpath[depth] = 'a' + i;
walk_rtx (XVECEXP (x, 2, i), newpath);
}
+ free (newpath);
return;
case ADDRESS:
return;
case ADDRESS:
@@
-270,7
+272,7
@@
walk_rtx (x, path)
break;
}
break;
}
- newpath =
(char *) alloca
(depth + 2);
+ newpath =
xmalloc
(depth + 2);
strcpy (newpath, path);
newpath[depth + 1] = 0;
strcpy (newpath, path);
newpath[depth + 1] = 0;
@@
-293,6
+295,7
@@
walk_rtx (x, path)
}
}
}
}
}
}
+ free (newpath);
}
/* Given a PATH, representing a path down the instruction's
}
/* Given a PATH, representing a path down the instruction's
@@
-300,11
+303,10
@@
walk_rtx (x, path)
evaluate to the rtx at that point. */
static void
evaluate to the rtx at that point. */
static void
-print_path (path)
- const char *path;
+print_path (const char *path)
{
{
-
register
int len = strlen (path);
-
register
int i;
+ int len = strlen (path);
+ int i;
if (len == 0)
{
if (len == 0)
{
@@
-317,16
+319,16
@@
print_path (path)
/* We first write out the operations (XEXP or XVECEXP) in reverse
order, then write "insn", then the indices in forward order. */
/* We first write out the operations (XEXP or XVECEXP) in reverse
order, then write "insn", then the indices in forward order. */
- for (i = len - 1; i >=0 ; i--)
+ for (i = len - 1; i >=
0 ; i--)
{
if (ISLOWER(path[i]))
printf ("XVECEXP (");
else if (ISDIGIT(path[i]))
printf ("XEXP (");
else
{
if (ISLOWER(path[i]))
printf ("XVECEXP (");
else if (ISDIGIT(path[i]))
printf ("XEXP (");
else
-
abort
();
+
gcc_unreachable
();
}
}
-
+
printf ("pat");
for (i = 0; i < len; i++)
printf ("pat");
for (i = 0; i < len; i++)
@@
-336,16
+338,13
@@
print_path (path)
else if (ISDIGIT(path[i]))
printf (", %d)", path[i] - '0');
else
else if (ISDIGIT(path[i]))
printf (", %d)", path[i] - '0');
else
-
abort
();
+
gcc_unreachable
();
}
}
\f
}
}
\f
-extern int main PARAMS ((int, char **));
int
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
rtx desc;
int i;
{
rtx desc;
int i;
@@
-355,10
+354,7
@@
main (argc, argv)
progname = "genextract";
progname = "genextract";
- if (argc <= 1)
- fatal ("No input file name.");
-
- if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
+ if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE);
/* Assign sequential codes to all entries in the machine description
return (FATAL_EXIT_CODE);
/* Assign sequential codes to all entries in the machine description
@@
-371,6
+367,8
@@
from the machine description file `md'. */\n\n");
printf ("#include \"config.h\"\n");
printf ("#include \"system.h\"\n");
printf ("#include \"config.h\"\n");
printf ("#include \"system.h\"\n");
+ printf ("#include \"coretypes.h\"\n");
+ printf ("#include \"tm.h\"\n");
printf ("#include \"rtl.h\"\n");
printf ("#include \"insn-config.h\"\n");
printf ("#include \"recog.h\"\n");
printf ("#include \"rtl.h\"\n");
printf ("#include \"insn-config.h\"\n");
printf ("#include \"recog.h\"\n");
@@
-380,15
+378,16
@@
from the machine description file `md'. */\n\n");
of any missing operand whose numbers are skipped by a given pattern. */
printf ("static rtx junk ATTRIBUTE_UNUSED;\n");
of any missing operand whose numbers are skipped by a given pattern. */
printf ("static rtx junk ATTRIBUTE_UNUSED;\n");
- printf ("void\ninsn_extract (insn)\n");
- printf (" rtx insn;\n");
+ printf ("void\ninsn_extract (rtx insn)\n");
printf ("{\n");
printf ("{\n");
- printf (" r
egister r
tx *ro = recog_data.operand;\n");
- printf (" r
egister r
tx **ro_loc = recog_data.operand_loc;\n");
+ printf (" rtx *ro = recog_data.operand;\n");
+ printf (" rtx **ro_loc = recog_data.operand_loc;\n");
printf (" rtx pat = PATTERN (insn);\n");
printf (" int i ATTRIBUTE_UNUSED;\n\n");
printf (" rtx pat = PATTERN (insn);\n");
printf (" int i ATTRIBUTE_UNUSED;\n\n");
- printf (" memset (ro, 0, sizeof (*ro) * MAX_RECOG_OPERANDS);\n");
- printf (" memset (ro_loc, 0, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n");
+#ifdef ENABLE_CHECKING
+ printf (" memset (ro, 0xab, sizeof (*ro) * MAX_RECOG_OPERANDS);\n");
+ printf (" memset (ro_loc, 0xab, sizeof (*ro_loc) * MAX_RECOG_OPERANDS);\n");
+#endif
printf (" switch (INSN_CODE (insn))\n");
printf (" {\n");
printf (" case -1:\n");
printf (" switch (INSN_CODE (insn))\n");
printf (" {\n");
printf (" case -1:\n");
@@
-412,8
+411,7
@@
from the machine description file `md'. */\n\n");
else if (GET_CODE (desc) == DEFINE_PEEPHOLE)
{
else if (GET_CODE (desc) == DEFINE_PEEPHOLE)
{
- struct code_ptr *link
- = (struct code_ptr *) xmalloc (sizeof (struct code_ptr));
+ struct code_ptr *link = xmalloc (sizeof (struct code_ptr));
link->insn_code = insn_code_number;
link->next = peepholes;
link->insn_code = insn_code_number;
link->next = peepholes;
@@
-430,9
+428,11
@@
from the machine description file `md'. */\n\n");
/* The vector in the insn says how many operands it has.
And all it contains are operands. In fact, the vector was
/* The vector in the insn says how many operands it has.
And all it contains are operands. In fact, the vector was
- created just for the sake of this function. */
+ created just for the sake of this function. We need to set the
+ location of the operands for sake of simplifications after
+ extraction, like eliminating subregs. */
printf (" for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)\n");
printf (" for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)\n");
- printf (" ro[i] =
XVECEXP (pat, 0, i
);\n");
+ printf (" ro[i] =
*(ro_loc[i] = &XVECEXP (pat, 0, i)
);\n");
printf (" break;\n\n");
}
printf (" break;\n\n");
}
@@
-448,7
+448,7
@@
from the machine description file `md'. */\n\n");
else
printf (" case %d:\n", i);
}
else
printf (" case %d:\n", i);
}
-
+
for (i = 0; i < p->op_count; i++)
{
if (p->oplocs[i] == 0)
for (i = 0; i < p->op_count; i++)
{
if (p->oplocs[i] == 0)
@@
-478,7
+478,7
@@
from the machine description file `md'. */\n\n");
/* This should never be reached. Note that we would also reach this abort
if we tried to extract something whose INSN_CODE was a DEFINE_EXPAND or
DEFINE_SPLIT, but that is correct. */
/* This should never be reached. Note that we would also reach this abort
if we tried to extract something whose INSN_CODE was a DEFINE_EXPAND or
DEFINE_SPLIT, but that is correct. */
- printf (" default:\n
abort
();\n");
+ printf (" default:\n
gcc_unreachable
();\n");
printf (" }\n}\n");
printf (" }\n}\n");
@@
-488,8
+488,7
@@
from the machine description file `md'. */\n\n");
/* Define this so we can link with print-rtl.o to get debug_rtx function. */
const char *
/* Define this so we can link with print-rtl.o to get debug_rtx function. */
const char *
-get_insn_name (code)
- int code ATTRIBUTE_UNUSED;
+get_insn_name (int code ATTRIBUTE_UNUSED)
{
if (code < insn_name_ptr_size)
return insn_name_ptr[code];
{
if (code < insn_name_ptr_size)
return insn_name_ptr[code];
@@
-498,9
+497,7
@@
get_insn_name (code)
}
static void
}
static void
-record_insn_name (code, name)
- int code;
- const char *name;
+record_insn_name (int code, const char *name)
{
static const char *last_real_name = "insn";
static int last_real_code = 0;
{
static const char *last_real_name = "insn";
static int last_real_code = 0;
@@
-510,9
+507,8
@@
record_insn_name (code, name)
{
int new_size;
new_size = (insn_name_ptr_size ? insn_name_ptr_size * 2 : 512);
{
int new_size;
new_size = (insn_name_ptr_size ? insn_name_ptr_size * 2 : 512);
- insn_name_ptr =
- (char **) xrealloc (insn_name_ptr, sizeof(char *) * new_size);
- memset (insn_name_ptr + insn_name_ptr_size, 0,
+ insn_name_ptr = xrealloc (insn_name_ptr, sizeof(char *) * new_size);
+ memset (insn_name_ptr + insn_name_ptr_size, 0,
sizeof(char *) * (new_size - insn_name_ptr_size));
insn_name_ptr_size = new_size;
}
sizeof(char *) * (new_size - insn_name_ptr_size));
insn_name_ptr_size = new_size;
}
@@
-527,6
+523,6
@@
record_insn_name (code, name)
last_real_name = new = xstrdup (name);
last_real_code = code;
}
last_real_name = new = xstrdup (name);
last_real_code = code;
}
-
+
insn_name_ptr[code] = new;
insn_name_ptr[code] = new;
-}
+}