From patchwork Fri Jun 19 07:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 1312630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=EkKda5fu; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49p8z72Mcxz9sRk for ; Fri, 19 Jun 2020 17:08:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86A2D3890434; Fri, 19 Jun 2020 07:08:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 3E025383E821 for ; Fri, 19 Jun 2020 07:08:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3E025383E821 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kito.cheng@sifive.com Received: by mail-pf1-x443.google.com with SMTP id b16so4013308pfi.13 for ; Fri, 19 Jun 2020 00:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VegJAH641djozzOu7Bsu4Of3/pu8I+c01z0H9Sqp+jU=; b=EkKda5fu35yyqIVXgreHS2Ce5UGSVw4Zi2IcYetpVthy0wK4ICCvn6vaA9HoFbLd3i OWHEfOYlmZxWRB/Bol9f9czxuupjoNY8qquxX9nLZ7sTfFrdsvPkZ9EllxuyzjhuSVFf ln23KYqZixwBHwVk+h8xJY5wTK9G19w5RxjCq/qjVKyKNIctZ1/OlFztdBcgSq/NOvhY Yipl+rklvRNLfpx9bT3kyG0fweLl+Ueuyzm3ELDRB+GpnlvoIAie2nsYFWKns9vjnHtF +NpCwMrqOCWVM76bb0A0gLKGGLVbgDK1K2h2oLJ2CMDvYdCjViAWZxbTtsaP4sdfGcIq qEYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VegJAH641djozzOu7Bsu4Of3/pu8I+c01z0H9Sqp+jU=; b=PY6AKgvquQKlD0Bw2wSU5v3vbW53qJ7/F91LL5Fy0QOCxuBhsrWRn9H2PCC/nUbEsK jCFLORmFRJ75MXa/BGKt8ef3cJYEjWzDaRAauY3Hz4WH4EQ+zVcW/U5lYxCQJTLodVJx G8iX4fUbwDBRFyZ0si8tvphR1qQR8TJjfpQUD7A03W/yF2qFkoky6FDxyY5hdoatfbJN gSA9cde/F50arOXV0DaTqI+0fzTr1ZaJHcsq5qZiJTRo8zXW882TeuInximLZXD/2GQ0 DswA4psnBnpxwR+LZaTCUvjHjfa8aXy8RvzC3g3Db+k0L2gBPJWWntuwbvqrxT3Q00xh OYqQ== X-Gm-Message-State: AOAM530bDPYanUFfN0LIRo50Gd784BzTNUmjKjoAK0VW8nqjfDLmL5Fb K3ruA72uXhm+ZX/s9Y/uZkH+aSV++5E= X-Google-Smtp-Source: ABdhPJy8HZWIJ9DjgNY+t/n3aolmFliuk5fdsOoefiD3zagIMfW6ynjh1imnsmRgoRFlhNB+QPmXZA== X-Received: by 2002:a63:482:: with SMTP id 124mr1935385pge.169.1592550485785; Fri, 19 Jun 2020 00:08:05 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id d206sm4765030pfd.40.2020.06.19.00.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 00:08:05 -0700 (PDT) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com Subject: [PATCH] RISC-V: Fix compilation failed for frflags builtin in C++ mode Date: Fri, 19 Jun 2020 15:08:01 +0800 Message-Id: <20200619070801.8462-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Status: No, score=-15.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Kito Cheng Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" - g++ will complain too few arguments for frflags builtin like bellow message: error: too few arguments to function 'unsigned int __builtin_riscv_frflags(void)' - However it's no arguments needed, it because we declare the function type with VOID arguments, that seems like require a VOID argument in the c++ front-end when GCC tried to resolve the function. gcc/ChangeLog * config/riscv/riscv-builtins.c (RISCV_FTYPE_NAME0): New. (RISCV_FTYPE_ATYPES0): New. (riscv_builtins): Using RISCV_USI_FTYPE for frflags. * config/riscv/riscv-ftypes.def: Remove VOID argument. gcc/testsuite/ChangeLog * g++.target/riscv/frflags.C: New. --- gcc/config/riscv/riscv-builtins.c | 5 ++++- gcc/config/riscv/riscv-ftypes.def | 2 +- gcc/testsuite/g++.target/riscv/frflags.C | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.target/riscv/frflags.C diff --git a/gcc/config/riscv/riscv-builtins.c b/gcc/config/riscv/riscv-builtins.c index a45108e03557..bc959389c76c 100644 --- a/gcc/config/riscv/riscv-builtins.c +++ b/gcc/config/riscv/riscv-builtins.c @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" /* Macros to create an enumeration identifier for a function prototype. */ +#define RISCV_FTYPE_NAME0(A) RISCV_##A##_FTYPE #define RISCV_FTYPE_NAME1(A, B) RISCV_##A##_FTYPE_##B /* Classifies the prototype of a built-in function. */ @@ -121,11 +122,13 @@ AVAIL (hard_float, TARGET_HARD_FLOAT) /* RISCV_FTYPE_ATYPESN takes N RISCV_FTYPES-like type codes and lists their associated RISCV_ATYPEs. */ +#define RISCV_FTYPE_ATYPES0(A) \ + RISCV_ATYPE_##A #define RISCV_FTYPE_ATYPES1(A, B) \ RISCV_ATYPE_##A, RISCV_ATYPE_##B static const struct riscv_builtin_description riscv_builtins[] = { - DIRECT_BUILTIN (frflags, RISCV_USI_FTYPE_VOID, hard_float), + DIRECT_BUILTIN (frflags, RISCV_USI_FTYPE, hard_float), DIRECT_NO_TARGET_BUILTIN (fsflags, RISCV_VOID_FTYPE_USI, hard_float) }; diff --git a/gcc/config/riscv/riscv-ftypes.def b/gcc/config/riscv/riscv-ftypes.def index 5edeb481a72d..1c6bc4e9dce1 100644 --- a/gcc/config/riscv/riscv-ftypes.def +++ b/gcc/config/riscv/riscv-ftypes.def @@ -26,5 +26,5 @@ along with GCC; see the file COPYING3. If not see LIST contains the return-type code followed by the codes for each argument type. */ -DEF_RISCV_FTYPE (1, (USI, VOID)) +DEF_RISCV_FTYPE (0, (USI)) DEF_RISCV_FTYPE (1, (VOID, USI)) diff --git a/gcc/testsuite/g++.target/riscv/frflags.C b/gcc/testsuite/g++.target/riscv/frflags.C new file mode 100644 index 000000000000..be0bd4db01c3 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/frflags.C @@ -0,0 +1,7 @@ +/* { dg-options "-O2 -march=rv32if" } */ +/* { dg-do compile } */ + +int f() +{ + return __builtin_riscv_frflags(); +}