Patchwork [1/2] m32c: Don't use set_optab_handler

login
register
mail settings
Submitter Richard Henderson
Date Aug. 1, 2012, 8:36 p.m.
Message ID <1343853361-21574-1-git-send-email-rth@redhat.com>
Download mbox | patch
Permalink /patch/174597/
State New
Headers show

Comments

Richard Henderson - Aug. 1, 2012, 8:36 p.m.
Committed after a build completed.


r~


	* config/m32c/m32c.c (TARGET_INIT_LIBFUNCS): Remove.
	(m32c_init_libfuncs): Remove.
	* config/m32c/cond.md (cstore<QHPSI>4_16): Rename from cstore<QHPSI>4.
	(cstore<QHPSI>4): New expander.
DJ Delorie - Aug. 1, 2012, 10:01 p.m.
I tried to test this, but newlib won't build (looks unrelated).  The
failure is this assert in expmed.h:


  gcc_assert (to_mode >= MIN_MODE_INT
	      && to_mode <= MAX_MODE_INT
	      && from_mode >= MIN_MODE_INT
	      && from_mode <= MAX_MODE_INT);

which can't possibly work on any platform with partial int modes
(PSImode) because the P*modes are enumerated *after* the regular
integer modes, so PSImode's enum value is higher than TImode
(MAX_MODE_INT for m32c).  Should there be a range check for
MIN,MAX_MODE_PARTIAL_INT as well?

