Oleg Endo <oleg.e...@t-online.de> wrote: > This adds the two common built-in functions __builtin_thread_pointer and > __builtin_set_thread_pointer to the SH port. > I've done it in a way so that hopefully it can be transitioned to target > independent thread pointer built-ins easily, as suggested by Richard a > while ago: > http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00946.html > > Originally I wanted to wait until the target independent bits are in, > but somehow the thread mentioned above died and I got impatient. > > I've also added support for SH's GBR based displacement addressing > modes. They are not used for general purpose mem loads/stores by the > compiler, but rather when code accesses data behind the thread pointer > (thread control block or something). > The way GBR displacement address opportunities are discovered might not > be the best way of doing this sort of thing, but it works. The insn > walking could potentially slow down compile times, but it is only > enabled for functions where the GBR is referenced, so it shouldn't be so > bad. Alternatives and suggestions are highly appreciated. :) > > Tested on rev 191894 with 'make all' (c,c++) and > 'make -k check-gcc RUNTESTFLAGS="sh.exp --target_board=sh-sim > \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"' > > For code that doesn't reference GBR there are no functional changes. > TLS code that references GBR might trigger the 'sh_find_equiv_gbr_addr' > function. Unfortunately TLS tests don't seem to work on sh-sim, so I > could not test this part.
sh4-unknown-linux-gnu build failed during compiling libmudflap: /exp/ldroot/dodes/xsh-gcc/./gcc/xgcc -B/exp/ldroot/dodes/xsh-gcc/./gcc/ -B/usr/local/sh4-unknown-linux-gnu/bin/ -B/usr/local/sh4-unknown-linux-gnu/lib/ -isystem /usr/local/sh4-unknown-linux-gnu/include -isystem /usr/local/sh4-unknown-linux-gnu/sys-include -DHAVE_CONFIG_H -I. -I../../../LOCAL/trunk/libmudflap -DLIBMUDFLAPTH -g -O2 -MT libmudflapth_la-mf-runtime.lo -MD -MP -MF .deps/libmudflapth_la-mf-runtime.Tpo -c ../../../LOCAL/trunk/libmudflap/mf-runtime.c -o libmudflapth_la-mf-runtime.o ../../../LOCAL/trunk/libmudflap/mf-runtime.c: In function 'begin_recursion_protect1': ../../../LOCAL/trunk/libmudflap/mf-runtime.c:152:1: internal compiler error: Segmentation fault } ^ 0x8529c60 crash_signal ../../LOCAL/trunk/gcc/toplev.c:335 0x8771a87 sh_find_base_reg_disp ../../LOCAL/trunk/gcc/config/sh/sh.c:13344 0x8791554 sh_find_equiv_gbr_addr(rtx_def*, rtx_def*) ../../LOCAL/trunk/gcc/config/sh/sh.c:13395 0x87ce6cf gen_split_1029(rtx_def*, rtx_def**) ../../LOCAL/trunk/gcc/config/sh/sh.md:10184 0x87ea6e0 split_1 ../../LOCAL/trunk/gcc/config/sh/sh.md:10183 0x87ea6e0 split_3 ../../LOCAL/trunk/gcc/config/sh/sh.md:7082 0x82bf8a1 try_split(rtx_def*, rtx_def*, int) ../../LOCAL/trunk/gcc/emit-rtl.c:3503 0x849c642 split_insn ../../LOCAL/trunk/gcc/recog.c:2809 0x84a08b5 split_all_insns() ../../LOCAL/trunk/gcc/recog.c:2899 0x84a09a7 rest_of_handle_split_all_insns ../../LOCAL/trunk/gcc/recog.c:3751 Looks prev_nonnote_insn returns a barrier there: (gdb) fr 0 #0 0x08771a87 in sh_find_base_reg_disp (insn=<optimized out>, x=0xb79ddd40, base_reg=0x0, disp=0) at ../../LOCAL/trunk/gcc/config/sh/sh.c:13344 13344 if (p != NULL && GET_CODE (p) == SET && REG_P (XEXP (p, 0)) (gdb) p p $1 = (rtx) 0xafafafaf (gdb) p i $2 = (rtx_def *) 0xb79ecc3c (gdb) call debug_rtx(i) (barrier 216 215 217) > (builtin_description): Add is_enabled member. > (shmedia_builtin, sh1_builtin): New functions. > (signature_args): Add SH_BLTIN_VP. > (bdesc): Use shmedia_builtin for existing built-ins. Add > __builtin_thread_pointer and __builtin_set_thread_pointer as > sh1_builtin. > (sh_media_init_builtins, sh_init_builtins): Merge into single > function sh_init_builtins. Add is_enabled checking. > (sh_media_builtin_decl, sh_builtin_decl): Merge into single > function sh_builtin_decl. Add is_enabled checking. It would be better to separate this part except new thread pointer builtins into an independent patch which should be tested also with sh64-elf build, though now unified sh64-elf build is failing. I'd like to commit a quick fix for sh64-elf build failure. Regards, kaz