From patchwork Fri Nov 11 17:30:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 18927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp875340wru; Fri, 11 Nov 2022 09:32:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5znKKmFhfyLTaNbeEcpD0lmRn9LZqSS4xxRPwAZJaOeSuoCn27Oqv93m6D6J/JVg2lDPJN X-Received: by 2002:a17:906:1187:b0:7ae:3b9d:1d5d with SMTP id n7-20020a170906118700b007ae3b9d1d5dmr2746353eja.328.1668187976824; Fri, 11 Nov 2022 09:32:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668187976; cv=none; d=google.com; s=arc-20160816; b=Gk2f/5dvuRnFH3bqkrVBXPO9ErPXDF6CrTWKBWMVXrlzLBjjXKBOLizxax0LoayPJS xqaYFWZ2AO8JgFKkE91YeThpJ6t3X/8NvIx+3TWI+MVys+2oFLKv9LRynEdPQWCvJpk3 6luVgSg4MvAwRuX1deXdrDqWpHk8zSF7Bo6L0GeLJi6jJb+HxWazYK+f937y0yOV/4ob pw7katjZX1ueUTH1n6D1JQTfUw7mRhN5Hx2Rjdue4Bmmz3jjs3GCIZGhMxOTbCvrvGWF BJzx77HrcXmA/XDKtBke9oGcYq7sIi0Qhcf5215uDEjUsnJssM7PsB/BcyeZ1zDQZima 7r3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:date:subject:mail-followup-to:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=isPRRVLxJFmOYoWh+P53XZQFpW5ad1wcXt5CvjVQRQ4=; b=LaueYgclgphQq+AEPDB1TJ9rmqkoHxHh/reKWdepv5ut+olOnGg92Pyg3q0sOyw3v5 Yz6PGJOJyAK9dVWS2kbmXHBVXOT2RsbH912sH/xByRDjI3V0OPffGeBkEYjUupZNpttJ rIo4Gt7n/MemxyuuJdZWwHz/k8PNKlzEnn06MktZhj7P+61MqmKzXs/QnujP8mhjZzLN UMMahZWwDoNxEiLov4HAa6sMhG6Xjrx7zgkNjxXmb8TN0qZnAD140NdlfvC3QqcG4IK5 JTI+8fjVAieuhQWp4+gx7N/4s+nBzjGO69PIujQKbU4ENx1RiNF2ir3A58lDeWOBPJXX kVog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yaaeQoR8; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org ([2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o19-20020a1709064f9300b007adbc807ca8si2245468eju.137.2022.11.11.09.32.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 09:32:56 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yaaeQoR8; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B284383F95C for ; Fri, 11 Nov 2022 17:32:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B284383F95C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668187947; bh=isPRRVLxJFmOYoWh+P53XZQFpW5ad1wcXt5CvjVQRQ4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yaaeQoR8D7GRCHQJGxRXxTfJbhgGxvgfN53vHHHEwYvfQuOmdjq4+eKYJLc9t5twh LQAvSBDqmdctOgViFM9M67SzXc/omcdMymTXTQ9oHEqViKBvgUYSUuoNc9ZBfgOAzU 0yZuWKiIJfQ1r2Y+zvSlHuooScGmeS62+VinXhoA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 1E7583858D39 for ; Fri, 11 Nov 2022 17:31:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E7583858D39 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D67281FB for ; Fri, 11 Nov 2022 09:31:06 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 31E853F534 for ; Fri, 11 Nov 2022 09:31:00 -0800 (PST) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] Allow targets to add USEs to asms Date: Fri, 11 Nov 2022 17:30:58 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-42.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749221875990160619?= X-GMAIL-MSGID: =?utf-8?q?1749221875990160619?= Arm's SME has an array called ZA that for inline asm purposes is effectively a form of special-purpose memory. It doesn't have an associated storage type and so can't be passed and returned in normal C/C++ objects. We'd therefore like "za" in a clobber list to mean that an inline asm can read from and write to ZA. (Just reading or writing individually is unlikely to be useful, but we could add syntax for that too if necessary.) There is currently a TARGET_MD_ASM_ADJUST target hook that allows targets to add clobbers to an asm instruction. This patch extends that to allow targets to add USEs as well. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Also tested by building cc1 for one target per affected CPU. OK to install? Richard gcc/ * target.def (md_asm_adjust): Add a uses parameter. * doc/gccint/target-macros/tm.rst.in: Regenerate. * cfgexpand.cc (expand_asm_loc): Update call to md_asm_adjust. Handle any USEs created by the target. (expand_asm_stmt): Likewise. * recog.cc (asm_noperands): Handle asms with USEs. (decode_asm_operands): Likewise. * config/arm/aarch-common-protos.h (arm_md_asm_adjust): Add uses parameter. * config/arm/aarch-common.cc (arm_md_asm_adjust): Likewise. * config/arm/arm.cc (thumb1_md_asm_adjust): Likewise. * config/avr/avr.cc (avr_md_asm_adjust): Likewise. * config/cris/cris.cc (cris_md_asm_adjust): Likewise. * config/i386/i386.cc (ix86_md_asm_adjust): Likewise. * config/mn10300/mn10300.cc (mn10300_md_asm_adjust): Likewise. * config/nds32/nds32.cc (nds32_md_asm_adjust): Likewise. * config/pdp11/pdp11.cc (pdp11_md_asm_adjust): Likewise. * config/rs6000/rs6000.cc (rs6000_md_asm_adjust): Likewise. * config/s390/s390.cc (s390_md_asm_adjust): Likewise. * config/vax/vax.cc (vax_md_asm_adjust): Likewise. * config/visium/visium.cc (visium_md_asm_adjust): Likewise. --- gcc/cfgexpand.cc | 37 +++++++++++++++++--------- gcc/config/arm/aarch-common-protos.h | 2 +- gcc/config/arm/aarch-common.cc | 3 ++- gcc/config/arm/arm.cc | 5 ++-- gcc/config/avr/avr.cc | 1 + gcc/config/cris/cris.cc | 6 +++-- gcc/config/i386/i386.cc | 5 ++-- gcc/config/mn10300/mn10300.cc | 3 ++- gcc/config/nds32/nds32.cc | 4 +-- gcc/config/pdp11/pdp11.cc | 6 +++-- gcc/config/rs6000/rs6000.cc | 3 ++- gcc/config/s390/s390.cc | 3 ++- gcc/config/vax/vax.cc | 4 ++- gcc/config/visium/visium.cc | 5 ++-- gcc/doc/gccint/target-macros/tm.rst.in | 9 ++++--- gcc/recog.cc | 20 +++++++++----- gcc/target.def | 9 ++++--- 17 files changed, 81 insertions(+), 44 deletions(-) diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index dd29ffffc03..82cb6450281 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -2873,6 +2873,7 @@ expand_asm_loc (tree string, int vol, location_t locus) auto_vec input_rvec, output_rvec; auto_vec input_mode; auto_vec constraints; + auto_vec use_rvec; auto_vec clobber_rvec; HARD_REG_SET clobbered_regs; CLEAR_HARD_REG_SET (clobbered_regs); @@ -2882,16 +2883,20 @@ expand_asm_loc (tree string, int vol, location_t locus) if (targetm.md_asm_adjust) targetm.md_asm_adjust (output_rvec, input_rvec, input_mode, - constraints, clobber_rvec, clobbered_regs, - locus); + constraints, use_rvec, clobber_rvec, + clobbered_regs, locus); asm_op = body; nclobbers = clobber_rvec.length (); - body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (1 + nclobbers)); + auto nuses = use_rvec.length (); + body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (1 + nuses + nclobbers)); - XVECEXP (body, 0, 0) = asm_op; - for (i = 0; i < nclobbers; i++) - XVECEXP (body, 0, i + 1) = gen_rtx_CLOBBER (VOIDmode, clobber_rvec[i]); + i = 0; + XVECEXP (body, 0, i++) = asm_op; + for (rtx use : use_rvec) + XVECEXP (body, 0, i++) = gen_rtx_USE (VOIDmode, use); + for (rtx clobber : clobber_rvec) + XVECEXP (body, 0, i++) = gen_rtx_CLOBBER (VOIDmode, clobber); } emit_insn (body); @@ -3443,11 +3448,12 @@ expand_asm_stmt (gasm *stmt) maintaining source-level compatibility means automatically clobbering the flags register. */ rtx_insn *after_md_seq = NULL; + auto_vec use_rvec; if (targetm.md_asm_adjust) after_md_seq = targetm.md_asm_adjust (output_rvec, input_rvec, input_mode, - constraints, clobber_rvec, clobbered_regs, - locus); + constraints, use_rvec, clobber_rvec, + clobbered_regs, locus); /* Do not allow the hook to change the output and input count, lest it mess up the operand numbering. */ @@ -3455,7 +3461,8 @@ expand_asm_stmt (gasm *stmt) gcc_assert (input_rvec.length() == ninputs); gcc_assert (constraints.length() == noutputs + ninputs); - /* But it certainly can adjust the clobbers. */ + /* But it certainly can adjust the uses and clobbers. */ + unsigned nuses = use_rvec.length (); unsigned nclobbers = clobber_rvec.length (); /* Third pass checks for easy conflicts. */ @@ -3527,7 +3534,7 @@ expand_asm_stmt (gasm *stmt) ARGVEC CONSTRAINTS OPNAMES)) If there is more than one, put them inside a PARALLEL. */ - if (noutputs == 0 && nclobbers == 0) + if (noutputs == 0 && nuses == 0 && nclobbers == 0) { /* No output operands: put in a raw ASM_OPERANDS rtx. */ if (nlabels > 0) @@ -3535,7 +3542,7 @@ expand_asm_stmt (gasm *stmt) else emit_insn (body); } - else if (noutputs == 1 && nclobbers == 0) + else if (noutputs == 1 && nuses == 0 && nclobbers == 0) { ASM_OPERANDS_OUTPUT_CONSTRAINT (body) = constraints[0]; if (nlabels > 0) @@ -3551,7 +3558,8 @@ expand_asm_stmt (gasm *stmt) if (num == 0) num = 1; - body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num + nclobbers)); + body = gen_rtx_PARALLEL (VOIDmode, + rtvec_alloc (num + nuses + nclobbers)); /* For each output operand, store a SET. */ for (i = 0; i < noutputs; ++i) @@ -3578,6 +3586,11 @@ expand_asm_stmt (gasm *stmt) if (i == 0) XVECEXP (body, 0, i++) = obody; + /* Add the uses specified by the target hook. No checking should + be needed since this doesn't come directly from user code. */ + for (rtx use : use_rvec) + XVECEXP (body, 0, i++) = gen_rtx_USE (VOIDmode, use); + /* Store (clobber REG) for each clobbered register specified. */ for (unsigned j = 0; j < nclobbers; ++j) { diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index ae0465159f7..3b525c174a4 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -149,7 +149,7 @@ struct cpu_cost_table rtx_insn *arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, - vec &constraints, + vec &constraints, vec &, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t loc); diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc index 04a53d75093..365cfc14036 100644 --- a/gcc/config/arm/aarch-common.cc +++ b/gcc/config/arm/aarch-common.cc @@ -533,7 +533,8 @@ arm_mac_accumulator_is_mul_result (rtx producer, rtx consumer) rtx_insn * arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, - vec &constraints, vec & /*clobbers*/, + vec &constraints, + vec & /*uses*/, vec & /*clobbers*/, HARD_REG_SET & /*clobbered_regs*/, location_t loc) { bool saw_asm_flag = false; diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 2eb4d51e4a3..a46a2b845d5 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -325,7 +325,7 @@ static HOST_WIDE_INT arm_constant_alignment (const_tree, HOST_WIDE_INT); static rtx_insn *thumb1_md_asm_adjust (vec &, vec &, vec &, vec &, vec &, - HARD_REG_SET &, location_t); + vec &, HARD_REG_SET &, location_t); static const char *arm_identify_fpu_from_isa (sbitmap); /* Table of machine attributes. */ @@ -34290,7 +34290,8 @@ arm_stack_protect_guard (void) rtx_insn * thumb1_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, - vec &constraints, vec & /*clobbers*/, + vec &constraints, + vec &, vec & /*clobbers*/, HARD_REG_SET & /*clobbered_regs*/, location_t /*loc*/) { for (unsigned i = 0, n = outputs.length (); i < n; ++i) diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 4ed390e4cf9..1b5a95410a7 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -14497,6 +14497,7 @@ static rtx_insn * avr_md_asm_adjust (vec &/*outputs*/, vec &/*inputs*/, vec & /*input_modes*/, vec &/*constraints*/, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index f0017d63022..3a1c8548107 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -151,7 +151,8 @@ static void cris_function_arg_advance (cumulative_args_t, const function_arg_info &); static rtx_insn *cris_md_asm_adjust (vec &, vec &, vec &, vec &, - vec &, HARD_REG_SET &, location_t); + vec &, vec &, + HARD_REG_SET &, location_t); static void cris_option_override (void); @@ -3506,7 +3507,8 @@ cris_function_arg_advance (cumulative_args_t ca_v, static rtx_insn * cris_md_asm_adjust (vec &outputs, vec &inputs, vec & /*input_modes*/, - vec &constraints, vec &clobbers, + vec &constraints, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { /* For the time being, all asms clobber condition codes. diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index f8586499cd1..6231808a5ae 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -22488,8 +22488,9 @@ ix86_c_mode_for_suffix (char suffix) static rtx_insn * ix86_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec & /*input_modes*/, - vec &constraints, vec &clobbers, - HARD_REG_SET &clobbered_regs, location_t loc) + vec &constraints, vec &/*uses*/, + vec &clobbers, HARD_REG_SET &clobbered_regs, + location_t loc) { bool saw_asm_flag = false; diff --git a/gcc/config/mn10300/mn10300.cc b/gcc/config/mn10300/mn10300.cc index 2a58dd9256d..2ca2c769c7f 100644 --- a/gcc/config/mn10300/mn10300.cc +++ b/gcc/config/mn10300/mn10300.cc @@ -2849,7 +2849,8 @@ mn10300_conditional_register_usage (void) static rtx_insn * mn10300_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, - vec & /*constraints*/, vec &clobbers, + vec & /*constraints*/, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, CC_REG)); diff --git a/gcc/config/nds32/nds32.cc b/gcc/config/nds32/nds32.cc index 639baef6c17..7ea89ccf870 100644 --- a/gcc/config/nds32/nds32.cc +++ b/gcc/config/nds32/nds32.cc @@ -4202,8 +4202,8 @@ nds32_md_asm_adjust (vec &outputs ATTRIBUTE_UNUSED, vec &inputs ATTRIBUTE_UNUSED, vec &input_modes ATTRIBUTE_UNUSED, vec &constraints ATTRIBUTE_UNUSED, - vec &clobbers, HARD_REG_SET &clobbered_regs, - location_t /*loc*/) + vec &/*uses*/, vec &clobbers, + HARD_REG_SET &clobbered_regs, location_t /*loc*/) { if (!flag_inline_asm_r15) { diff --git a/gcc/config/pdp11/pdp11.cc b/gcc/config/pdp11/pdp11.cc index 380223439a4..25cf62cbc9d 100644 --- a/gcc/config/pdp11/pdp11.cc +++ b/gcc/config/pdp11/pdp11.cc @@ -155,7 +155,8 @@ static int pdp11_addr_cost (rtx, machine_mode, addr_space_t, bool); static int pdp11_insn_cost (rtx_insn *insn, bool speed); static rtx_insn *pdp11_md_asm_adjust (vec &, vec &, vec &, vec &, - vec &, HARD_REG_SET &, location_t); + vec &, vec &, + HARD_REG_SET &, location_t); static bool pdp11_return_in_memory (const_tree, const_tree); static rtx pdp11_function_value (const_tree, const_tree, bool); static rtx pdp11_libcall_value (machine_mode, const_rtx); @@ -2137,7 +2138,8 @@ pdp11_cmp_length (rtx *operands, int words) static rtx_insn * pdp11_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, - vec & /*constraints*/, vec &clobbers, + vec & /*constraints*/, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, CC_REGNUM)); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index a85d7630b41..9a86ef4a3bd 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -3373,7 +3373,8 @@ darwin_rs6000_override_options (void) static rtx_insn * rs6000_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, - vec & /*constraints*/, vec &clobbers, + vec & /*constraints*/, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (SImode, CA_REGNO)); diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index f5c75395cf3..2e59f21d2cd 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -17081,7 +17081,8 @@ s390_hard_fp_reg_p (rtx x) static rtx_insn * s390_md_asm_adjust (vec &outputs, vec &inputs, vec &input_modes, - vec &constraints, vec & /*clobbers*/, + vec &constraints, + vec &/*uses*/, vec & /*clobbers*/, HARD_REG_SET & /*clobbered_regs*/, location_t /*loc*/) { if (!TARGET_VXE) diff --git a/gcc/config/vax/vax.cc b/gcc/config/vax/vax.cc index 28c1af59a99..7673a142804 100644 --- a/gcc/config/vax/vax.cc +++ b/gcc/config/vax/vax.cc @@ -57,7 +57,8 @@ static bool vax_rtx_costs (rtx, machine_mode, int, int, int *, bool); static machine_mode vax_cc_modes_compatible (machine_mode, machine_mode); static rtx_insn *vax_md_asm_adjust (vec &, vec &, vec &, vec &, - vec &, HARD_REG_SET &, location_t); + vec &, vec &, HARD_REG_SET &, + location_t); static rtx vax_function_arg (cumulative_args_t, const function_arg_info &); static void vax_function_arg_advance (cumulative_args_t, const function_arg_info &); @@ -1179,6 +1180,7 @@ vax_md_asm_adjust (vec &outputs ATTRIBUTE_UNUSED, vec &inputs ATTRIBUTE_UNUSED, vec &input_modes ATTRIBUTE_UNUSED, vec &constraints ATTRIBUTE_UNUSED, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { diff --git a/gcc/config/visium/visium.cc b/gcc/config/visium/visium.cc index e7d15960fc7..6c915ffa9c1 100644 --- a/gcc/config/visium/visium.cc +++ b/gcc/config/visium/visium.cc @@ -190,7 +190,7 @@ static tree visium_build_builtin_va_list (void); static rtx_insn *visium_md_asm_adjust (vec &, vec &, vec &, vec &, vec &, - HARD_REG_SET &, location_t); + vec &, HARD_REG_SET &, location_t); static bool visium_legitimate_constant_p (machine_mode, rtx); @@ -794,7 +794,8 @@ visium_conditional_register_usage (void) static rtx_insn * visium_md_asm_adjust (vec & /*outputs*/, vec & /*inputs*/, vec & /*input_modes*/, - vec & /*constraints*/, vec &clobbers, + vec & /*constraints*/, + vec &/*uses*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t /*loc*/) { clobbers.safe_push (gen_rtx_REG (CCmode, FLAGS_REGNUM)); diff --git a/gcc/doc/gccint/target-macros/tm.rst.in b/gcc/doc/gccint/target-macros/tm.rst.in index 04be4bda3f6..3d71eda810f 100644 --- a/gcc/doc/gccint/target-macros/tm.rst.in +++ b/gcc/doc/gccint/target-macros/tm.rst.in @@ -3877,13 +3877,14 @@ [TARGET_BUILTIN_SETJMP_FRAME_VALUE] [TARGET_MD_ASM_ADJUST] -.. function:: rtx_insn * TARGET_MD_ASM_ADJUST (vec& outputs, vec& inputs, vec& input_modes, vec& constraints, vec& clobbers, HARD_REG_SET& clobbered_regs, location_t loc) +.. function:: rtx_insn * TARGET_MD_ASM_ADJUST (vec& outputs, vec& inputs, vec& input_modes, vec& constraints, vec& usess, vec& clobbers, HARD_REG_SET& clobbered_regs, location_t loc) This target hook may add :dfn:`clobbers` to :samp:`{clobbers}` and :samp:`{clobbered_regs}` for any hard regs the port wishes to automatically - clobber for an asm. The :samp:`{outputs}` and :samp:`{inputs}` may be inspected - to avoid clobbering a register that is already used by the asm. :samp:`{loc}` - is the source location of the asm. + clobber for an asm. It can also add hard registers that are used by the + asm to :samp:`uses`. The :samp:`{outputs}` and :samp:`{inputs}` may be + inspected to avoid clobbering a register that is already used by the asm. + :samp:`{loc}` is the source location of the asm. It may modify the :samp:`{outputs}`, :samp:`{inputs}`, :samp:`{input_modes}`, and :samp:`{constraints}` as necessary for other pre-processing. In this case the diff --git a/gcc/recog.cc b/gcc/recog.cc index dac172bc7c0..831c53f5045 100644 --- a/gcc/recog.cc +++ b/gcc/recog.cc @@ -1977,13 +1977,17 @@ asm_noperands (const_rtx body) { /* Multiple output operands, or 1 output plus some clobbers: body is - [(set OUTPUT (asm_operands ...))... (clobber (reg ...))...]. */ - /* Count backwards through CLOBBERs to determine number of SETs. */ + [(set OUTPUT (asm_operands ...))... + (use (reg ...))... + (clobber (reg ...))...]. */ + /* Count backwards through USEs and CLOBBERs to determine + number of SETs. */ for (i = XVECLEN (body, 0); i > 0; i--) { if (GET_CODE (XVECEXP (body, 0, i - 1)) == SET) break; - if (GET_CODE (XVECEXP (body, 0, i - 1)) != CLOBBER) + if (GET_CODE (XVECEXP (body, 0, i - 1)) != USE + && GET_CODE (XVECEXP (body, 0, i - 1)) != CLOBBER) return -1; } @@ -2010,10 +2014,13 @@ asm_noperands (const_rtx body) else { /* 0 outputs, but some clobbers: - body is [(asm_operands ...) (clobber (reg ...))...]. */ + body is [(asm_operands ...) + (use (reg ...))... + (clobber (reg ...))...]. */ /* Make sure all the other parallel things really are clobbers. */ for (i = XVECLEN (body, 0) - 1; i > 0; i--) - if (GET_CODE (XVECEXP (body, 0, i)) != CLOBBER) + if (GET_CODE (XVECEXP (body, 0, i)) != USE + && GET_CODE (XVECEXP (body, 0, i)) != CLOBBER) return -1; } } @@ -2080,7 +2087,8 @@ decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs, the SETs. Their constraints are in the ASM_OPERANDS itself. */ for (i = 0; i < nparallel; i++) { - if (GET_CODE (XVECEXP (body, 0, i)) == CLOBBER) + if (GET_CODE (XVECEXP (body, 0, i)) == USE + || GET_CODE (XVECEXP (body, 0, i)) == CLOBBER) break; /* Past last SET */ gcc_assert (GET_CODE (XVECEXP (body, 0, i)) == SET); if (operands) diff --git a/gcc/target.def b/gcc/target.def index e6a388f9675..040b2fa3294 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4251,9 +4251,10 @@ DEFHOOK (md_asm_adjust, "This target hook may add :dfn:`clobbers` to :samp:`{clobbers}` and\n\ :samp:`{clobbered_regs}` for any hard regs the port wishes to automatically\n\ -clobber for an asm. The :samp:`{outputs}` and :samp:`{inputs}` may be inspected\n\ -to avoid clobbering a register that is already used by the asm. :samp:`{loc}`\n\ -is the source location of the asm.\n\ +clobber for an asm. It can also add hard registers that are used by the\n\ +asm to :samp:`uses`. The :samp:`{outputs}` and :samp:`{inputs}` may be\n\ +inspected to avoid clobbering a register that is already used by the asm.\n\ +:samp:`{loc}` is the source location of the asm.\n\ \n\ It may modify the :samp:`{outputs}`, :samp:`{inputs}`, :samp:`{input_modes}`, and\n\ :samp:`{constraints}` as necessary for other pre-processing. In this case the\n\ @@ -4262,7 +4263,7 @@ changes to :samp:`{inputs}` must be accompanied by the corresponding changes\n\ to :samp:`{input_modes}`.", rtx_insn *, (vec& outputs, vec& inputs, vec& input_modes, - vec& constraints, vec& clobbers, + vec& constraints, vec& usess, vec& clobbers, HARD_REG_SET& clobbered_regs, location_t loc), NULL)