c4x.c: Convert to use GEN_INT.
authorMichael Hayes <m.hayes@elec.canterbury.ac.nz>
Wed, 14 Oct 1998 22:46:04 +0000 (22:46 +0000)
committerMichael Hayes <m.hayes@gcc.gnu.org>
Wed, 14 Oct 1998 22:46:04 +0000 (22:46 +0000)
* config/c4x/c4x.c: Convert to use GEN_INT.
(c4x_parallel_process): Rework to handle new repeat loop structure.
* config/c4x/c4x.md: Convert to use GEN_INT.
(rptb_end): Convert to use GE test.  Replace uses with clobbers.
(decrement_and_branch_on_count): Likewise.
* config/c4x/c4x.h (REPEAT_BLOCK_PROCESS): Deleted hook now that
loop.c has the desired functionality.
(rc_reg_operand): New prototype.
* config/c4x/t-c4x: Can now build all front ends.

From-SVN: r23103

gcc/ChangeLog
gcc/config/c4x/c4x.c
gcc/config/c4x/c4x.h
gcc/config/c4x/c4x.md
gcc/config/c4x/t-c4x

index a817a34cc10fc60d8ca74609f17fab2a35c000df..a78adfbccc0cbadad052715570cf44793538b0dd 100644 (file)
@@ -1,3 +1,18 @@
+Thu Oct 15 17:36:48 1998  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>
+
+       * config/c4x/c4x.c: Convert to use GEN_INT.
+       (c4x_parallel_process): Rework to handle new repeat loop structure.
+
+       * config/c4x/c4x.md: Convert to use GEN_INT. 
+       (rptb_end): Convert to use GE test.  Replace uses with clobbers.
+       (decrement_and_branch_on_count): Likewise.
+
+       * config/c4x/c4x.h (REPEAT_BLOCK_PROCESS): Deleted hook now that
+       loop.c has the desired functionality.
+       (rc_reg_operand): New prototype.
+
+       * config/c4x/t-c4x: Can now build all front ends.
+
 Wed Oct 14 23:27:08 1998  Didier FORT (didier.fort@fedex.com)
 
        * fixincludes: Fix up rpc/{clnt,svr,xdr}.h for SunOS.
index b471e3758d20faad37ab7db26159ec8d2e8277db..312c2daa154da3c50803510c857e583c56df25c7 100644 (file)
@@ -1120,7 +1120,7 @@ c4x_emit_libcall_mulhi (name, code, mode, operands)
                             gen_rtx_MULT (HImode,
                                      gen_rtx (code, HImode, operands[1]),
                                      gen_rtx (code, HImode, operands[2])),
-                                     gen_rtx_CONST_INT (VOIDmode, 32)));
+                                     GEN_INT (32)));
   insns = get_insns ();
   end_sequence ();
   emit_libcall_block (insns, operands[0], ret, equiv);
