rl78.c (rl78_asm_file_start): Specify alternate vregs location for RL78/G10.
authorDJ Delorie <dj@redhat.com>
Mon, 16 Sep 2013 21:15:46 +0000 (17:15 -0400)
committerDJ Delorie <dj@gcc.gnu.org>
Mon, 16 Sep 2013 21:15:46 +0000 (17:15 -0400)
* config/rl78/rl78.c (rl78_asm_file_start): Specify alternate
vregs location for RL78/G10.
(rl78_expand_prologue): Avoid SEL on G10.
(rl78_expand_epilogue): Likewise.
(rl78_peep_movhi_p): Can't move a constant to memory in HImode.
* config/rl78/rl78.h (TARGET_CPU_CPP_BUILTINS): Define
__RL78_G10__ when appropriate.
(ASM_SPEC): Pass -mg10 along to the assembler.
* config/rl78/rl78.md (sel_rb): Disable for G10.
* config/rl78/rl78.opt: Add -mg10 option.
* config/rl78/t-rl78: Add -mg10 multilib.

* config/rl78/lib2mul.c: Enable for RL78/G10.
* config/rl78/lib2div.c: Likewise.
* config/rl78/lshrsi3.S: Use vregs.h.
* config/rl78/cmpsi2.S: Likewise.
* config/rl78/trampoline.S: Likewise.
* config/rl78/mulsi2.S: Likewise.  Disable for RL78/G10.

From-SVN: r202637

12 files changed:
gcc/ChangeLog
gcc/config/rl78/rl78.c
gcc/config/rl78/rl78.h
gcc/config/rl78/rl78.opt
gcc/config/rl78/t-rl78
libgcc/ChangeLog
libgcc/config/rl78/cmpsi2.S
libgcc/config/rl78/lib2div.c
libgcc/config/rl78/lib2mul.c
libgcc/config/rl78/lshrsi3.S
libgcc/config/rl78/mulsi3.S
libgcc/config/rl78/trampoline.S

index fbcd00dcc3ddf160fa7f1323c9ba5b411a209f82..cc1935997dc3fe784b3798d2067c8b8d7d493cde 100644 (file)
@@ -1,3 +1,17 @@
+2013-09-16  DJ Delorie  <dj@redhat.com>
+
+       * config/rl78/rl78.c (rl78_asm_file_start): Specify alternate
+       vregs location for RL78/G10.
+       (rl78_expand_prologue): Avoid SEL on G10.
+       (rl78_expand_epilogue): Likewise.
+       (rl78_peep_movhi_p): Can't move a constant to memory in HImode.
+       * config/rl78/rl78.h (TARGET_CPU_CPP_BUILTINS): Define
+       __RL78_G10__ when appropriate.
+       (ASM_SPEC): Pass -mg10 along to the assembler.
+       * config/rl78/rl78.md (sel_rb): Disable for G10.
+       * config/rl78/rl78.opt: Add -mg10 option.
+       * config/rl78/t-rl78: Add -mg10 multilib.
+
 2013-09-16  Xinliang David Li  <davidxl@google.com>
 
        * tree-if-conv.c (main_tree_if_conversion): Check new flag.
