2002-07-29 20:02:47 +02:00
|
|
|
/* Process machine description and calculate constant conditions.
|
2014-01-02 23:23:26 +01:00
|
|
|
Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
2002-07-29 20:02:47 +02:00
|
|
|
|
c-pch.c, [...]: Replace "GNU CC" with "GCC".
* c-pch.c, dummy-conditions.c, genautomata.c, genconditions.c,
langhooks.c, tree-inline.c, unwind-dw2-fde-darwin.c,
unwind-dw2-fde-glibc.c, unwind-libunwind.c, vmsdbgout.c: Replace
"GNU CC" with "GCC".
From-SVN: r64297
2003-03-13 04:48:31 +01:00
|
|
|
This file is part of GCC.
|
2002-07-29 20:02:47 +02:00
|
|
|
|
c-pch.c, [...]: Replace "GNU CC" with "GCC".
* c-pch.c, dummy-conditions.c, genautomata.c, genconditions.c,
langhooks.c, tree-inline.c, unwind-dw2-fde-darwin.c,
unwind-dw2-fde-glibc.c, unwind-libunwind.c, vmsdbgout.c: Replace
"GNU CC" with "GCC".
From-SVN: r64297
2003-03-13 04:48:31 +01:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
2002-07-29 20:02:47 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-26 10:37:01 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
2002-07-29 20:02:47 +02:00
|
|
|
any later version.
|
|
|
|
|
c-pch.c, [...]: Replace "GNU CC" with "GCC".
* c-pch.c, dummy-conditions.c, genautomata.c, genconditions.c,
langhooks.c, tree-inline.c, unwind-dw2-fde-darwin.c,
unwind-dw2-fde-glibc.c, unwind-libunwind.c, vmsdbgout.c: Replace
"GNU CC" with "GCC".
From-SVN: r64297
2003-03-13 04:48:31 +01:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
2002-07-29 20:02:47 +02:00
|
|
|
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
|
2007-07-26 10:37:01 +02:00
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2002-07-29 20:02:47 +02:00
|
|
|
|
|
|
|
/* In a machine description, all of the insn patterns - define_insn,
|
|
|
|
define_expand, define_split, define_peephole, define_peephole2 -
|
|
|
|
contain an optional C expression which makes the final decision
|
|
|
|
about whether or not this pattern is usable. That expression may
|
|
|
|
turn out to be always false when the compiler is built. If it is,
|
|
|
|
most of the programs that generate code from the machine
|
|
|
|
description can simply ignore the entire pattern. */
|
|
|
|
|
2002-12-16 19:23:00 +01:00
|
|
|
#include "bconfig.h"
|
2002-07-29 20:02:47 +02:00
|
|
|
#include "system.h"
|
2002-12-16 19:23:00 +01:00
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
2002-07-29 20:02:47 +02:00
|
|
|
#include "rtl.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "hashtab.h"
|
Makefile.in (READ_MD_H): New variable.
gcc/
* Makefile.in (READ_MD_H): New variable.
(BUILD_RTL): Add build/read-md.o.
(lto-wrapper.o): Depend on coretypes.h instead of defaults.h.
(build/gensupport.o, build/read-rtl.o, build/genattr.o)
(build/genattrtab.o, build/genconditions.o build/genemit.o)
(build/genextract.o, build/genflags.o, build/genoutput.o)
(build/genpreds.o, build/genrecog.o): Depend on $(READ_MD_H).
(build/read-md.o): New rule.
* defaults.h (obstack_chunk_alloc, obstack_chunk_free)
(OBSTACK_CHUNK_SIZE, gcc_obstack_init): Move to...
* coretypes.h: ...here.
* lto-wrapper.c: Include coretypes.h instead of defaults.h.
* pretty-print.c (obstack_chunk_alloc, obstack_chunk_free): Delete.
* genattr.c: Include read-md.h.
* genattrtab.c: Likewise.
* genconditions.c: Likewise.
* genemit.c: Likewise.
* genextract.c: Likewise.
* genflags.c: Likewise.
* genoutput.c: Likewise.
* genpreds.c: Likewise.
* genrecog.c: Likewise.
* rtl.h (read_skip_spaces, copy_rtx_ptr_loc, print_rtx_ptr_loc)
(join_c_conditions, print_c_condition, read_rtx_filename)
(read_rtx_lineno): Move to read-md.h.
* read-rtl.c: Include read-md.h.
(ptr_loc, string_obstack, ptr_locs, ptr_loc_obstack)
(joined_conditions, joined_conditions_obstack, read_rtx_lineno)
(read_rtx_filename, fatal_with_file_and_line, fatal_expected_char)
(leading_ptr_hash, leading_ptr_eq_p, set_rtx_ptr_loc, get_rtx_ptr_loc)
(copy_rtx_ptr_loc, print_rtx_ptr_loc, join_c_conditions)
(print_c_condition, read_skip_spaces, read_escape, read_quoted_string)
(read_braced_string, read_string): Move to read-md.c.
(read_rtx): Move some initialization to init_md_reader and call
init_md_reader here.
* gensupport.h (message_with_line, n_comma_elts, scan_comma_elt):
Move to read-md.h.
* gensupport.c: Include read-md.h.
(message_with_line, n_comma_elts, scan_comma_elt): Move to
read-md.c.
* read-md.h, read-md.c: New files.
From-SVN: r160570
2010-06-10 22:21:23 +02:00
|
|
|
#include "read-md.h"
|
2002-07-29 20:02:47 +02:00
|
|
|
#include "gensupport.h"
|
|
|
|
|
2004-01-16 02:44:06 +01:00
|
|
|
/* so we can include except.h in the generated file. */
|
2002-07-29 20:02:47 +02:00
|
|
|
static int saw_eh_return;
|
|
|
|
|
2003-06-01 17:59:10 +02:00
|
|
|
static void write_header (void);
|
|
|
|
static void write_conditions (void);
|
|
|
|
static int write_one_condition (void **, void *);
|
2002-07-29 20:02:47 +02:00
|
|
|
|
|
|
|
/* Generate the header for insn-conditions.c. */
|
|
|
|
|
|
|
|
static void
|
2003-06-01 17:59:10 +02:00
|
|
|
write_header (void)
|
2002-07-29 20:02:47 +02:00
|
|
|
{
|
|
|
|
puts ("\
|
|
|
|
/* Generated automatically by the program `genconditions' from the target\n\
|
|
|
|
machine description file. */\n\
|
|
|
|
\n\
|
2002-12-16 19:23:00 +01:00
|
|
|
#include \"bconfig.h\"\n\
|
2006-01-29 04:30:47 +01:00
|
|
|
#include \"system.h\"\n\
|
|
|
|
\n\
|
2006-01-26 22:21:42 +01:00
|
|
|
/* It is necessary, but not entirely safe, to include the headers below\n\
|
|
|
|
in a generator program. As a defensive measure, don't do so when the\n\
|
|
|
|
table isn't going to have anything in it. */\n\
|
|
|
|
#if GCC_VERSION >= 3001\n\
|
|
|
|
\n\
|
2002-07-29 20:02:47 +02:00
|
|
|
/* Do not allow checking to confuse the issue. */\n\
|
|
|
|
#undef ENABLE_CHECKING\n\
|
|
|
|
#undef ENABLE_TREE_CHECKING\n\
|
|
|
|
#undef ENABLE_RTL_CHECKING\n\
|
|
|
|
#undef ENABLE_RTL_FLAG_CHECKING\n\
|
|
|
|
#undef ENABLE_GC_CHECKING\n\
|
2006-01-29 04:30:47 +01:00
|
|
|
#undef ENABLE_GC_ALWAYS_COLLECT\n\
|
|
|
|
\n\
|
2002-12-16 19:23:00 +01:00
|
|
|
#include \"coretypes.h\"\n\
|
|
|
|
#include \"tm.h\"\n\
|
2006-01-26 22:21:42 +01:00
|
|
|
#include \"insn-constants.h\"\n\
|
2014-10-04 15:29:26 +02:00
|
|
|
#include \"ggc.h\"\n\
|
2002-07-29 20:02:47 +02:00
|
|
|
#include \"rtl.h\"\n\
|
|
|
|
#include \"tm_p.h\"\n\
|
2006-01-29 04:30:47 +01:00
|
|
|
#include \"function.h\"\n\
|
|
|
|
\n\
|
2002-07-29 20:02:47 +02:00
|
|
|
/* Fake - insn-config.h doesn't exist yet. */\n\
|
|
|
|
#define MAX_RECOG_OPERANDS 10\n\
|
|
|
|
#define MAX_DUP_OPERANDS 10\n\
|
2006-01-29 04:30:47 +01:00
|
|
|
#define MAX_INSNS_PER_SPLIT 5\n\
|
|
|
|
\n\
|
2002-07-29 20:02:47 +02:00
|
|
|
#include \"regs.h\"\n\
|
|
|
|
#include \"recog.h\"\n\
|
|
|
|
#include \"output.h\"\n\
|
|
|
|
#include \"flags.h\"\n\
|
|
|
|
#include \"hard-reg-set.h\"\n\
|
|
|
|
#include \"resource.h\"\n\
|
2010-07-09 03:34:40 +02:00
|
|
|
#include \"diagnostic-core.h\"\n\
|
2006-03-30 00:58:32 +02:00
|
|
|
#include \"reload.h\"\n\
|
|
|
|
#include \"tm-constrs.h\"\n");
|
2002-07-29 20:02:47 +02:00
|
|
|
|
|
|
|
if (saw_eh_return)
|
|
|
|
puts ("#define HAVE_eh_return 1");
|
|
|
|
puts ("#include \"except.h\"\n");
|
|
|
|
|
|
|
|
puts ("\
|
|
|
|
/* Dummy external declarations. */\n\
|
Use rtx_insn internally within generated functions
2014-08-21 David Malcolm <dmalcolm@redhat.com>
* recog.h (insn_output_fn): Update this function typedef to match
the changes below to the generated output functions, strengthening
the 2nd param from rtx to rtx_insn *.
* final.c (get_insn_template): Add a checked cast to rtx_insn * on
insn when invoking an output function, to match the new signature
of insn_output_fn with a stronger second param.
* genconditions.c (write_header): In the generated code for
gencondmd.c, strengthen the global "insn" from rtx to rtx_insn *
to match the other changes in this patch.
* genemit.c (gen_split): Strengthen the 1st param "curr_insn" of
the generated "gen_" functions from rtx to rtx_insn * within their
implementations.
* genrecog.c (write_subroutine): Strengthen the 2nd param "insn" of
the subfunctions within the generated "recog_", "split", "peephole2"
function trees from rtx to rtx_insn *. For now, the top-level
generated functions ("recog", "split", "peephole2") continue to
take a plain rtx for "insn", to avoid introducing dependencies on
other patches. Rename this 2nd param from "insn" to
"uncast_insn", and reintroduce "insn" as a local variable of type
rtx_insn *, initialized at the top of the generated function with
a checked cast on "uncast_insn".
(make_insn_sequence): Strengthen the 1st param "curr_insn" of
the generated "gen_" functions from rtx to rtx_insn * within their
prototypes.
* genoutput.c (process_template): Strengthen the 2nd param within
the generated "output_" functions "insn" from rtx to rtx_insn *.
From-SVN: r214257
2014-08-21 09:49:28 +02:00
|
|
|
extern rtx_insn *insn;\n\
|
2002-07-29 20:02:47 +02:00
|
|
|
extern rtx ins1;\n\
|
2006-01-26 22:21:42 +01:00
|
|
|
extern rtx operands[];\n\
|
|
|
|
\n\
|
|
|
|
#endif /* gcc >= 3.0.1 */\n");
|
2002-07-29 20:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out one entry in the conditions table, using the data pointed
|
|
|
|
to by SLOT. Each entry looks like this:
|
* rtl.h (copy_rtx_ptr_loc, print_rtx_ptr_loc, join_c_conditions)
(print_c_condition): Declare.
* read-rtl.c (ptr_loc): New structure.
(ptr_locs, ptr_loc_obstack, joined_conditions)
(joined_conditions_obstack): New variables.
(leading_ptr_hash, leading_ptr_eq_p, set_rtx_ptr_loc)
(get_rtx_ptr_loc, copy_rtx_ptr_loc, print_rtx_ptr_loc)
(join_c_conditions, print_c_condition): New functions.
(apply_macro_to_string): Associate the new string with the same
source location as the old one.
(add_condition_to_string): Use join_c_conditions.
(read_string): Use set_rtx_ptr_loc to record a filename and line
number for the string.
(read_rtx): Initialize the new variables above.
* genattrtab.c (write_test_expr, write_attr_value): Use
print_c_condition.
* genconditions.c (write_header): Don't define MAYBE_EVAL. Move its
comment above the GCC_VERSION check.
(write_one_condition): Use print_rtx_ptr_loc and print_c_condition.
Inline the definition of MAYBE_EVAL.
* genemit.c (gen_expand, gen_split): Use print_rtx_ptr_loc.
* genoutput.c (process_template): Likewise.
* genpreds.c (write_predicate_subfunction): Likewise.
(write_predicate_expr): Use print_c_condition.
* genrecog.c (write_cond): Likewise.
* gensupport.c (process_rtx): Use join_c_conditions to join the
conditions of a define_insn_and_split. Record a source location
for the string after the "&&".
(alter_test_for_insn): Use join_c_conditions.
From-SVN: r95883
2005-03-04 12:10:35 +01:00
|
|
|
|
|
|
|
{ "! optimize_size && ! TARGET_READ_MODIFY_WRITE",
|
|
|
|
__builtin_constant_p (! optimize_size && ! TARGET_READ_MODIFY_WRITE)
|
|
|
|
? (int) (! optimize_size && ! TARGET_READ_MODIFY_WRITE)
|
|
|
|
: -1) }, */
|
2002-07-29 20:02:47 +02:00
|
|
|
|
|
|
|
static int
|
2004-07-25 02:13:01 +02:00
|
|
|
write_one_condition (void **slot, void * ARG_UNUSED (dummy))
|
2002-07-29 20:02:47 +02:00
|
|
|
{
|
|
|
|
const struct c_test *test = * (const struct c_test **) slot;
|
|
|
|
const char *p;
|
|
|
|
|
2010-06-10 22:21:35 +02:00
|
|
|
print_md_ptr_loc (test->expr);
|
2002-07-29 20:02:47 +02:00
|
|
|
fputs (" { \"", stdout);
|
|
|
|
for (p = test->expr; *p; p++)
|
|
|
|
{
|
2006-01-26 22:21:42 +01:00
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '\n': fputs ("\\n\\", stdout); break;
|
|
|
|
case '\\':
|
|
|
|
case '\"': putchar ('\\'); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
putchar (*p);
|
2002-07-29 20:02:47 +02:00
|
|
|
}
|
|
|
|
|
2006-01-29 04:30:47 +01:00
|
|
|
fputs ("\",\n __builtin_constant_p ", stdout);
|
* rtl.h (copy_rtx_ptr_loc, print_rtx_ptr_loc, join_c_conditions)
(print_c_condition): Declare.
* read-rtl.c (ptr_loc): New structure.
(ptr_locs, ptr_loc_obstack, joined_conditions)
(joined_conditions_obstack): New variables.
(leading_ptr_hash, leading_ptr_eq_p, set_rtx_ptr_loc)
(get_rtx_ptr_loc, copy_rtx_ptr_loc, print_rtx_ptr_loc)
(join_c_conditions, print_c_condition): New functions.
(apply_macro_to_string): Associate the new string with the same
source location as the old one.
(add_condition_to_string): Use join_c_conditions.
(read_string): Use set_rtx_ptr_loc to record a filename and line
number for the string.
(read_rtx): Initialize the new variables above.
* genattrtab.c (write_test_expr, write_attr_value): Use
print_c_condition.
* genconditions.c (write_header): Don't define MAYBE_EVAL. Move its
comment above the GCC_VERSION check.
(write_one_condition): Use print_rtx_ptr_loc and print_c_condition.
Inline the definition of MAYBE_EVAL.
* genemit.c (gen_expand, gen_split): Use print_rtx_ptr_loc.
* genoutput.c (process_template): Likewise.
* genpreds.c (write_predicate_subfunction): Likewise.
(write_predicate_expr): Use print_c_condition.
* genrecog.c (write_cond): Likewise.
* gensupport.c (process_rtx): Use join_c_conditions to join the
conditions of a define_insn_and_split. Record a source location
for the string after the "&&".
(alter_test_for_insn): Use join_c_conditions.
From-SVN: r95883
2005-03-04 12:10:35 +01:00
|
|
|
print_c_condition (test->expr);
|
2006-01-29 04:30:47 +01:00
|
|
|
fputs ("\n ? (int) ", stdout);
|
* rtl.h (copy_rtx_ptr_loc, print_rtx_ptr_loc, join_c_conditions)
(print_c_condition): Declare.
* read-rtl.c (ptr_loc): New structure.
(ptr_locs, ptr_loc_obstack, joined_conditions)
(joined_conditions_obstack): New variables.
(leading_ptr_hash, leading_ptr_eq_p, set_rtx_ptr_loc)
(get_rtx_ptr_loc, copy_rtx_ptr_loc, print_rtx_ptr_loc)
(join_c_conditions, print_c_condition): New functions.
(apply_macro_to_string): Associate the new string with the same
source location as the old one.
(add_condition_to_string): Use join_c_conditions.
(read_string): Use set_rtx_ptr_loc to record a filename and line
number for the string.
(read_rtx): Initialize the new variables above.
* genattrtab.c (write_test_expr, write_attr_value): Use
print_c_condition.
* genconditions.c (write_header): Don't define MAYBE_EVAL. Move its
comment above the GCC_VERSION check.
(write_one_condition): Use print_rtx_ptr_loc and print_c_condition.
Inline the definition of MAYBE_EVAL.
* genemit.c (gen_expand, gen_split): Use print_rtx_ptr_loc.
* genoutput.c (process_template): Likewise.
* genpreds.c (write_predicate_subfunction): Likewise.
(write_predicate_expr): Use print_c_condition.
* genrecog.c (write_cond): Likewise.
* gensupport.c (process_rtx): Use join_c_conditions to join the
conditions of a define_insn_and_split. Record a source location
for the string after the "&&".
(alter_test_for_insn): Use join_c_conditions.
From-SVN: r95883
2005-03-04 12:10:35 +01:00
|
|
|
print_c_condition (test->expr);
|
2006-01-29 04:30:47 +01:00
|
|
|
fputs ("\n : -1 },\n", stdout);
|
2002-07-29 20:02:47 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out the complete conditions table, its size, and a flag
|
|
|
|
indicating that gensupport.c can now do insn elision. */
|
|
|
|
static void
|
2003-06-01 17:59:10 +02:00
|
|
|
write_conditions (void)
|
2002-07-29 20:02:47 +02:00
|
|
|
{
|
2006-01-26 22:21:42 +01:00
|
|
|
puts ("\
|
|
|
|
/* Structure definition duplicated from gensupport.h rather than\n\
|
|
|
|
drag in that file and its dependencies. */\n\
|
|
|
|
struct c_test\n\
|
|
|
|
{\n\
|
|
|
|
const char *expr;\n\
|
|
|
|
int value;\n\
|
2006-01-29 04:30:47 +01:00
|
|
|
};\n\
|
|
|
|
\n\
|
2002-07-29 20:02:47 +02:00
|
|
|
/* This table lists each condition found in the machine description.\n\
|
|
|
|
Each condition is mapped to its truth value (0 or 1), or -1 if that\n\
|
2006-01-26 22:21:42 +01:00
|
|
|
cannot be calculated at compile time.\n\
|
|
|
|
If we don't have __builtin_constant_p, or it's not acceptable in array\n\
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
initializers, fall back to assuming that all conditions potentially\n\
|
|
|
|
vary at run time. It works in 3.0.1 and later; 3.0 only when not\n\
|
|
|
|
optimizing. */\n\
|
2006-01-26 22:21:42 +01:00
|
|
|
\n\
|
2006-02-07 19:04:29 +01:00
|
|
|
#if GCC_VERSION >= 3001\n\
|
|
|
|
static const struct c_test insn_conditions[] = {\n");
|
2002-07-29 20:02:47 +02:00
|
|
|
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
traverse_c_tests (write_one_condition, 0);
|
2002-07-29 20:02:47 +02:00
|
|
|
|
2006-02-07 19:04:29 +01:00
|
|
|
puts ("\n};\n#endif /* gcc >= 3.0.1 */\n");
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
}
|
2002-07-29 20:02:47 +02:00
|
|
|
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
/* Emit code which will convert the C-format table to a
|
|
|
|
(define_conditions) form, which the MD reader can understand.
|
|
|
|
The result will be added to the set of files scanned by
|
|
|
|
'downstream' generators. */
|
|
|
|
static void
|
|
|
|
write_writer (void)
|
|
|
|
{
|
2006-01-26 22:21:42 +01:00
|
|
|
puts ("int\n"
|
|
|
|
"main(void)\n"
|
|
|
|
"{\n"
|
|
|
|
" unsigned int i;\n"
|
|
|
|
" const char *p;\n"
|
|
|
|
" puts (\"(define_conditions [\");\n"
|
2006-02-07 19:04:29 +01:00
|
|
|
"#if GCC_VERSION >= 3001\n"
|
2006-01-26 22:21:42 +01:00
|
|
|
" for (i = 0; i < ARRAY_SIZE (insn_conditions); i++)\n"
|
|
|
|
" {\n"
|
|
|
|
" printf (\" (%d \\\"\", insn_conditions[i].value);\n"
|
|
|
|
" for (p = insn_conditions[i].expr; *p; p++)\n"
|
|
|
|
" {\n"
|
|
|
|
" switch (*p)\n"
|
|
|
|
" {\n"
|
|
|
|
" case '\\\\':\n"
|
|
|
|
" case '\\\"': putchar ('\\\\'); break;\n"
|
|
|
|
" default: break;\n"
|
|
|
|
" }\n"
|
|
|
|
" putchar (*p);\n"
|
|
|
|
" }\n"
|
|
|
|
" puts (\"\\\")\");\n"
|
2006-01-29 04:30:47 +01:00
|
|
|
" }\n"
|
2006-02-07 19:04:29 +01:00
|
|
|
"#endif /* gcc >= 3.0.1 */\n"
|
2006-01-29 04:30:47 +01:00
|
|
|
" puts (\"])\");\n"
|
2006-01-26 22:21:42 +01:00
|
|
|
" fflush (stdout);\n"
|
|
|
|
"return ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;\n"
|
|
|
|
"}");
|
2002-07-29 20:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-06-01 17:59:10 +02:00
|
|
|
main (int argc, char **argv)
|
2002-07-29 20:02:47 +02:00
|
|
|
{
|
|
|
|
rtx desc;
|
|
|
|
int pattern_lineno; /* not used */
|
|
|
|
int code;
|
|
|
|
|
|
|
|
progname = "genconditions";
|
|
|
|
|
Makefile.in (build/genmddeps.o): Depend on $(READ_MD_H).
gcc/
* Makefile.in (build/genmddeps.o): Depend on $(READ_MD_H).
* genmddeps.c: Include read-md.h.
(main): Call init_rtx_reader_args instead of init_md_reader_args.
* genattr.c (main): Likewise.
* genattrtab.c (main): Likewise.
* genautomata.c (main): Likewise.
* gencodes.c (main): Likewise.
* genconditions.c (main): Likewise.
* genconfig.c (main): Likewise.
* genconstants.c (main): Likewise.
* genemit.c (main): Likewise.
* genextract.c (main): Likewise.
* genflags.c (main): Likewise.
* genopinit.c (main): Likewise.
* genoutput.c (main): Likewise.
* genpeep.c (main): Likewise.
* genrecog.c (main): Likewise.
* genpreds.c (main): Likewise.
* gensupport.h (in_fname): Move to read-md.h.
(init_md_reader_args_cb): Rename to...
(init_rtx_reader_args_cb): ...this and return a bool.
(init_md_reader_args): Rename to...
(init_rtx_reader_args): ...this and return a bool.
(include_callback): Move to read-md.h.
* gensupport.c (in_fname, include_callback, base_dir, max_include_len)
(file_name_list, first_dir_md_include): Move to read-md.c
(first_bracket_include): Delete unused variable.
(last_dir_md_include): Move to read-md.c.
(process_include): Delete, moving code to read-md.c:handle_include.
(process_rtx): Don't handle INCLUDE.
(save_string): Delete.
(rtx_handle_directive): New function.
(init_md_reader_args_cb): Rename to...
(init_rtx_reader_args_cb): ...this and return a boolean success value.
Use read_md_args.
(init_md_reader_args): Rename to...
(init_rtx_reader_args): ...this and return a boolean success value.
* rtl.def (INCLUDE): Delete.
* rtl.h (read_rtx): Remove "int *" argument. Add "const char *"
argument.
* read-rtl.c (read_conditions): Don't gobble ')' here.
(read_mapping): Likewise.
(read_rtx): Remove LINENO argument. Add RTX_NAME argument.
Handle top-level non-rtx constructs here rather than in read_rtx_1.
Store the whole queue in *X. Remove call to init_md_reader.
(read_rtx_1): Rename to...
(read_rtx_code): ...this. Call read_nested_rtx to read subrtxes.
Don't handle top-level non-rtx constructs here. Don't handle (nil)
here.
(read_nested_rtx): New function. Handle (nil) here rather than
in read_rtx_code.
(read_rtx_variadic): Call read_nested_rtx to read subrtxes. Don't
gobble ')' here.
* read-md.h (directive_handler_t): New type.
(in_fname, include_callback): Moved from read-md.h.
(read_constants, init_md_reader): Delete.
(read_md_files): Declare.
* read-md.c (file_name_list, in_fname, base_dir, first_dir_md_include)
(last_dir_md_include_ptr, include_callback, max_include_len): Moved
from gensupport.c.
(read_constants): Rename to...
(handle_constants): ...this. Don't gobble ')' here.
(handle_include, handle_file, handle_toplevel_file)
(parse_include): New functions, mostly taken from gensupport.c.
(init_md_reader): Subsume into...
(read_md_files): ...this new function.
From-SVN: r160577
2010-06-10 22:23:13 +02:00
|
|
|
if (!init_rtx_reader_args (argc, argv))
|
2002-07-29 20:02:47 +02:00
|
|
|
return (FATAL_EXIT_CODE);
|
|
|
|
|
|
|
|
/* Read the machine description. */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
desc = read_md_rtx (&pattern_lineno, &code);
|
|
|
|
if (desc == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* N.B. define_insn_and_split, define_cond_exec are handled
|
|
|
|
entirely within read_md_rtx; we never see them. */
|
|
|
|
switch (GET_CODE (desc))
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEFINE_INSN:
|
|
|
|
case DEFINE_EXPAND:
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
add_c_test (XSTR (desc, 2), -1);
|
2002-07-29 20:02:47 +02:00
|
|
|
/* except.h needs to know whether there is an eh_return
|
|
|
|
pattern in the machine description. */
|
|
|
|
if (!strcmp (XSTR (desc, 0), "eh_return"))
|
|
|
|
saw_eh_return = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEFINE_SPLIT:
|
|
|
|
case DEFINE_PEEPHOLE:
|
|
|
|
case DEFINE_PEEPHOLE2:
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
add_c_test (XSTR (desc, 1), -1);
|
2002-07-29 20:02:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
write_header ();
|
|
|
|
write_conditions ();
|
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
From-SVN: r110119
2006-01-23 16:15:05 +01:00
|
|
|
write_writer ();
|
2002-07-29 20:02:47 +02:00
|
|
|
|
|
|
|
fflush (stdout);
|
|
|
|
return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
|
|
|
|
}
|