@@ -1910,9 +1910,9 @@ c4x_scan_for_ldp (newop, insn, operand0)
              addr = XEXP (addr, 0);
              if (GET_CODE (addr) == CONST_INT)
                {
-                 op1 = gen_rtx_CONST_INT (VOIDmode, INTVAL (addr) & ~0xffff);
+                 op1 = GEN_INT (INTVAL (addr) & ~0xffff);
                  emit_insn_before (gen_movqi (operand0, op1), insn);
-                 op1 = gen_rtx_CONST_INT (VOIDmode, INTVAL (addr) & 0xffff);
+                 op1 = GEN_INT (INTVAL (addr) & 0xffff);
                  emit_insn_before (gen_iorqi3_noclobber (operand0,
                                                      operand0, op1), insn);
                  delete_insn (insn);
@@ -4598,14 +4598,18 @@ c4x_parallel_process (loop_start, loop_end)
   rtx insn;
   rtx insn2;
   rtx pack;
-  rtx hoist;
-  rtx sink;
+  rtx hoist_pos;
+  rtx sink_pos;
   rtx loop_count;
   rtx loop_count_set;
+  rtx loop_count_reg;
+  rtx jump_insn;
   rtx end_label;
   int num_packs;
   int bb;
 
+  jump_insn = PREV_INSN (loop_end);
+
   /* The loop must have a calculable number of iterations
      since we need to reduce the loop count by one.  
 
@@ -4614,77 +4618,34 @@ c4x_parallel_process (loop_start, loop_end)
 
      The loop count must be at least 2?  */
 
-  loop_count = NEXT_INSN (loop_start);
-
-  /* Skip past CLOBBER and USE and deleted insn. This is from flow. */
-  for (;;)
-    {
-      if (GET_CODE (loop_count) == INSN)
-       {
-          rtx x = PATTERN (loop_count);
-          if (GET_CODE (x) != USE && GET_CODE (x) != CLOBBER)
-           break;
-       }
-      else if (GET_CODE (loop_count) == NOTE)
-       {
-         if (! INSN_DELETED_P (loop_count))
-           break;
-       }
-      else
-       break;
-      loop_count = NEXT_INSN (loop_count);
-    }
+  loop_count = PREV_INSN (loop_start);
   
   if (!(loop_count_set = single_set (loop_count)))
     return 0;
-  
-  if (!REG_P (SET_DEST (loop_count_set)) 
-      || REGNO (SET_DEST (loop_count_set)) != RC_REGNO)
+
+  if (!find_reg_note (loop_count, REG_LOOP_COUNT, NULL_RTX))
     return 0;
 
-  /* Determine places to hoist and sink insns out of the loop.  We
-     won't have to update basic_block_head if we move things after
-     loop_count. */
+  loop_count_reg = SET_DEST (loop_count_set);
+                 
+  /* Determine places to hoist and sink insns out of the loop. 
+     We need to hoist insns before the label at the top of the loop. 
+     We'll have to update basic_block_head.  */
   
-  hoist = loop_count;
-  end_label = PREV_INSN (loop_end);
-
-  /* Skip past filler insn if present.  */
-  if (GET_CODE (end_label) != CODE_LABEL)
-    end_label = PREV_INSN (end_label);
-
-  /* Skip past CLOBBER, USE, and deleted insns inserted by the flow pass. */
-  for (;;)
-    {
-      if (GET_CODE (end_label) == INSN)
-       {
-          rtx x = PATTERN (end_label);
-          if (GET_CODE (x) != USE && GET_CODE (x) != CLOBBER)
-           break;
-       }
-      else if (GET_CODE (end_label) == NOTE)
-       {
-         if (! INSN_DELETED_P (end_label))
-           break;
-       }
-      else
-       break;
-      end_label = PREV_INSN (end_label);
-    }
+  /* Place in the rtx where we hoist insns after.  */
+  hoist_pos = loop_count;
 
-  if (GET_CODE (end_label) != CODE_LABEL)
-    return 0;
-
-  sink = end_label;
+  /* Place in the rtx where we sink insns after.  */
+  sink_pos = loop_end;
 
   /* There must be an easier way to work out which basic block we are
      in.  */
   for (bb = 0; bb < n_basic_blocks; bb++)
-    if (basic_block_head[bb] == sink)
+    if (basic_block_head[bb] == NEXT_INSN (loop_end))
       break;
 
   if (bb >= n_basic_blocks)
-    fatal_insn("Cannot find basic block for insn", sink);
+    fatal_insn("Cannot find basic block for insn", NEXT_INSN (loop_end));
 
   /* Skip to label at top of loop.  */
   for (; GET_CODE (loop_start) != CODE_LABEL;
@@ -4750,12 +4711,13 @@ c4x_parallel_process (loop_start, loop_end)
 
              /* We need to hoist all the insns from the loop top
                 to and including insn.  */
-             c4x_copy_insns_after(NEXT_INSN (loop_start), insn, &hoist, bb);
+             c4x_copy_insns_after (NEXT_INSN (loop_start), insn,
+                                   &hoist_pos, bb);
 
              /* We need to sink all the insns after insn to 
                 loop_end.  */
-             c4x_copy_insns_after (NEXT_INSN (insn), PREV_INSN(end_label),
-                                   &sink, bb + 1);
+             c4x_copy_insns_after (NEXT_INSN (insn), PREV_INSN (jump_insn),
+                                   &sink_pos, bb + 1);
 
              /* Change insn to the new parallel insn, retaining the notes
                 of the old insn.  */
@@ -4776,34 +4738,30 @@ c4x_parallel_process (loop_start, loop_end)
              if (note)
                remove_note (insn, note);
 
-             /* Do we have to modify the LOG_LINKS?  */
+             /* ??? Do we have to modify the LOG_LINKS?  */
 
              /* We need to decrement the loop count.  We probably
-                should test if RC is negative and branch to end label
-                if so.  */
+                should test if the loop count is negative and branch
+                to end label if so.  */
              if (GET_CODE (SET_SRC (loop_count_set)) == CONST_INT)
                {
                  /* The loop count must be more than 1 surely?  */
                  SET_SRC (loop_count_set) 
-                   = gen_rtx_CONST_INT (VOIDmode,
-                                        INTVAL (SET_SRC (loop_count_set)) -1);
+                   = GEN_INT (INTVAL (SET_SRC (loop_count_set)) - 1);
                }
              else if (GET_CODE (SET_SRC (loop_count_set)) == PLUS
                       && GET_CODE (XEXP (SET_SRC (loop_count_set), 1))
                       == CONST_INT)
                {
                  XEXP (SET_SRC (loop_count_set), 1)
-                   = gen_rtx_CONST_INT (VOIDmode,
-                                   INTVAL (XEXP (SET_SRC (loop_count_set), 1))
-                                        - 1);
+                   = GEN_INT (INTVAL (XEXP (SET_SRC (loop_count_set), 1))
+                              - 1);
                }
              else
                {
                  start_sequence ();
-                 expand_binop (QImode, sub_optab,
-                               gen_rtx_REG (QImode, RC_REGNO),
-                               gen_rtx_CONST_INT (VOIDmode, 1),
-                               gen_rtx_REG (QImode, RC_REGNO),
+                 expand_binop (QImode, sub_optab, loop_count_reg,
+                               GEN_INT (1), loop_count_reg,            
                                1, OPTAB_DIRECT);
                  seq_start = get_insns ();
                  end_sequence ();
@@ -4813,23 +4771,30 @@ c4x_parallel_process (loop_start, loop_end)
                     Can we emit more than one insn? */
                  REG_NOTES (seq_start)
                    = gen_rtx_EXPR_LIST (REG_UNUSED,
-                              gen_rtx_REG (QImode, RC_REGNO),
+                              loop_count_reg,
                               REG_NOTES (seq_start));
                }
 
-             start_sequence ();
-             emit_cmp_insn (gen_rtx_REG (QImode, RC_REGNO),
-                            const0_rtx, LT, NULL_RTX, QImode, 0, 0);
-             emit_jump_insn (gen_blt (end_label));
-             seq_start = get_insns ();
-             end_sequence ();
-             emit_insns_after (seq_start, hoist);
-             
-             /* This is a bit of a hack... */
-             REG_NOTES (NEXT_INSN (seq_start))
-               = gen_rtx_EXPR_LIST (REG_DEAD,
-                          gen_rtx_REG (QImode, RC_REGNO),
-                          REG_NOTES (NEXT_INSN (seq_start)));
+             if (GET_CODE (SET_SRC (loop_count_set)) != CONST_INT)
+               {
+                 end_label = gen_label_rtx();
+                 start_sequence ();
+                 emit_cmp_insn (loop_count_reg,
+                                const0_rtx, LT, NULL_RTX, word_mode, 0, 0);
+                 emit_jump_insn (gen_blt (end_label));
+                 seq_start = get_insns ();
+                 end_sequence ();
+                 emit_insns_after (seq_start, hoist_pos);
+                 emit_label_after (end_label, sink_pos);
+                
+#if 0 
+                 /* This is a bit of a hack...but why was it necessary?  */
+                 REG_NOTES (NEXT_INSN (seq_start))
+                   = gen_rtx_EXPR_LIST (REG_DEAD,
+                                        loop_count_reg,
+                                        REG_NOTES (NEXT_INSN (seq_start)));
+#endif
+               }
 
              if (TARGET_DEVEL)
                debug_rtx(insn);
@@ -5258,7 +5223,7 @@ c4x_rptb_emit_init (loop_info)
 
   /* If have a known constant loop count, things are easy...  */
   if (loop_info->loop_count > 0)
-    return gen_rtx_CONST_INT (VOIDmode, loop_info->loop_count - 1);
+    return GEN_INT (loop_info->loop_count - 1);
 
   if (loop_info->shift < 0)
     abort ();
@@ -5288,14 +5253,13 @@ c4x_rptb_emit_init (loop_info)
       /* (end_value - start_value + adjust) >> shift */
       result = expand_binop (QImode, loop_info->unsigned_p ?
                             lshr_optab : ashr_optab, result,
-                            gen_rtx_CONST_INT (VOIDmode,
-                                     loop_info->shift),
+                            GEN_INT (loop_info->shift),
                             0, loop_info->unsigned_p, OPTAB_DIRECT);
     }
 
   /* ((end_value - start_value + adjust) >> shift) - 1 */
   result = expand_binop (QImode, sub_optab,
-                        result, gen_rtx_CONST_INT (VOIDmode, 1),
+                        result, GEN_INT (1),
                         0, loop_info->unsigned_p, OPTAB_DIRECT);
 
   seq_start = get_insns ();
index d68427d326131174019c9f7e1290ea1fadff7357..527c0a721bd9763bdb2604c0904789dfa23aa210 100644 (file)
@@ -2458,11 +2458,6 @@ if (final_sequence != NULL_RTX)          \
 
 #define NO_FUNCTION_CSE
 
-/* Repeat block stuff (hook into strength_reduce() in loop.c).  */
-
-extern void c4x_rptb_process ();
-#define REPEAT_BLOCK_PROCESS(START, END) c4x_rptb_process(START, END)
-
 /* We don't want a leading tab.  */
 
 #define ASM_OUTPUT_ASM(FILE, STRING) fprintf (FILE, "%s\n", STRING)
@@ -2581,6 +2576,8 @@ extern int dp_reg_operand ();
 
 extern int sp_reg_operand ();
 
+extern int rc_reg_operand ();
+
 extern int st_reg_operand ();
 
 extern int call_operand ();
index ccccdeb12d97f08732671a600464e00d32ec5f03..bfcc7b0e33bbe1aab8beee5755cc92eaf09d1d00 100644 (file)
 
    if (!TARGET_C3X && which_alternative == 3)
      {
-       operands[1] = gen_rtx_CONST_INT (VOIDmode, 
-                                        (INTVAL (operands[1]) >> 16) & 0xffff);
+       operands[1] = GEN_INT ((INTVAL (operands[1]) >> 16) & 0xffff);
        return \"ldhi\\t%1,%0\";
      }
 
   "*
    if (INTVAL (operands[2]) == 8)
      {
-       operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 8);
+       operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
        return \"lb%3\\t%1,%0\";
      }
-   operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 16);
+   operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
    return \"lh%3\\t%1,%0\";
   "
   [(set_attr "type" "binarycc,binary")
   "*
    if (INTVAL (operands[2]) == 8)
      {
-       operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 8);
+       operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
        return \"lb%3\\t%1,%0\";
      }
