[llvm] [LLParser] Support identifiers like `nan` and `pinf` for special FP values (PR #102790)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 22:25:19 PDT 2024


mshockwave wrote:

I've updated the patch so now `nan` represent the default QNaN with no payload; `snan(payload)` and `qnan(payload)` allow you to customize the payload. I decided to have a separate `snan` and `qnan` for the payload version because it's easier to create the value using the existing `APFloat` APIs, which always ask the signaling bit up ahead and "sanitize" the payload accordingly.

There are some rough edges on specifying the payload value, because LLParser always use a IEEEdouble to carry the value before converting them into the actual types, which might truncate the payload in an unexpected way. I think it's pretty difficult to fully fix so instead, I stated this issue in the LangRef and asked users to be careful.

A patch for the AsmWriter support, namely, printing `nan`, `pinf`, and `ninf` as well, is on the way. I put it in a separate patch because there are tons of changes in the tests.

https://github.com/llvm/llvm-project/pull/102790


More information about the llvm-commits mailing list