Skip to content

Commit

Permalink
intrinsic-test: Print C++ float16_t in hex
Browse files Browse the repository at this point in the history
Upstream Rust currently does not support printing f16s in decimal.
For the intrinsics tests to work, make C++ print float16_t in the same
format.

Can be droppen once rust-lang/rust#127013
is merged.
  • Loading branch information
mrkajetanp authored and Amanieu committed Feb 24, 2025
1 parent aae8eb3 commit 2a20b05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/intrinsic-test/missing_aarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ vrnd64z_f64

# Broken in Clang
vcvth_s16_f16
# FIXME: Broken output due to missing f16 printing support in Rust, see git blame for this line
vmulh_lane_f16
vmulh_laneq_f16
9 changes: 9 additions & 0 deletions crates/intrinsic-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ std::ostream& operator<<(std::ostream& os, poly128_t value) {{
}}
#endif
std::ostream& operator<<(std::ostream& os, float16_t value) {{
uint16_t temp = 0;
memcpy(&temp, &value, sizeof(float16_t));
std::stringstream ss;
ss << "0x" << std::setfill('0') << std::setw(4) << std::hex << temp;
os << ss.str();
return os;
}}
{arglists}
int main(int argc, char **argv) {{
Expand Down

0 comments on commit 2a20b05

Please sign in to comment.