From patchwork Thu Nov 14 10:07:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 179389 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp10837508ilf; Thu, 14 Nov 2019 02:08:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzTeZRA8rZPvAFWCJMguwkG1oN6knHapDDMOrHcW+1mwuf2Y2YeYwPSnrrnvBTCNnUPIdEP X-Received: by 2002:aa7:cac7:: with SMTP id l7mr213826edt.196.1573726121329; Thu, 14 Nov 2019 02:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573726121; cv=none; d=google.com; s=arc-20160816; b=AGZt0JoGICjBN0g/rSA3xipRbnoVbVfBDAXJvtLWaZnfpxRTAhPGOC+I7SY1dABG0X 203DMTVXZZSVZXfB23t3v7HTSCYGaWlgt9GS0IaGjuia2fVgwk13LA7NQmag30ODiNjc WBIBHyAMc4cICvLCNKBRlRJgwqdo0ZyT5irmfa4EHOM85sVr6ZkeVXSXz/vTQ3jXirEm I5xwAo3ApljcnMdx7viyadrBnQCTtKkRRqa5cvqN392nKnfYi/UWaPisviC+nPJmd8tV DWx+NRC5tvxOjy0BhMtuSX8fYO3Se2LngG7SqxiZYFjDHIO1IYGaGW+0qIll57+5Z3/1 HyiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=cfWouoiTuLqtn4owVbGbFtTbXksZS2HtVe0IEdTKdxM=; b=HELSOPzhqKBKC/Wv+/kJRs/6lMigJolbMMe3ni654bSB+fnUTlrT4KJxLj37Q53AIj EoRtfZzfuuptOmdjZnX7KJzQs3llC88k3ml6opfuqDPmJe3ReNthFXKlEuewftovj/YY C61CmNNOC+qin0d9JBQ9g9xWSH5HmIxSn7YDdUceDZ/OzBhp44meEjTz9yx9q9hqzxI6 9trIs/IcIi+x9w6Abkq/xaMrAOQCI7NFuR7etF0Je+/9Z/c9rPRMnft/ZhitDett11TV qWOGDF8AlcxP4XFMRBWdweMGGn/wUMcHKw45rg7mUbKAaJ2oWrmXzw17NoRNBXaaq7ol IdYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nzJmQKI7; dkim=pass header.i=@linaro.org header.s=google header.b=F2AO7r90; spf=pass (google.com: domain of gcc-patches-return-513347-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-513347-patch=linaro.org@gcc.gnu.org"; dmarc=pass (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 t6si3220579eji.80.2019.11.14.02.08.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2019 02:08:41 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-513347-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=nzJmQKI7; dkim=pass header.i=@linaro.org header.s=google header.b=F2AO7r90; spf=pass (google.com: domain of gcc-patches-return-513347-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-513347-patch=linaro.org@gcc.gnu.org"; dmarc=pass (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:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=aJShTIwdTyckZjx5iv6xi0ota6xo950UWi9Ltx1wuN7UKXbt2ccHI JxEVWmPBHvcEYeo/sD6DMZanm/1iOsEQWH8XdYiNjO5DpzLhr7pvsHIMQwsNlclR FD53R7g++XqQrEK2P5p5L6U0s55XS5EGbeCD11V7Q7XMSoroOzhdLM= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=pYo8++ItxzSgAiC4nnqSayeVMEQ=; b=nzJmQKI7fX9pxdToPym/ n3i/fvGcixRL1XeDfV5BH/5lCvc9PmI7jqGBMspXBWTkYJySo/xb3dCtq/TYTl/4 JsFQb1HEUzk1L7fpKe2vSD7xLMEMuXekoVjR/IEAsETBwSYan5gSFSraDnSN+UJ2 RLjRwKbkaEvQcRQoYw6/dCk= Received: (qmail 75526 invoked by alias); 14 Nov 2019 10:07:43 -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 75463 invoked by uid 89); 14 Nov 2019 10:07:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 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= X-HELO: mail-wm1-f43.google.com Received: from mail-wm1-f43.google.com (HELO mail-wm1-f43.google.com) (209.85.128.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 10:07:40 +0000 Received: by mail-wm1-f43.google.com with SMTP id t26so5199569wmi.4 for ; Thu, 14 Nov 2019 02:07:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cfWouoiTuLqtn4owVbGbFtTbXksZS2HtVe0IEdTKdxM=; b=F2AO7r90Nn26GH57s7SaamjMUSIaHDxsi1A2nAAgJODu/0IJXTZfMYd9c96GmbCAct TxH8SrZnd0gy0pLXjPBtbedzNNB5s3QOqJwlkfd5gM8tb90hPd69BKR2eaoDO8ubTkQo 9JH1HBXKaHDbo9MQaSc0yxv5Zfp7tQWr7a93UssqKl8Ju/l/rEuaDxdbz+9AjK3glFoD PQLdDOrCo2Tw5H5byzxbQwkcNd8Ihk/G37XatPzvdxX1OcL94VHAdyWRcy2s21IcUomW LSVDpPJSmv/7a1eJlUjprSp80z+5I/6BQTDEWXyKOPEZLjeq3IUHeJjOAAXj967VXig6 CEFg== Return-Path: Received: from localhost.localdomain (184.red-37-158-56.dynamicip.rima-tde.net. [37.158.56.184]) by smtp.gmail.com with ESMTPSA id x26sm5359539wmc.14.2019.11.14.02.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 02:07:37 -0800 (PST) From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: richard.earnshaw@arm.com, kyrylo.tkachov@arm.com, richard.sandiford@arm.com Subject: [PATCH v2 5/6] arm: Add testsuite checks for asm-flag Date: Thu, 14 Nov 2019 11:07:15 +0100 Message-Id: <20191114100716.28827-6-richard.henderson@linaro.org> In-Reply-To: <20191114100716.28827-1-richard.henderson@linaro.org> References: <20191114100716.28827-1-richard.henderson@linaro.org> Inspired by the tests in gcc.target/i386. Testing code generation, diagnostics, and execution. * gcc.target/arm/asm-flag-1.c: New test. * gcc.target/arm/asm-flag-3.c: New test. * gcc.target/arm/asm-flag-5.c: New test. * gcc.target/arm/asm-flag-6.c: New test. --- gcc/testsuite/gcc.target/arm/asm-flag-1.c | 36 +++++++++++++ gcc/testsuite/gcc.target/arm/asm-flag-3.c | 38 ++++++++++++++ gcc/testsuite/gcc.target/arm/asm-flag-5.c | 30 +++++++++++ gcc/testsuite/gcc.target/arm/asm-flag-6.c | 62 +++++++++++++++++++++++ 4 files changed, 166 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-1.c create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-3.c create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-5.c create mode 100644 gcc/testsuite/gcc.target/arm/asm-flag-6.c -- 2.17.1 diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-1.c b/gcc/testsuite/gcc.target/arm/asm-flag-1.c new file mode 100644 index 00000000000..9707ebfcebb --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-1.c @@ -0,0 +1,36 @@ +/* Test the valid @cc asm flag outputs. */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +#ifndef __GCC_ASM_FLAG_OUTPUTS__ +#error "missing preprocessor define" +#endif + +void f(char *out) +{ + asm("" + : "=@ccne"(out[0]), "=@cceq"(out[1]), + "=@cccs"(out[2]), "=@cccc"(out[3]), + "=@ccmi"(out[4]), "=@ccpl"(out[5]), + "=@ccvs"(out[6]), "=@ccvc"(out[7]), + "=@cchi"(out[8]), "=@ccls"(out[9]), + "=@ccge"(out[10]), "=@cclt"(out[11]), + "=@ccgt"(out[12]), "=@ccle"(out[13]), + "=@cchs"(out[14]), "=@cclo"(out[15])); +} + +/* There will be at least one of each. */ +/* { dg-final { scan-assembler "movne" } } */ +/* { dg-final { scan-assembler "moveq" } } */ +/* { dg-final { scan-assembler "movcs" } } */ +/* { dg-final { scan-assembler "movcc" } } */ +/* { dg-final { scan-assembler "movmi" } } */ +/* { dg-final { scan-assembler "movpl" } } */ +/* { dg-final { scan-assembler "movvs" } } */ +/* { dg-final { scan-assembler "movvc" } } */ +/* { dg-final { scan-assembler "movhi" } } */ +/* { dg-final { scan-assembler "movls" } } */ +/* { dg-final { scan-assembler "movge" } } */ +/* { dg-final { scan-assembler "movls" } } */ +/* { dg-final { scan-assembler "movgt" } } */ +/* { dg-final { scan-assembler "movle" } } */ diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-3.c b/gcc/testsuite/gcc.target/arm/asm-flag-3.c new file mode 100644 index 00000000000..e84e3431277 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-3.c @@ -0,0 +1,38 @@ +/* Test some of the valid @cc asm flag outputs. */ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +#define DO(C) \ +void f##C(void) { char x; asm("" : "=@cc"#C(x)); if (!x) asm(""); asm(""); } + +DO(ne) +DO(eq) +DO(cs) +DO(cc) +DO(hs) +DO(lo) +DO(mi) +DO(pl) +DO(vs) +DO(vc) +DO(hi) +DO(ls) +DO(ge) +DO(lt) +DO(gt) +DO(le) + +/* { dg-final { scan-assembler "bne" } } */ +/* { dg-final { scan-assembler "beq" } } */ +/* { dg-final { scan-assembler "bcs" } } */ +/* { dg-final { scan-assembler "bcc" } } */ +/* { dg-final { scan-assembler "bmi" } } */ +/* { dg-final { scan-assembler "bpl" } } */ +/* { dg-final { scan-assembler "bvs" } } */ +/* { dg-final { scan-assembler "bvc" } } */ +/* { dg-final { scan-assembler "bhi" } } */ +/* { dg-final { scan-assembler "bls" } } */ +/* { dg-final { scan-assembler "bge" } } */ +/* { dg-final { scan-assembler "blt" } } */ +/* { dg-final { scan-assembler "bgt" } } */ +/* { dg-final { scan-assembler "ble" } } */ diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-5.c b/gcc/testsuite/gcc.target/arm/asm-flag-5.c new file mode 100644 index 00000000000..4d4394e1478 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-5.c @@ -0,0 +1,30 @@ +/* Test error conditions of asm flag outputs. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void f_B(void) { _Bool x; asm("" : "=@cccc"(x)); } +void f_c(void) { char x; asm("" : "=@cccc"(x)); } +void f_s(void) { short x; asm("" : "=@cccc"(x)); } +void f_i(void) { int x; asm("" : "=@cccc"(x)); } +void f_l(void) { long x; asm("" : "=@cccc"(x)); } +void f_ll(void) { long long x; asm("" : "=@cccc"(x)); } + +void f_f(void) +{ + float x; + asm("" : "=@cccc"(x)); /* { dg-error invalid type } */ +} + +void f_d(void) +{ + double x; + asm("" : "=@cccc"(x)); /* { dg-error invalid type } */ +} + +struct S { int x[3]; }; + +void f_S(void) +{ + struct S x; + asm("" : "=@cccc"(x)); /* { dg-error invalid type } */ +} diff --git a/gcc/testsuite/gcc.target/arm/asm-flag-6.c b/gcc/testsuite/gcc.target/arm/asm-flag-6.c new file mode 100644 index 00000000000..09174e04ae6 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-6.c @@ -0,0 +1,62 @@ +/* Executable testcase for 'output flags.' */ +/* { dg-do run } */ + +int test_bits (long nzcv) +{ + long n, z, c, v; + + __asm__ ("msr APSR_nzcvq, %[in]" + : "=@ccmi"(n), "=@cceq"(z), "=@cccs"(c), "=@ccvs"(v) + : [in] "r"(nzcv << 28)); + + return n * 8 + z * 4 + c * 2 + v == nzcv; +} + +int test_cmps (long x, long y) +{ + long gt, lt, ge, le; + + __asm__ ("cmp %[x], %[y]" + : "=@ccgt"(gt), "=@cclt"(lt), "=@ccge"(ge), "=@ccle"(le) + : [x] "r"(x), [y] "r"(y)); + + return (gt == (x > y) + && lt == (x < y) + && ge == (x >= y) + && le == (x <= y)); +} + +int test_cmpu (unsigned long x, unsigned long y) +{ + long gt, lt, ge, le; + + __asm__ ("cmp %[x], %[y]" + : "=@cchi"(gt), "=@cclo"(lt), "=@cchs"(ge), "=@ccls"(le) + : [x] "r"(x), [y] "r"(y)); + + return (gt == (x > y) + && lt == (x < y) + && ge == (x >= y) + && le == (x <= y)); +} + +int main () +{ + long i, j; + + for (i = 0; i < 16; ++i) + if (!test_bits (i)) + __builtin_abort (); + + for (i = -1; i <= 1; ++i) + for (j = -1; j <= 1; ++j) + if (!test_cmps (i, j)) + __builtin_abort (); + + for (i = 0; i <= 2; ++i) + for (j = 0; j <= 2; ++j) + if (!test_cmpu (i, j)) + __builtin_abort (); + + return 0; +}