[llvm] [GlobalISel] use constexpr LLT types when creating ISel data (PR #191574)
Alan Li via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 12 06:42:47 PDT 2026
================
@@ -408,18 +408,44 @@ void LLTCodeGen::emitCxxEnumValue(raw_ostream &OS) const {
llvm_unreachable("Unhandled LLT");
}
+/// Emit a constexpr LLT constructor call for an IEEE floating-point type.
+/// Using specific constructors (float16, float32, etc.) instead of the generic
+/// floatIEEE() avoids static initialization order issues: floatIEEE() calls
+/// getUseExtended() which may return false during static init, producing
+/// LLT::scalar() instead of the intended float type.
+static void emitFloatIEEECxxConstructorCall(raw_ostream &OS,
+ unsigned SizeInBits) {
+ switch (SizeInBits) {
+ case 16:
+ OS << "LLT::float16()";
+ break;
+ case 32:
+ OS << "LLT::float32()";
+ break;
+ case 64:
+ OS << "LLT::float64()";
+ break;
+ case 128:
+ OS << "LLT::float128()";
+ break;
+ default:
+ OS << "LLT::floatIEEE(" << SizeInBits << ")";
----------------
lialan wrote:
is this conflicting the function comment which says:
```
Using specific constructors (float16, float32, etc.) instead of the generic ... floatIEEE()
```
https://github.com/llvm/llvm-project/pull/191574
More information about the llvm-commits
mailing list