diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c811552b2f1..f8e2ea55c9a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,25 @@ 2000-07-27 Alexandre Oliva + * Makefile.in (INSN_ATTR_H): New macro. Replace all dependencies + on insn-attr.h with it. + * genattr.c: Generate `#include "insn-addr.h"' if HAVE_ATTR_length. + * insn-addr.h: New header. + (insn_addresses_): Renamed from insn_addresses. + (INSN_ADDRESSES_DEFN, INSN_ADDRESSES, INSN_ADDRESSES_ALLOC, + INSN_ADDRESSES_FREE, INSN_ADDRESSES_SET_P, INSN_ADDRESSES_SIZE, + INSN_ADDRESSES_NEW): New macros. + * genattrtab.c (write_test_expr): Use new macros. + * final.c (insn_addresses, init_insn_lengths): Likewise. + (align_fuzz, shorten_branches): Likewise. + (final): Likewise. Do not reject new insns if their addresses + have been added to INSN_ADDRESSES. + * config/arm/arm.c, config/avr/avr.c: Use new macros. + * config/h8300/h8300.c, config/i370/i370.c: Likewise. + * config/m88k/m88k.c, config/pa/pa.c, config/pa/pa.md: Likewise. + * config/sparc/sparc.c, config/sparc/sparc.md: Likewise. + * config/sh/sh.c: Likewise. + (output_branchy_insn): Use INSN_ADDRESSES_NEW. + * Makefile.in (bootstrap): Move -BstageN/ back to the beginning. 2000-07-27 Andrew Cagney diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 9a773f4f904..85e33d62fa0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -777,6 +777,7 @@ LOOP_H = loop.h varray.h bitmap.h GCC_H = gcc.h version.h GGC_H = ggc.h varray.h TIMEVAR_H = timevar.h timevar.def +INSN_ATTR_H = insn-attr.h $(srcdir)/insn-addr.h $(srcdir)/varray.h # # Language makefile fragments. @@ -1238,9 +1239,9 @@ fold-const.o : fold-const.c $(CONFIG_H) system.h $(TREE_H) flags.h toplev.h \ $(RTL_H) ggc.h diagnostic.o : diagnostic.c diagnostic.h \ $(CONFIG_H) system.h $(TREE_H) $(RTL_H) tm_p.h flags.h \ - $(GGC_H) input.h insn-attr.h insn-codes.h insn-config.h toplev.h intl.h + $(GGC_H) input.h $(INSN_ATTR_H) insn-codes.h insn-config.h toplev.h intl.h toplev.o : toplev.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) function.h \ - flags.h input.h insn-attr.h xcoffout.h defaults.h output.h diagnostic.h \ + flags.h input.h $(INSN_ATTR_H) xcoffout.h defaults.h output.h diagnostic.h \ insn-codes.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h dwarfout.h \ dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \ graph.h loop.h except.h regs.h $(TIMEVAR_H) $(lang_options_files) @@ -1310,7 +1311,7 @@ integrate.o : integrate.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \ intl.h function.h output.h $(RECOG_H) except.h toplev.h $(LOOP_H) jump.o : jump.c $(CONFIG_H) system.h $(RTL_H) flags.h hard-reg-set.h $(REGS_H) \ insn-config.h insn-flags.h $(RECOG_H) $(EXPR_H) real.h except.h function.h \ - toplev.h insn-attr.h + toplev.h $(INSN_ATTR_H) simplify-rtx.o : simplify-rtx.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) \ hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \ @@ -1324,9 +1325,9 @@ sibcall.o : sibcall.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) function.h \ hard-reg-set.h flags.h insn-config.h $(RECOG_H) $(BASIC_BLOCK_H) resource.o : resource.c $(CONFIG_H) $(RTL_H) hard-reg-set.h system.h \ $(BASIC_BLOCK_H) $(REGS_H) flags.h output.h resource.h function.h toplev.h \ - insn-attr.h except.h + $(INSN_ATTR_H) except.h lcm.o : lcm.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) hard-reg-set.h flags.h \ - real.h insn-config.h insn-attr.h $(RECOG_H) $(EXPR_H) $(BASIC_BLOCK_H) + real.h insn-config.h $(INSN_ATTR_H) $(RECOG_H) $(EXPR_H) $(BASIC_BLOCK_H) ssa.o : ssa.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) $(BASIC_BLOCK_H) \ output.h insn-config.h conflict.o : conflict.c $(CONFIG_H) system.h $(OBSTACK_H) $(HASHTAB_H) \ @@ -1344,14 +1345,14 @@ flow.o : flow.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h insn-config.h \ $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \ insn-flags.h function.h except.h $(EXPR_H) combine.o : combine.c $(CONFIG_H) system.h $(RTL_H) flags.h function.h \ - insn-config.h insn-flags.h insn-codes.h insn-attr.h $(REGS_H) $(EXPR_H) \ + insn-config.h insn-flags.h insn-codes.h $(INSN_ATTR_H) $(REGS_H) $(EXPR_H) \ $(BASIC_BLOCK_H) $(RECOG_H) real.h hard-reg-set.h toplev.h regclass.o : regclass.c $(CONFIG_H) system.h $(RTL_H) hard-reg-set.h flags.h \ $(BASIC_BLOCK_H) $(REGS_H) insn-config.h $(RECOG_H) reload.h real.h \ toplev.h function.h output.h $(GGC_H) local-alloc.o : local-alloc.c $(CONFIG_H) system.h $(RTL_H) flags.h \ $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h insn-config.h $(RECOG_H) \ - output.h function.h insn-attr.h toplev.h + output.h function.h $(INSN_ATTR_H) toplev.h bitmap.o : bitmap.c $(CONFIG_H) system.h $(RTL_H) flags.h $(BASIC_BLOCK_H) \ $(REGS_H) global.o : global.c $(CONFIG_H) system.h $(RTL_H) flags.h reload.h function.h \ @@ -1367,7 +1368,7 @@ caller-save.o : caller-save.c $(CONFIG_H) system.h $(RTL_H) flags.h \ $(REGS_H) hard-reg-set.h insn-config.h $(BASIC_BLOCK_H) function.h \ $(RECOG_H) reload.h $(EXPR_H) toplev.h reorg.o : reorg.c $(CONFIG_H) system.h $(RTL_H) conditions.h hard-reg-set.h \ - $(BASIC_BLOCK_H) $(REGS_H) insn-config.h insn-attr.h insn-flags.h \ + $(BASIC_BLOCK_H) $(REGS_H) insn-config.h $(INSN_ATTR_H) insn-flags.h \ $(RECOG_H) function.h flags.h output.h $(EXPR_H) toplev.h alias.o : alias.c $(CONFIG_H) system.h $(RTL_H) flags.h hard-reg-set.h \ $(REGS_H) toplev.h output.h $(EXPR_H) insn-flags.h $(GGC_H) function.h \ @@ -1377,14 +1378,14 @@ regmove.o : regmove.c $(CONFIG_H) system.h $(RTL_H) insn-config.h \ $(EXPR_H) insn-flags.h $(BASIC_BLOCK_H) toplev.h haifa-sched.o : haifa-sched.c $(CONFIG_H) system.h $(RTL_H) \ $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \ - insn-attr.h toplev.h $(RECOG_H) except.h + $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h final.o : final.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h intl.h \ - $(REGS_H) $(RECOG_H) conditions.h insn-config.h insn-attr.h function.h \ + $(REGS_H) $(RECOG_H) conditions.h insn-config.h $(INSN_ATTR_H) function.h \ real.h output.h hard-reg-set.h insn-flags.h insn-codes.h gstab.h except.h \ xcoffout.h defaults.h toplev.h reload.h dwarfout.h dwarf2out.h sdbout.h \ dbxout.h $(BASIC_BLOCK_H) recog.o : recog.c $(CONFIG_H) system.h $(RTL_H) function.h $(BASIC_BLOCK_H) \ - $(REGS_H) $(RECOG_H) hard-reg-set.h flags.h insn-config.h insn-attr.h \ + $(REGS_H) $(RECOG_H) hard-reg-set.h flags.h insn-config.h $(INSN_ATTR_H) \ insn-flags.h insn-codes.h real.h toplev.h output.h reg-stack.o : reg-stack.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) $(RECOG_H) \ $(REGS_H) hard-reg-set.h flags.h insn-config.h insn-flags.h toplev.h \ @@ -1405,7 +1406,7 @@ ifcvt.o : ifcvt.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) \ output.h $(out_object_file): $(out_file) $(CONFIG_H) $(TREE_H) $(GGC_H) \ $(RTL_H) $(REGS_H) hard-reg-set.h real.h insn-config.h conditions.h \ - insn-flags.h output.h insn-attr.h insn-codes.h system.h toplev.h function.h + insn-flags.h output.h $(INSN_ATTR_H) insn-codes.h system.h toplev.h function.h $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(out_file) # Build auxiliary files that support ecoff format. @@ -1528,7 +1529,7 @@ s-peep : $(md_file) genpeep $(srcdir)/move-if-change touch s-peep insn-attrtab.o : insn-attrtab.c $(CONFIG_H) $(RTL_H) $(REGS_H) real.h \ - output.h insn-attr.h insn-config.h system.h toplev.h $(RECOG_H) + output.h $(INSN_ATTR_H) insn-config.h system.h toplev.h $(RECOG_H) $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c insn-attrtab.c insn-attr.h: s-attr ; @true @@ -1544,7 +1545,7 @@ s-attrtab : $(md_file) genattrtab $(srcdir)/move-if-change touch s-attrtab insn-output.o : insn-output.c $(CONFIG_H) $(RTL_H) $(GGC_H) $(REGS_H) real.h \ - conditions.h hard-reg-set.h insn-config.h insn-flags.h insn-attr.h \ + conditions.h hard-reg-set.h insn-config.h insn-flags.h $(INSN_ATTR_H) \ output.h $(RECOG_H) function.h insn-codes.h system.h toplev.h flags.h $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c insn-output.c diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index ec8086356ba..5d83e4b0175 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -8570,10 +8570,9 @@ void thumb_final_prescan_insn (insn) rtx insn; { - extern int * insn_addresses; - if (flag_print_asm_name) - asm_fprintf (asm_out_file, "%@ 0x%04x\n", insn_addresses[INSN_UID (insn)]); + asm_fprintf (asm_out_file, "%@ 0x%04x\n", + INSN_ADDRESSES (INSN_UID (insn))); } int diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index ac07707dddd..14ea8a9847a 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -605,8 +605,8 @@ function_epilogue (FILE *file, int size) signal_func_p = signal_function_p (current_function_decl); leaf_func_p = leaf_function_p (); main_p = ! strcmp ("main", current_function_name); - function_size = (insn_addresses[INSN_UID (get_last_insn ())] - - insn_addresses[INSN_UID (get_insns ())]); + function_size = (INSN_ADDRESSES (INSN_UID (get_last_insn ())) + - INSN_ADDRESSES (INSN_UID (get_insns ()))); live_seq = sequent_regs_live (); minimize = (TARGET_CALL_PROLOGUES && !interrupt_func_p && !signal_func_p && live_seq); @@ -1089,9 +1089,9 @@ avr_jump_mode (x,insn) rtx x; /* jump operand */ rtx insn; /* jump insn */ { - int dest_addr = insn_addresses[INSN_UID (GET_MODE (x) == LABEL_REF - ? XEXP (x, 0) : x)]; - int cur_addr = insn_addresses[INSN_UID (insn)]; + int dest_addr = INSN_ADDRESSES (INSN_UID (GET_MODE (x) == LABEL_REF + ? XEXP (x, 0) : x)); + int cur_addr = INSN_ADDRESSES (INSN_UID (insn)); int jump_distance = cur_addr - dest_addr; if (-63 <= jump_distance && jump_distance <= 62) @@ -1212,11 +1212,12 @@ final_prescan_insn (insn, operand, num_operands) if (TARGET_INSN_SIZE_DUMP || TARGET_ALL_DEBUG) { - fprintf (asm_out_file, "/*DEBUG: 0x%x\t\t%d\t%d */\n", insn_addresses[uid], - insn_addresses[uid] - last_insn_address, - rtx_cost (PATTERN (insn),INSN)); + fprintf (asm_out_file, "/*DEBUG: 0x%x\t\t%d\t%d */\n", + INSN_ADDRESSES (uid), + INSN_ADDRESSES (uid) - last_insn_address, + rtx_cost (PATTERN (insn), INSN)); } - last_insn_address = insn_addresses[uid]; + last_insn_address = INSN_ADDRESSES (uid); if (TARGET_RTL_DUMP) { @@ -3999,8 +4000,8 @@ jump_over_one_insn_p (insn, dest) int uid = INSN_UID (GET_CODE (dest) == LABEL_REF ? XEXP (dest, 0) : dest); - int jump_addr = insn_addresses[INSN_UID (insn)]; - int dest_addr = insn_addresses[uid]; + int jump_addr = INSN_ADDRESSES (INSN_UID (insn)); + int dest_addr = INSN_ADDRESSES (uid); return dest_addr - jump_addr == 2; } diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index c2d74bfcf4b..5c404eb1f98 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -1534,9 +1534,9 @@ final_prescan_insn (insn, operand, num_operands) if (TARGET_ADDRESSES) { - fprintf (asm_out_file, "; 0x%x %d\n", insn_addresses[uid], - insn_addresses[uid] - last_insn_address); - last_insn_address = insn_addresses[uid]; + fprintf (asm_out_file, "; 0x%x %d\n", INSN_ADDRESSES (uid), + INSN_ADDRESSES (uid) - last_insn_address); + last_insn_address = INSN_ADDRESSES (uid); } } diff --git a/gcc/config/i370/i370.c b/gcc/config/i370/i370.c index ce13fe76b7e..2aa7d31ee25 100644 --- a/gcc/config/i370/i370.c +++ b/gcc/config/i370/i370.c @@ -328,7 +328,7 @@ i370_branch_dest (branch) dest = XEXP (dest, 1); dest = XEXP (dest, 0); dest_uid = INSN_UID (dest); - dest_addr = insn_addresses[dest_uid]; + dest_addr = INSN_ADDRESSES (dest_uid); /* next, record the address of this insn as the true addr of first ref */ { @@ -349,7 +349,7 @@ i370_branch_length (insn) rtx insn; { int here, there; - here = insn_addresses[INSN_UID (insn)]; + here = INSN_ADDRESSES (INSN_UID (insn)); there = i370_branch_dest (insn); return (there - here); } @@ -407,13 +407,13 @@ i370_label_scan () for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { - int here = insn_addresses[INSN_UID (insn)]; + int here = INSN_ADDRESSES (INSN_UID (insn)); enum rtx_code code = GET_CODE(insn); /* ??? adjust for tables embedded in the .text section that * the compiler didn't take into account */ here += tablejump_offset; - insn_addresses[INSN_UID (insn)] = here; + INSN_ADDRESSES (INSN_UID (insn)) = here; /* check to see if this insn is a label ... */ if (CODE_LABEL == code) diff --git a/gcc/config/m88k/m88k.c b/gcc/config/m88k/m88k.c index 555d49f23a5..ab79bf015fe 100644 --- a/gcc/config/m88k/m88k.c +++ b/gcc/config/m88k/m88k.c @@ -853,8 +853,8 @@ output_call (operands, addr) rtx low, high; const char *last; rtx dest = XEXP (SET_SRC (PATTERN (jump)), 0); - int delta = 4 * (insn_addresses[INSN_UID (dest)] - - insn_addresses[INSN_UID (seq_insn)] + int delta = 4 * (INSN_ADDRESSES (INSN_UID (dest)) + - INSN_ADDRESSES (INSN_UID (seq_insn)) - 2); #if (MONITOR_GCC & 0x2) /* How often do long branches happen? */ if ((unsigned) (delta + 0x8000) >= 0x10000) @@ -1039,8 +1039,8 @@ mostly_false_jump (jump_insn, condition) insnj = NEXT_INSN (PREV_INSN (XVECEXP (final_sequence, 0, 0))); else insnj = jump_insn; - if (insn_addresses[INSN_UID (insnj)] - > insn_addresses[INSN_UID (target_label)]) + if (INSN_ADDRESSES (INSN_UID (insnj)) + > INSN_ADDRESSES (INSN_UID (target_label))) return 0; /* EQ tests are usually false and NE tests are usually true. Also, diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 88be9b414b9..8cdd43e115d 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -2910,11 +2910,11 @@ output_function_prologue (file, size) we don't need to accumulate the total number of code bytes. */ if (TARGET_GAS && ! TARGET_PORTABLE_RUNTIME) total_code_bytes = 0; - else if (insn_addresses) + else if (INSN_ADDRESSES_SET_P ()) { unsigned int old_total = total_code_bytes; - total_code_bytes += insn_addresses[INSN_UID (get_last_insn())]; + total_code_bytes += INSN_ADDRESSES (INSN_UID (get_last_insn())); total_code_bytes += FUNCTION_BOUNDARY / BITS_PER_UNIT; /* Be prepared to handle overflows. */ @@ -4887,9 +4887,9 @@ output_cbranch (operands, nullify, length, negated, insn) taken and untaken branches. */ else if (dbr_sequence_length () == 0 && ! forward_branch_p (insn) - && insn_addresses - && VAL_14_BITS_P (insn_addresses[INSN_UID (JUMP_LABEL (insn))] - - insn_addresses[INSN_UID (insn)] - 8)) + && INSN_ADDRESSES_SET_P () + && VAL_14_BITS_P (INSN_ADDRESSES (INSN_UID (JUMP_LABEL (insn))) + - INSN_ADDRESSES (INSN_UID (insn)) - 8)) { strcpy (buf, "{com%I2b,|cmp%I2b,}"); if (GET_MODE (operands[1]) == DImode) @@ -5104,9 +5104,9 @@ output_bb (operands, nullify, length, negated, insn, which) taken and untaken branches. */ else if (dbr_sequence_length () == 0 && ! forward_branch_p (insn) - && insn_addresses - && VAL_14_BITS_P (insn_addresses[INSN_UID (JUMP_LABEL (insn))] - - insn_addresses[INSN_UID (insn)] - 8)) + && INSN_ADDRESSES_SET_P () + && VAL_14_BITS_P (INSN_ADDRESSES (INSN_UID (JUMP_LABEL (insn))) + - INSN_ADDRESSES (INSN_UID (insn)) - 8)) { strcpy (buf, "bb,"); if (GET_MODE (operands[0]) == DImode) @@ -5252,9 +5252,9 @@ output_bvb (operands, nullify, length, negated, insn, which) taken and untaken branches. */ else if (dbr_sequence_length () == 0 && ! forward_branch_p (insn) - && insn_addresses - && VAL_14_BITS_P (insn_addresses[INSN_UID (JUMP_LABEL (insn))] - - insn_addresses[INSN_UID (insn)] - 8)) + && INSN_ADDRESSES_SET_P () + && VAL_14_BITS_P (INSN_ADDRESSES (INSN_UID (JUMP_LABEL (insn))) + - INSN_ADDRESSES (INSN_UID (insn)) - 8)) { strcpy (buf, "{bvb,|bb,}"); if (GET_MODE (operands[0]) == DImode) @@ -5361,9 +5361,9 @@ output_dbra (operands, insn, which_alternative) taken and untaken branches. */ else if (dbr_sequence_length () == 0 && ! forward_branch_p (insn) - && insn_addresses - && VAL_14_BITS_P (insn_addresses[INSN_UID (JUMP_LABEL (insn))] - - insn_addresses[INSN_UID (insn)] - 8)) + && INSN_ADDRESSES_SET_P () + && VAL_14_BITS_P (INSN_ADDRESSES (INSN_UID (JUMP_LABEL (insn))) + - INSN_ADDRESSES (INSN_UID (insn)) - 8)) return "addib,%C2 %1,%0,%3%#"; /* Handle normal cases. */ @@ -5469,9 +5469,9 @@ output_movb (operands, insn, which_alternative, reverse_comparison) taken and untaken branches. */ else if (dbr_sequence_length () == 0 && ! forward_branch_p (insn) - && insn_addresses - && VAL_14_BITS_P (insn_addresses[INSN_UID (JUMP_LABEL (insn))] - - insn_addresses[INSN_UID (insn)] - 8)) + && INSN_ADDRESSES_SET_P () + && VAL_14_BITS_P (INSN_ADDRESSES (INSN_UID (JUMP_LABEL (insn))) + - INSN_ADDRESSES (INSN_UID (insn)) - 8)) return "movb,%C2 %1,%0,%3%#"; /* Handle normal cases. */ if (nullify) @@ -5644,8 +5644,8 @@ output_millicode_call (insn, call_dest) /* Use the containing sequence insn's address. */ seq_insn = NEXT_INSN (PREV_INSN (XVECEXP (final_sequence, 0, 0))); - distance = insn_addresses[INSN_UID (JUMP_LABEL (NEXT_INSN (insn)))] - - insn_addresses[INSN_UID (seq_insn)] - 8; + distance = INSN_ADDRESSES (INSN_UID (JUMP_LABEL (NEXT_INSN (insn)))) + - INSN_ADDRESSES (INSN_UID (seq_insn)) - 8; /* If the branch was too far away, emit a normal call followed by a nop, followed by the unconditional branch. @@ -5917,8 +5917,8 @@ output_call (insn, call_dest, sibcall) /* Use the containing sequence insn's address. */ seq_insn = NEXT_INSN (PREV_INSN (XVECEXP (final_sequence, 0, 0))); - distance = insn_addresses[INSN_UID (JUMP_LABEL (NEXT_INSN (insn)))] - - insn_addresses[INSN_UID (seq_insn)] - 8; + distance = INSN_ADDRESSES (INSN_UID (JUMP_LABEL (NEXT_INSN (insn)))) + - INSN_ADDRESSES (INSN_UID (seq_insn)) - 8; /* If the branch was too far away, emit a normal call followed by a nop, followed by the unconditional branch. diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index 45045875ffb..547d4212113 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -2205,9 +2205,9 @@ /* If we're trying to load the address of a label that happens to be close, then we can use a shorter sequence. */ if (GET_CODE (operands[1]) == LABEL_REF - && insn_addresses - && abs (insn_addresses[INSN_UID (XEXP (operands[1], 0))] - - insn_addresses[INSN_UID (insn)]) < 8100) + && INSN_ADDRESSES_SET_P () + && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0))) + - INSN_ADDRESSES (INSN_UID (insn))) < 8100) { /* Prefixing with R% here is wrong, it extracts just 11 bits and is always non-negative. */ diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index f2c4ef02690..c6103de292e 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -73,10 +73,6 @@ int pragma_nosave_low_regs; sh_expand_prologue. */ int current_function_anonymous_args; -/* Global variables from toplev.c and final.c that are used within, but - not declared in any header file. */ -extern int *insn_addresses; - /* Global variables for machine-dependent things. */ /* Which cpu are we scheduling for. */ @@ -696,7 +692,7 @@ output_far_jump (insn, op) struct { rtx lab, reg, op; } this; const char *jump; int far; - int offset = branch_dest (insn) - insn_addresses[INSN_UID (insn)]; + int offset = branch_dest (insn) - INSN_ADDRESSES (INSN_UID (insn)); this.lab = gen_label_rtx (); @@ -818,12 +814,15 @@ output_branchy_insn (code, template, insn, operands) /* Following branch not taken */ operands[9] = gen_label_rtx (); emit_label_after (operands[9], next_insn); + INSN_ADDRESSES_NEW (operands[9], + INSN_ADDRESSES (INSN_UID (next_insn)) + + get_attr_length (next_insn)); return template; } else { int offset = (branch_dest (next_insn) - - insn_addresses[INSN_UID (next_insn)] + 4); + - INSN_ADDRESSES (INSN_UID (next_insn)) + 4); if (offset >= -252 && offset <= 258) { if (GET_CODE (src) == IF_THEN_ELSE) @@ -836,6 +835,9 @@ output_branchy_insn (code, template, insn, operands) } operands[9] = gen_label_rtx (); emit_label_after (operands[9], insn); + INSN_ADDRESSES_NEW (operands[9], + INSN_ADDRESSES (INSN_UID (insn)) + + get_attr_length (insn)); return template; } @@ -2502,7 +2504,7 @@ gen_block_redirect (jump, addr, need_block) dest = XEXP (SET_SRC (PATTERN (jump)), 0); /* If the branch is out of range, try to find a scratch register for it. */ if (optimize - && (insn_addresses[INSN_UID (dest)] - addr + 4092U > 4092 + 4098)) + && (INSN_ADDRESSES (INSN_UID (dest)) - addr + 4092U > 4092 + 4098)) { rtx scan; /* Don't look for the stack pointer as a scratch register, @@ -2578,8 +2580,9 @@ gen_block_redirect (jump, addr, need_block) { dest = JUMP_LABEL (next); if (dest - && insn_addresses[INSN_UID (dest)] - addr + 4092U > 4092 + 4098) - gen_block_redirect (next, insn_addresses[INSN_UID (next)], -1); + && (INSN_ADDRESSES (INSN_UID (dest)) - addr + 4092U + > 4092 + 4098)) + gen_block_redirect (next, INSN_ADDRESSES (INSN_UID (next)), -1); } } @@ -3231,7 +3234,7 @@ machine_dependent_reorg (first) } mdep_reorg_phase = SH_SHORTEN_BRANCHES1; - insn_addresses = 0; + INSN_ADDRESSES_FREE (); split_branches (first); /* The INSN_REFERENCES_ARE_DELAYED in sh.h is problematic because it @@ -3330,7 +3333,7 @@ split_branches (first) { rtx src = SET_SRC (PATTERN (insn)); rtx olabel = XEXP (XEXP (src, 1), 0); - int addr = insn_addresses[INSN_UID (insn)]; + int addr = INSN_ADDRESSES (INSN_UID (insn)); rtx label = 0; int dest_uid = get_dest_uid (olabel, max_uid); struct far_branch *bp = uid_branch[dest_uid]; @@ -3409,11 +3412,12 @@ split_branches (first) == JUMP_INSN)) && GET_CODE (PATTERN (beyond)) == SET && recog_memoized (beyond) == CODE_FOR_jump - && ((insn_addresses[INSN_UID (XEXP (SET_SRC (PATTERN (beyond)), 0))] - - insn_addresses[INSN_UID (insn)] + 252U) + && ((INSN_ADDRESSES + (INSN_UID (XEXP (SET_SRC (PATTERN (beyond)), 0))) + - INSN_ADDRESSES (INSN_UID (insn)) + 252U) > 252 + 258 + 2)) gen_block_redirect (beyond, - insn_addresses[INSN_UID (beyond)], 1); + INSN_ADDRESSES (INSN_UID (beyond)), 1); } next = next_active_insn (insn); @@ -3422,14 +3426,15 @@ split_branches (first) || GET_CODE (next = next_active_insn (next)) == JUMP_INSN) && GET_CODE (PATTERN (next)) == SET && recog_memoized (next) == CODE_FOR_jump - && ((insn_addresses[INSN_UID (XEXP (SET_SRC (PATTERN (next)), 0))] - - insn_addresses[INSN_UID (insn)] + 252U) + && ((INSN_ADDRESSES + (INSN_UID (XEXP (SET_SRC (PATTERN (next)), 0))) + - INSN_ADDRESSES (INSN_UID (insn)) + 252U) > 252 + 258 + 2)) - gen_block_redirect (next, insn_addresses[INSN_UID (next)], 1); + gen_block_redirect (next, INSN_ADDRESSES (INSN_UID (next)), 1); } else if (type == TYPE_JUMP || type == TYPE_RETURN) { - int addr = insn_addresses[INSN_UID (insn)]; + int addr = INSN_ADDRESSES (INSN_UID (insn)); rtx far_label = 0; int dest_uid = 0; struct far_branch *bp; @@ -3524,7 +3529,7 @@ final_prescan_insn (insn, opvec, noperands) int noperands ATTRIBUTE_UNUSED; { if (TARGET_DUMPISIZE) - fprintf (asm_out_file, "\n! at %04x\n", insn_addresses[INSN_UID (insn)]); + fprintf (asm_out_file, "\n! at %04x\n", INSN_ADDRESSES (INSN_UID (insn))); if (TARGET_RELAX) { @@ -4792,7 +4797,7 @@ branch_dest (branch) dest = XEXP (dest, 1); dest = XEXP (dest, 0); dest_uid = INSN_UID (dest); - return insn_addresses[dest_uid]; + return INSN_ADDRESSES (dest_uid); } /* Return non-zero if REG is not used after INSN. diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 2b44d2f1bc1..f6a354dfab2 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -2625,7 +2625,7 @@ int short_branch (uid1, uid2) int uid1, uid2; { - int delta = insn_addresses[uid1] - insn_addresses[uid2]; + int delta = INSN_ADDRESSES (uid1) - INSN_ADDRESSES (uid2); /* Leave a few words of "slop". */ if (delta >= -1023 && delta <= 1022) diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index eca1a73098d..8fb4b941d4e 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -8415,8 +8415,8 @@ instead. */ if (! TARGET_V9 && flag_delayed_branch - && (insn_addresses[INSN_UID (operands[0])] - == insn_addresses[INSN_UID (insn)])) + && (INSN_ADDRESSES (INSN_UID (operands[0])) + == INSN_ADDRESSES (INSN_UID (insn)))) return \"b\\t%l0%#\"; else return TARGET_V9 ? \"ba,pt%*\\t%%xcc, %l0%(\" : \"b%*\\t%l0%(\"; diff --git a/gcc/final.c b/gcc/final.c index e655637644f..1fc72c9402b 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -612,7 +612,10 @@ dbr_sequence_length () `insn_current_length'. */ static short *insn_lengths; -int *insn_addresses; + +#ifdef HAVE_ATTR_length +varray_type insn_addresses_; +#endif /* Max uid for which the above arrays are valid. */ static int insn_lengths_max_uid; @@ -665,11 +668,9 @@ init_insn_lengths () insn_lengths = 0; insn_lengths_max_uid = 0; } - if (insn_addresses) - { - free (insn_addresses); - insn_addresses = 0; - } +#ifdef HAVE_ATTR_length + INSN_ADDRESSES_FREE (); +#endif if (uid_align) { free (uid_align); @@ -889,7 +890,7 @@ align_fuzz (start, end, known_align_log, growth) int align_addr, new_align; uid = INSN_UID (align_label); - align_addr = insn_addresses[uid] - insn_lengths[uid]; + align_addr = INSN_ADDRESSES (uid) - insn_lengths[uid]; if (uid_shuid[uid] > end_shuid) break; known_align_log = LABEL_TO_ALIGNMENT (align_label); @@ -1135,7 +1136,7 @@ shorten_branches (first) insn_lengths_max_uid = max_uid; /* Syntax errors can lead to labels being outside of the main insn stream. Initialize insn_addresses, so that we get reproducible results. */ - insn_addresses = (int *) xcalloc (max_uid, sizeof (int)); + INSN_ADDRESSES_ALLOC (max_uid); varying_length = (char *) xcalloc (max_uid, sizeof (char)); @@ -1242,7 +1243,7 @@ shorten_branches (first) } } - insn_addresses[uid] = insn_current_address; + INSN_ADDRESSES (uid) = insn_current_address; if (GET_CODE (insn) == NOTE || GET_CODE (insn) == BARRIER || GET_CODE (insn) == CODE_LABEL) @@ -1298,8 +1299,8 @@ shorten_branches (first) if ((varying_length[inner_uid] = insn_variable_length_p (inner_insn)) != 0) varying_length[uid] = 1; - insn_addresses[inner_uid] = (insn_current_address + - insn_lengths[uid]); + INSN_ADDRESSES (inner_uid) = (insn_current_address + + insn_lengths[uid]); } else varying_length[inner_uid] = 0; @@ -1353,7 +1354,7 @@ shorten_branches (first) } else insn_lengths[uid] = 0; - insn_addresses[uid] = insn_current_address; + INSN_ADDRESSES (uid) = insn_current_address; continue; } @@ -1361,8 +1362,8 @@ shorten_branches (first) if (length_align < insn_current_align) insn_current_align = length_align; - insn_last_address = insn_addresses[uid]; - insn_addresses[uid] = insn_current_address; + insn_last_address = INSN_ADDRESSES (uid); + INSN_ADDRESSES (uid) = insn_current_address; #ifdef CASE_VECTOR_SHORTEN_MODE if (optimize && GET_CODE (insn) == JUMP_INSN @@ -1374,9 +1375,9 @@ shorten_branches (first) rtx min_lab = XEXP (XEXP (body, 2), 0); rtx max_lab = XEXP (XEXP (body, 3), 0); addr_diff_vec_flags flags = ADDR_DIFF_VEC_FLAGS (body); - int rel_addr = insn_addresses[INSN_UID (rel_lab)]; - int min_addr = insn_addresses[INSN_UID (min_lab)]; - int max_addr = insn_addresses[INSN_UID (max_lab)]; + int rel_addr = INSN_ADDRESSES (INSN_UID (rel_lab)); + int min_addr = INSN_ADDRESSES (INSN_UID (min_lab)); + int max_addr = INSN_ADDRESSES (INSN_UID (max_lab)); rtx prev; int rel_align = 0; @@ -1491,7 +1492,7 @@ shorten_branches (first) int inner_uid = INSN_UID (inner_insn); int inner_length; - insn_addresses[inner_uid] = insn_current_address; + INSN_ADDRESSES (inner_uid) = insn_current_address; /* insn_current_length returns 0 for insns with a non-varying length. */ @@ -2018,7 +2019,7 @@ final (first, file, optimize, prescan) for (insn = NEXT_INSN (first); insn;) { #ifdef HAVE_ATTR_length - if (INSN_UID (insn) >= insn_lengths_max_uid) + if (INSN_UID (insn) >= INSN_ADDRESSES_SIZE ()) { #ifdef STACK_REGS /* Irritatingly, the reg-stack pass is creating new instructions @@ -2032,7 +2033,7 @@ final (first, file, optimize, prescan) #endif } else - insn_current_address = insn_addresses[INSN_UID (insn)]; + insn_current_address = INSN_ADDRESSES (INSN_UID (insn)); #endif /* HAVE_ATTR_length */ insn = final_scan_insn (insn, file, optimize, prescan, 0); diff --git a/gcc/genattr.c b/gcc/genattr.c index 6a593edeb21..770379a53d5 100644 --- a/gcc/genattr.c +++ b/gcc/genattr.c @@ -126,8 +126,7 @@ gen_attr (attr) printf ("extern int insn_default_length PARAMS ((rtx));\n"); printf ("extern int insn_variable_length_p PARAMS ((rtx));\n"); printf ("extern int insn_current_length PARAMS ((rtx));\n\n"); - printf ("extern int *insn_addresses;\n"); - printf ("extern int insn_current_address;\n\n"); + printf ("#include \"insn-addr.h\"\n\n"); } } diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c index 5b4d656d0b1..153c2786734 100644 --- a/gcc/genattrtab.c +++ b/gcc/genattrtab.c @@ -4662,7 +4662,7 @@ write_test_expr (exp, flags) /* The address of the branch target. */ case MATCH_DUP: - printf ("insn_addresses[INSN_UID (GET_CODE (operands[%d]) == LABEL_REF ? XEXP (operands[%d], 0) : operands[%d])]", + printf ("INSN_ADDRESSES (INSN_UID (GET_CODE (operands[%d]) == LABEL_REF ? XEXP (operands[%d], 0) : operands[%d]))", XINT (exp, 0), XINT (exp, 0), XINT (exp, 0)); break; diff --git a/gcc/insn-addr.h b/gcc/insn-addr.h new file mode 100644 index 00000000000..4ae59f7fddb --- /dev/null +++ b/gcc/insn-addr.h @@ -0,0 +1,46 @@ +/* Macros to support INSN_ADDRESSES + Copyright (C) 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. */ + +#ifndef _INSN_ADDR_H +#define _INSN_ADDR_H 1 + +#include "varray.h" + +extern varray_type insn_addresses_; +extern int insn_current_address; + +#define INSN_ADDRESSES_DEFN() varray_type insn_addresses_ +#define INSN_ADDRESSES(id) VARRAY_INT (insn_addresses_, (id)) +#define INSN_ADDRESSES_ALLOC(size) \ + VARRAY_INT_INIT (insn_addresses_, (size), "insn_addresses") +#define INSN_ADDRESSES_FREE() VARRAY_FREE (insn_addresses_) +#define INSN_ADDRESSES_SET_P() (insn_addresses_ != 0) +#define INSN_ADDRESSES_SIZE() VARRAY_SIZE (insn_addresses_) +#define INSN_ADDRESSES_NEW(insn,addr) do { \ + int insn_uid__ = INSN_UID ((insn)), insn_addr__ = (addr); \ + \ + if (INSN_ADDRESSES_SET_P()) { \ + if (INSN_ADDRESSES_SIZE() <= insn_uid__) \ + insn_addresses_ = VARRAY_GROW (insn_addresses_, insn_uid__ + 1); \ + INSN_ADDRESSES (insn_uid__) = insn_addr__; \ + } \ +} while (0) + +#endif /* _INSN_ADDR_H */