-   operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 16);
+   operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
    return \"lh%3\\t%1,%0\";
   "
   [(set_attr "type" "binarycc")
   "*
    if (INTVAL (operands[2]) == 8)
      {
-       operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 8);
+       operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
        return \"lb%3\\t%1,%0\";
      }
-   operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 16);
+   operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
    return \"lh%3\\t%1,%0\";
   "
   [(set_attr "type" "binarycc")
   "*
    if (INTVAL (operands[2]) == 8)
      {
-       operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 8);
+       operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
        return \"lbu%3\\t%1,%0\";
      }
-   operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 16);
+   operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
    return \"lhu%3\\t%1,%0\";
   "
   [(set_attr "type" "binarycc,binary")
   "*
    if (INTVAL (operands[2]) == 8)
      {
-       operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 8);
+       operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
        return \"lbu%3\\t%1,%0\";
      }
-   operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 16);
+   operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
    return \"lhu%3\\t%1,%0\";
   "
   [(set_attr "type" "binarycc")
   "*
    if (INTVAL (operands[2]) == 8)
      {
-       operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 8);
+       operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
        return \"lbu%3\\t%1,%0\";
      }
-   operands[3] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[3]) / 16);
+   operands[3] = GEN_INT (INTVAL (operands[3]) / 16);
    return \"lhu%3\\t%1,%0\";
   "
   [(set_attr "type" "binarycc")
   "*
    if (INTVAL (operands[1]) == 8)
      {
-       operands[2] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[2]) / 8);
+       operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
        return \"mb%2\\t%3,%0\";
      }
    else if (INTVAL (operands[1]) == 16)
      {
-       operands[2] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[2]) / 16);
+       operands[2] = GEN_INT (INTVAL (operands[2]) / 16);
        return \"mh%2\\t%3,%0\";
      }
    return \"lwl1\\t%3,%0\";
   "*
    if (INTVAL (operands[1]) == 8)
      {
-       operands[2] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[2]) / 8);
+       operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
        return \"mb%2\\t%3,%0\";
      }
-   operands[2] = gen_rtx_CONST_INT (VOIDmode, INTVAL (operands[2]) / 16);
+   operands[2] = GEN_INT (INTVAL (operands[2]) / 16);
    return \"mh%2\\t%3,%0\";
   "
   [(set_attr "type" "binarycc")
 
 (define_insn "rptb_end"
   [(set (pc)
-        (if_then_else (ne (match_operand:QI 0 "rc_reg_operand" "v")
+        (if_then_else (ge (match_operand:QI 0 "rc_reg_operand" "v")
                           (const_int 0))
                       (label_ref (match_operand 1 "" ""))
                       (pc)))
-   (use (reg:QI 25))
-   (use (reg:QI 26))
    (set (match_dup 0)
         (plus:QI (match_dup 0)
-                 (const_int -1)))]
+                 (const_int -1)))
+   (clobber (reg:QI 25))
+   (clobber (reg:QI 26))]
   ""
   "*
    return c4x_rptb_nop_p(insn) ? \"nop\" : \"\";"
 
 (define_expand "decrement_and_branch_on_count"
   [(parallel [(set (pc)
-                   (if_then_else (ne (match_operand:QI 0 "rc_reg_operand" "v")
+                   (if_then_else (ge (match_operand:QI 0 "rc_reg_operand" "v")
                                      (const_int 0))
                                  (label_ref (match_operand 1 "" ""))
                                  (pc)))
-              (use (reg:QI 25))
-              (use (reg:QI 26))
-              (set (match_dup 0) (plus:QI (match_dup 0) (const_int -1)))])]
+              (set (match_dup 0) (plus:QI (match_dup 0) (const_int -1)))
+              (clobber (reg:QI 25))
+              (clobber (reg:QI 26))])]
   ""
   "")
 
        rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
        rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
        rtx op1lo = operand_subword (operands[1], 0, 0, HImode);
