i386 call pattern fixes

Richard Henderson rth@cygnus.com
Mon Mar 27 11:21:00 GMT 2000


The stdcall patterns now support sibcalls.  Also correct -fpic output
I broke last week whereby we never made direct calls thru the plt.

Bootstrapped i686-linux, with -fpic and without.


r~

        * i386.md (call_pop_0, call_value_pop_0): New.
        (call_pop_1): Remove constraint from unused arg.  Support sibcalls.
        (call_value_pop_1): Likewise.
        (call_0, call_value_0): New.
        (call_1, call_value_1): Remove constraint from unused arg.


Index: config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.md,v
retrieving revision 1.145
diff -c -p -d -r1.145 i386.md
*** i386.md	2000/03/18 19:01:04	1.145
--- i386.md	2000/03/27 19:12:30
***************
*** 7039,7057 ****
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
  (define_insn "*call_pop_1"
    [(call (match_operand:QI 0 "call_insn_operand" "m")
! 	 (match_operand:SI 1 "general_operand" "g"))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 3 "immediate_operand" "i")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[0], GET_MODE (operands[0])))
!     return \"call\\t%P0\";
!   
    operands[0] = XEXP (operands[0], 0);
!   return \"call\\t%*%0\";
  }"
    [(set_attr "type" "call")])
  
--- 7039,7079 ----
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
+ (define_insn "*call_pop_0"
+   [(call (match_operand:QI 0 "constant_call_address_operand" "")
+ 	 (match_operand:SI 1 "" ""))
+    (set (reg:SI 7) (plus:SI (reg:SI 7)
+ 			    (match_operand:SI 3 "immediate_operand" "")))]
+   ""
+   "*
+ {
+   if (SIBLING_CALL_P (insn))
+     return \"jmp\\t%P0\";
+   else
+     return \"call\\t%P0\";
+ }"
+   [(set_attr "type" "call")])
+   
  (define_insn "*call_pop_1"
    [(call (match_operand:QI 0 "call_insn_operand" "m")
! 	 (match_operand:SI 1 "" ""))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 3 "immediate_operand" "i")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[0], QImode))
!     {
!       if (SIBLING_CALL_P (insn))
! 	return \"jmp\\t%P0\";
!       else
! 	return \"call\\t%P0\";
!     }
    operands[0] = XEXP (operands[0], 0);
!   if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%*%0\";
!   else
!     return \"call\\t%*%0\";
  }"
    [(set_attr "type" "call")])
  
***************
*** 7070,7090 ****
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
  (define_insn "*call_1"
    [(call (match_operand:QI 0 "call_insn_operand" "m")
! 	 (match_operand:SI 1 "general_operand" "g"))]
!   ;; Operand 1 not used on the i386.
    ""
    "*
  {
!   if (constant_call_address_operand (operands[0], GET_MODE (operands[0])))
      {
        if (SIBLING_CALL_P (insn))
  	return \"jmp\\t%P0\";
        else
  	return \"call\\t%P0\";
      }
- 
    operands[0] = XEXP (operands[0], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%0\";
--- 7092,7123 ----
      XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
  }")
  
+ (define_insn "*call_0"
+   [(call (match_operand:QI 0 "constant_call_address_operand" "")
+ 	 (match_operand:SI 1 "" ""))]
+   ""
+   "*
+ {
+   if (SIBLING_CALL_P (insn))
+     return \"jmp\\t%P0\";
+   else
+     return \"call\\t%P0\";
+ }"
+   [(set_attr "type" "call")])
+ 
  (define_insn "*call_1"
    [(call (match_operand:QI 0 "call_insn_operand" "m")
! 	 (match_operand:SI 1 "" ""))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[0], QImode))
      {
        if (SIBLING_CALL_P (insn))
  	return \"jmp\\t%P0\";
        else
  	return \"call\\t%P0\";
      }
    operands[0] = XEXP (operands[0], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%0\";
***************
*** 9363,9401 ****
  ;; Call-value patterns last so that the wildcard operand does not
  ;; disrupt insn-recog's switch tables.
  
  (define_insn "*call_value_pop_1"
    [(set (match_operand 0 "" "")
  	(call (match_operand:QI 1 "call_insn_operand" "m")
! 	      (match_operand:SI 2 "general_operand" "g")))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 4 "immediate_operand" "i")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[1], GET_MODE (operands[1])))
!     return \"call\\t%P1\";
!   
    operands[1] = XEXP (operands[1], 0);
!   return \"call\\t%*%1\";
  }"
    [(set_attr "type" "callv")])
  
  (define_insn "*call_value_1"
    [(set (match_operand 0 "" "")
  	(call (match_operand:QI 1 "call_insn_operand" "m")
! 	      (match_operand:SI 2 "general_operand" "g")))]
!   ;; Operand 2 not used on the i386.
    ""
    "*
  {
!   if (constant_call_address_operand (operands[1], GET_MODE (operands[1])))
      {
        if (SIBLING_CALL_P (insn))
  	return \"jmp\\t%P1\";
        else
  	return \"call\\t%P1\";
      }
-   
    operands[1] = XEXP (operands[1], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%1\";
--- 9396,9469 ----
  ;; Call-value patterns last so that the wildcard operand does not
  ;; disrupt insn-recog's switch tables.
  
+ (define_insn "*call_value_pop_0"
+   [(set (match_operand 0 "" "")
+ 	(call (match_operand:QI 1 "constant_call_address_operand" "")
+ 	      (match_operand:SI 2 "" "")))
+    (set (reg:SI 7) (plus:SI (reg:SI 7)
+ 			    (match_operand:SI 4 "immediate_operand" "")))]
+   ""
+   "*
+ {
+   if (SIBLING_CALL_P (insn))
+     return \"jmp\\t%P1\";
+   else
+     return \"call\\t%P1\";
+ }"
+   [(set_attr "type" "callv")])
+ 
  (define_insn "*call_value_pop_1"
    [(set (match_operand 0 "" "")
  	(call (match_operand:QI 1 "call_insn_operand" "m")
! 	      (match_operand:SI 2 "" "")))
     (set (reg:SI 7) (plus:SI (reg:SI 7)
  			    (match_operand:SI 4 "immediate_operand" "i")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[1], QImode))
!     {
!       if (SIBLING_CALL_P (insn))
! 	return \"jmp\\t%P1\";
!       else
! 	return \"call\\t%P1\";
!     }
    operands[1] = XEXP (operands[1], 0);
!   if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%*%1\";
!   else
!     return \"call\\t%*%1\";
! }"
!   [(set_attr "type" "callv")])
! 
! (define_insn "*call_value_0"
!   [(set (match_operand 0 "" "")
! 	(call (match_operand:QI 1 "constant_call_address_operand" "")
! 	      (match_operand:SI 2 "" "")))]
!   ""
!   "*
! {
!   if (SIBLING_CALL_P (insn))
!     return \"jmp\\t%P1\";
!   else
!     return \"call\\t%P1\";
  }"
    [(set_attr "type" "callv")])
  
  (define_insn "*call_value_1"
    [(set (match_operand 0 "" "")
  	(call (match_operand:QI 1 "call_insn_operand" "m")
! 	      (match_operand:SI 2 "" "")))]
    ""
    "*
  {
!   if (constant_call_address_operand (operands[1], QImode))
      {
        if (SIBLING_CALL_P (insn))
  	return \"jmp\\t%P1\";
        else
  	return \"call\\t%P1\";
      }
    operands[1] = XEXP (operands[1], 0);
    if (SIBLING_CALL_P (insn))
      return \"jmp\\t%*%1\";


More information about the Gcc-patches mailing list