From patchwork Fri Nov 8 10:54:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 178872 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2505851ilf; Fri, 8 Nov 2019 02:55:36 -0800 (PST) X-Google-Smtp-Source: APXvYqwhmNtNU1cqZx/56Gb0IRwbMkGHPnNqfVu/DE0n3vyafAxm1wTlLA/Q1ANLKqM8veuzYCRB X-Received: by 2002:aa7:db52:: with SMTP id n18mr9043665edt.169.1573210536840; Fri, 08 Nov 2019 02:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573210536; cv=none; d=google.com; s=arc-20160816; b=IF3q6wNdya956YdORqvlDiXOGPTxu1PruLjxyh0PIOur8UaNzBCPUg2ajk8j/n6gZj pjpTotdNx07OQRl59BUZ4X61l6De8GoBed3MmtCwpGtQ7t456EnXk4wr4W4NLENDM4qz ynBQ5UoRXzS5M5LEoTgQLEOb2JlU2cXWSPvKoy/5Y0dNXOnTv4Wn9fhiuJyr8wEbHAQD 95ayhawRc4ynKA9fXpwH7KnUUINdAMW7T6gCJ12lENpXdYgYLlWZMgvXwYEjhViN0Qv8 3c12Pv9TO5foAykRsPGce5DjvewLUvi3TkUlLo1MHqbvfvR6jlou/u+ilNZZ7YHPsILg YTRw== 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=9WtPtAWd9ubLryf1sZgnr9XBbX5IRKSHE7mRyyOM/GI=; b=VHatIX28Jgw1zUwgLdWnmV2YXynozK1sG53qZMpLzw2tS5Whp3kfWSlI7F2fMeCh1O yeNEW399kFMCvowbGkg3Spmv25eSUUAvw2Vs5JIWLIfMF4FShSPKFm9lMclQ45NY/cWU DcJZwn7geTD9YGv8GwetyUBxF2SwhsAtustWO0yTnT/VW5P38Ha1g7mJDO28ss9SN7Ac W/GQj5XYEV1e1xTXwaQbFsKh4NV7ZFvnjOlIeW4oaVoNEiqxdUTM0+uUZLl0DkUOf+Pw GrZbwfml9SfXmJZoBis3jTCrp36US74Z+aWciS39+u7GLn/iF9/LO1lM3seBf7X6zJ9J wbhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lA0txAq2; dkim=pass header.i=@linaro.org header.s=google header.b=p1lLLRg5; spf=pass (google.com: domain of gcc-patches-return-512805-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-512805-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 b17si3534640ejp.326.2019.11.08.02.55.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Nov 2019 02:55:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-512805-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=lA0txAq2; dkim=pass header.i=@linaro.org header.s=google header.b=p1lLLRg5; spf=pass (google.com: domain of gcc-patches-return-512805-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-512805-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=xhV05Kg//tzFS2BGyaHfC2bdOp5yUehZEmlHmixEhZI9AkO6qqDHQ ovpm5JMS/e3Pd5/zsCKrgoB01bjLJQ5uUT559oNOefHMBwoAc+NPxvMSXBCdgiq+ b2AsY6zrYihkotTE0DFtAVKKdu62D8r3uVNkSulaqonp2b1/hMwJzU= 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=CLzxxMqaoZkBw4amLvxAF3idEFY=; b=lA0txAq24RegjflRi30x CMMKjEKSZSquM2cxCZncp03ZE3N3fOgc9jTeGqY5l/IpBZnXWhxcX0ItY/X3Kl+m QFiCDeGjsTkThqi6edp3L7uUT/rwsruy8EyA6LMyzu7wt/uHCBRIAw1FVxJdwFqd 6wBaoqvlD8DvIsDUVpXAxas= Received: (qmail 106677 invoked by alias); 8 Nov 2019 10:54:35 -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 106550 invoked by uid 89); 8 Nov 2019 10:54:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.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=ble, bhi X-HELO: mail-wr1-f43.google.com Received: from mail-wr1-f43.google.com (HELO mail-wr1-f43.google.com) (209.85.221.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2019 10:54:32 +0000 Received: by mail-wr1-f43.google.com with SMTP id e6so6564643wrw.1 for ; Fri, 08 Nov 2019 02:54:31 -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=9WtPtAWd9ubLryf1sZgnr9XBbX5IRKSHE7mRyyOM/GI=; b=p1lLLRg55b9ltq44SAnzKmAsAahYbzCzYYz4Fe2Ebq9QEBBETnoTltSssliH62XkrQ grkt9dW4wei4hh88WDrJh7X7oovdMmwZKsWNnO8AaZGh97x2Bh6m0JAJhG3MS9MJNkUp ddzNMFVYh1edkFO/+F7Klzofq+EydL+iL5o06Au1h+Asf+XcA8u9zIhRn9Nthyfn1Ou1 9ohk7M2oZIoQ6UZenjySxpFFRkBHMhaVuGQuvFNSqUAg4XTq4vLhuosHxUgbDAusFqsP RunYfNImKBPSYK4Ie/WkUt+3xAjia8ElzSqku2j19iEshuaNh3Olp6XnL12sievyKKMn eagA== Return-Path: Received: from localhost.localdomain (212.red-213-99-162.dynamicip.rima-tde.net. [213.99.162.212]) by smtp.gmail.com with ESMTPSA id 19sm8046565wrc.47.2019.11.08.02.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 02:54:29 -0800 (PST) From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: richard.earnshaw@arm.com, james.greenhalgh@arm.com, richard.sandiford@arm.com, marcus.shawcroft@arm.com, kyrylo.tkachov@arm.com Subject: [PATCH 5/6] arm: Add testsuite checks for asm-flag Date: Fri, 8 Nov 2019 11:54:07 +0100 Message-Id: <20191108105408.27584-6-richard.henderson@linaro.org> In-Reply-To: <20191108105408.27584-1-richard.henderson@linaro.org> References: <20191108105408.27584-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 | 35 ++++++++++++++++++ gcc/testsuite/gcc.target/arm/asm-flag-3.c | 36 +++++++++++++++++++ gcc/testsuite/gcc.target/arm/asm-flag-5.c | 30 ++++++++++++++++ gcc/testsuite/gcc.target/arm/asm-flag-6.c | 43 +++++++++++++++++++++++ 4 files changed, 144 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..e1ce4120d98 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/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])); +} + +/* There will be at least one of each, probably two. */ +/* { 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..8b0bd8a00f9 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-3.c @@ -0,0 +1,36 @@ +/* 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(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..ef2e06afc37 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/asm-flag-6.c @@ -0,0 +1,43 @@ +/* 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_cmp (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 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_cmp (i, j)) + __builtin_abort (); + + return 0; +}