Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get/set_fpcr_aarch64 #44256

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/processor_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1843,20 +1843,20 @@ extern "C" int jl_test_cpu_feature(jl_cpu_feature_t feature)

#ifdef _CPU_AARCH64_
// FPCR FZ, bit [24]
static constexpr uint32_t fpcr_fz_mask = 1 << 24;
static constexpr uint64_t fpcr_fz_mask = 1 << 24;
// FPCR FZ16, bit [19]
static constexpr uint32_t fpcr_fz16_mask = 1 << 19;
static constexpr uint64_t fpcr_fz16_mask = 1 << 19;
// FPCR DN, bit [25]
static constexpr uint32_t fpcr_dn_mask = 1 << 25;
static constexpr uint64_t fpcr_dn_mask = 1 << 25;

static inline uint32_t get_fpcr_aarch64(void)
static inline uint64_t get_fpcr_aarch64(void)
{
uint32_t fpcr;
uint64_t fpcr;
asm volatile("mrs %0, fpcr" : "=r"(fpcr));
return fpcr;
}

static inline void set_fpcr_aarch64(uint32_t fpcr)
static inline void set_fpcr_aarch64(uint64_t fpcr)
{
asm volatile("msr fpcr, %0" :: "r"(fpcr));
}
Expand All @@ -1868,8 +1868,8 @@ extern "C" JL_DLLEXPORT int32_t jl_get_zero_subnormals(void)

extern "C" JL_DLLEXPORT int32_t jl_set_zero_subnormals(int8_t isZero)
{
uint32_t fpcr = get_fpcr_aarch64();
static uint32_t mask = fpcr_fz_mask | (jl_test_cpu_feature(JL_AArch64_fullfp16) ? fpcr_fz16_mask : 0);
uint64_t fpcr = get_fpcr_aarch64();
static uint64_t mask = fpcr_fz_mask | (jl_test_cpu_feature(JL_AArch64_fullfp16) ? fpcr_fz16_mask : 0);
fpcr = isZero ? (fpcr | mask) : (fpcr & ~mask);
set_fpcr_aarch64(fpcr);
return 0;
Expand All @@ -1882,7 +1882,7 @@ extern "C" JL_DLLEXPORT int32_t jl_get_default_nans(void)

extern "C" JL_DLLEXPORT int32_t jl_set_default_nans(int8_t isDefault)
{
uint32_t fpcr = get_fpcr_aarch64();
uint64_t fpcr = get_fpcr_aarch64();
fpcr = isDefault ? (fpcr | fpcr_dn_mask) : (fpcr & ~fpcr_dn_mask);
set_fpcr_aarch64(fpcr);
return 0;
Expand Down