enum machine_mode
{
  VOIDmode,                /* machmode.def:173 */
  BLKmode,                 /* machmode.def:177 */
  CCmode,                  /* machmode.def:205 */
  BImode,                  /* machmode.def:180 */
  QImode,                  /* machmode.def:185 */
  HImode,                  /* machmode.def:186 */
  SImode,                  /* machmode.def:187 */
  DImode,                  /* machmode.def:188 */
  TImode,                  /* machmode.def:189 */
  PSImode,                 /* config/m32c/m32c-modes.def:26 */


m32c-elf-gcc -B/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/newlib/ -isystem /greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/newlib/targ-include -isystem /greed/dj/m32c/newlib/src/newlib/libc/include -B/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/libgloss/m32c -L/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/libgloss/libnosys -L/greed/dj/m32c/newlib/src/libgloss/m32c  -mcpu=m32cm -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.20.0\" -DPACKAGE_STRING=\"newlib\ 1.20.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../../src/newlib/libc/stdio -O1 -DPREFER_SIZE_OVER_SPEED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES -DABORT_PROVIDED -fno-builtin      -g -O2 -fshort-enums -DSTRING_ONLY -c ../../../../../../src/newlib/libc/stdio/vfprintf.c -o lib_a-svfprintf.o
In file included from ../../../../../../src/newlib/libc/stdio/vfprintf.c:151:0:
../../../../../../src/newlib/libc/stdio/vfprintf.c: In function '_svfprintf_r':
../../../../../../src/newlib/libc/stdio/vfprintf.c:137:24: internal compiler error: in convert_cost_ptr, at expmed.h:639
 #   define _VFPRINTF_R _svfprintf_r
                        ^
../../../../../../src/newlib/libc/stdio/vfprintf.c:541:8: note: in expansion of macro '_VFPRINTF_R'
 _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
        ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [lib_a-svfprintf.o] Error 1


dj@greed pts/3 ~/m32c/gcc/m32c-elf/gcc
$ gdb cc1
GNU gdb (GDB) Red Hat Enterprise Linux (7.1-29.el6_0.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /greed/dj/m32c/gcc/m32c-elf/gcc/cc1...done.
Breakpoint 1 at 0xb25eb0: file ../../gcc/gcc/diagnostic.c, line 1010.
Breakpoint 2 at 0xb25de0: file ../../gcc/gcc/diagnostic.c, line 951.
Breakpoint 3 at 0x45f728
Breakpoint 4 at 0x45f5e8

[ gdb ] r -fpreprocessed vfprintf.i -quiet -dumpbase vfprintf.c -mcpu=m32cm -auxbase-strip lib_a-svfprintf.o -g -O1 -O2 -version -fno-builtin -fshort-enums -o vfprintf.s
GNU C (GCC) version 4.8.0 20120731 (experimental) [trunk revision 190021] (m32c-elf)
        compiled by GNU C version 4.4.6 20110731 (Red Hat 4.4.6-3), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.8.0 20120731 (experimental) [trunk revision 190021] (m32c-elf)
        compiled by GNU C version 4.4.6 20110731 (Red Hat 4.4.6-3), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 827bbd6609eec0d0ea9ef658ea29c21b

Breakpoint 1, fancy_abort (file=0xc3f911 "../../gcc/gcc/expmed.h", line=639, function=0xc40340 "convert_cost_ptr")
    at ../../gcc/gcc/diagnostic.c:1010
1010    {
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.47.el6_2.5.x86_64

[ gdb ] up
#1  0x0000000000aa9ffd in convert_cost_ptr (to_mode=SImode, from_mode=PSImode, speed=1 '\001')
    at ../../gcc/gcc/expmed.h:636
636       gcc_assert (to_mode >= MIN_MODE_INT

[ gdb ] where
#0  fancy_abort (file=0xc3f911 "../../gcc/gcc/expmed.h", line=639, function=0xc40340 "convert_cost_ptr")
    at ../../gcc/gcc/diagnostic.c:1010
#1  0x0000000000aa9ffd in convert_cost_ptr (to_mode=SImode, from_mode=PSImode, speed=1 '\001')
    at ../../gcc/gcc/expmed.h:636
#2  0x0000000000aaa08a in convert_cost (to_mode=SImode, from_mode=PSImode, speed=1 '\001')
    at ../../gcc/gcc/expmed.h:663
#3  0x0000000000aaae59 in stmt_cost (gs=0x7ffff77fbae0, speed=1 '\001')
    at ../../gcc/gcc/gimple-ssa-strength-reduction.c:359
#4  0x0000000000aabb6b in create_add_ssa_cand (gs=0x7ffff77da4e0, base_in=0x7ffff7b66280, 
    addend_in=0x7ffff77dfaf0, subtract_p=1 '\001', speed=1 '\001')
    at ../../gcc/gcc/gimple-ssa-strength-reduction.c:639
#5  0x0000000000aac6ce in slsr_process_add (gs=0x7ffff77da4e0, rhs1=0x7ffff7b66280, rhs2=0x7ffff77dfaf0, 
    speed=1 '\001') at ../../gcc/gcc/gimple-ssa-strength-reduction.c:801
#6  0x0000000000aad724 in find_candidates_in_block (walk_data=0x7fffffffe550, bb=0x7ffff7ba0930)
    at ../../gcc/gcc/gimple-ssa-strength-reduction.c:1096
#7  0x0000000000aa1506 in walk_dominator_tree (walk_data=0x7fffffffe550, bb=0x7ffff7ba0930)
    at ../../gcc/gcc/domwalk.c:188
#8  0x0000000000aae642 in execute_strength_reduction () at ../../gcc/gcc/gimple-ssa-strength-reduction.c:1468
#9  0x00000000007a8739 in execute_one_pass (pass=0xf38460) at ../../gcc/gcc/passes.c:2158
#10 0x00000000007a8ab5 in execute_pass_list (pass=0xf38460) at ../../gcc/gcc/passes.c:2213
#11 0x00000000007a8ac7 in execute_pass_list (pass=0xf33d60) at ../../gcc/gcc/passes.c:2214
#12 0x000000000058d806 in expand_function (node=0x7ffff79f2000) at ../../gcc/gcc/cgraphunit.c:1614
#13 0x000000000058e529 in expand_all_functions () at ../../gcc/gcc/cgraphunit.c:1719
#14 compile () at ../../gcc/gcc/cgraphunit.c:2017
#15 0x000000000058f8aa in finalize_compilation_unit () at ../../gcc/gcc/cgraphunit.c:2094
#16 0x0000000000472828 in c_write_global_declarations () at ../../gcc/gcc/c/c-decl.c:10116
#17 0x0000000000820b4d in compile_file () at ../../gcc/gcc/toplev.c:560
#18 0x000000000082202e in do_compile (argc=17, argv=0x7fffffffe808) at ../../gcc/gcc/toplev.c:1863
#19 toplev_main (argc=17, argv=0x7fffffffe808) at ../../gcc/gcc/toplev.c:1939
#20 0x0000003698c1ecdd in __libc_start_main () from /lib64/libc.so.6
#21 0x0000000000460289 in _start ()

[ gdb ]

Patch

diff --git a/gcc/config/m32c/cond.md b/gcc/config/m32c/cond.md
index c751070..5886a7d 100644
--- a/gcc/config/m32c/cond.md
+++ b/gcc/config/m32c/cond.md
@@ -152,14 +152,31 @@ 
 
 ;; These are the pre-split patterns for the conditional sets.
 
-(define_insn_and_split "cstore<mode>4"
+(define_expand "cstore<mode>4"
+  [(set (match_operand:QI 0 "register_operand")
+	(match_operator:QI 1 "ordered_comparison_operator"
+	 [(match_operand:QHPSI 2 "mra_operand")
+	  (match_operand:QHPSI 3 "mrai_operand")]))]
+  ""
+{
+  if (TARGET_A24)
+    {
+      rtx o = gen_reg_rtx (HImode);
+      emit_insn (gen_cstore<mode>4_24 (o, operands[1],
+				       operands[2], operands[3]));
+      emit_move_insn (operands[0], gen_lowpart (QImode, o));
+      DONE;
+    }
+})
+
+(define_insn_and_split "*cstore<mode>4_16"
   [(set (match_operand:QI 0 "register_operand" "=Rqi")
 	(match_operator:QI 1 "ordered_comparison_operator"
 	 [(match_operand:QHPSI 2 "mra_operand" "RraSd")
 	  (match_operand:QHPSI 3 "mrai_operand" "RraSdi")]))]
   "TARGET_A16"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(set (reg:CC FLG_REGNO)
 	(compare (match_dup 2)
 		 (match_dup 3)))
@@ -176,7 +193,7 @@ 
 	  (match_operand:QHPSI 3 "mrai_operand" "RraSdi")]))]
   "TARGET_A24"
   "#"
