diff options
author | Zack Weinberg <zack@bitmover.com> | 1999-08-31 19:39:10 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 1999-08-31 19:39:10 +0000 |
commit | ef178af3a4faba2594c5a106ca721a5c3db4f693 (patch) | |
tree | 0b67c4cdc852a2b9c74808c3b360549b5fc234f0 /gcc/rtl.c | |
parent | 8230525836955815b66b3e2a7a46fd6a0dbb7fd6 (diff) | |
download | gcc-ef178af3a4faba2594c5a106ca721a5c3db4f693.zip gcc-ef178af3a4faba2594c5a106ca721a5c3db4f693.tar.gz gcc-ef178af3a4faba2594c5a106ca721a5c3db4f693.tar.bz2 |
rtl.h (RTL_CHECK1, RTL_CHECK2): New macros which type- and bounds- check RTL accesses if --enable-checking.
1999-08-31 12:20 -0700 Zack Weinberg <zack@bitmover.com>
* rtl.h (RTL_CHECK1, RTL_CHECK2): New macros which type- and
bounds- check RTL accesses if --enable-checking.
(RTVEC_ELT): Bounds check if --enable-checking.
(XWINT, XINT, XSTR, XEXP, XVEC, XMODE, XBITMAP, XTREE,
XBBDEF): Use RTL_CHECK1/RTL_CHECK2 as appropriate.
(XVECEXP, XVECLEN): Define in terms of XVEC, RTVEC_ELT, and
GET_NUM_ELEM.
(X0WINT, X0INT, X0STR, X0EXP, X0VEC, X0MODE, X0BITMAP, X0TREE,
X0BBDEF, X0ADVFLAGS): New macros for accessing '0' slots of RTXes.
(ADDR_DIFF_VEC_FLAGS): Use X0ADVFLAGS.
(NOTE_SOURCE_FILE): Use X0STR.
(NOTE_BLOCK_NUMBER, NOTE_EH_HANDLER, LABEL_NUSES,
MEM_ALIAS_SET): Use X0INT.
(NOTE_RANGE_INFO, NOTE_LIVE_INFO, NOTE_BASIC_BLOCK,
JUMP_LABEL, LABEL_REFS, LABEL_NEXTREF, CONTAINING_INSN):
Use X0EXP.
* real.h (CONST_DOUBLE_CHAIN): Use X0EXP.
* rtl.c (copy_rtx, copy_most_rtx): Copy '0' slots with X0WINT.
(rtl_check_failed_bounds, rtl_check_failed_type1,
rtl_check_failed_type2, rtvec_check_failed_bounds): New
functions.
(fancy_abort): Fix comment.
* cse.c (canon_hash): Read CONST_DOUBLE data slots with XWINT.
(cse_insn): Decrement LABEL_NUSES for jump target before
deleting jump insn.
* emit-rtl.c (gen_rtx_CONST_DOUBLE): Use X0EXP for slot 1.
* final.c (alter_subreg): Compute regno before changing x to
REG; set REGNO(x) after changing it.
* flow.c (count_basic_blocks): Use XWINT to inspect EH_REGION
notes containing CONST_INTs.
(delete_eh_regions): Use NOTE_EH_HANDLER.
* function.c (put_reg_into_stack): Make reg a MEM before
initializing it.
(fixup_var_refs_insns): Save REG_NOTES (insn) in case we
delete insn.
(gen_mem_addressof): Make reg a MEM before initializing it.
* integrate.c (copy_rtx_and_substitute): Copy '0' slots with
X0WINT.
* local-alloc.c (update_equiv_regs): Zap REG_NOTES before
deleting an insn, not after.
(block_alloc): Only look at PATTERN(insn) if we have to, and
only if it's format class 'i'.
* loop.c (check_dbra_loop): Check bl->biv->add_val is a
CONST_INT before using its INTVAL.
* print-rtl.c (print_rtx): Use X0STR.
* regmove.c (fixup_match_1): Don't look at PATTERN of
non-class-'i' insn chain elements.
* reload.c (loc_mentioned_in_p): Take address of
in->fld[1].rtx directly.
* reload1.c (reload): Change reg to a MEM before initializing
it.
* varasm.c (mark_constant_pool): Skip CONST_DOUBLES, which
have no names.
* config/i386/i386.md (decrement_and_branch_if_zero): Fix typo.
From-SVN: r29008
Diffstat (limited to 'gcc/rtl.c')
-rw-r--r-- | gcc/rtl.c | 76 |
1 files changed, 71 insertions, 5 deletions
@@ -387,7 +387,6 @@ copy_rtx (orig) XEXP (copy, i) = copy_rtx (XEXP (orig, i)); break; - case '0': case 'u': XEXP (copy, i) = XEXP (orig, i); break; @@ -428,6 +427,11 @@ copy_rtx (orig) XSTR (copy, i) = XSTR (orig, i); break; + case '0': + /* Copy this through the wide int field; that's safest. */ + X0WINT (copy, i) = X0WINT (orig, i); + break; + default: abort (); } @@ -487,7 +491,6 @@ copy_most_rtx (orig, may_share) XEXP (copy, i) = copy_most_rtx (XEXP (orig, i), may_share); break; - case '0': case 'u': XEXP (copy, i) = XEXP (orig, i); break; @@ -522,6 +525,11 @@ copy_most_rtx (orig, may_share) XSTR (copy, i) = XSTR (orig, i); break; + case '0': + /* Copy this through the wide int field; that's safest. */ + X0WINT (copy, i) = X0WINT (orig, i); + break; + default: abort (); } @@ -934,6 +942,65 @@ read_rtx (infile) return return_rtx; } +#if defined ENABLE_CHECKING && (__GNUC__ > 2 || __GNUC_MINOR__ > 6) +void +rtl_check_failed_bounds (r, n, file, line, func) + rtx r; + int n; + const char *file; + int line; + const char *func; +{ + error ("RTL check: access of elt %d of `%s' with last elt %d", + n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r))-1); + fancy_abort (file, line, func); +} + +void +rtl_check_failed_type1 (r, n, c1, file, line, func) + rtx r; + int n; + int c1; + const char *file; + int line; + const char *func; +{ + error ("RTL check: expected elt %d type '%c', have '%c' (rtx %s)", + n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r))); + fancy_abort (file, line, func); +} + +void +rtl_check_failed_type2 (r, n, c1, c2, file, line, func) + rtx r; + int n; + int c1; + int c2; + const char *file; + int line; + const char *func; +{ + error ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s)", + n, c1, c2, + GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE(r))); + fancy_abort (file, line, func); +} + +/* XXX Maybe print the vector? */ +void +rtvec_check_failed_bounds (r, n, file, line, func) + rtvec r; + int n; + const char *file; + int line; + const char *func; +{ + error ("RTL check: access of elt %d of vector with last elt %d", + n, GET_NUM_ELEM (r)-1); + fancy_abort (file, line, func); +} +#endif /* ENABLE_CHECKING */ + /* These are utility functions used by fatal-error functions all over the code. rtl.c happens to be linked by all the programs that need them, so these are here. In the future we want to break out all error handling @@ -962,11 +1029,10 @@ trim_filename (name) } /* Report an internal compiler error in a friendly manner and without - dumping core. There are two versions because __FUNCTION__ isn't - available except in gcc 2.7 and later. */ + dumping core. */ extern void fatal PVPROTO ((const char *, ...)) - ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; + ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; void fancy_abort (file, line, function) |