From patchwork Tue Nov 19 10:35:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 179734 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp438922ilf; Tue, 19 Nov 2019 02:35:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyfCk7c5WRr1lAAvxF486wR1iLkOsPWLouYy7xkKHdQOJH5F5Vi5PXM1+S60tMRSGwX3tvU X-Received: by 2002:adf:e803:: with SMTP id o3mr36577491wrm.326.1574159741257; Tue, 19 Nov 2019 02:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574159741; cv=none; d=google.com; s=arc-20160816; b=ggS79gzdIcoW2xTJorPgPfZIb4WjOVeEMwrkO2RaWL/nTqbBWtfhvplJbZDkkPaHkp l+tgXAxeMigzuZK+Tik0ksK4B2mYQ8M7oMb+Y9yQuVMKwie9XDap0KD6GX4ckBluMhHV VDHJTst89AH5nGUWLfhBmfGoCBoW6knz20vzSX6ZSd3cSOcSLnlJa7RUn4CnrJZSJvh4 Tcj3L027jCl8VhvA5t+ffQSBH1iQXbjex4fCQzbVUYjOS7PG1GvKzOar/j+9HKvPjXbC 8Lnhr/crh+gIcdmN5v+rxzV4uOXRvswLrLgdFX5bl+dH9zaIiGhjCcbIRQay1NzWC62y 3cYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:date:message-id:openpgp:subject:from:to :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=20MDQkv1rV/oWCwU6CjfMSYq/RIgXmjbOhGFmeLceSU=; b=ZNJbi0CcsE0BV5rhXqGh3vysGHMGo+0+FH/9lEMSkZE/aHZ1Sm7KAUKSbps8UAcgN7 PTgqrpZS6ocAI6j5taicVOao/7PFAy/dTPRDwUY9gRzjKO3lPqPR32cUaw2DfiofL6cL kQR6N6i7x0Q0SuL2isJMVUdnCvC7EtOtvSR+kqiPzQ2inzktOjpFzZCVCIzYtJ3+BHwW e+u7MtEd8OUQASWihL+ld6IpOLPTwChsnoU+hezmw/3TNxEFAir+JQnQ6EpG8jvUAaIF 6/WVNgQ/UxEDsU/nrrMzTDMt+dvSzFjebX2v9WL+CJBFVHQJFerwYc5eUNhK/nXKOcNK KwoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RfmVk39Z; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HNSytSgI; spf=pass (google.com: domain of gcc-patches-return-514019-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-514019-patch=linaro.org@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x50si15650424eda.155.2019.11.19.02.35.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 02:35:41 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-514019-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RfmVk39Z; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HNSytSgI; spf=pass (google.com: domain of gcc-patches-return-514019-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-514019-patch=linaro.org@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Mk2i+ZPTPp0DljcsK7Ime9iz/N/PvHXHtT0JjV5qHfV8SF3MOw 2/o7z9ejqwJK/j4CHO19l51lBcvHxpCm9Gnk89WC6Ng5U19hGQlnEcKR9G/7jJrf Upy9OWxfYm5jsJJrw34//C53MMrDBeqQvtt/ns0JvMPy5UqnMhv4DzGfo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=uYH7RcDYgqJrZl3YGpro5JNAxI8=; b=RfmVk39ZmNM2af06fW4s dWEVlYQ4xuQvBEhVxEnWQncjTA9QdFhlyqMht4jXc97jgXEWEV7D6jOdEI9VkBKH 725EWpoglh24R+3YjkpElUNNDgDEdTAXnrW7BbVr1M2GA57kCP6iOIBfui+x//Xg AOxRpcKSD5sRqomtVSLwjWE= Received: (qmail 97381 invoked by alias); 19 Nov 2019 10:35:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 97361 invoked by uid 89); 19 Nov 2019 10:35:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Worker, checking_p, CHECKING_P X-HELO: mail-wm1-f44.google.com Received: from mail-wm1-f44.google.com (HELO mail-wm1-f44.google.com) (209.85.128.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Nov 2019 10:35:15 +0000 Received: by mail-wm1-f44.google.com with SMTP id 8so2933466wmo.0 for ; Tue, 19 Nov 2019 02:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:from:subject:openpgp:message-id:date:user-agent:mime-version :content-language; bh=P+jcnAJXyZJJK0PWoHtdCLu/DGdc1Z38O2b4NjLXkEs=; b=HNSytSgIG3Ye2wCDEdncjw4tYtga2fQJWZSX54LFqa/+vlyps777DTrwGEGO54l4er nzqtE+O79u2eODDXw87U8Qy1CjiP8LK+9WGNo5GVuJaLKCQRvQtKkR0J2rvD8JpMCvKM yHFISzB7+mbu7Vi644JoiCEKGJjfzXkMxVnyeMYXXSpp2TD0dZXZlFhZgBDcf2C7DUtM m8xH98MIYSixjtHmQX0cRjxJcSZ7B38UhjwVafLPcwr5/s9K9dBK33bwQfhTY1lld3oR SsDZNutPHVEmv4AC0dSAs3rj9/S3bwY4IuA7Y5Ter6OVMXbyY2M5ZBuXPNh4vYnR8PNG lHMQ== Return-Path: Received: from [192.168.8.102] (64.red-79-149-204.dynamicip.rima-tde.net. [79.149.204.64]) by smtp.gmail.com with ESMTPSA id y16sm26522121wro.25.2019.11.19.02.35.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 02:35:12 -0800 (PST) To: GCC Patches , Richard Earnshaw , Christophe Lyon From: Richard Henderson Subject: [arm, v3] Follow up for asm-flags (thumb1, ilp32) Openpgp: preference=signencrypt Message-ID: <5106a66b-1b19-94de-4727-5932859a24ea@linaro.org> Date: Tue, 19 Nov 2019 11:35:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 I'm not sure what happened to v2. I can see it in my sent email, but it never made it to the mailing list, and possibly not to Richard E. either. So resending, with an extra testsuite fix for ilp32, spotted by Christophe. Re thumb1, rather than an ifdef in config/arm/aarch-common.c, as I did in v1, I am swapping out a targetm hook when changing into and out of thumb1 mode. r~ gcc/ * config/arm/arm-c.c (arm_cpu_builtins): Use def_or_undef_macro to define __GCC_ASM_FLAG_OUTPUTS__. * config/arm/arm.c (thumb1_md_asm_adjust): New function. (arm_option_params_internal): Swap out targetm.md_asm_adjust depending on TARGET_THUMB1. * doc/extend.texi (FlagOutputOperands): Document thumb1 restriction. gcc/testsuite/ * testsuite/gcc.target/arm/asm-flag-3.c: Skip for thumb1. * testsuite/gcc.target/arm/asm-flag-5.c: Likewise. * testsuite/gcc.target/arm/asm-flag-6.c: Likewise. * testsuite/gcc.target/arm/asm-flag-4.c: New test. * testsuite/gcc.target/aarch64/asm-flag-6.c: Use %w for asm inputs to cmp instruction for ILP32. diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c index c4485ce7af1..546b35a5cbd 100644 --- a/gcc/config/arm/arm-c.c +++ b/gcc/config/arm/arm-c.c @@ -122,7 +122,8 @@ arm_cpu_builtins (struct cpp_reader* pfile) if (arm_arch_notm) builtin_define ("__ARM_ARCH_ISA_ARM"); builtin_define ("__APCS_32__"); - builtin_define ("__GCC_ASM_FLAG_OUTPUTS__"); + + def_or_undef_macro (pfile, "__GCC_ASM_FLAG_OUTPUTS__", !TARGET_THUMB1); def_or_undef_macro (pfile, "__thumb__", TARGET_THUMB); def_or_undef_macro (pfile, "__thumb2__", TARGET_THUMB2); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 1fd30c238cd..a6b401b7f2e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -325,6 +325,9 @@ static unsigned int arm_hard_regno_nregs (unsigned int, machine_mode); static bool arm_hard_regno_mode_ok (unsigned int, machine_mode); static bool arm_modes_tieable_p (machine_mode, machine_mode); static HOST_WIDE_INT arm_constant_alignment (const_tree, HOST_WIDE_INT); +static rtx_insn * thumb1_md_asm_adjust (vec &, vec &, + vec &, vec &, + HARD_REG_SET &); /* Table of machine attributes. */ static const struct attribute_spec arm_attribute_table[] = @@ -2941,6 +2944,11 @@ arm_option_params_internal (void) /* For THUMB2, we limit the conditional sequence to one IT block. */ if (TARGET_THUMB2) max_insns_skipped = MIN (max_insns_skipped, MAX_INSN_PER_IT_BLOCK); + + if (TARGET_THUMB1) + targetm.md_asm_adjust = thumb1_md_asm_adjust; + else + targetm.md_asm_adjust = arm_md_asm_adjust; } /* True if -mflip-thumb should next add an attribute for the default @@ -32528,6 +32536,23 @@ arm_run_selftests (void) #define TARGET_RUN_TARGET_SELFTESTS selftest::arm_run_selftests #endif /* CHECKING_P */ +/* Worker function for TARGET_MD_ASM_ADJUST, while in thumb1 mode. + Unlike the arm version, we do NOT implement asm flag outputs. */ + +rtx_insn * +thumb1_md_asm_adjust (vec &outputs, vec &/*inputs*/, + vec &constraints, + vec &/*clobbers*/, HARD_REG_SET &/*clobbered_regs*/) +{ + for (unsigned i = 0, n = outputs.length (); i < n; ++i) + if (strncmp (constraints[i], "=@cc", 4) == 0) + { + sorry ("asm flags not supported in thumb1 mode"); + break; + } + return NULL; +} + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-arm.h" diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-6.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-6.c index 963b5a48c70..54d7fbf317d 100644 --- a/gcc/testsuite/gcc.target/aarch64/asm-flag-6.c +++ b/gcc/testsuite/gcc.target/aarch64/asm-flag-6.c @@ -1,6 +1,12 @@ /* Executable testcase for 'output flags.' */ /* { dg-do run } */ +#ifdef __LP64__ +#define W "" +#else +#define W "w" +#endif + int test_bits (long nzcv) { long n, z, c, v; @@ -16,7 +22,7 @@ int test_cmps (long x, long y) { long gt, lt, ge, le; - __asm__ ("cmp %[x], %[y]" + __asm__ ("cmp %"W"[x], %"W"[y]" : "=@ccgt"(gt), "=@cclt"(lt), "=@ccge"(ge), "=@ccle"(le) : [x] "r"(x), [y] "r"(y)); @@ -30,7 +36,7 @@ int test_cmpu (unsigned long x, unsigned long y) { long gt, lt, ge, le; - __asm__ ("cmp %[x], %[y]" + __asm__ ("cmp %"W"[x], %"W"[y]" : "=@cchi"(gt), "=@cclo"(lt), "=@cchs"(ge), "=@ccls"(le) : [x] "r"(x), [y] "r"(y)); diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-1.c b/gcc/testsuite/gcc.target/arm/asm-flag-1.c index 9707ebfcebb..97104d3ac73 100644 --- a/gcc/testsuite/gcc.target/arm/asm-flag-1.c +++ b/gcc/testsuite/gcc.target/arm/asm-flag-1.c @@ -1,6 +1,7 @@ /* Test the valid @cc asm flag outputs. */ /* { dg-do compile } */ /* { dg-options "-O" } */ +/* { dg-skip-if "" { arm_thumb1 } } */ #ifndef __GCC_ASM_FLAG_OUTPUTS__ #error "missing preprocessor define" diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-3.c b/gcc/testsuite/gcc.target/arm/asm-flag-3.c index e84e3431277..e2d616051cc 100644 --- a/gcc/testsuite/gcc.target/arm/asm-flag-3.c +++ b/gcc/testsuite/gcc.target/arm/asm-flag-3.c @@ -1,6 +1,7 @@ /* Test some of the valid @cc asm flag outputs. */ /* { dg-do compile } */ /* { dg-options "-O" } */ +/* { dg-skip-if "" { arm_thumb1 } } */ #define DO(C) \ void f##C(void) { char x; asm("" : "=@cc"#C(x)); if (!x) asm(""); asm(""); } diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-4.c b/gcc/testsuite/gcc.target/arm/asm-flag-4.c new file mode 100644 index 00000000000..3791cadda02 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-4.c @@ -0,0 +1,13 @@ +/* Test that we do not ice in thumb1 mode */ +/* { dg-do compile } */ +/* { dg-options "-march=armv4t" } */ + +void __attribute__((target("arm"))) f(char *out) +{ + asm("" : "=@ccne"(out[0])); +} + +void __attribute__((target("thumb"))) g(char *out) +{ + asm("" : "=@ccne"(out[0])); /* { dg-error asm flags not supported } */ +} diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-5.c b/gcc/testsuite/gcc.target/arm/asm-flag-5.c index 4d4394e1478..9a8ff586c29 100644 --- a/gcc/testsuite/gcc.target/arm/asm-flag-5.c +++ b/gcc/testsuite/gcc.target/arm/asm-flag-5.c @@ -1,6 +1,7 @@ /* Test error conditions of asm flag outputs. */ /* { dg-do compile } */ /* { dg-options "" } */ +/* { dg-skip-if "" { arm_thumb1 } } */ void f_B(void) { _Bool x; asm("" : "=@cccc"(x)); } void f_c(void) { char x; asm("" : "=@cccc"(x)); } diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-6.c b/gcc/testsuite/gcc.target/arm/asm-flag-6.c index 09174e04ae6..d862db4e106 100644 --- a/gcc/testsuite/gcc.target/arm/asm-flag-6.c +++ b/gcc/testsuite/gcc.target/arm/asm-flag-6.c @@ -1,5 +1,6 @@ /* Executable testcase for 'output flags.' */ /* { dg-do run } */ +/* { dg-skip-if "" { arm_thumb1 } } */ int test_bits (long nzcv) { diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 1c8ae0d5cd3..62a98e939c8 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9810,6 +9810,8 @@ signed greater than signed less than equal @end table +The flag output constraints are not supported in thumb1 mode. + @item x86 family The flag output constraints for the x86 family are of the form @samp{=@@cc@var{cond}} where @var{cond} is one of the standard