From patchwork Thu Nov 14 10:07:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 179391 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp10837977ilf; Thu, 14 Nov 2019 02:09:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxqH1y1jxu25VobwbSD0Z8Fe+OTexteOaH+fLrdET4Ta/xT1XDuW6VBOddiwudSwAdsUlZl X-Received: by 2002:a17:906:c7d0:: with SMTP id dc16mr7636657ejb.73.1573726146930; Thu, 14 Nov 2019 02:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573726146; cv=none; d=google.com; s=arc-20160816; b=SeOwQqVzJ9zQHqfvYj9HbVSfh2XzPfP1qhtbC/CAOncTheDee3dhor3+/e1mBjfpFi qmnZWjHTI3iJZH2l3xZ2jZiqg6AD0nwuArgWU0c65D8XY7YmdBB6N2wEnq3ZQIxrYyjP dnvwNEVuCEzkyTlwd9bbV8jDFwMjF1egisEOOWvWKrXg54O1i66jFT5OmBjdEzexhsv8 b4wOGbjJhdF/Q19T2a3H5zG1rx8nj8qkl/lcucynfrC73KiDG4QiMgDbtKJiCE9Lcrc4 6mfrPboVD9WypfKotMSzHsjXBW3/HTOqERRPF7v9Lz/M3zc345HqhJgWuEDu1VacvH6F PtXA== 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=qTLRNJGYUWBbLSlMGp/8P5kVUZPNHAxVu1yc+8wDaOc=; b=ecQOJl03YujF3VjqW20CHh0dfmcVSboFsxu/dIYi/B2RbxhT9/C2D80+2dTpZofecA DaaV2erY6V4OObx6v54BIcn8w5KGk/9BxRzDH2xV+Qk0mDFon91fuDjAi6mH3k/wZUJW 1u1BB+xQmXwAtssALuYefqfRVKiA/cWEHzN+8L7VLcUx4fUPuujBNIFmayat6n2/GFJm rjD/UPqHTO0Z5g3sr47G3j3xplEd/rLI1IrqjZib7tH74D6QrmllJsSl6yPl7O9njgt+ 82Npo3z3vEqlU4ddsOkEU5rO/H4a9kPOaNqiOGU+O5fw12JCk27Nc4Z9iuaSXItOX1iO g9Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=G8lLzWD1; dkim=pass header.i=@linaro.org header.s=google header.b=oButCwXh; spf=pass (google.com: domain of gcc-patches-return-513349-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-513349-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 s1si3450413ejl.235.2019.11.14.02.09.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2019 02:09:06 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-513349-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=G8lLzWD1; dkim=pass header.i=@linaro.org header.s=google header.b=oButCwXh; spf=pass (google.com: domain of gcc-patches-return-513349-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-513349-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=yPi553bAj039SfTZC3JHLeWVPfwR0xMPnaYnaCp7GkJUk5BG+Us7K RIZVqVjYmVmisbP7T8z20F9YuOVDfXwdxsZTY88+tp2QSdigQM1fYBZsbibCHfgl V+NM+PMNnYAGYmmQJlIC/bzObHbu2K3E3tM7qBan9J7QdBsrML6BSk= 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=N/zpe628UwiBjK6d2C/HdWEmHfI=; b=G8lLzWD1pAWc5Fap60Gg W+SL+Lp3N4oTYIkBTUR32zVu2ovmTjmNkY3n/sw5l/c4KfknFra7CbPRYPkJsr/M sliqZ2UjIVYYY/BXYVH+gc4EjiAllADFfMqFRCZ/DsUz+2fkmvW1eUTOIW8uuDOU bNZcmpNkY/VR3FT7JqHYTQw= Received: (qmail 75854 invoked by alias); 14 Nov 2019 10:07:45 -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 75774 invoked by uid 89); 14 Nov 2019 10:07:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 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-f50.google.com Received: from mail-wm1-f50.google.com (HELO mail-wm1-f50.google.com) (209.85.128.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 10:07:42 +0000 Received: by mail-wm1-f50.google.com with SMTP id b17so5198194wmj.2 for ; Thu, 14 Nov 2019 02:07:42 -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=qTLRNJGYUWBbLSlMGp/8P5kVUZPNHAxVu1yc+8wDaOc=; b=oButCwXhBA9OQVUZkhQLe8u7V4F+sxO4ULraqSZSYIGsbGzsRXjM7c5X+bZqbQJhCO nMe89k8oTHoRAJ176izvyWjxAADv92aFrayWj5xV4S/WpTbjomfPAtlDpjy//vgLGBRu IbVbH5uva3l5W9W9xvhwLSlxV4y+emVvg7sMLikGM+syvwOJavatl3erdOEv3fYKi6Jt 15oiVVsKCw7m9YfpxqzIaUJEn0zrXBE3dXj9ACMGk4RbJCyqTVzVpGF2Kbm5rHmIfNjk VK1eAwgUuHbH9j3nKLcIC6xQ4FarR1VIIvAba2k7hk+AkoTJXlisvEj4bSowAoWDlm8m bIpQ== 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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 02:07:39 -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 6/6] aarch64: Add testsuite checks for asm-flag Date: Thu, 14 Nov 2019 11:07:16 +0100 Message-Id: <20191114100716.28827-7-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/aarch64/asm-flag-1.c: New test. * gcc.target/aarch64/asm-flag-3.c: New test. * gcc.target/aarch64/asm-flag-5.c: New test. * gcc.target/aarch64/asm-flag-6.c: New test. --- gcc/testsuite/gcc.target/aarch64/asm-flag-1.c | 35 +++++++++++ gcc/testsuite/gcc.target/aarch64/asm-flag-3.c | 38 ++++++++++++ gcc/testsuite/gcc.target/aarch64/asm-flag-5.c | 30 +++++++++ gcc/testsuite/gcc.target/aarch64/asm-flag-6.c | 62 +++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-3.c create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-5.c create mode 100644 gcc/testsuite/gcc.target/aarch64/asm-flag-6.c -- 2.17.1 diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-1.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-1.c new file mode 100644 index 00000000000..49901e59c38 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/asm-flag-1.c @@ -0,0 +1,35 @@ +/* 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])); +} + +/* { dg-final { scan-assembler "cset.*, ne" } } */ +/* { dg-final { scan-assembler "cset.*, eq" } } */ +/* { dg-final { scan-assembler "cset.*, cs" } } */ +/* { dg-final { scan-assembler "cset.*, cc" } } */ +/* { dg-final { scan-assembler "cset.*, mi" } } */ +/* { dg-final { scan-assembler "cset.*, pl" } } */ +/* { dg-final { scan-assembler "cset.*, vs" } } */ +/* { dg-final { scan-assembler "cset.*, vc" } } */ +/* { dg-final { scan-assembler "cset.*, hi" } } */ +/* { dg-final { scan-assembler "cset.*, ls" } } */ +/* { dg-final { scan-assembler "cset.*, ge" } } */ +/* { dg-final { scan-assembler "cset.*, ls" } } */ +/* { dg-final { scan-assembler "cset.*, gt" } } */ +/* { dg-final { scan-assembler "cset.*, le" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/asm-flag-3.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-3.c new file mode 100644 index 00000000000..e84e3431277 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/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/aarch64/asm-flag-5.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-5.c new file mode 100644 index 00000000000..4d4394e1478 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/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/aarch64/asm-flag-6.c b/gcc/testsuite/gcc.target/aarch64/asm-flag-6.c new file mode 100644 index 00000000000..963b5a48c70 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/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 nzcv, %[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; +}