[llvm] [GlobalISel][LLT] Introduce FPInfo for LLT (Enable bfloat, ppc128float and others in GlobalISel) (PR #155107)
Serge Pavlov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 18 08:00:55 PST 2025
================
@@ -39,68 +42,156 @@ class raw_ostream;
class LLT {
public:
+ using FpSemantics = APFloat::Semantics;
+
+ enum class Kind : uint8_t {
+ INVALID,
+ ANY_SCALAR,
+ INTEGER,
+ FLOAT,
+ POINTER,
+ VECTOR_ANY,
+ VECTOR_INTEGER,
+ VECTOR_FLOAT,
+ VECTOR_POINTER,
+ };
+
+ constexpr static Kind toVector(Kind Ty) {
+ if (Ty == Kind::POINTER)
+ return Kind::VECTOR_POINTER;
+
+ if (Ty == Kind::INTEGER)
+ return Kind::VECTOR_INTEGER;
+
+ if (Ty == Kind::FLOAT)
+ return Kind::VECTOR_FLOAT;
+
+ return Kind::VECTOR_ANY;
+ }
+
+ constexpr static Kind toScalar(Kind Ty) {
+ if (Ty == Kind::VECTOR_POINTER)
+ return Kind::POINTER;
+
+ if (Ty == Kind::VECTOR_INTEGER)
+ return Kind::INTEGER;
+
+ if (Ty == Kind::VECTOR_FLOAT)
+ return Kind::FLOAT;
+
+ return Kind::ANY_SCALAR;
+ }
+
/// Get a low-level scalar or aggregate "bag of bits".
static constexpr LLT scalar(unsigned SizeInBits) {
- return LLT{/*isPointer=*/false, /*isVector=*/false, /*isScalar=*/true,
- ElementCount::getFixed(0), SizeInBits,
- /*AddressSpace=*/0};
+ return LLT{Kind::ANY_SCALAR, ElementCount::getFixed(0), SizeInBits,
+ /*AddressSpace=*/0, static_cast<FpSemantics>(0)};
----------------
spavloff wrote:
`static_cast<FpSemantics>(0)` is `S_IEEEhalf`, which looks strange. Instead of passing bogus values, could we have several constructors for various layouts?
https://github.com/llvm/llvm-project/pull/155107
More information about the llvm-commits
mailing list