[Mlir-commits] [mlir] [MLIR][NVVM] Update support for conversions to f8x2 and f6x2 types (PR #137781)

Srinivasa Ravi llvmlistbot at llvm.org
Mon May 5 03:33:46 PDT 2025


================
@@ -1290,17 +1350,81 @@ llvm::Intrinsic::ID CvtFloatToTF32Op::getIntrinsicID(NVVM::FPRoundingMode rnd,
   }
 }
 
-#define CVT_TO_F6X2_ID_IMPL(type, has_relu)                                    \
+#define GET_FLOAT_TO_F6x2_ID(type, has_relu)                                   \
   has_relu ? llvm::Intrinsic::nvvm_ff_to_##type##_rn_relu_satfinite            \
            : llvm::Intrinsic::nvvm_ff_to_##type##_rn_satfinite
 
-llvm::Intrinsic::ID CvtToF6x2Op::getIntrinsicID(NVVM::CVTFP6Type type,
-                                                bool hasRelu) {
+llvm::Intrinsic::ID CvtFloatToF6x2Op::getIntrinsicID(NVVM::CVTFP6Type type,
+                                                     bool hasRelu) {
   switch (type) {
   case NVVM::CVTFP6Type::E2M3:
-    return CVT_TO_F6X2_ID_IMPL(e2m3x2, hasRelu);
+    return GET_FLOAT_TO_F6x2_ID(e2m3x2, hasRelu);
   case NVVM::CVTFP6Type::E3M2:
-    return CVT_TO_F6X2_ID_IMPL(e3m2x2, hasRelu);
+    return GET_FLOAT_TO_F6x2_ID(e3m2x2, hasRelu);
+  }
+}
+
+#define GET_FLOAT_TO_F8X2_US_ID(rnd, has_satf)                                 \
+  has_satf ? llvm::Intrinsic::nvvm_ff_to_ue8m0x2_##rnd##_satfinite             \
+           : llvm::Intrinsic::nvvm_ff_to_ue8m0x2_##rnd
+
+#define GET_FLOAT_TO_F8X2_S_ID(type, has_relu)                                 \
+  has_relu ? llvm::Intrinsic::nvvm_ff_to_##type##_rn_relu                      \
+           : llvm::Intrinsic::nvvm_ff_to_##type##_rn
+
+llvm::Intrinsic::ID CvtFloatToF8x2Op::getIntrinsicID(NVVM::CVTFP8Type type,
+                                                     NVVM::FPRoundingMode rnd,
+                                                     NVVM::SaturationMode sat,
+                                                     bool hasRelu) {
+  bool hasSatFinite = (sat == NVVM::SaturationMode::SATFINITE);
+  bool hasRoundingModeRZ = (rnd == NVVM::FPRoundingMode::RZ);
+  bool hasRoundingModeRP = (rnd == NVVM::FPRoundingMode::RP);
+
+  switch (type) {
+  case NVVM::CVTFP8Type::E4M3:
+    return GET_FLOAT_TO_F8X2_S_ID(e4m3x2, hasRelu);
----------------
Wolfram70 wrote:

The issue here is that the intrinsics for the `e4m3x2` and `e5m2x2` types do not have the `_satfinite` suffix even though the instructions themselves require it, whereas the intrinsics for the `ue8m0x2` intrinsics do (along with all others which support `satfinite`). So, I am not sure what a clean one macro solution for this would be (without pulling out the `hasSatfinite` check outside the macro).

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


More information about the Mlir-commits mailing list