From 2f6bd6eb67a11faef36ab3420cf6783de15e4760 Mon Sep 17 00:00:00 2001 From: Yoshinori Sato Date: Tue, 28 Apr 2015 04:16:27 +0900 Subject: [PATCH] config.gcc: Add h8300-*-linux. gcc/ * config.gcc: Add h8300-*-linux. * config/h8300/linux.h: New. * config/h8300/t-linux: New. * config/h8300/h8300.c (h8300_option_override): Normal mode is not supported for h8300-*-linux. (h8300_file_start): Target priority change. (get_shift_alg): Likewise. (h8300_shift_need_scratch_p): Likewise. * config/h8300/h8300.h (TARGET_CPU_CPP_BUILTINS): Likewise. * config/h8300/h8300.md (define_peephole2): Remove duplicate condition. libgcc/ * config.host: Add h8300-*-linux * config/h8300/t-linux: New file. * config/h8300/lib1funs.s: Change symbol prefix. * config/h8300/sfp-machine.h: 64bit double support. From-SVN: r222479 --- gcc/ChangeLog | 13 +++++ gcc/config.gcc | 4 ++ gcc/config/h8300/h8300.c | 26 ++++++---- gcc/config/h8300/h8300.h | 20 ++++---- gcc/config/h8300/h8300.md | 2 +- gcc/config/h8300/linux.h | 50 +++++++++++++++++++ gcc/config/h8300/t-linux | 20 ++++++++ libgcc/ChangeLog | 7 +++ libgcc/config.host | 4 ++ libgcc/config/h8300/lib1funcs.S | 80 +++++++++++++++++-------------- libgcc/config/h8300/sfp-machine.h | 76 +++++++++++++++++++++++++++++ libgcc/config/h8300/t-linux | 10 ++++ 12 files changed, 255 insertions(+), 57 deletions(-) create mode 100644 gcc/config/h8300/linux.h create mode 100644 gcc/config/h8300/t-linux create mode 100644 libgcc/config/h8300/sfp-machine.h create mode 100644 libgcc/config/h8300/t-linux diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b36391e029f..a24e57c65ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2015-04-27 Yoshinori Sato + + * config.gcc: Add h8300-*-linux. + * config/h8300/linux.h: New. + * config/h8300/t-linux: New. + * config/h8300/h8300.c (h8300_option_override): Normal mode + is not supported for h8300-*-linux. + (h8300_file_start): Target priority change. + (get_shift_alg): Likewise. + (h8300_shift_need_scratch_p): Likewise. + * config/h8300/h8300.h (TARGET_CPU_CPP_BUILTINS): Likewise. + * config/h8300/h8300.md (define_peephole2): Remove duplicate condition. + 2015-04-27 Caroline Tice * final.c (final_scan_insn): Output cold_function_nmae as function diff --git a/gcc/config.gcc b/gcc/config.gcc index a1df0433285..5c48cd0c682 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1218,6 +1218,10 @@ h8300-*-elf*) tmake_file="h8300/t-h8300" tm_file="h8300/h8300.h dbxelf.h elfos.h newlib-stdint.h h8300/elf.h" ;; +h8300-*-linux*) + tmake_file="${tmake_file} h8300/t-h8300 h8300/t-linux" + tm_file="h8300/h8300.h dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h h8300/linux.h" + ;; hppa*64*-*-linux*) target_cpu_default="MASK_PA_11|MASK_PA_20" tm_file="pa/pa64-start.h ${tm_file} dbxelf.h elfos.h gnu-user.h linux.h \ diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 4e9110ecb7d..00087f30318 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -406,6 +406,14 @@ h8300_option_override (void) - Option ignored!"); } +#ifdef H8300_LINUX + if ((TARGET_NORMAL_MODE)) + { + error ("-mn is not supported for linux targets"); + target_flags ^= MASK_NORMAL_MODE; + } +#endif + /* Some of the shifts are optimized for speed by default. See http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01858.html If optimizing for size, change shift_alg for those shift to @@ -1006,12 +1014,12 @@ h8300_file_start (void) { default_file_start (); - if (TARGET_H8300H) - fputs (TARGET_NORMAL_MODE ? "\t.h8300hn\n" : "\t.h8300h\n", asm_out_file); - else if (TARGET_H8300SX) + if (TARGET_H8300SX) fputs (TARGET_NORMAL_MODE ? "\t.h8300sxn\n" : "\t.h8300sx\n", asm_out_file); else if (TARGET_H8300S) fputs (TARGET_NORMAL_MODE ? "\t.h8300sn\n" : "\t.h8300s\n", asm_out_file); + else if (TARGET_H8300H) + fputs (TARGET_NORMAL_MODE ? "\t.h8300hn\n" : "\t.h8300h\n", asm_out_file); } /* Output assembly language code for the end of file. */ @@ -4094,10 +4102,10 @@ get_shift_alg (enum shift_type shift_type, enum shift_mode shift_mode, /* Find the target CPU. */ if (TARGET_H8300) cpu = H8_300; - else if (TARGET_H8300H) - cpu = H8_300H; - else + else if (TARGET_H8300S) cpu = H8_S; + else + cpu = H8_300H; /* Find the shift algorithm. */ info->alg = SHIFT_LOOP; @@ -4540,10 +4548,10 @@ h8300_shift_needs_scratch_p (int count, machine_mode mode) /* Find out the target CPU. */ if (TARGET_H8300) cpu = H8_300; - else if (TARGET_H8300H) - cpu = H8_300H; - else + else if (TARGET_H8300S) cpu = H8_S; + else + cpu = H8_300H; /* Find the shift algorithm. */ switch (mode) diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 2a47aa840c1..86fd7d1f338 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -39,29 +39,29 @@ extern const char * const *h8_reg_names; #define TARGET_CPU_CPP_BUILTINS() \ do \ { \ - if (TARGET_H8300H) \ + if (TARGET_H8300SX) \ { \ - builtin_define ("__H8300H__"); \ - builtin_assert ("cpu=h8300h"); \ - builtin_assert ("machine=h8300h"); \ + builtin_define ("__H8300SX__"); \ if (TARGET_NORMAL_MODE) \ { \ builtin_define ("__NORMAL_MODE__"); \ } \ } \ - else if (TARGET_H8300SX) \ + else if (TARGET_H8300S) \ { \ - builtin_define ("__H8300SX__"); \ + builtin_define ("__H8300S__"); \ + builtin_assert ("cpu=h8300s"); \ + builtin_assert ("machine=h8300s"); \ if (TARGET_NORMAL_MODE) \ { \ builtin_define ("__NORMAL_MODE__"); \ } \ } \ - else if (TARGET_H8300S) \ + else if (TARGET_H8300H) \ { \ - builtin_define ("__H8300S__"); \ - builtin_assert ("cpu=h8300s"); \ - builtin_assert ("machine=h8300s"); \ + builtin_define ("__H8300H__"); \ + builtin_assert ("cpu=h8300h"); \ + builtin_assert ("machine=h8300h"); \ if (TARGET_NORMAL_MODE) \ { \ builtin_define ("__NORMAL_MODE__"); \ diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md index dfd082ce0df..4079b306d5c 100644 --- a/gcc/config/h8300/h8300.md +++ b/gcc/config/h8300/h8300.md @@ -5847,7 +5847,7 @@ (pc)))] "(TARGET_H8300H || TARGET_H8300S) && peep2_reg_dead_p (1, operands[0]) - && ((TARGET_H8300H && INTVAL (operands[1]) == 3) + && (INTVAL (operands[1]) == 3 || INTVAL (operands[1]) == 7 || INTVAL (operands[1]) == 15 || INTVAL (operands[1]) == 31 diff --git a/gcc/config/h8300/linux.h b/gcc/config/h8300/linux.h new file mode 100644 index 00000000000..ef31e8659f1 --- /dev/null +++ b/gcc/config/h8300/linux.h @@ -0,0 +1,50 @@ +/* Definitions of target machine for GNU compiler. + Renesas H8/300 (linux variant) + Copyright (C) 2015 + Free Software Foundation, Inc. + Contributed by Yoshinori Sato + +This file is part of GCC. + +GCC 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 3, or (at your option) +any later version. + +GCC 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 GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_H8300_LINUX_H +#define GCC_H8300_LINUX_H + +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + GNU_USER_TARGET_OS_CPP_BUILTINS(); \ + } \ + while (0) + +#undef LINK_SPEC +#define LINK_SPEC "%{mh:-mh8300helf_linux} %{ms:-m h8300self_linux} %{msx:-m h8300sxelf_linux}" + +#undef TARGET_DEFAULT +#define TARGET_DEFAULT (MASK_QUICKCALL | MASK_INT32 | MASK_H8300H) + +/* Width of a word, in units (bytes). */ +#undef DOUBLE_TYPE_SIZE +#define DOUBLE_TYPE_SIZE 64 + +#undef DEFAULT_SIGNED_CHAR +#define DEFAULT_SIGNED_CHAR 1 + +#undef USER_LABEL_PREFIX + +#define H8300_LINUX + +#endif /* ! GCC_H8300_LINUX_H */ diff --git a/gcc/config/h8300/t-linux b/gcc/config/h8300/t-linux new file mode 100644 index 00000000000..11237ea99f7 --- /dev/null +++ b/gcc/config/h8300/t-linux @@ -0,0 +1,20 @@ +# Copyright (C) 2015 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC 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 3, or (at your option) +# any later version. +# +# GCC 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 GCC; see the file COPYING3. If not see +# . + +MULTILIB_OPTIONS = ms/msx +MULTILIB_DIRNAMES = h8300s h8sx diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 0891353a5e5..c48a61cbe37 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,10 @@ +2015-04-27 Yoshinori Sato + + * config.host: Add h8300-*-linux + * config/h8300/t-linux: New file. + * config/h8300/lib1funs.s: Change symbol prefix. + * config/h8300/sfp-machine.h: 64bit double support. + 2015-04-22 Gregor Richards Szabolcs Nagy diff --git a/libgcc/config.host b/libgcc/config.host index ce14b9ee625..570998feffa 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -487,6 +487,10 @@ h8300-*-elf*) tm_file="$tm_file h8300/h8300-lib.h" extra_parts="$extra_parts crti.o crtn.o" ;; +h8300-*-linux*) + tmake_file="t-linux h8300/t-linux t-softfp-sfdf t-softfp" + tm_file="$tm_file h8300/h8300-lib.h" + ;; hppa*64*-*-linux*) tmake_file="$tmake_file pa/t-linux pa/t-linux64" extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" diff --git a/libgcc/config/h8300/lib1funcs.S b/libgcc/config/h8300/lib1funcs.S index 36e7d53a45d..24a74a93373 100644 --- a/libgcc/config/h8300/lib1funcs.S +++ b/libgcc/config/h8300/lib1funcs.S @@ -84,6 +84,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define A3E e3 #endif +#define CONCAT(A,B) A##B +#define LABEL0(U,X) CONCAT(U,__##X) +#define LABEL0_DEF(U,X) CONCAT(U,__##X##:) +#define LABEL_DEF(X) LABEL0_DEF(__USER_LABEL_PREFIX__,X) +#define LABEL(X) LABEL0(__USER_LABEL_PREFIX__,X) + #ifdef __H8300H__ #ifdef __NORMAL_MODE__ .h8300hn @@ -111,8 +117,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifdef __H8300__ .section .text .align 2 - .global ___cmpsi2 -___cmpsi2: + .global LABEL(cmpsi2) +LABEL_DEF(cmpsi2) cmp.w A0,A2 bne .L2 cmp.w A1,A3 @@ -137,8 +143,8 @@ ___cmpsi2: #ifdef __H8300__ .section .text .align 2 - .global ___ucmpsi2 -___ucmpsi2: + .global LABEL(ucmpsi2) +LABEL_DEF(ucmpsi2) cmp.w A0,A2 bne .L2 cmp.w A1,A3 @@ -207,10 +213,10 @@ _lab8: rts ; A0=A0/A1 signed - .global ___divhi3 -___divhi3: + .global LABEL(divhi3) +LABEL_DEF(divhi3) bsr divnorm - bsr ___udivhi3 + bsr LABEL(udivhi3) negans: btst #3,A2L ; should answer be negative ? beq _lab4 not A0H ; yes, so make it so @@ -220,18 +226,18 @@ _lab4: rts ; A0=A0%A1 signed - .global ___modhi3 -___modhi3: + .global LABEL(modhi3) +LABEL_DEF(modhi3) bsr modnorm - bsr ___udivhi3 + bsr LABEL(udivhi3) mov A3,A0 bra negans ; A0=A0%A1 unsigned - .global ___umodhi3 -___umodhi3: - bsr ___udivhi3 + .global LABEL(umodhi3) +LABEL_DEF(umodhi3) + bsr LABEL(udivhi3) mov A3,A0 rts @@ -251,8 +257,8 @@ ___umodhi3: ; The H8/300 only has a 16/8 bit divide, so we look at the incoming and ; see how to partition up the expression. - .global ___udivhi3 -___udivhi3: + .global LABEL(udivhi3) +LABEL_DEF(udivhi3) ; A0 A1 A2 A3 ; Nn Dd P sub.w A3,A3 ; Nn Dd xP 00 @@ -418,8 +424,8 @@ mpostive2: ; numerator in A0/A1 ; denominator in A2/A3 - .global ___modsi3 -___modsi3: + .global LABEL(modsi3) +LABEL_DEF(modsi3) #ifdef __H8300__ PUSHP S2P PUSHP S0P @@ -432,7 +438,7 @@ ___modsi3: #else PUSHP S2P bsr modnorm - bsr ___udivsi3 + bsr LABEL(divsi3) mov.l er3,er0 bra exitdiv #endif @@ -440,8 +446,8 @@ ___modsi3: ;; H8/300H and H8S version of ___udivsi3 is defined later in ;; the file. #ifdef __H8300__ - .global ___udivsi3 -___udivsi3: + .global LABEL(udivsi3) +LABEL_DEF(udivsi3) PUSHP S2P PUSHP S0P PUSHP S1P @@ -449,8 +455,8 @@ ___udivsi3: bra reti #endif - .global ___umodsi3 -___umodsi3: + .global LABEL(umodsi3) +LABEL_DEF(umodsi3) #ifdef __H8300__ PUSHP S2P PUSHP S0P @@ -460,13 +466,13 @@ ___umodsi3: mov S1,A1 bra reti #else - bsr ___udivsi3 + bsr LABEL(udivsi3) mov.l er3,er0 rts #endif - .global ___divsi3 -___divsi3: + .global LABEL(divsi3) +LABEL_DEF(divsi3) #ifdef __H8300__ PUSHP S2P PUSHP S0P @@ -476,7 +482,7 @@ ___divsi3: #else PUSHP S2P jsr divnorm - bsr ___udivsi3 + bsr LABEL(udivsi3) #endif ; examine what the sign should be @@ -591,8 +597,8 @@ setone: #else /* __H8300H__ */ ;; This function also computes the remainder and stores it in er3. - .global ___udivsi3 -___udivsi3: + .global LABEL(udivsi3) +LABEL_DEF(udivsi3) mov.w A1E,A1E ; denominator top word 0? bne DenHighNonZero @@ -681,8 +687,8 @@ divmod_L26: #ifdef __H8300__ .section .text .align 2 - .global ___mulhi3 -___mulhi3: + .global LABEL(mulhi3) +LABEL_DEF(mulhi3) mov.b A1L,A2L ; A2l gets srcb.l mulxu A0L,A2 ; A2 gets first sub product @@ -726,8 +732,8 @@ ___mulhi3: #ifdef __H8300__ - .global ___mulsi3 -___mulsi3: + .global LABEL(mulsi3) +LABEL_DEF(mulsi3) PUSHP S0P PUSHP S1P @@ -785,8 +791,8 @@ _done: ; 32b * 32b = 92 states ; - .global ___mulsi3 -___mulsi3: + .global LABEL(mulsi3) +LABEL_DEF(mulsi3) mov.w r1,r2 ; ( 2 states) b * d mulxu r0,er2 ; (22 states) @@ -814,11 +820,11 @@ L_skip2: #ifdef __H8300__ /* We still treat NANs different than libgcc2.c, but then, the behavior is undefined anyways. */ - .global ___fixunssfsi -___fixunssfsi: + .global LABEL(fixunssfsi) +LABEL_DEF(fixunssfsi) cmp.b #0x4f,r0h bge Large_num - jmp @___fixsfsi + jmp @LABEL(fixsfsi) Large_num: bhi L_huge_num xor.b #0x80,A0L diff --git a/libgcc/config/h8300/sfp-machine.h b/libgcc/config/h8300/sfp-machine.h new file mode 100644 index 00000000000..6a4f97553ae --- /dev/null +++ b/libgcc/config/h8300/sfp-machine.h @@ -0,0 +1,76 @@ +/* Soft-FP definitions for H8/300 + Copyright (C) 2015 Free Software Foundation, Inc. + +This file 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 3, or (at your option) any +later version. + +This file 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. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#define _FP_W_TYPE_SIZE 32 +#define _FP_W_TYPE unsigned long +#define _FP_WS_TYPE signed long +#define _FP_I_TYPE long + +#define _FP_MUL_MEAT_S(R,X,Y) \ + _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_D(R,X,Y) \ + _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) +#define _FP_MUL_MEAT_Q(R,X,Y) \ + _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) + +#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) +#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y) +#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) + +#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1) +#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1 +#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1 +#define _FP_NANSIGN_S 0 +#define _FP_NANSIGN_D 0 +#define _FP_NANSIGN_Q 0 + +#define _FP_KEEPNANFRACP 1 +#define _FP_QNANNEGATEDP 0 + +/* Someone please check this. */ +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ + do { \ + if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ + && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ + { \ + R##_s = Y##_s; \ + _FP_FRAC_COPY_##wc(R,Y); \ + } \ + else \ + { \ + R##_s = X##_s; \ + _FP_FRAC_COPY_##wc(R,X); \ + } \ + R##_c = FP_CLS_NAN; \ + } while (0) + +/* Not checked. */ +#define _FP_TININESS_AFTER_ROUNDING 0 + +#define __BIG_ENDIAN 4321 + +#define __BYTE_ORDER __BIG_ENDIAN + +/* Define ALIASNAME as a strong alias for NAME. */ +# define strong_alias(name, aliasname) _strong_alias(name, aliasname) +# define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); diff --git a/libgcc/config/h8300/t-linux b/libgcc/config/h8300/t-linux new file mode 100644 index 00000000000..a575e755a8a --- /dev/null +++ b/libgcc/config/h8300/t-linux @@ -0,0 +1,10 @@ +LIB1ASMSRC = h8300/lib1funcs.S +LIB1ASMFUNCS = _cmpsi2 _ucmpsi2 _divhi3 _divsi3 _mulhi3 _mulsi3 \ + _fixunssfsi_asm + +LIB2ADD += \ + $(srcdir)/config/h8300/clzhi2.c \ + $(srcdir)/config/h8300/ctzhi2.c \ + $(srcdir)/config/h8300/parityhi2.c \ + $(srcdir)/config/h8300/popcounthi2.c \ + $(srcdir)/config/h8300/fixunssfsi.c -- 2.30.2