[NDS32] Consider TARGET_CMODEL_LARGE for function call instructions.
authorChung-Ju Wu <jasonwucj@gmail.com>
Tue, 13 Jan 2015 05:37:07 +0000 (05:37 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Tue, 13 Jan 2015 05:37:07 +0000 (05:37 +0000)
gcc/
* config/nds32/nds32.md (call): Use pseudo instruction bal which
clobbers TA_REGNUM if large code model is specified.
(call_register): Likewise.
(call_immediate): Likewise.
(call_value): Likewise.
(call_value_register): Likewise.
(call_value_immediate): Likewise.

From-SVN: r219512

gcc/ChangeLog
gcc/config/nds32/nds32.md

index f4fae586b27084cd8e27f964c62edfb861f30da2..047af3dbe4436b752862812c70cdaa89652f058d 100644 (file)
@@ -1,3 +1,13 @@
+2015-01-13  Chung-Ju Wu  <jasonwucj@gmail.com>
+
+       * config/nds32/nds32.md (call): Use pseudo instruction bal which
+       clobbers TA_REGNUM if large code model is specified.
+       (call_register): Likewise.
+       (call_immediate): Likewise.
+       (call_value): Likewise.
+       (call_value_register): Likewise.
+       (call_value_immediate): Likewise.
+
 2015-01-13  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.h (TARGET_CMODEL_SMALL): New macro.
index 41b5bdc29f69f54af39bf0fca25a6015e2d57a3a..8302969fcabf9512df241d7f833e76a58111a891 100644 (file)
@@ -1902,7 +1902,8 @@ create_template:
 (define_expand "call"
   [(parallel [(call (match_operand 0 "memory_operand" "")
                    (match_operand 1))
-             (clobber (reg:SI LP_REGNUM))])]
+             (clobber (reg:SI LP_REGNUM))
+             (clobber (reg:SI TA_REGNUM))])]
   ""
   ""
 )
@@ -1910,7 +1911,8 @@ create_template:
 (define_insn "*call_register"
   [(parallel [(call (mem (match_operand:SI 0 "register_operand" "r, r"))
                    (match_operand 1))
-             (clobber (reg:SI LP_REGNUM))])]
+             (clobber (reg:SI LP_REGNUM))
+             (clobber (reg:SI TA_REGNUM))])]
   ""
   "@
   jral5\t%0
@@ -1921,11 +1923,20 @@ create_template:
 (define_insn "*call_immediate"
   [(parallel [(call (mem (match_operand:SI 0 "immediate_operand" "i"))
                    (match_operand 1))
-             (clobber (reg:SI LP_REGNUM))])]
+             (clobber (reg:SI LP_REGNUM))
+             (clobber (reg:SI TA_REGNUM))])]
   ""
-  "jal\t%0"
+{
+  if (TARGET_CMODEL_LARGE)
+    return "bal\t%0";
+  else
+    return "jal\t%0";
+}
   [(set_attr "type"   "branch")
-   (set_attr "length"      "4")])
+   (set (attr "length")
+       (if_then_else (match_test "TARGET_CMODEL_LARGE")
+                     (const_int 12)
+                     (const_int 4)))])
 
 
 ;; Subroutine call instruction returning a value.
@@ -1938,7 +1949,8 @@ create_template:
   [(parallel [(set (match_operand 0)
                   (call (match_operand 1 "memory_operand" "")
                         (match_operand 2)))
-             (clobber (reg:SI LP_REGNUM))])]
+             (clobber (reg:SI LP_REGNUM))
+             (clobber (reg:SI TA_REGNUM))])]
   ""
   ""
 )
@@ -1947,7 +1959,8 @@ create_template:
   [(parallel [(set (match_operand 0)
                   (call (mem (match_operand:SI 1 "register_operand" "r, r"))
                         (match_operand 2)))
-             (clobber (reg:SI LP_REGNUM))])]
+             (clobber (reg:SI LP_REGNUM))
+             (clobber (reg:SI TA_REGNUM))])]
   ""
   "@
   jral5\t%1
@@ -1959,11 +1972,20 @@ create_template:
   [(parallel [(set (match_operand 0)
                   (call (mem (match_operand:SI 1 "immediate_operand" "i"))
                         (match_operand 2)))
-             (clobber (reg:SI LP_REGNUM))])]
+             (clobber (reg:SI LP_REGNUM))
+             (clobber (reg:SI TA_REGNUM))])]
   ""
-  "jal\t%1"
+{
+  if (TARGET_CMODEL_LARGE)
+    return "bal\t%1";
+  else
+    return "jal\t%1";
+}
   [(set_attr "type"   "branch")
-   (set_attr "length"      "4")])
+   (set (attr "length")
+       (if_then_else (match_test "TARGET_CMODEL_LARGE")
+                     (const_int 12)
+                     (const_int 4)))])
 
 
 ;; prologue and epilogue.