From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2152) id CFABE3994813; Fri, 30 Jul 2021 21:39:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFABE3994813 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Hans-Peter Nilsson To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2639] MMIX: remove generic placeholders parameters in call insn patterns. X-Act-Checkin: gcc X-Git-Author: Hans-Peter Nilsson X-Git-Refname: refs/heads/master X-Git-Oldrev: ee189a7327565cfcc2441aa308333ad3b6525e6e X-Git-Newrev: 5b2515f5ae86c21fc13021e1a8728a48e68aa7d6 Message-Id: <20210730213915.CFABE3994813@sourceware.org> Date: Fri, 30 Jul 2021 21:39:15 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2021 21:39:15 -0000 https://gcc.gnu.org/g:5b2515f5ae86c21fc13021e1a8728a48e68aa7d6 commit r12-2639-g5b2515f5ae86c21fc13021e1a8728a48e68aa7d6 Author: Hans-Peter Nilsson Date: Sun Jul 18 04:59:30 2021 +0200 MMIX: remove generic placeholders parameters in call insn patterns. I guess the best way to describe these operands, at least for MMIX, is "ballast". Some targets seem to drag along one or two of the incoming pattern operands through the rtl passes and not dropping them until assembly output. Let's stop doing that for MMIX. There really are *two* unused parameters: one is a number corresponding to the stack-size of arguments as a const_int and the other is whatever the target yields for targetm.calls.function_arg (args_so_far, function_arg_info::end_marker ()). There's a mandatory second argument to the "call" RTX, but the target doesn't have to keep it a variable number; it can be replaced by (const_int 0) early, like this. Astute readers may object that as the MMIX call-type insns (PUSHJ, PUSHGO) have a parameter in addition to the address of the called function, so should the emitted RTL. But, that parameter depends only on the local function, not the called function (IOW, it's the same for all calls in a function), and its value isn't known until frame layout time. Having it a parameter in the emitted RTL for the call would just be confusing. (Maybe this will be amended later, if/when improving "shrink-wrapping".) gcc: * config/mmix/mmix.md ("call", "call_value", "*call_real") ("*call_value_real"): Don't generate rtx mentioning the generic operands 1 and 2 to "call", and similarly for "call_value". * config/mmix/mmix.c (mmix_print_operand_punct_valid_p) (mmix_print_operand): Use '!' instead of 'p'. Diff: --- gcc/config/mmix/mmix.c | 20 +++++++++--------- gcc/config/mmix/mmix.md | 56 ++++++++++++++++++++----------------------------- 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index db7af7b75b6..010cd4773ea 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -1624,6 +1624,12 @@ mmix_print_operand (FILE *stream, rtx x, int code) fprintf (stream, "%d", MMIX_POP_ARGUMENT ()); return; + case '!': + /* The number of registers we want to save. This was setup by the + prologue. */ + fprintf (stream, "%d", cfun->machine->highest_saved_stack_register + 1); + return; + case 'B': if (GET_CODE (x) != CONST_INT) fatal_insn ("MMIX Internal: Expected a CONST_INT, not this", x); @@ -1712,15 +1718,6 @@ mmix_print_operand (FILE *stream, rtx x, int code) (int64_t) (mmix_intval (x) - 1)); return; - case 'p': - /* Store the number of registers we want to save. This was setup - by the prologue. The actual operand contains the number of - registers to pass, but we don't use it currently. Anyway, we - need to output the number of saved registers here. */ - fprintf (stream, "%d", - cfun->machine->highest_saved_stack_register + 1); - return; - case 'r': /* Store the register to output a constant to. */ if (! REG_P (x)) @@ -1830,7 +1827,10 @@ mmix_print_operand_punct_valid_p (unsigned char code) /* A '+' is used for branch prediction, similar to other ports. */ return code == '+' /* A '.' is used for the %d in the POP %d,0 return insn. */ - || code == '.'; + || code == '.' + /* A '!' is used for the number of saved registers, like when outputting + PUSHJ and PUSHGO. */ + || code == '!'; } /* TARGET_PRINT_OPERAND_ADDRESS. */ diff --git a/gcc/config/mmix/mmix.md b/gcc/config/mmix/mmix.md index 33e9c60982d..99be8263a1a 100644 --- a/gcc/config/mmix/mmix.md +++ b/gcc/config/mmix/mmix.md @@ -974,11 +974,9 @@ DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2") "%+B%D1 %2,%0") (define_expand "call" - [(parallel [(call (match_operand:QI 0 "memory_operand" "") - (match_operand 1 "general_operand" "")) - (use (match_operand 2 "general_operand" "")) - (clobber (match_dup 4))]) - (set (match_dup 4) (match_dup 3))] + [(parallel [(call (match_operand:QI 0 "memory_operand" "") (const_int 0)) + (clobber (match_dup 1))]) + (set (match_dup 1) (match_dup 2))] "" " { @@ -992,28 +990,24 @@ DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2") = replace_equiv_address (operands[0], force_reg (Pmode, XEXP (operands[0], 0))); + /* Note that we overwrite the generic operands[1] and operands[2]; we + don't use those values. */ + operands[1] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); + /* Since the epilogue 'uses' the return address, and it is clobbered in the call, and we set it back after every call (all but one setting will be optimized away), integrity is maintained. */ - operands[3] + operands[2] = mmix_get_hard_reg_initial_val (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); - - /* NULL gets passed as operand[2] when we get out of registers, - which later confuses gcc. Replace it with const_int 0. */ - if (operands[2] == NULL_RTX) - operands[2] = const0_rtx; - - operands[4] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); }") (define_expand "call_value" [(parallel [(set (match_operand 0 "" "") (call (match_operand:QI 1 "memory_operand" "") - (match_operand 2 "general_operand" ""))) - (use (match_operand 3 "general_operand" "")) - (clobber (match_dup 5))]) - (set (match_dup 5) (match_dup 4))] + (const_int 0))) + (clobber (match_dup 2))]) + (set (match_dup 2) (match_dup 3))] "" " { @@ -1027,18 +1021,16 @@ DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2") = replace_equiv_address (operands[1], force_reg (Pmode, XEXP (operands[1], 0))); + /* Note that we overwrite the generic operands[2] and operands[3]; we + don't use those values. */ + operands[2] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); + /* Since the epilogue 'uses' the return address, and it is clobbered in the call, and we set it back after every call (all but one setting will be optimized away), integrity is maintained. */ - operands[4] + operands[3] = mmix_get_hard_reg_initial_val (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); - - /* See 'call'. */ - if (operands[3] == NULL_RTX) - operands[3] = const0_rtx; - - operands[5] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM); }") ;; Don't use 'p' here. A 'p' must stand first in constraints, or reload @@ -1059,25 +1051,23 @@ DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2") (define_insn "*call_real" [(call (mem:QI (match_operand:DI 0 "mmix_symbolic_or_address_operand" "s,rU")) - (match_operand 1 "" "")) - (use (match_operand 2 "" "")) + (const_int 0)) (clobber (reg:DI MMIX_rJ_REGNUM))] "" "@ - PUSHJ $%p2,%0 - PUSHGO $%p2,%a0") + PUSHJ $%!,%0 + PUSHGO $%!,%a0") (define_insn "*call_value_real" [(set (match_operand 0 "register_operand" "=r,r") (call (mem:QI (match_operand:DI 1 "mmix_symbolic_or_address_operand" "s,rU")) - (match_operand 2 "" ""))) - (use (match_operand 3 "" "")) - (clobber (reg:DI MMIX_rJ_REGNUM))] + (const_int 0))) + (clobber (reg:DI MMIX_rJ_REGNUM))] "" "@ - PUSHJ $%p3,%1 - PUSHGO $%p3,%a1") + PUSHJ $%!,%1 + PUSHGO $%!,%a1") ;; I hope untyped_call and untyped_return are not needed for MMIX. ;; Users of Objective-C will notice.