index 3f13955d896e4ff59e9df0a84acc9ed0d2980aa3..d99cecfbff1e52f96931bbfb6ecc40ee5e652239 100644 (file)
@@ -259,10 +259,20 @@ rl78_asm_file_start (void)
 {
   int i;
 
-  for (i = 0; i < 8; i++)
+  if (TARGET_G10)
     {
-      fprintf (asm_out_file, "r%d\t=\t0x%x\n", 8 + i, 0xffef0 + i);
-      fprintf (asm_out_file, "r%d\t=\t0x%x\n", 16 + i, 0xffee8 + i);
+      /* The memory used is 0xffec8 to 0xffedf; real registers are in
+        0xffee0 to 0xffee7.  */
+      for (i = 8; i < 32; i++)
+       fprintf (asm_out_file, "r%d\t=\t0x%x\n", i, 0xffec0 + i);
+    }
+  else
+    {
+      for (i = 0; i < 8; i++)
+       {
+         fprintf (asm_out_file, "r%d\t=\t0x%x\n", 8 + i, 0xffef0 + i);
+         fprintf (asm_out_file, "r%d\t=\t0x%x\n", 16 + i, 0xffee8 + i);
+       }
     }
 
   opt_pass *rl78_devirt_pass = make_pass_rl78_devirt (g);
@@ -1018,19 +1028,26 @@ rl78_expand_prologue (void)
   if (flag_stack_usage_info)
     current_function_static_stack_size = cfun->machine->framesize;
 
-  if (is_interrupt_func (cfun->decl))
+  if (is_interrupt_func (cfun->decl) && !TARGET_G10)
     emit_insn (gen_sel_rb (GEN_INT (0)));
 
   for (i = 0; i < 16; i++)
     if (cfun->machine->need_to_push [i])
       {
-       int need_bank = i/4;
-       if (need_bank != rb)
+       if (TARGET_G10)
          {
-           emit_insn (gen_sel_rb (GEN_INT (need_bank)));
-           rb = need_bank;
+           emit_move_insn (gen_rtx_REG (HImode, 0), gen_rtx_REG (HImode, i*2));
+           F (emit_insn (gen_push (gen_rtx_REG (HImode, 0))));
          }
-       F (emit_insn (gen_push (gen_rtx_REG (HImode, i*2))));
+       else {
+         int need_bank = i/4;
+         if (need_bank != rb)
+           {
+             emit_insn (gen_sel_rb (GEN_INT (need_bank)));
+             rb = need_bank;
+           }
+         F (emit_insn (gen_push (gen_rtx_REG (HImode, i*2))));
+       }
       }
   if (rb != 0)
     emit_insn (gen_sel_rb (GEN_INT (0)));
@@ -1085,14 +1102,22 @@ rl78_expand_epilogue (void)
   for (i = 15; i >= 0; i--)
     if (cfun->machine->need_to_push [i])
       {
-       int need_bank = i / 4;
-
-       if (need_bank != rb)
+       if (TARGET_G10)
          {
-           emit_insn (gen_sel_rb (GEN_INT (need_bank)));
-           rb = need_bank;
+           emit_insn (gen_pop (gen_rtx_REG (HImode, 0)));
+           emit_move_insn (gen_rtx_REG (HImode, i*2), gen_rtx_REG (HImode, 0));
+         }
+       else
+         {
+           int need_bank = i / 4;
+
+           if (need_bank != rb)
+             {
+               emit_insn (gen_sel_rb (GEN_INT (need_bank)));
+               rb = need_bank;
+             }
+           emit_insn (gen_pop (gen_rtx_REG (HImode, i * 2)));
          }
-       emit_insn (gen_pop (gen_rtx_REG (HImode, i * 2)));
       }
 
   if (rb != 0)
@@ -1630,6 +1655,16 @@ rl78_peep_movhi_p (rtx *operands)
   fprintf (stderr, "\033[0m");
 #endif
 
+  /* You can move a constant to memory as QImode, but not HImode.  */
+  if (GET_CODE (operands[0]) == MEM
+      && GET_CODE (operands[1]) != REG)
+    {
+#if DEBUG_PEEP
+      fprintf (stderr, "no peep: move constant to memory\n");
+#endif
+      return false;
+    }
+
   if (rtx_equal_p (operands[0], operands[3]))
     {
 #if DEBUG_PEEP
index 00d2b83b9f5690647122e9e9362ee0e0c98890c6..8cf634eeb9f9078e42296314f52e213fd00a24ab 100644 (file)
@@ -32,6 +32,8 @@
        builtin_define ("__RL78_MUL_RL78__");   \
       if (RL78_MUL_G13)                                \
        builtin_define ("__RL78_MUL_G13__");    \
+      if (TARGET_G10)                          \
+       builtin_define ("__RL78_G10__");        \
     }                                           \
   while (0)
 
@@ -44,6 +46,7 @@
 #undef  ASM_SPEC
 #define ASM_SPEC "\
 %{mrelax:-relax} \
+%{mg10} \
 "
 
 #undef  LINK_SPEC
index 1538b897c57023766e781b9fd391cb9522c70619..9b573c10363a7589f2d57622a81986da1f2f0e0e 100644 (file)
@@ -45,3 +45,7 @@ Enum(rl78_mul_types) String(g13) Value(MUL_G13)
 mrelax
 Target
 Enable assembler and linker relaxation.
+
+mg10
+Target Mask(G10)
+Target the RL78/G10 series
index ed7ee74448b752f147065eebe9ad08f4fbf34cce..30705b3e5e519242db144541381d5cd13c30ca44 100644 (file)
@@ -20,3 +20,8 @@
 
 rl78-c.o: $(srcdir)/config/rl78/rl78-c.c $(RTL_H) $(TREE_H) $(CONFIG_H) $(TM_H)
        $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
+# Enable multilibs:
+
+MULTILIB_OPTIONS    = mg10
+MULTILIB_DIRNAMES   = g10
index 518a26c9470cb0af1a67fc6a5bbb0dbadf144ce9..728360ca8cc3f3b9eda61ead3a08da3619cd03c0 100644 (file)
@@ -1,3 +1,12 @@
+2013-09-16  DJ Delorie  <dj@redhat.com>
+
+       * config/rl78/lib2mul.c: Enable for RL78/G10.
+       * config/rl78/lib2div.c: Likewise.
+       * config/rl78/lshrsi3.S: Use vregs.h.
+       * config/rl78/cmpsi2.S: Likewise.
+       * config/rl78/trampoline.S: Likewise.
+       * config/rl78/mulsi2.S: Likewise.  Disable for RL78/G10.
+
 2013-09-14  DJ Delorie  <dj@redhat.com>
            Nick Clifton  <nickc@redhat.com>
 
index d815793daba2d908d4af9cd820f76758c7a4e077..7fdc76a03f65cf9e0ca5877eff754a423b4fb7ff 100644 (file)
@@ -21,8 +21,7 @@
 ; <http://www.gnu.org/licenses/>.
 
 
-; clobberable
-r8     =       0xffef0
+#include "vregs.h"
 
        .text
 
index 4b5033ef9708e0594546d38868739202634b5705..b37f55a94ac9b2b8e36f25af59e42d3dfd2af750 100644 (file)
@@ -34,7 +34,7 @@ typedef int           word_type     __attribute__ ((mode (__word__)));
 #define C3B(a,b,c) a##b##c
 #define C3(a,b,c) C3B(a,b,c)
 
-#if 0
+#ifdef __RL78_G10__
 
 #define UINT_TYPE      uint32_type
 #define SINT_TYPE      sint32_type
index 6460f9e69db64fae40afa93c260c0300f00caed1..fee50817722789ef5c5fb305da064dbdda5bad58 100644 (file)
@@ -30,12 +30,25 @@ typedef unsigned int  uint08_type   __attribute__ ((mode (QI)));
 #define C3B(a,b,c) a##b##c
 #define C3(a,b,c) C3B(a,b,c)
 
+#ifdef __RL78_G10__
+
+#define UINT_TYPE      uint32_type
+#define BITS_MINUS_1   31
+#define NAME_MODE      si
+
+#include "rl78-mul.h"
+
+#undef UINT_TYPE
+#undef BITS_MINUS_1
+#undef NAME_MODE
 
 #define UINT_TYPE      uint16_type
 #define BITS_MINUS_1   15
 #define NAME_MODE      hi
 
-/*#include "rl78-mul.h"*/
+#include "rl78-mul.h"
+
+#endif
 
 #undef UINT_TYPE
 #undef BITS_MINUS_1
index 1ee7325143ffe2b3f0499d1ecb6f56359323b926..8bd997897aa06b650b5ba02e829a5de59471a801 100644 (file)
 ; see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 ; <http://www.gnu.org/licenses/>.
 
-r8     =       0xffef0
-r16    =       0xffee8
-r9     =       0xffef1
-r17    =       0xffee9
-r10    =       0xffef2
-r18    =       0xffeea
-r11    =       0xffef3
-r19    =       0xffeeb
-r12    =       0xffef4
-r20    =       0xffeec
-r13    =       0xffef5
-r21    =       0xffeed
-r14    =       0xffef6
-r22    =       0xffeee
-r15    =       0xffef7
-r23    =       0xffeef
+#include "vregs.h"
        
        .text
        .global ___lshrsi3
index 012e87e285ffa86f5f360237f7745ae027b23ec4..1ce45ba3402c78517ff89db8e21a5fe547d65ade 100644 (file)
 
 ;; 32x32=32 multiply
 
-; real
-; GAS defines r0..r7 as aliases for real registers; we want the saddr
-; forms here.
-r_0    =       0xffef8
-r_1    =       0xffef9
-r_2    =       0xffefa
-r_3    =       0xffefb
-r_4    =       0xffefc
-r_5    =       0xffefd
-r_6    =       0xffefe
-r_7    =       0xffeff
-; clobberable
-r8     =       0xffef0
-r9     =       0xffef1
-r10    =       0xffef2
-r11    =       0xffef3
-r12    =       0xffef4
-r13    =       0xffef5
-r14    =       0xffef6
-r15    =       0xffef7
-; preserved
-r16    =       0xffee8
-r17    =       0xffee9
-r18    =       0xffeea
-r19    =       0xffeeb
-r20    =       0xffeec
-r21    =       0xffeed
-r22    =       0xffeee
-r23    =       0xffeef
+#include "vregs.h"
+; the G10 only has one register bank, so cannot use these optimized
+; versions.  Use the C version instead.
+
+#ifndef __RL78_G10__
 
 
 ;----------------------------------------------------------------------
@@ -221,3 +198,5 @@ ___mulhi3:
 
 .Lmul_hi_done:
        ret
+
+#endif
index b15b0d361e212c8ec373063973ac31aaf75c3daa..59d429eb589ffcfac7f13610aa2a86c06e00637b 100644 (file)
@@ -32,9 +32,7 @@
 
 */
 
-r8     =       0xffef0
-r10    =       0xffef2
-r14    =       0xffef6
+#include "vregs.h"
 
        .data
        .p2align        1