[llvm] [llubi] Initial support for floating-point numbers (PR #188453)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 06:39:03 PDT 2026


================
@@ -503,6 +503,39 @@ uint64_t Context::getEffectiveTypeStoreSize(Type *Ty) {
   return getEffectiveTypeSize(DL.getTypeStoreSize(Ty));
 }
 
+RoundingMode Context::getCurrentRoundingMode() const {
+  return CurrentRoundingMode;
+}
+
+fp::ExceptionBehavior Context::getCurrentExceptionBehavior() const {
+  return CurrentExceptionBehavior;
+}
+
+void Context::setCurrentRoundingMode(RoundingMode RM) {
+  CurrentRoundingMode = RM;
+}
+
+void Context::setCurrentExceptionBehavior(fp::ExceptionBehavior EB) {
+  CurrentExceptionBehavior = EB;
+}
+
+bool Context::isDefaultFPEnv() const {
+  return isDefaultFPEnvironment(CurrentExceptionBehavior, CurrentRoundingMode);
+}
+
+bool Context::getRandomBool() {
+  // We use the lowest bit of the raw bits from RNG as the result:
+  if (UndefBehavior == UndefValueBehavior::NonDeterministic)
----------------
nikic wrote:

Okay, looking a bit further into the patch, it looks like we're basically using undef behavior zero as "disable *all* non-determinism".

I think it makes a lot of sense to have a mode like that, but in terms of naming it probably shouldn't be tied to undef?

I'd rather have a `-deterministc=1` (or `-nondeterministic=0`) option that allows fully disabling non-determinism and will try to do the "most reasonable" thing everywhere (e.g. zero init for undef, preferred nan, no nsz sign flipping etc) and then more specific options that apply if non-determinism is enabled (e.g. to only control undef behavior). Though for those I'm not sure how fine-grained is actually useful.

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


More information about the llvm-commits mailing list