-       rtx count = gen_rtx_CONST_INT (VOIDmode, (INTVAL (operands[2]) - 32));
+       rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
 
        if (INTVAL (count))
          emit_insn (gen_ashlqi3 (op0hi, op1lo, count));
        rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
        rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
        rtx op1hi = operand_subword (operands[1], 1, 0, HImode);
-       rtx count = gen_rtx_CONST_INT (VOIDmode, (INTVAL (operands[2]) - 32));
+       rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
 
        if (INTVAL (count))
          emit_insn (gen_lshrqi3 (op0lo, op1hi, count));
        rtx op0hi = operand_subword (operands[0], 1, 0, HImode);
        rtx op0lo = operand_subword (operands[0], 0, 0, HImode);
        rtx op1hi = operand_subword (operands[1], 1, 0, HImode);
-       rtx count = gen_rtx_CONST_INT (VOIDmode, (INTVAL (operands[2]) - 32));
+       rtx count = GEN_INT ((INTVAL (operands[2]) - 32));
 
        if (INTVAL (count))
          emit_insn (gen_ashrqi3 (op0lo, op1hi, count));
        else
          emit_insn (gen_movqi (op0lo, op1hi));
-       emit_insn (gen_ashrqi3 (op0hi, op1hi, 
-                               gen_rtx_CONST_INT (VOIDmode, 31)));
+       emit_insn (gen_ashrqi3 (op0hi, op1hi, GEN_INT (31)));
        DONE;
     }
     emit_insn (gen_ashrhi3_reg (operands[0], operands[1], operands[2]));
index 1a16b90444c82f24c2e9486a2b4c5a8024d4265a..39e316e4d8d1563b32b0c7749145648fce87922c 100644 (file)
@@ -8,7 +8,7 @@ LIB1ASMFUNCS = _divqf3 _divqi3 _udivqi3 _umodqi3 _modqi3 _mulqi3 \
 
 # We do not have DF or DI types (or SF and SI for that matter),
 # so fake out the libgcc2 compilation.
-LIBGCC2_CFLAGS = -O2 -Dexit=unused_exit $(GCC_CFLAGS) $(LIBGCC2_INCLUDES) -DDF=HF -DDI=HI -DSF=QF -DSI=QI
+LIBGCC2_CFLAGS = -O2 -Dexit=unused_exit $(GCC_CFLAGS) $(LIBGCC2_INCLUDES) -DDF=HF -DDI=HI -DSF=QF -DSI=QI -Dinhibit_libc
 
 MULTILIB_OPTIONS = m30 msmall mmemparm
 MULTILIB_DIRNAMES = c3x small mem
@@ -20,7 +20,3 @@ INSTALL_LIBGCC = install-multilib
 
 # Don't make libgcc1-test since require crt0.o
 LIBGCC1_TEST =
-
-# C[34]x has its own float and limits.h
-TARGET_FLOAT_H=config/c4x/c4x-float.h
-TARGET_LIMITS_H=config/c4x/c4x-limits.h