Commit 09bcc433 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC: create is_snan helper functions

Simulator needs a way to check if a fp input is
a signalling NaN and `issignaling` doesn't seem to be
supported on the latest gclient update and causes link errors.

Change-Id: Id2a7200b6cf13bb6174b052728fc5a0d5436321c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3581768Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#79929}
parent 1b405b14
......@@ -642,6 +642,18 @@ static bool AllOnOnePage(uintptr_t start, int size) {
return start_page == end_page;
}
static bool is_snan(float input) {
uint32_t kQuietNanFPBit = 1 << 22;
uint32_t InputAsUint = bit_cast<uint32_t>(input);
return isnan(input) && ((InputAsUint & kQuietNanFPBit) == 0);
}
static bool is_snan(double input) {
uint64_t kQuietNanDPBit = 1L << 51;
uint64_t InputAsUint = bit_cast<uint64_t>(input);
return isnan(input) && ((InputAsUint & kQuietNanDPBit) == 0);
}
void Simulator::set_last_debugger_input(char* input) {
DeleteArray(last_debugger_input_);
last_debugger_input_ = input;
......@@ -4784,7 +4796,7 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
bit_cast<float, uint32_t>(static_cast<uint32_t>(double_bits >> 32));
double_bits = bit_cast<uint64_t, double>(static_cast<double>(f));
// Preserve snan.
if (issignaling(f)) {
if (is_snan(f)) {
double_bits &= 0xFFF7FFFFFFFFFFFFU; // Clear bit 51.
}
set_d_register(t, double_bits);
......@@ -4797,7 +4809,7 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
uint64_t float_bits = static_cast<uint64_t>(
bit_cast<uint32_t, float>(static_cast<float>(b_val)));
// Preserve snan.
if (issignaling(b_val)) {
if (is_snan(b_val)) {
float_bits &= 0xFFBFFFFFU; // Clear bit 22.
}
// fp result is placed in both 32bit halfs of the dst.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment