Commit 3b80f6ca by Richard Henderson Committed by Richard Henderson

Makefile.in (OBJ, GEN, RTL_H): Add genrtl.[oh] bits.

* Makefile.in (OBJ, GEN, RTL_H): Add genrtl.[oh] bits.
* emit-rtl.c (gen_rtx): Move special code to ...
(gen_rtx_CONST_INT): New function.
(gen_rtx_REG): New function.
(*): Update all calls to gen_rtx.
* genemit.c (gen_exp): Emit calls to gen_rtx_FOO for constant FOO.
* rtl.h: Include genrtl.h; prototype CONST_INT & REG generators.
(GEN_INT): Call gen_rtx_CONST_INT.
* gengenrtl.c: New file.

From-SVN: r17312
parent f4a23343
Thu Jan 8 21:06:54 1998 Richard Henderson <rth@cygnus.com>
* Makefile.in (OBJ, GEN, RTL_H): Add genrtl.[oh] bits.
* emit-rtl.c (gen_rtx): Move special code to ...
(gen_rtx_CONST_INT): New function.
(gen_rtx_REG): New function.
(*): Update all calls to gen_rtx.
* genemit.c (gen_exp): Emit calls to gen_rtx_FOO for constant FOO.
* rtl.h: Include genrtl.h; prototype CONST_INT & REG generators.
(GEN_INT): Call gen_rtx_CONST_INT.
* gengenrtl.c: New file.
Mon Jan 5 13:00:18 1998 John F. Carr <jfc@mit.edu> Mon Jan 5 13:00:18 1998 John F. Carr <jfc@mit.edu>
* alias.c (*_dependence): Call base_alias_check before canon_rtx. * alias.c (*_dependence): Call base_alias_check before canon_rtx.
......
...@@ -589,7 +589,7 @@ SCHED_CFLAGS = @sched_cflags@ ...@@ -589,7 +589,7 @@ SCHED_CFLAGS = @sched_cflags@
# Language-independent object files. # Language-independent object files.
OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \ OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
function.o stmt.o except.o expr.o calls.o expmed.o explow.o optabs.o \ function.o stmt.o except.o expr.o calls.o expmed.o explow.o optabs.o \
varasm.o rtl.o print-rtl.o rtlanal.o emit-rtl.o real.o regmove.o \ varasm.o rtl.o print-rtl.o rtlanal.o emit-rtl.o genrtl.o real.o regmove.o \
dbxout.o sdbout.o dwarfout.o dwarf2out.o xcoffout.o bitmap.o alias.o \ dbxout.o sdbout.o dwarfout.o dwarf2out.o xcoffout.o bitmap.o alias.o \
integrate.o jump.o cse.o loop.o unroll.o flow.o stupid.o combine.o \ integrate.o jump.o cse.o loop.o unroll.o flow.o stupid.o combine.o \
regclass.o local-alloc.o global.o reload.o reload1.o caller-save.o \ regclass.o local-alloc.o global.o reload.o reload1.o caller-save.o \
...@@ -600,7 +600,8 @@ OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \ ...@@ -600,7 +600,8 @@ OBJS = toplev.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
# GEN files are listed separately, so they can be built before doing parallel # GEN files are listed separately, so they can be built before doing parallel
# makes for cc1 or cc1plus. Otherwise sequent parallel make attempts to load # makes for cc1 or cc1plus. Otherwise sequent parallel make attempts to load
# them before rtl.o is compiled. # them before rtl.o is compiled.
GEN= genemit genoutput genrecog genextract genflags gencodes genconfig genpeep GEN= genemit genoutput genrecog genextract genflags gencodes genconfig \
genpeep gengenrtl
CCCP=cccp CCCP=cccp
# Uncomment this line if you want to use cppmain (w/cpplib) as cpp. # Uncomment this line if you want to use cppmain (w/cpplib) as cpp.
...@@ -669,7 +670,8 @@ DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \ ...@@ -669,7 +670,8 @@ DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
# If it is, rm *.o is an easy way to do it. # If it is, rm *.o is an easy way to do it.
# CONFIG_H = $(host_xm_file) $(tm_file) # CONFIG_H = $(host_xm_file) $(tm_file)
CONFIG_H = CONFIG_H =
RTL_H = rtl.h rtl.def gansidecl.h machmode.h machmode.def RTL_BASE_H = rtl.h rtl.def gansidecl.h machmode.h machmode.def
RTL_H = $(RTL_BASE_H) genrtl.h
TREE_H = tree.h real.h tree.def gansidecl.h machmode.h machmode.def TREE_H = tree.h real.h tree.def gansidecl.h machmode.h machmode.def
BYTECODE_H = bytecode.h bc-emit.h bc-optab.h BYTECODE_H = bytecode.h bc-emit.h bc-optab.h
BASIC_BLOCK_H = basic-block.h bitmap.h BASIC_BLOCK_H = basic-block.h bitmap.h
...@@ -1242,8 +1244,8 @@ $(srcdir)/c-gperf.h: c-parse.gperf ...@@ -1242,8 +1244,8 @@ $(srcdir)/c-gperf.h: c-parse.gperf
c-decl.o : c-decl.c $(CONFIG_H) $(TREE_H) c-tree.h c-lex.h flags.h output.h c-decl.o : c-decl.c $(CONFIG_H) $(TREE_H) c-tree.h c-lex.h flags.h output.h
c-typeck.o : c-typeck.c $(CONFIG_H) $(TREE_H) c-tree.h flags.h output.h c-typeck.o : c-typeck.c $(CONFIG_H) $(TREE_H) c-tree.h flags.h output.h
c-lang.o : c-lang.c $(CONFIG_H) $(TREE_H) c-lang.o : c-lang.c $(CONFIG_H) $(TREE_H)
c-lex.o : c-lex.c $(CONFIG_H) $(TREE_H) c-lex.h c-tree.h $(srcdir)/c-parse.h \ c-lex.o : c-lex.c $(CONFIG_H) $(TREE_H) $(RTL_H) c-lex.h c-tree.h \
input.h flags.h $(srcdir)/c-gperf.h c-pragma.h $(srcdir)/c-parse.h input.h flags.h $(srcdir)/c-gperf.h c-pragma.h
c-aux-info.o : c-aux-info.c $(CONFIG_H) $(TREE_H) c-tree.h flags.h c-aux-info.o : c-aux-info.c $(CONFIG_H) $(TREE_H) c-tree.h flags.h
c-convert.o : c-convert.c $(CONFIG_H) $(TREE_H) flags.h c-convert.o : c-convert.c $(CONFIG_H) $(TREE_H) flags.h
c-pragma.o: c-pragma.c $(CONFIG_H) $(TREE_H) except.h function.h \ c-pragma.o: c-pragma.c $(CONFIG_H) $(TREE_H) except.h function.h \
...@@ -1580,6 +1582,15 @@ stamp-output : $(md_file) genoutput $(srcdir)/move-if-change ...@@ -1580,6 +1582,15 @@ stamp-output : $(md_file) genoutput $(srcdir)/move-if-change
./genoutput $(md_file) > tmp-output.c ./genoutput $(md_file) > tmp-output.c
$(srcdir)/move-if-change tmp-output.c insn-output.c $(srcdir)/move-if-change tmp-output.c insn-output.c
touch stamp-output touch stamp-output
genrtl.o : genrtl.c $(CONFIG_H) $(RTL_H)
genrtl.c genrtl.h : stamp-genrtl
stamp-genrtl: gengenrtl $(srcdir)/move-if-change $(RTL_BASE_H)
./gengenrtl tmp-genrtl.h tmp-genrtl.c
$(srcdir)/move-if-change tmp-genrtl.h genrtl.h
$(srcdir)/move-if-change tmp-genrtl.c genrtl.c
touch stamp-genrtl
# #
# Compile the programs that generate insn-* from the machine description. # Compile the programs that generate insn-* from the machine description.
# They are compiled with $(HOST_CC), and associated libraries, # They are compiled with $(HOST_CC), and associated libraries,
...@@ -1673,6 +1684,14 @@ genoutput : genoutput.o $(HOST_RTL) $(HOST_LIBDEPS) ...@@ -1673,6 +1684,14 @@ genoutput : genoutput.o $(HOST_RTL) $(HOST_LIBDEPS)
genoutput.o : genoutput.c $(RTL_H) $(build_xm_file) genoutput.o : genoutput.c $(RTL_H) $(build_xm_file)
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genoutput.c $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genoutput.c
gengenrtl : gengenrtl.o $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
gengenrtl.o $(HOST_LIBS)
gengenrtl.o : gengenrtl.c $(RTL_BASE_H)
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gengenrtl.c
# #
# Compile the libraries to be used by gen*. # Compile the libraries to be used by gen*.
# If we are not cross-building, gen* use the same .o's that cc1 will use, # If we are not cross-building, gen* use the same .o's that cc1 will use,
......
...@@ -188,7 +188,7 @@ gen_exp (x) ...@@ -188,7 +188,7 @@ gen_exp (x)
return; return;
case MATCH_SCRATCH: case MATCH_SCRATCH:
printf ("gen_rtx (SCRATCH, %smode, 0)", GET_MODE_NAME (GET_MODE (x))); printf ("gen_rtx_SCRATCH (%smode)", GET_MODE_NAME (GET_MODE (x)));
return; return;
case ADDRESS: case ADDRESS:
...@@ -230,9 +230,9 @@ gen_exp (x) ...@@ -230,9 +230,9 @@ gen_exp (x)
break; break;
} }
printf ("gen_rtx ("); printf ("gen_rtx_");
print_code (code); print_code (code);
printf (", %smode", GET_MODE_NAME (GET_MODE (x))); printf (" (%smode", GET_MODE_NAME (GET_MODE (x)));
fmt = GET_RTX_FORMAT (code); fmt = GET_RTX_FORMAT (code);
len = GET_RTX_LENGTH (code); len = GET_RTX_LENGTH (code);
...@@ -371,7 +371,7 @@ gen_insn (insn) ...@@ -371,7 +371,7 @@ gen_insn (insn)
} }
else else
{ {
printf (" return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (%d", XVECLEN (insn, 1)); printf (" return gen_rtx_PARALLEL (VOIDmode, gen_rtvec (%d", XVECLEN (insn, 1));
for (i = 0; i < XVECLEN (insn, 1); i++) for (i = 0; i < XVECLEN (insn, 1); i++)
{ {
printf (",\n\t\t"); printf (",\n\t\t");
......
/* Generate code to allocate RTL structures.
Copyright (C) 1997 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, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "hconfig.h"
#include <stdio.h>
#include "obstack.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
#define NO_GENRTL_H
#include "rtl.h"
struct rtx_definition
{
const char *enumname, *name, *format;
};
#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) { # ENUM, NAME, FORMAT },
struct rtx_definition defs[] =
{
#include "rtl.def" /* rtl expressions are documented here */
};
const char *formats[NUM_RTX_CODE];
static const char *
type_from_format (char c)
{
switch (c)
{
case 'i':
return "int";
case 'w':
return "HOST_WIDE_INT";
case 's':
return "char *";
case 'e':
case 'u':
return "rtx";
case 'E':
return "rtvec";
default:
abort ();
}
}
static const char *
accessor_from_format (char c)
{
switch (c)
{
case 'i':
return "XINT";
case 'w':
return "XWINT";
case 's':
return "XSTR";
case 'e':
case 'u':
return "XEXP";
case 'E':
return "XVEC";
default:
abort ();
}
}
static int
special_format (fmt)
const char *fmt;
{
return (strchr (fmt, '*') != 0
|| strchr (fmt, 'V') != 0
|| strchr (fmt, 'S') != 0
|| strchr (fmt, 'n') != 0);
}
static int
special_rtx (idx)
int idx;
{
return (strcmp (defs[idx].enumname, "CONST_INT") == 0
|| strcmp (defs[idx].enumname, "REG") == 0);
}
static void
find_formats ()
{
int i;
for (i = 0; i < NUM_RTX_CODE; ++i)
{
const char **f;
if (special_format (defs[i].format))
continue;
for (f = formats; *f ; ++f)
if (!strcmp(*f, defs[i].format))
break;
if (!*f)
*f = defs[i].format;
}
}
static void
gendecl (f, format)
FILE *f;
const char *format;
{
const char *p;
int i;
fprintf (f, "extern rtx gen_rtx_fmt_%s PROTO((RTX_CODE, enum machine_mode mode",
format);
for (p = format, i = 0; *p ; ++p)
if (*p != '0')
fprintf (f, ", %s arg%d", type_from_format (*p), i++);
fprintf (f, "));\n");
}
static void
genmacro (f, idx)
FILE *f;
int idx;
{
const char *p;
int i;
fprintf (f, "#define gen_rtx_%s%s(mode",
(special_rtx (idx) ? "raw_" : ""), defs[idx].enumname);
for (p = defs[idx].format, i = 0; *p ; ++p)
if (*p != '0')
fprintf (f, ", arg%d", i++);
fprintf (f, ") ");
fprintf (f, "gen_rtx_fmt_%s(%s,(mode)", defs[idx].format, defs[idx].enumname);
for (p = defs[idx].format, i = 0; *p ; ++p)
if (*p != '0')
fprintf (f, ",(arg%d)", i++);
fprintf (f, ")\n");
}
static void
gendef (f, format)
FILE *f;
const char *format;
{
const char *p;
int i, j;
fprintf (f, "rtx\ngen_rtx_fmt_%s (code, mode", format);
for (p = format, i = 0; *p ; ++p)
if (*p != '0')
fprintf (f, ", arg%d", i++);
fprintf (f, ")\n RTX_CODE code;\n enum machine_mode mode;\n");
for (p = format, i = 0; *p ; ++p)
if (*p != '0')
fprintf (f, " %s arg%d;\n", type_from_format (*p), i++);
/* See rtx_alloc in rtl.c for comments. */
fprintf (f, "{\n");
fprintf (f, " register int length = sizeof (struct rtx_def)");
fprintf (f, " + %d * sizeof (rtunion);\n", strlen (format) - 1);
fprintf (f, " rtx rt = (rtx)obstack_alloc (rtl_obstack, length);\n");
fprintf (f, " if (sizeof(struct rtx_def) - sizeof(rtunion) == sizeof(int))\n");
fprintf (f, " *(int *)rt = 0;\n");
fprintf (f, " else if (sizeof(struct rtx_def) - sizeof(rtunion) == sizeof(HOST_WIDE_INT))\n");
fprintf (f, " *(HOST_WIDE_INT *)rt = 0;\n");
fprintf (f, " else\n");
fprintf (f, " bzero(rt, sizeof(struct rtx_def) - sizeof(rtunion));\n\n");
fprintf (f, " PUT_CODE (rt, code);\n");
fprintf (f, " PUT_MODE (rt, mode);\n");
for (p = format, i = j = 0; *p ; ++p, ++i)
if (*p != '0')
{
fprintf (f, " %s (rt, %d) = arg%d;\n",
accessor_from_format (*p), i, j++);
}
fprintf (f, "\n return rt;\n}\n\n");
}
static void
genlegend (f)
FILE *f;
{
fprintf (f, "/* Generated automaticaly by the program `gengenrtl'\n");
fprintf (f, " from the RTL description file `rtl.def' */\n\n");
}
static void
genheader (f)
FILE *f;
{
int i;
const char **fmt;
for (fmt = formats; *fmt; ++fmt)
gendecl (f, *fmt);
fprintf(f, "\n");
for (i = 0; i < NUM_RTX_CODE; i++)
{
if (special_format (defs[i].format))
continue;
genmacro (f, i);
}
}
static void
gencode (f)
FILE *f;
{
const char **fmt;
fprintf(f, "#include \"config.h\"\n");
fprintf(f, "#include \"obstack.h\"\n");
fprintf(f, "#include \"rtl.h\"\n\n");
fprintf(f, "extern struct obstack *rtl_obstack;\n\n");
for (fmt = formats; *fmt; ++fmt)
gendef (f, *fmt);
}
int
main(argc, argv)
int argc;
char **argv;
{
FILE *f;
if (argc != 3)
exit (1);
find_formats ();
f = fopen (argv[1], "w");
if (f == NULL)
{
perror(argv[1]);
exit (1);
}
genlegend (f);
genheader (f);
fclose(f);
f = fopen (argv[2], "w");
if (f == NULL)
{
perror(argv[2]);
exit (1);
}
genlegend (f);
gencode (f);
fclose(f);
exit (0);
}
...@@ -681,8 +681,6 @@ extern int ceil_log2 PROTO((unsigned HOST_WIDE_INT)); ...@@ -681,8 +681,6 @@ extern int ceil_log2 PROTO((unsigned HOST_WIDE_INT));
extern rtx plus_constant_wide PROTO((rtx, HOST_WIDE_INT)); extern rtx plus_constant_wide PROTO((rtx, HOST_WIDE_INT));
extern rtx plus_constant_for_output_wide PROTO((rtx, HOST_WIDE_INT)); extern rtx plus_constant_for_output_wide PROTO((rtx, HOST_WIDE_INT));
#define GEN_INT(N) gen_rtx (CONST_INT, VOIDmode, (HOST_WIDE_INT) (N))
struct bc_label; struct bc_label;
extern rtx bc_gen_rtx PROTO ((char *, int, extern rtx bc_gen_rtx PROTO ((char *, int,
struct bc_label *)); struct bc_label *));
...@@ -934,6 +932,22 @@ extern rtx struct_value_incoming_rtx; ...@@ -934,6 +932,22 @@ extern rtx struct_value_incoming_rtx;
extern rtx static_chain_rtx; extern rtx static_chain_rtx;
extern rtx static_chain_incoming_rtx; extern rtx static_chain_incoming_rtx;
/* Include the RTL generation functions. */
#ifndef NO_GENRTL_H
#include "genrtl.h"
#endif
/* There are two RTL codes that require special attention; the generation
functions included above do the raw handling. */
extern rtx gen_rtx_CONST_INT PROTO((enum machine_mode, HOST_WIDE_INT));
extern rtx gen_rtx_REG PROTO((enum machine_mode, int));
#define GEN_INT(N) gen_rtx_CONST_INT (VOIDmode, (N))
/* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg /* If HARD_FRAME_POINTER_REGNUM is defined, then a special dummy reg
is used to represent the frame pointer. This is because the is used to represent the frame pointer. This is because the
hard frame pointer and the automatic variables are separated by an amount hard frame pointer and the automatic variables are separated by an amount
...@@ -1376,4 +1390,3 @@ extern void init_alias_analysis PROTO ((void)); ...@@ -1376,4 +1390,3 @@ extern void init_alias_analysis PROTO ((void));
extern void end_alias_analysis PROTO ((void)); extern void end_alias_analysis PROTO ((void));
#endif /* _RTL_H */ #endif /* _RTL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment