This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[yara] build fixes, and use FOR_BB_INSNS where possible


Hi Vlad, all,

With this patch, I can bootstrap the compilers for c,c++,fortran on x86_64,
though I still can't do a full bootstrap because of an ICE in lower-subreg.
But it's progress compared to earlier today, when I had lots of warnings
and even a normal build wouldn't work.

This also cleans up a few places to use FOR_BB_INSNS instead of a special
loop.

Vlad, can you put this  on the yara-branch if it looks good to you?

Gr.
Steven

	* yara-int.h (struct reg_eliminate, struct allocno_change,
	struct insn_allocno_change, struct insn_allocno, struct copy_change,
	struct copy): Use ENUM_BITFIELD and BOOL_BITFIELD where appropriate.
	Don't create bitfields of signed types.
	* lower-subreg.c (decompose_multiword_subregs): Make it static.

	* yara-insn.c (setup_possible_alternatives): Use FOR_BB_INSNS.
	* yara-color.c (setup_can_classes,
	setup_cover_classes_and_reg_costs, calculate_reg_pressure,
	add_move_costs, setup_bb_pos_insn_maps): Likewise.
	* yara-final.c (process_bb_locs, yara_rewrite): Likewise.
	* yara.c (check_allocation, yara): Likewise.
	* yara-ir.c (find_possible_eliminations, set_insn_regno_regs,
	scan_insn_for_reg_equivs, initiate_equivs, create_bb_insn_allocnos,
	make_vn, make_aggressive_coalescing): Likewise.

Index: yara-int.h
===================================================================
--- yara-int.h	(revision 115809)
+++ yara-int.h	(working copy)
@@ -97,8 +97,8 @@ struct reg_eliminate GTY(())
   /* It is used temporary to calculate possible elimination.  Finally
      we have only eliminations with nonzero value in the table
      REG_ELIMINATE.  */
-  bool can_eliminate:1;
-  bool obligatory:1;
+  BOOL_BITFIELD can_eliminate:1;
+  BOOL_BITFIELD obligatory:1;
   /* Next possible elimination for given register FROM.  Finally we
      can have only one obligatory elimination for given register.  */
   struct reg_eliminate *from_next;
@@ -289,7 +289,7 @@ struct allocno_change
 {
   /* This member is true only for pseudo-register which will be
      changed by equivalent constant.  */
-  bool use_equiv_const_p : 1;
+  BOOL_BITFIELD use_equiv_const_p : 1;
   /* Allocated start hard regno. -1 for memory or constant.  */
   short hard_regno;
   /* Pseudo-register could need several hard registers starting with
@@ -307,15 +307,15 @@ struct allocno_change
    representing a pseudo-register in a part of his live range.  */
 struct allocno_common
 {
-  enum allocno_type type : 2;
+  ENUM_BITFIELD(allocno_type) type : 2;
   /* The following true if the allocno crosses a call.  */
-  bool call_cross_p : 1;
+  BOOL_BITFIELD call_cross_p : 1;
   /* Very contradictory for subregs -- check and fix ????? Mode of the
      pseudo-register, hard register, scratch or non-register operand.
      For insn allocnos, it is taken from recog_data which is mode of
      operand or mode form the insn template if the former is of
      VOIDmode.  */
-  enum machine_mode mode : 8;
+  ENUM_BITFIELD(machine_mode) mode : 8;
 
   int allocno_num; /* ?!? if conflicts as arcs */
 
@@ -381,14 +381,14 @@ struct insn_allocno_change
      case the previous member refers to the duplicate), otherwise it
      is duplicate (in this case the previous member refers to the
      original).  */
-  bool original_p : 1;
+  BOOL_BITFIELD original_p : 1;
   /* This member is true only for constant which should be placed in
      const pool.  */
-  bool const_pool_p : 1;
+  BOOL_BITFIELD const_pool_p : 1;
   /* This member is true only for operand which is used without
      change.  It is possible for memory, constant, or hard
      register.  */
-  bool use_without_change_p : 1;
+  BOOL_BITFIELD use_without_change_p : 1;
   /* The following is a hard register needed for elimination.  The
      negative value means we don't need a hard register for the
      elimination.  The elimination register mode is always Pmode.  */
@@ -414,23 +414,23 @@ struct insn_allocno
   /* If the allocno LOC contains subreg or inside subreg, this is the
      biggest mode of subreg and subreg internal.  Otherwise it is just
      allocno mode (mode of LOC). */
-  enum machine_mode biggest_mode : 8;
-  enum op_type op_mode : 8;
+  ENUM_BITFIELD(machine_mode) biggest_mode : 8;
+  ENUM_BITFIELD(op_type) op_mode : 8;
   int type : 8; /* 0 - Base, 1 - Index, 2, 3, 4, ... - Operand #val - 2. */
   /* The following member value is true if there is early clobber flag
      for the corresponding operand.  Actually the clobber flag
      belongs to an alternative but it is hard to represent and use it
      for allocno conflicts.  Therefore we make it true for all
      alternatives if there is a flag.  */
-  bool early_clobber : 1;
+  BOOL_BITFIELD early_clobber : 1;
   /* The following is true if the allocno contains a register can be
      eliminated.  We ignore the registers in memory expression.  They
      will be processed in other allocnos.  */
-  bool elimination_p : 1;
+  BOOL_BITFIELD elimination_p : 1;
   /* The value is true if it is a constant being a part of expression
      which might be transformed by register elimination.  Such
      constant never gets a hard register or memory.  */
-  bool elimination_part_const_p : 1;
+  BOOL_BITFIELD elimination_part_const_p : 1;
   rtx insn;
   /* It is address of rtx of the allocno.  If the allocno corresponing
      an operand, it is an operand location.  */
@@ -591,11 +591,14 @@ struct copy_change
 #ifdef HAVE_SECONDARY_RELOADS
   /* The following true value means that we use icode insn with src as
      an operand.  Otherwise we use dst as output of icode insn.  */
-  bool in_p : 1;
+  BOOL_BITFIELD in_p : 1;
   /* Code of reload insn used for copying, CODE_FOR_nothing if we use
      standard move patterns.  */
-  enum insn_code icode : 15;
-  enum machine_mode interm_mode : 8, scratch_mode : 8;
+  ENUM_BITFIELD(insn_code) icode : 15;
+ 
+  ENUM_BITFIELD(machine_mode) interm_mode : 8;
+  ENUM_BITFIELD(machine_mode) scratch_mode : 8;
+
   /* Start intermediate hard register needed for a secondary reload.
      -1 means it is not necessary.  */
   short interm_regno;
@@ -607,12 +610,12 @@ struct copy_change
   /* The following hard register (in given mode) might be needed to
      load equivalent constant into the destination allocno.  */
   short interm_equiv_const_regno;
-  enum machine_mode interm_equiv_const_mode : 8;
+  ENUM_BITFIELD(machine_mode) interm_equiv_const_mode : 8;
   /* The following two member values are used only when secondary
      memory is needed.  We don't need secondary memory if the two
      values are NULL.  */
 #ifdef SECONDARY_MEMORY_NEEDED
-  enum machine_mode memory_mode : 8;
+  ENUM_BITFIELD(machine_mode) memory_mode : 8;
   /* Value from SECONDARY_MEMORY_NEEDED_RTX, otherwise NULL.  */
   rtx user_defined_memory;
   /* Allocated memory used only the previous value is NULL.  */
@@ -651,10 +654,11 @@ struct copy
 
   short freq;
   /* Flag of that source and target are already synchronized.  */
-  bool sync_p : 1;
+  BOOL_BITFIELD sync_p : 1;
+
   /* Use the hard regno (if it is not negative) instead of src
      location.  */
-  short subst_src_hard_regno : 15;
+  short subst_src_hard_regno;
 
   /* Set of hard regs conflicting with the copy.  */
   HARD_REG_SET hard_reg_conflicts;
Index: lower-subreg.c
===================================================================
--- lower-subreg.c	(revision 115809)
+++ lower-subreg.c	(working copy)
@@ -554,7 +554,7 @@ resolve_use (rtx pat, rtx insn)
 
 /* */
 
-void
+static void
 decompose_multiword_subregs (void)
 {
   rtx insn, set;
Index: yara-insn.c
===================================================================
--- yara-insn.c	(revision 115809)
+++ yara-insn.c	(working copy)
@@ -402,12 +402,11 @@ void
 setup_possible_alternatives (bool strict_p)
 {
   basic_block bb;
-  rtx bound, insn;
+  rtx insn;
 
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  setup_possible_operand_alternatives (insn, strict_p);
     }
Index: yara-color.c
===================================================================
--- yara-color.c	(revision 115809)
+++ yara-color.c	(working copy)
@@ -966,7 +966,7 @@ process_insn_op_allocno_for_can_classes 
 static void
 setup_can_classes (void)
 {
-  rtx insn, bound;
+  rtx insn;
   allocno_t a;
   can_t can;
   int i, j, can_num, hard_regno, op_num, curr_alt;
@@ -982,8 +982,7 @@ setup_can_classes (void)
   sbitmap_zero (can_classes_sbitmap);
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  {
 	    info = insn_infos [INSN_UID (insn)];
@@ -1078,7 +1077,7 @@ setup_cover_classes_and_reg_costs (void)
 {
   int i, j, k, n, cost, min_cost, freq, op_num, can_num, hard_regno;
   enum reg_class cl, cl1, best_class, cover_class, *classes;
-  rtx insn, bound;
+  rtx insn;
   enum machine_mode mode;
   enum op_type op_mode;
   basic_block bb;
@@ -1096,11 +1095,10 @@ setup_cover_classes_and_reg_costs (void)
   memset (can_memory_cost, 0, cans_num * sizeof (int));
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
       freq = bb->frequency;
       if (freq == 0)
 	freq = 1;
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  {
 	    curr_preference_insn = insn;
@@ -1372,7 +1370,7 @@ calculate_reg_pressure (void)
 {
   int i, class_num;
   unsigned int uid, j;
-  rtx insn, bound;
+  rtx insn;
   allocno_t a;
   copy_t before_copies, after_copies, cp;
   bitmap_iterator bi;
@@ -1406,10 +1404,8 @@ calculate_reg_pressure (void)
 	{
 	  live_allocno (allocnos [j]);;
 	}
-      bound = NEXT_INSN (BB_END (curr_reg_pressure_calculation_bb_node->bb));
-      for (insn = BB_HEAD (curr_reg_pressure_calculation_bb_node->bb);
-	   insn != bound;
-	   insn = NEXT_INSN (insn))
+
+      FOR_BB_INSNS (curr_reg_pressure_calculation_bb_node->bb, insn)
 	{
 	  if (! INSN_P (insn))
 	    continue;
@@ -1875,7 +1871,7 @@ static void
 add_move_costs (void)
 {
   int i, freq, hard_regno;
-  rtx insn, bound, set, dst, src;
+  rtx insn, set, dst, src;
   basic_block bb;
   allocno_t a, src_a, dst_a;
   copy_t cp;
@@ -1902,11 +1898,10 @@ add_move_costs (void)
     }
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
       freq = bb->frequency;
       if (freq == 0)
 	freq = 1;
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn) && (set = single_set (insn)) != NULL_RTX
 	    && REG_P (SET_DEST (set))
 	    && REG_P (SET_SRC (set))
@@ -2703,11 +2698,10 @@ static int *insn_pos_map;
 static void
 setup_bb_pos_insn_maps (void)
 {
-  rtx insn, bound;
+  rtx insn;
 
-  bound = NEXT_INSN (BB_END (curr_bb));
   VARRAY_POP_ALL (pos_insn_map);
-  for (insn = BB_HEAD (curr_bb); insn != bound; insn = NEXT_INSN (insn))
+  FOR_BB_INSNS (curr_bb, insn)
     if (INSN_P (insn))
       {
 	VARRAY_PUSH_RTX (pos_insn_map, insn);
Index: yara-final.c
===================================================================
--- yara-final.c	(revision 115809)
+++ yara-final.c	(working copy)
@@ -333,15 +333,14 @@ static void
 process_bb_locs (basic_block bb)
 {
   int i, hard_regno;
-  rtx insn, bound, set;
+  rtx insn, set;
   enum machine_mode mode;
   allocno_t a, a2;
   struct memory_slot *memory_slot;
   bool cont_p;
 
-  bound = NEXT_INSN (BB_END (bb));
   process_copy_locs (at_bb_start_copies [bb->index]);
-  for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+  FOR_BB_INSNS (bb, insn)
     {
       if (! INSN_P (insn))
 	continue;
@@ -3098,7 +3097,7 @@ yara_rewrite (void)
   basic_block bb;
   edge_iterator ei;
   edge e;
-  rtx bound, insn, next_insn, set;
+  rtx insn, next_insn, set;
   bool remove_p;
 
   if ((YARA_PARAMS & YARA_NO_COPY_SYNC) == 0)
@@ -3113,8 +3112,7 @@ yara_rewrite (void)
   allocate_stack_memory ();
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = next_insn)
+      FOR_BB_INSNS (bb, insn)
 	{
 	  next_insn = NEXT_INSN (insn);
 	  if (INSN_P (insn) && INSN_UID (insn) < yara_max_uid)
Index: yara.c
===================================================================
--- yara.c	(revision 115809)
+++ yara.c	(working copy)
@@ -361,12 +361,11 @@ static void
 check_allocation (void)
 {
   basic_block bb;
-  rtx bound, insn;
+  rtx insn;
 
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	/* ????!!!! We should check somehow code inside use clobber and
 	   asm.  */
 	if (INSN_P (insn) && GET_CODE (PATTERN (insn)) != USE
@@ -403,15 +402,14 @@ void
 yara (FILE *f)
 {
   basic_block bb;
-  rtx bound, insn;
+  rtx insn;
 
   yara_max_uid = get_max_uid ();
   /* Our code is based on assumption that there is no subreg of hard
      registers and memory.  */
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  cleanup_subreg_operands (insn);
     }
Index: yara-ir.c
===================================================================
--- yara-ir.c	(revision 115809)
+++ yara-ir.c	(working copy)
@@ -493,13 +493,12 @@ static void
 find_possible_eliminations (void)
 {
   basic_block bb;
-  rtx insn, bound;
+  rtx insn;
   struct reg_eliminate *ep;
 
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	{
 	  if (INSN_P (insn))
 	    note_stores (PATTERN (insn), mark_set_reg_not_eliminable, NULL);
@@ -1025,13 +1024,13 @@ set_insn_regno_regs (rtx x)
 static void
 set_bb_regno_refs (struct yara_loop_tree_node *bb_node)
 {
-  rtx insn, bound;
+  rtx insn;
   basic_block bb;
 
   curr_bb_node = bb_node;
   bb = bb_node->bb;
-  bound = NEXT_INSN (BB_END (bb));
-  for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+
+  FOR_BB_INSNS (bb, insn)
     if (INSN_P (insn))
       set_insn_regno_regs (PATTERN (insn));
 }
@@ -1278,7 +1277,7 @@ scan_insn_for_reg_equivs (rtx insn)
 static void
 initiate_equivs (void)
 {
-  rtx insn, bound;
+  rtx insn;
   basic_block bb;
 
   reg_equiv_constant = yara_allocate (max_regno * sizeof (rtx));
@@ -1301,8 +1300,7 @@ initiate_equivs (void)
   equiv_memory_num = 0;
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  {
 	    scan_rtx_for_reg_size_alignment (PATTERN (insn));
@@ -3874,15 +3872,13 @@ static int all, moves;
 static void
 create_bb_insn_allocnos (struct yara_loop_tree_node *bb_node)
 {
-  rtx insn, next_insn, prev_insn, set, bound;
+  rtx insn, next_insn, prev_insn, set;
   basic_block bb;
 
   curr_bb_node = bb_node;
   bb = bb_node->bb;
-  bound = NEXT_INSN (BB_END (bb));
-  for (prev_insn = NULL_RTX, insn = BB_HEAD (bb);
-       insn != bound;
-       insn = next_insn)
+  prev_insn = NULL_RTX;
+  FOR_BB_INSNS (bb, insn)
     if (! INSN_P (insn))
       next_insn = NEXT_INSN (insn);
     else
@@ -4710,7 +4706,7 @@ make_vn (void)
   basic_block bb;
   edge_iterator ei;
   edge e;
-  rtx insn, bound, set;
+  rtx insn, set;
   allocno_t a, a2;
   allocno_t *vec;
 
@@ -4740,8 +4736,7 @@ make_vn (void)
 	    }
 	  if (propagate_copy_value (at_bb_start_copies [bb->index]))
 	    changed_p = true;
-	  bound = NEXT_INSN (BB_END (bb));
-	  for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+	  FOR_BB_INSNS (bb, insn)
 	    if (INSN_P (insn))
 	      {
 		if (propagate_copy_value (before_insn_copies
@@ -5525,14 +5520,13 @@ make_aggressive_coalescing (void)
   struct move_info *move, *last;
   varray_type move_varray;
   basic_block bb;
-  rtx insn, bound, set;
+  rtx insn, set;
 
   VARRAY_RTX_INIT (move_insn_varray, yara_max_uid, "move insns");
   VARRAY_GENERIC_PTR_NOGC_INIT (move_varray, yara_max_uid, "moves");
   FOR_EACH_BB (bb)
     {
-      bound = NEXT_INSN (BB_END (bb));
-      for (insn = BB_HEAD (bb); insn != bound; insn = NEXT_INSN (insn))
+      FOR_BB_INSNS (bb, insn)
 	if (INSN_P (insn))
 	  {
 	    if ((set = single_set (insn)) != NULL_RTX


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]