From: "Paul A. Clarke" <pc@us.ibm.com>
To: libc-alpha@sourceware.org
Subject: [PATCH] [powerpc] Tighten contraints for asm constant parameters
Date: Tue, 19 Oct 2021 10:14:13 -0500 [thread overview]
Message-ID: <20211019151413.123039-1-pc@us.ibm.com> (raw)
There are a few places where only constants are acceptable for `asm`
parameters, yet the constraint "i" is used. "i" is for "any integer"
including variables.
Use "n" instead of "i" where constant integers are required.
Suggested-by: Segher Boessenkool <segher@kernel.crashing.org>
---
sysdeps/powerpc/fpu/fenv_libc.h | 8 ++++----
sysdeps/powerpc/test-get_hwcap.c | 8 ++++----
sysdeps/powerpc/tst-tlsifunc.c | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h
index dc35b9dbe0d0..a04fb928cae2 100644
--- a/sysdeps/powerpc/fpu/fenv_libc.h
+++ b/sysdeps/powerpc/fpu/fenv_libc.h
@@ -73,7 +73,7 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden;
if (__builtin_constant_p (rn)) \
__asm__ __volatile__ ( \
".machine push; .machine \"power9\"; mffscrni %0,%1; .machine pop" \
- : "=f" (__fr.fenv) : "i" (rn)); \
+ : "=f" (__fr.fenv) : "n" (rn)); \
else \
{ \
__fr.l = (rn); \
@@ -135,8 +135,8 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden;
/* Set/clear a particular FPSCR bit (for instance,
reset_fpscr_bit(FPSCR_VE);
prevents INVALID exceptions from being raised). */
-#define set_fpscr_bit(x) asm volatile ("mtfsb1 %0" : : "i"(x))
-#define reset_fpscr_bit(x) asm volatile ("mtfsb0 %0" : : "i"(x))
+#define set_fpscr_bit(x) asm volatile ("mtfsb1 %0" : : "n"(x))
+#define reset_fpscr_bit(x) asm volatile ("mtfsb0 %0" : : "n"(x))
typedef union
{
@@ -184,7 +184,7 @@ __fesetround_inline_nocheck (const int round)
if (__glibc_likely (GLRO(dl_hwcap2) & PPC_FEATURE2_ARCH_3_00))
__fe_mffscrn (round);
else
- asm volatile ("mtfsfi 7,%0" : : "i" (round));
+ asm volatile ("mtfsfi 7,%0" : : "n" (round));
#endif
}
diff --git a/sysdeps/powerpc/test-get_hwcap.c b/sysdeps/powerpc/test-get_hwcap.c
index b5cef93cddd4..a64b63080756 100644
--- a/sysdeps/powerpc/test-get_hwcap.c
+++ b/sysdeps/powerpc/test-get_hwcap.c
@@ -63,16 +63,16 @@ uint64_t check_tcbhwcap (long tid)
#ifdef __powerpc64__
__asm__ ("ld %0,%1(%2)\n"
: "=r" (tcb_hwcap)
- : "i" (__HWCAPOFF), "b" (__tp));
+ : "n" (__HWCAPOFF), "b" (__tp));
#else
uint64_t h1, h2;
__asm__ ("lwz %0,%1(%2)\n"
: "=r" (h1)
- : "i" (__HWCAPOFF), "b" (__tp));
+ : "n" (__HWCAPOFF), "b" (__tp));
__asm__ ("lwz %0,%1(%2)\n"
: "=r" (h2)
- : "i" (__HWCAP2OFF), "b" (__tp));
+ : "n" (__HWCAP2OFF), "b" (__tp));
tcb_hwcap = (h1 >> 32) << 32 | (h2 >> 32);
#endif
@@ -117,7 +117,7 @@ uint64_t check_tcbhwcap (long tid)
/* Same test for the platform number. */
__asm__ ("lwz %0,%1(%2)\n"
: "=r" (tcb_at_platform)
- : "i" (__ATPLATOFF), "b" (__tp));
+ : "n" (__ATPLATOFF), "b" (__tp));
at_platform_string = (const char *) getauxval (AT_PLATFORM);
at_platform = _dl_string_platform (at_platform_string);
diff --git a/sysdeps/powerpc/tst-tlsifunc.c b/sysdeps/powerpc/tst-tlsifunc.c
index c8c0bada4547..f2eaf11bb407 100644
--- a/sysdeps/powerpc/tst-tlsifunc.c
+++ b/sysdeps/powerpc/tst-tlsifunc.c
@@ -49,7 +49,7 @@ get_platform (void)
__asm__ ("lwz %0,%1(%2)\n"
: "=r" (tmp)
- : "i" (__ATPLATOFF), "b" (tp));
+ : "n" (__ATPLATOFF), "b" (tp));
return tmp;
}
--
2.27.0
next reply other threads:[~2021-10-19 15:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 15:14 Paul A. Clarke [this message]
2021-10-19 15:26 ` Florian Weimer
2021-10-19 15:58 ` Paul A. Clarke
2021-10-19 15:59 ` Florian Weimer
2021-10-29 19:26 ` Tulio Magno Quites Machado Filho
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=20211019151413.123039-1-pc@us.ibm.com \
--to=pc@us.ibm.com \
--cc=libc-alpha@sourceware.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).