-  "reload_completed"
+  "&& reload_completed"
   [(set (reg:CC FLG_REGNO)
 	(compare (match_dup 2)
 		 (match_dup 3)))
diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c
index 79b03fa..878be09 100644
--- a/gcc/config/m32c/m32c.c
+++ b/gcc/config/m32c/m32c.c
@@ -1857,25 +1857,6 @@  m32c_trampoline_init (rtx m_tramp, tree fndecl, rtx chainval)
 #undef A0
 }
 
-/* Implicit Calls to Library Routines */
-
-#undef TARGET_INIT_LIBFUNCS
-#define TARGET_INIT_LIBFUNCS m32c_init_libfuncs
-static void
-m32c_init_libfuncs (void)
-{
-  /* We do this because the M32C has an HImode operand, but the
-     M16C has an 8-bit operand.  Since gcc looks at the match data
-     and not the expanded rtl, we have to reset the optab so that
-     the right modes are found. */
-  if (TARGET_A24)
-    {
-      set_optab_handler (cstore_optab, QImode, CODE_FOR_cstoreqi4_24);
-      set_optab_handler (cstore_optab, HImode, CODE_FOR_cstorehi4_24);
-      set_optab_handler (cstore_optab, PSImode, CODE_FOR_cstorepsi4_24);
-    }
-}
-
 /* Addressing Modes */
 
 /* The r8c/m32c family supports a wide range of non-orthogonal