From: arthur.cohen@embecosm.com
To: gcc-patches@gcc.gnu.org
Cc: gcc-rust@gcc.gnu.org, "Marc Poulhiès" <dkm@kataplop.net>
Subject: [COMMITTED 6/9] gccrs: add powi intrinsics
Date: Wed, 21 Feb 2024 14:15:24 +0100 [thread overview]
Message-ID: <20240221131636.3336103-9-arthur.cohen@embecosm.com> (raw)
In-Reply-To: <20240221131636.3336103-2-arthur.cohen@embecosm.com>
From: Marc Poulhiès <dkm@kataplop.net>
gcc/rust/ChangeLog:
* backend/rust-builtins.cc
(BuiltinsContext::register_rust_mappings): Add powi and reformat.
* backend/rust-builtins.h: Add missing copyright header.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-math.rs: Adjust pow test, add
test for powi.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
---
gcc/rust/backend/rust-builtins.cc | 30 +++++++++++++++++--
gcc/rust/backend/rust-builtins.h | 2 ++
.../rust/compile/torture/intrinsics-math.rs | 12 ++++++--
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/gcc/rust/backend/rust-builtins.cc b/gcc/rust/backend/rust-builtins.cc
index 1a87f869206..282ecba70cb 100644
--- a/gcc/rust/backend/rust-builtins.cc
+++ b/gcc/rust/backend/rust-builtins.cc
@@ -285,46 +285,70 @@ void
BuiltinsContext::register_rust_mappings ()
{
rust_intrinsic_to_gcc_builtin = {
- {"sinf32", "__builtin_sinf"},
- {"sqrtf32", "__builtin_sqrtf"},
- {"sqrtf64", "__builtin_sqrt"},
{"unreachable", "__builtin_unreachable"},
{"abort", "__builtin_abort"},
+
+ // Math intrinsics
+ {"sqrtf32", "__builtin_sqrtf"},
+ {"sqrtf64", "__builtin_sqrt"},
+
+ {"sinf32", "__builtin_sinf"},
{"sinf64", "__builtin_sin"},
+
{"cosf32", "__builtin_cosf"},
{"cosf64", "__builtin_cos"},
+
{"powf32", "__builtin_powf"},
{"powf64", "__builtin_pow"},
+
+ {"powif32", "__builtin_powif"},
+ {"powif64", "__builtin_powi"},
+
{"expf32", "__builtin_expf"},
{"expf64", "__builtin_exp"},
+
{"exp2f32", "__builtin_exp2f"},
{"exp2f64", "__builtin_exp2"},
+
{"logf32", "__builtin_logf"},
{"logf64", "__builtin_log"},
+
{"log10f32", "__builtin_log10f"},
{"log10f64", "__builtin_log10"},
+
{"log2f32", "__builtin_log2f"},
{"log2f64", "__builtin_log2"},
+
{"fmaf32", "__builtin_fmaf"},
{"fmaf64", "__builtin_fma"},
+
{"fabsf32", "__builtin_fabsf"},
{"fabsf64", "__builtin_fabs"},
+
{"minnumf32", "__builtin_fminf"},
{"minnumf64", "__builtin_fmin"},
+
{"maxnumf32", "__builtin_fmaxf"},
{"maxnumf64", "__builtin_fmax"},
+
{"copysignf32", "__builtin_copysignf"},
{"copysignf64", "__builtin_copysign"},
+
{"floorf32", "__builtin_floorf"},
{"floorf64", "__builtin_floor"},
+
{"ceilf32", "__builtin_ceilf"},
{"ceilf64", "__builtin_ceil"},
+
{"truncf32", "__builtin_truncf"},
{"truncf64", "__builtin_trunc"},
+
{"rintf32", "__builtin_rintf"},
{"rintf64", "__builtin_rint"},
+
{"nearbyintf32", "__builtin_nearbyintf"},
{"nearbyintf64", "__builtin_nearbyint"},
+
{"roundf32", "__builtin_roundf"},
{"roundf64", "__builtin_round"},
};
diff --git a/gcc/rust/backend/rust-builtins.h b/gcc/rust/backend/rust-builtins.h
index 5052edad51e..65dd850e3c6 100644
--- a/gcc/rust/backend/rust-builtins.h
+++ b/gcc/rust/backend/rust-builtins.h
@@ -1,3 +1,5 @@
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
+
// This file is part of GCC.
// GCC is free software; you can redistribute it and/or modify it under
diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-math.rs b/gcc/testsuite/rust/compile/torture/intrinsics-math.rs
index 42acdde1494..e0d15f99d48 100644
--- a/gcc/testsuite/rust/compile/torture/intrinsics-math.rs
+++ b/gcc/testsuite/rust/compile/torture/intrinsics-math.rs
@@ -14,6 +14,9 @@ extern "rust-intrinsic" {
pub fn powf32(a: f32, x: f32) -> f32;
pub fn powf64(a: f64, x: f64) -> f64;
+ pub fn powif32(a: f32, x: i32) -> f32;
+ pub fn powif64(a: f64, x: i32) -> f64;
+
pub fn expf32(x: f32) -> f32;
pub fn expf64(x: f64) -> f64;
@@ -84,9 +87,14 @@ fn main() {
// { dg-final { scan-tree-dump-times {(?n)f64 .* __builtin_cos.? \(.*6\.0e\+0\);$} 1 original } }
f32 = powf32(7f32, 8f32);
- // { dg-final { scan-tree-dump-times {(?n)f32 .* __builtin_pow. \(.*7\.0e\+0, .*8\.0e\+0\);$} 1 original } }
+ // { dg-final { scan-tree-dump-times {(?n)f32 .* __builtin_pow[^i] \(.*7\.0e\+0, .*8\.0e\+0\);$} 1 original } }
f64 = powf64(9f64, 10f64);
- // { dg-final { scan-tree-dump-times {(?n)f64 .* __builtin_pow.? \(.*9\.0e\+0, .*1\.0e\+1\);$} 1 original } }
+ // { dg-final { scan-tree-dump-times {(?n)f64 .* __builtin_pow[^i]? \(.*9\.0e\+0, .*1\.0e\+1\);$} 1 original } }
+
+ f32 = powif32(7f32, 8i32);
+ // { dg-final { scan-tree-dump-times {(?n)f32 .* __builtin_powi. \(.*7\.0e\+0, .*8\);$} 1 original } }
+ f64 = powif64(9f64, 10i32);
+ // { dg-final { scan-tree-dump-times {(?n)f64 .* __builtin_powi.? \(.*9\.0e\+0, .*10\);$} 1 original } }
f32 = expf32(11f32);
// { dg-final { scan-tree-dump-times {(?n)f32 .* __builtin_exp. \(.*1\.1e\+1\);$} 1 original } }
--
2.42.1
next prev parent reply other threads:[~2024-02-21 13:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 13:15 [PATCHSET] Update Rust frontend 21/02/2024 arthur.cohen
2024-02-21 13:15 ` [COMMITTED 1/9] gccrs: Fix typo in RegionConstraints instance arthur.cohen
2024-02-21 13:15 ` [COMMITTED 2/9] gccrs: Add testcase for matches!() macro arthur.cohen
2024-02-21 13:15 ` [COMMITTED 3/9] gccrs: Fix rebinding imports arthur.cohen
2024-02-21 13:15 ` [COMMITTED 4/9] gccrs: expand: Fix formatting for "macro not found" error arthur.cohen
2024-02-21 13:15 ` [COMMITTED 5/9] gccrs: Add testcase for #[rustc_const_stable] arthur.cohen
2024-02-21 13:15 ` arthur.cohen [this message]
2024-02-21 13:15 ` [COMMITTED 7/9] gccrs: Fix lookup of TuplePattern sub-pattern types arthur.cohen
2024-02-21 13:15 ` [COMMITTED 8/9] gccrs: Add variadic check on function params arthur.cohen
2024-02-21 13:15 ` [COMMITTED 9/9] Update copyright years arthur.cohen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240221131636.3336103-9-arthur.cohen@embecosm.com \
--to=arthur.cohen@embecosm.com \
--cc=dkm@kataplop.net \
--cc=gcc-patches@gcc.gnu.org \
--cc=gcc-rust@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).