How do I obtain / compute values like FLT_MAX and FLT_EPSILON with LLVM?

Viewed 137

If my code is generating LLVM SSA for a platform that is possibly different than the one on which it is currently running, how do I obtain values like FLT_MAX or FLT_EPSILON (or the same for doubles, or any other floating point width)?

I'm guessing it's not correct, in general, to obtain those values for my own system and use them. It's also not an acceptable solution to delegate the question to clang or gcc.

When generating LLVM code, how do I know what value to emit for FLT_MAX?

1 Answers

FLT_MAX / FLT_EPSILON are entities specific to C/C++ and are not connected with LLVM. So, you'd need to resort to a C/C++ compiler in order to derive this. Alternatively, you'd need to keep the list of supported platforms and hard-code these values there for each supported platforms.

Related