ddef6bc7a3
2001-04-03 Jakub Jelinek <jakub@redhat.com> David S. Miller <davem@pierdol.cobaltmicro.com> Andrew MacLeod <amacleod@redhat.com> Use byte offsets in SUBREGs instead of words. * alias.c (nonlocal_mentioned_p): Use subreg_regno function. * caller-save.c (mark_set_regs): Change callers of subreg_hard_regno to pass new argument. (add_stored_regs): Use subreg_regno_offset function. * calls.c (expand_call): For non-paradoxical SUBREG take endianess into account. (precompute_arguments): Use gen_lowpart_SUBREG. * combine.c (try_combine): Replace explicit XEXP with SUBREG_REG. (combine_simplify_rtx): Rework to use SUBREG_BYTE. (simplify_set): Rework to use SUBREG_BYTE. (expand_field_assignment): Use SUBREG_BYTE. (make_extraction): Use SUBREG_BYTE. (if_then_else_cond): Use SUBREG_BYTE. (apply_distributive_law): Use SUBREG_BYTE and fixup subreg comments. (gen_lowpart_for_combine): Compute full byte offset. * cse.c (mention_regs): Use SUBREG_BYTE. (remove_invalid_subreg_refs): Rework to use SUBREG_BYTE. (canon_hash): Use SUBREG_BYTE. (fold_rtx): Pass SUBREG_BYTE div UNITS_PER_WORD to operand_subword. (gen_lowpart_if_possible): Formatting. * dbxout.c (dbxout_symbol_location): Compute SUBREG hard regnos correctly. * dwarf2out.c (is_pseudo_reg): Fixup explicit XEXP into SUBREG_REG (mem_loc_descriptor): Fixup explicit XEXP into SUBREG_REG (loc_descriptor): Fixup explicit XEXP into SUBREG_REG * dwarfout.c (is_pseudo_reg): Fixup explicit XEXP into SUBREG_REG (output_mem_loc_descriptor): Fixup explicit XEXP into SUBREG_REG (output_loc_descriptor): Fixup explicit XEXP into SUBREG_REG * emit-rtl.c (gen_rtx_SUBREG): New function, used to verify certain invariants about SUBREGs the compiler creates. (gen_lowpart_SUBREG): New function. (subreg_hard_regno): New function to get the final register number. (gen_lowpart_common): Use SUBREG_BYTE. (gen_imagpart): Spacing nits. (subreg_realpart_p): Use SUBREG_BYTE. (gen_highpart): Use SUBREG_BYTE. (subreg_lowpart_p): Always compute endian corrected goal offset, even at the byte level, then compare against that. (constant_subword): New function, pulled out all constant cases from operand_subword and changed second argument name to offset. (operand_subword): Detect non REG/SUBREG/CONCAT/MEM cases early and call constant_subword to do the work. Return const0_rtx if looking for a word outside of OP. (operand_subword_force): Change second arg name to offset. * expmed.c (store_bit_field): Use SUBREG_BYTE. (store_split_bit_field): Use SUBREG_BYTE. (extract_bit_field): Use SUBREG_BYTE. (extract_split_bit_field): Use SUBREG_BYTE. (expand_shift): Use SUBREG_BYTE. * expr.c (store_expr, expand_expr): Use gen_lowpart_SUBREG. * final.c (alter_subreg) Use subreg_hard_regno and SUBREG_BYTE. * flow.c (set_noop_p): Use SUBREG_BYTE. (mark_set_1): Remove ALTER_HARD_SUBREG. Use subreg_regno_offset instead. * function.c (fixup_var_refs_1): Fixup explicit XEXP into a SUBREG_REG. (fixup_memory_subreg): Use SUBREG_BYTE and remove byte endian correction code. (optimize_bit_field): Use SUBREG_BYTE. (purge_addressof_1): Use SUBREG_BYTE. (purge_single_hard_subreg_set): Use subreg_regno_offset function. (assign_params): Mark arguments SUBREG_PROMOTED_VAR_P if they are actually promoted by the caller and PROMOTE_FOR_CALLS_ONLY is true. * gengenrtl.c (special_rtx): Add SUBREG. * global.c (mark_reg_store): Use SUBREG_BYTE. (set_preference): Rework to use subreg_regno_offset and SUBREG_BYTE. * ifcvt (noce_emit_move_insn): Use SUBREG_BYTE. * integrate.c (copy_rtx_and_substitute): Use SUBREG_BYTE and make sure final byte offset is congruent to subreg's mode size. (subst_constants): Use SUBREG_BYTE. (mark_stores): Use subreg_regno_offset function. * jump.c (rtx_renumbered_equal_p, true_regnum): Use subreg_regno_offset function and SUBREG_BYTE. * local-alloc.c (combine_regs): Use subreg_regno_offset function. (reg_is_born): Use subreg_hard_regno. * recog.c (valid_replace_rtx_1): Use SUBREG_BYTE and remove byte endian correction code. Don't combine subregs unless resulting offset aligns with type. Fix subreg constant extraction for DImode. Simplify SUBREG of VOIDmode CONST_DOUBLE. (general_operand): Remove dead mode_altering_drug code. (indirect_operand): Use SUBREG_BYTE. (constrain_operands): Use subreg_regno_offset function. * reg-stack.c (get_true_reg): Use subreg_regno_offset function. * regmove.c (regmove_optimize): Use SUBREG_BYTE. (optimize_reg_copy_3): Use gen_lowpart_SUBREG. * regs.h (REG_SIZE): Allow target to override. (REGMODE_NATURAL_SIZE): New macro which target can override. * reload.c (reload_inner_reg_of_subreg): subreg_regno should be used on the entire subreg rtx. (push_reload): Use SUBREG_BYTE in comments and code. (find_dummy_reload): Use subreg_regno_offset. Only adjust offsets for hard registers inside subregs. (operands_match_p): Use subreg_regno_offset. (find_reloads): Use SUBREG_BYTE and only advance offset for subregs containing hard regs. (find_reload_toplev): Use SUBREG_BYTE. Remove byte endian corrections when fixing up MEM subregs. (find_reloads_address_1): Use SUBREG_BYTE, subreg_regno, and subreg_regno_offset where appropriate. (find_reloads_subreg_address): Use SUBREG_BYTE. Remove byte endian corrections when fixing up MEM subregs. (subst_reloads): When combining two subregs, make sure final offset is congruent to subreg's mode size. (find_replacement): Use SUBREG_BYTE and subreg_regno_offset. (refers_to_regno_for_reload_p): Use subreg_regno. (reg_overlap_mentioned_for_reload_p): Use subreg_regno_offset. * reload1.c (eliminate_regs) Use SUBREG_BYTE. Remove byte endian correction code for memory subreg fixups. (forget_old_reload_1): Use subreg_regno_offset. (choose_reload_regs): Use subreg_regno. (emit_input_reload_insns): Use SUBREG_BYTE. (reload_combine_note_store): Use subreg_regno_offset. (move2add_note_store): Use subreg_regno_offset. * resource.c (update_live_status, mark_referenced_resources): Use subreg_regno function. (mark_set_resources): Use subreg_regno function. * rtl.h (SUBREG_WORD): Rename to SUBREG_BYTE. (subreg_regno_offset, subreg_regno): Define prototypes. (subreg_hard_regno, constant_subword, gen_rtx_SUBREG): Newi functions. (gen_lowpart_SUBREG): Add prototype. * rtl.texi (subreg): Update to reflect new byte offset representation. Add mentioning of the effect that BYTES_BIG_ENDIAN has on subregs now. * rtlanal.c (refers_to_regno_p): Use subreg_regno. (reg_overlap_mentioned_p): Use subreg_regno. (replace_regs); Make sure final offset of combined subreg is congruent to size of subreg's mode. (subreg_regno_offset): New function. (subreg_regno): New function. * sched-vis.c (print_value): Change SUBREG_WORD to SUBREG_BYTE. * sdbout.c (sdbout_symbol): Compute offset using alter_subreg. * stmt.c (expand_anon_union_decl): Use gen_lowpart_SUBREG. * tm.texi (ALTER_HARD_SUBREG): Remove, it is now dead. (SUBREG_REGNO_OFFSET): Describe SUBREG_REGNO_OFFSET overrides. * config/a29k/a29k.c (gpc_reg_operand): Use subreg_regno. (a29k_get_reloaded_address): Use SUBREG_BYTE. (print_operand): Use SUBREG_BYTE. * config/alpha/alpha.c (print_operand_address): Use SUBREG_BYTE. * config/arm/arm.c (arm_reload_in_hi): Use SUBREG_BYTE. (arm_reload_out_hi): Use SUBREG_BYTE. * config/d30v/d30v.c (d30v_split_double): Use subreg_regno_offset instead of SUBREG_WORD. (d30v_print_operand_memory_reference): Use subreg_regno_offset. * config/dsp16xx/dsp16xx.md (extendqihi2, zero_extendqihi2): Fix SUBREG creation to use byte offset. * config/h8300/h8300.md (Unnamed HImode zero extraction and 16bit inverted load insns): Fix explicit rtl subregs to use byte offsets. * config/i370/i370.md (cmpstrsi, movstrsi, mulsi3, divsi3, udivsi3, umodsi3): Generate SUBREGs with byte offsets. * config/i860/i860.c (single_insn_src_p): Use SUBREG_BYTE. * config/i860/i860.md (mulsi3_big): Fixup explicit SUBREGs in rtl to use byte offsets. (unnamed fmlow.dd insn): Fixup SUBREGS to use byte offsets. * config/i960/i960.md (extendhisi2): Generate SUBREGs with byte offsets, also make sure it is congruent to SUBREG's mode size. (extendqisi2, extendqihi2, zero_extendhisi2, zero_extendqisi2, unnamed ldob insn): Generate SUBREGs with byte offset. (zero_extendqihi2): SUBREG's are byte offsets. * config/m68hc11/m68hc11.c (m68hc11_gen_lowpart): Use SUBREG_BYTE. (m68hc11_gen_highpart): Use SUBREG_BYTE. * config/m68k/m68k.md (zero_extendhisi2, zero_extendqihi2, zero-extendqisi2): Generate SUBREGs with byte offset. (umulsidi3, mulsidi3, subreghi1ashrdi_const32, subregsi1ashrdi_const32, subreg1lshrdi_const32): Fixup explicit subregs in rtl to use byte offsets. * config/m88k/m88k.md (extendsidi2): fixup subregs to use byte offset. * config/mips/mips.c (mips_move_1word): Use subreg_regno_offset. (mips_move_2words): Use subreg_regno_offset. (mips_secondary_reload_class): Use subreg_regno_offset. * config/mips/mips.md (DImode plus, minus, move, and logical op splits): Fixup explicit subregs in rtl to use byte offsets. * config/mn10200/mn10200.c (print_operand): Use subreg_regno function. * config/mn10300/mn10300.c (print_operand): Use subreg_regno function. * config/ns32k/ns32k.md (udivmoddisi4): Fix explicit subregs in rtl to use byte offsets. * config/pa/pa.c (emit_move_sequence): Use SUBREG_BYTE. * config/pa/pa.md (floatunssisf2, floatunssidf2, mulsi3): fix explicit subregs to use byte offsets. * config/pdp11/pdp11.md (zero_extendhisi2, modhi3, modhi3+1): Fixup explicit subregs in rtl to use byte offsets. * config/romp/romp.c (memory_offset_in_range_p): Use SUBREG_BYTE and remove byte endian correction code. * config/sh/sh.c (output_movedouble): Use subreg_regno. (gen_ashift_hi): Use SUBREG_BYTE. (regs_used): Use subreg_regno_offset. (machine_dependent_reorg): Use subreg_regno_offset. * config/sh/sh.h (INDEX_REGISTER_RTX_P): Use SUBREG_BYTE. * config/sh/sh.md (DImode and DFmode move splits): Use subreg_regno. (movdf_i4): Subregs are byte offsets now. * config/sparc/sparc.c (ultra_find_type): Use SUBREG_BYTE. * config/sparc/sparc.h (ALTER_HARD_SUBREG): Removed. (REGMODE_NATURAL_SIZE): Override. (REG_SIZE): For SUBREG check float mode on SUBREG_REG's mode. * config/sparc/sparc.md (TFmode move splits): Generate SUBREGs with byte offsets. (zero_extendhisi2, zero_extendqidi2_insn, extendhisi2, extendqihi2, sign_extendqihi2_insn, sign_extendqisi2_insn, extendqidi2): Generate SUBREGs with byte offsets, also make sure it is congruent to SUBREG's mode size. (smulsi3_highpart_v8plus): Fix explicit subregs in rtl to use byte offsets. (cmp_siqi_trunc, cmp_siqi_trunc_set, cmp_diqi_trunc, cmp_diqi_trunc_set, lshrdi3_v8plus+1, lshrdi3_v8plus+2, lshrdi3_v8plus+3, lshrdi3_v8plus+4): Use proper SUBREG_BYTE offset for non-paradoxical subregs in patterns. * config/v850/v850.c (print_operand, output_move_double): Use subreg_regno function. Co-Authored-By: Andrew MacLeod <amacleod@redhat.com> Co-Authored-By: David S. Miller <davem@pierdol.cobaltmicro.com> From-SVN: r41058
434 lines
9.9 KiB
C
434 lines
9.9 KiB
C
/* Generate code to allocate RTL structures.
|
||
Copyright (C) 1997, 1998, 1999, 2000 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 "system.h"
|
||
|
||
#define NO_GENRTL_H
|
||
#include "rtl.h"
|
||
#undef abort
|
||
|
||
#include "real.h"
|
||
|
||
/* Calculate the format for CONST_DOUBLE. This depends on the relative
|
||
widths of HOST_WIDE_INT and REAL_VALUE_TYPE.
|
||
|
||
We need to go out to e0wwwww, since REAL_ARITHMETIC assumes 16-bits
|
||
per element in REAL_VALUE_TYPE.
|
||
|
||
This is duplicated in rtl.c.
|
||
|
||
A number of places assume that there are always at least two 'w'
|
||
slots in a CONST_DOUBLE, so we provide them even if one would suffice. */
|
||
|
||
#ifdef REAL_ARITHMETIC
|
||
# if MAX_LONG_DOUBLE_TYPE_SIZE == 96
|
||
# define REAL_WIDTH \
|
||
(11*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT
|
||
# else
|
||
# if MAX_LONG_DOUBLE_TYPE_SIZE == 128
|
||
# define REAL_WIDTH \
|
||
(19*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT
|
||
# else
|
||
# if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
|
||
# define REAL_WIDTH \
|
||
(7*8 + HOST_BITS_PER_WIDE_INT)/HOST_BITS_PER_WIDE_INT
|
||
# endif
|
||
# endif
|
||
# endif
|
||
#endif /* REAL_ARITHMETIC */
|
||
|
||
#ifndef REAL_WIDTH
|
||
# if HOST_BITS_PER_WIDE_INT*2 >= MAX_LONG_DOUBLE_TYPE_SIZE
|
||
# define REAL_WIDTH 2
|
||
# else
|
||
# if HOST_BITS_PER_WIDE_INT*3 >= MAX_LONG_DOUBLE_TYPE_SIZE
|
||
# define REAL_WIDTH 3
|
||
# else
|
||
# if HOST_BITS_PER_WIDE_INT*4 >= MAX_LONG_DOUBLE_TYPE_SIZE
|
||
# define REAL_WIDTH 4
|
||
# endif
|
||
# endif
|
||
# endif
|
||
#endif /* REAL_WIDTH */
|
||
|
||
#if REAL_WIDTH == 1
|
||
# define CONST_DOUBLE_FORMAT "e0ww"
|
||
#else
|
||
# if REAL_WIDTH == 2
|
||
# define CONST_DOUBLE_FORMAT "e0ww"
|
||
# else
|
||
# if REAL_WIDTH == 3
|
||
# define CONST_DOUBLE_FORMAT "e0www"
|
||
# else
|
||
# if REAL_WIDTH == 4
|
||
# define CONST_DOUBLE_FORMAT "e0wwww"
|
||
# else
|
||
# if REAL_WIDTH == 5
|
||
# define CONST_DOUBLE_FORMAT "e0wwwww"
|
||
# else
|
||
# define CONST_DOUBLE_FORMAT /* nothing - will cause syntax error */
|
||
# endif
|
||
# endif
|
||
# endif
|
||
# endif
|
||
#endif
|
||
|
||
|
||
struct rtx_definition
|
||
{
|
||
const char *enumname, *name, *format;
|
||
};
|
||
|
||
#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) { STRINGX(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 PARAMS ((int));
|
||
static const char *accessor_from_format PARAMS ((int));
|
||
static int special_format PARAMS ((const char *));
|
||
static int special_rtx PARAMS ((int));
|
||
static void find_formats PARAMS ((void));
|
||
static void gendecl PARAMS ((const char *));
|
||
static void genmacro PARAMS ((int));
|
||
static void gendef PARAMS ((const char *));
|
||
static void genlegend PARAMS ((void));
|
||
static void genheader PARAMS ((void));
|
||
static void gencode PARAMS ((void));
|
||
|
||
/* Decode a format letter into a C type string. */
|
||
|
||
static const char *
|
||
type_from_format (c)
|
||
int c;
|
||
{
|
||
switch (c)
|
||
{
|
||
case 'i':
|
||
return "int ";
|
||
|
||
case 'w':
|
||
return "HOST_WIDE_INT ";
|
||
|
||
case 's':
|
||
return "const char *";
|
||
|
||
case 'e': case 'u':
|
||
return "rtx ";
|
||
|
||
case 'E':
|
||
return "rtvec ";
|
||
case 'b':
|
||
return "struct bitmap_head_def *"; /* bitmap - typedef not available */
|
||
case 't':
|
||
return "union tree_node *"; /* tree - typedef not available */
|
||
default:
|
||
abort ();
|
||
}
|
||
}
|
||
|
||
/* Decode a format letter into the proper accessor function. */
|
||
|
||
static const char *
|
||
accessor_from_format (c)
|
||
int 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";
|
||
|
||
case 'b':
|
||
return "XBITMAP";
|
||
|
||
case 't':
|
||
return "XTREE";
|
||
|
||
default:
|
||
abort ();
|
||
}
|
||
}
|
||
|
||
/* Return nonzero if we should ignore FMT, an RTL format, when making
|
||
the list of formats we write routines to create. */
|
||
|
||
static int
|
||
special_format (fmt)
|
||
const char *fmt;
|
||
{
|
||
return (strchr (fmt, '*') != 0
|
||
|| strchr (fmt, 'V') != 0
|
||
|| strchr (fmt, 'S') != 0
|
||
|| strchr (fmt, 'n') != 0);
|
||
}
|
||
|
||
/* Return nonzero if the RTL code given by index IDX is one that we should not
|
||
generate a gen_RTX_FOO function foo (because that function is present
|
||
elsewhere in the compiler). */
|
||
|
||
static int
|
||
special_rtx (idx)
|
||
int idx;
|
||
{
|
||
return (strcmp (defs[idx].enumname, "CONST_INT") == 0
|
||
|| strcmp (defs[idx].enumname, "CONST_DOUBLE") == 0
|
||
|| strcmp (defs[idx].enumname, "REG") == 0
|
||
|| strcmp (defs[idx].enumname, "SUBREG") == 0
|
||
|| strcmp (defs[idx].enumname, "MEM") == 0);
|
||
}
|
||
|
||
/* Place a list of all format specifiers we use into the array FORMAT. */
|
||
|
||
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 == 0)
|
||
*f = defs[i].format;
|
||
}
|
||
}
|
||
|
||
/* Write the declarations for the routine to allocate RTL with FORMAT. */
|
||
|
||
static void
|
||
gendecl (format)
|
||
const char *format;
|
||
{
|
||
const char *p;
|
||
int i, pos;
|
||
|
||
printf ("extern rtx gen_rtx_fmt_%s\tPARAMS ((RTX_CODE, ", format);
|
||
printf ("enum machine_mode mode");
|
||
|
||
/* Write each parameter that is needed and start a new line when the line
|
||
would overflow. */
|
||
for (p = format, i = 0, pos = 75; *p != 0; p++)
|
||
if (*p != '0')
|
||
{
|
||
int ourlen = strlen (type_from_format (*p)) + 6 + (i > 9);
|
||
|
||
printf (",");
|
||
if (pos + ourlen > 76)
|
||
printf ("\n\t\t\t\t "), pos = 39;
|
||
|
||
printf (" %sarg%d", type_from_format (*p), i++);
|
||
pos += ourlen;
|
||
}
|
||
|
||
printf ("));\n");
|
||
}
|
||
|
||
/* Generate macros to generate RTL of code IDX using the functions we
|
||
write. */
|
||
|
||
static void
|
||
genmacro (idx)
|
||
int idx;
|
||
{
|
||
const char *p;
|
||
int i;
|
||
|
||
/* We write a macro that defines gen_rtx_RTLCODE to be an equivalent to
|
||
gen_rtx_fmt_FORMAT where FORMAT is the RTX_FORMAT of RTLCODE. */
|
||
|
||
printf ("#define gen_rtx_%s%s(MODE",
|
||
special_rtx (idx) ? "raw_" : "", defs[idx].enumname);
|
||
|
||
for (p = defs[idx].format, i = 0; *p != 0; p++)
|
||
if (*p != '0')
|
||
printf (", ARG%d", i++);
|
||
|
||
printf (") \\\n gen_rtx_fmt_%s (%s, (MODE)",
|
||
defs[idx].format, defs[idx].enumname);
|
||
|
||
for (p = defs[idx].format, i = 0; *p != 0; p++)
|
||
if (*p != '0')
|
||
printf (", (ARG%d)", i++);
|
||
|
||
puts (")");
|
||
}
|
||
|
||
/* Generate the code for the function to generate RTL whose
|
||
format is FORMAT. */
|
||
|
||
static void
|
||
gendef (format)
|
||
const char *format;
|
||
{
|
||
const char *p;
|
||
int i, j;
|
||
|
||
/* Start by writing the definition of the function name and the types
|
||
of the arguments. */
|
||
|
||
printf ("rtx\ngen_rtx_fmt_%s (code, mode", format);
|
||
for (p = format, i = 0; *p != 0; p++)
|
||
if (*p != '0')
|
||
printf (", arg%d", i++);
|
||
|
||
puts (")\n RTX_CODE code;\n enum machine_mode mode;");
|
||
for (p = format, i = 0; *p != 0; p++)
|
||
if (*p != '0')
|
||
printf (" %sarg%d;\n", type_from_format (*p), i++);
|
||
|
||
/* Now write out the body of the function itself, which allocates
|
||
the memory and initializes it. */
|
||
puts ("{");
|
||
puts (" rtx rt;");
|
||
printf (" rt = ggc_alloc_rtx (%d);\n", (int) strlen (format));
|
||
|
||
puts (" memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion));\n");
|
||
puts (" PUT_CODE (rt, code);");
|
||
puts (" PUT_MODE (rt, mode);");
|
||
|
||
for (p = format, i = j = 0; *p ; ++p, ++i)
|
||
if (*p != '0')
|
||
printf (" %s (rt, %d) = arg%d;\n", accessor_from_format (*p), i, j++);
|
||
else
|
||
printf (" X0EXP (rt, %d) = NULL_RTX;\n", i);
|
||
|
||
puts ("\n return rt;\n}\n");
|
||
}
|
||
|
||
/* Generate the documentation header for files we write. */
|
||
|
||
static void
|
||
genlegend ()
|
||
{
|
||
puts ("/* Generated automatically by gengenrtl from rtl.def. */\n");
|
||
}
|
||
|
||
/* Generate the text of the header file we make, genrtl.h. */
|
||
|
||
static void
|
||
genheader ()
|
||
{
|
||
int i;
|
||
const char **fmt;
|
||
|
||
puts ("#ifndef GCC_GENRTL_H");
|
||
puts ("#define GCC_GENRTL_H\n");
|
||
|
||
for (fmt = formats; *fmt; ++fmt)
|
||
gendecl (*fmt);
|
||
|
||
putchar ('\n');
|
||
|
||
for (i = 0; i < NUM_RTX_CODE; i++)
|
||
if (! special_format (defs[i].format))
|
||
genmacro (i);
|
||
|
||
puts ("\n#endif /* GCC_GENRTL_H */");
|
||
}
|
||
|
||
/* Generate the text of the code file we write, genrtl.c. */
|
||
|
||
static void
|
||
gencode ()
|
||
{
|
||
const char **fmt;
|
||
|
||
puts ("#include \"config.h\"");
|
||
puts ("#include \"system.h\"");
|
||
puts ("#include \"obstack.h\"");
|
||
puts ("#include \"rtl.h\"");
|
||
puts ("#include \"ggc.h\"\n");
|
||
puts ("extern struct obstack *rtl_obstack;\n");
|
||
puts ("#define obstack_alloc_rtx(n) \\");
|
||
puts (" ((rtx) obstack_alloc (rtl_obstack, \\");
|
||
puts (" sizeof (struct rtx_def) \\");
|
||
puts (" + ((n) - 1) * sizeof (rtunion)))\n");
|
||
|
||
for (fmt = formats; *fmt != 0; fmt++)
|
||
gendef (*fmt);
|
||
}
|
||
|
||
#if defined(USE_C_ALLOCA)
|
||
PTR
|
||
xmalloc (nbytes)
|
||
size_t nbytes;
|
||
{
|
||
register PTR tmp = (PTR) really_call_malloc (nbytes);
|
||
|
||
if (!tmp)
|
||
{
|
||
fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n",
|
||
nbytes);
|
||
exit (FATAL_EXIT_CODE);
|
||
}
|
||
|
||
return tmp;
|
||
}
|
||
#endif /* USE_C_ALLOCA */
|
||
|
||
/* This is the main program. We accept only one argument, "-h", which
|
||
says we are writing the genrtl.h file. Otherwise we are writing the
|
||
genrtl.c file. */
|
||
extern int main PARAMS ((int, char **));
|
||
|
||
int
|
||
main (argc, argv)
|
||
int argc;
|
||
char **argv;
|
||
{
|
||
find_formats ();
|
||
genlegend ();
|
||
|
||
if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'h')
|
||
genheader ();
|
||
else
|
||
gencode ();
|
||
|
||
if (ferror (stdout) || fflush (stdout) || fclose (stdout))
|
||
return FATAL_EXIT_CODE;
|
||
|
||
return SUCCESS_EXIT_CODE;
|
||
}
|