[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 1 06:21:38 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/Floating.h:27-29
+  template <unsigned ReprBits> struct Repr;
+  template <> struct Repr<32> { using Type = float; };
+  template <> struct Repr<64> { using Type = double; };
----------------
jcranmer-intel wrote:
> aaron.ballman wrote:
> > Er, how will this extend to `long double` where the number of bits is rather more difficult?
> Or `half` and `bfloat`, which are both 16-bit floating-point types?
I have spent some time with this today and tried to simply always use `APFloat` instead of a primitive type. Unfortunately that doesn't work because what we put on the stack is not the `Floating` (or `Integral`), but the underlying primitive type. So even if we do the final math (in `::add`, etc) via `APFloat`, we need something we can serialize to `char[]` so we can put it on the stack. Do you think that would work?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134859/new/

https://reviews.llvm.org/D134859



More information about the cfe-commits mailing list