[mlir] Add support for f8 data types to LLVM dialect types
authorEugene Zhulenev <ezhulenev@google.com>
Wed, 1 Feb 2023 21:48:50 +0000 (13:48 -0800)
committerEugene Zhulenev <ezhulenev@google.com>
Fri, 10 Mar 2023 02:52:36 +0000 (18:52 -0800)
This change allows using fp8 pointers when exporting to LLVM, because we anyway export them as opaque pointers, however full support of fp8 types is not yet implemented on the LLVM side.

Differential Revision: https://reviews.llvm.org/D143008

mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
mlir/test/Target/LLVMIR/llvmir.mlir

index 2e6bf86..4b3b1e1 100644 (file)
@@ -731,6 +731,8 @@ bool mlir::LLVM::isCompatibleOuterType(Type type) {
       Float64Type,
       Float80Type,
       Float128Type,
+      Float8E4M3FNType,
+      Float8E5M2Type,
       LLVMArrayType,
       LLVMFunctionType,
       LLVMLabelType,
@@ -801,6 +803,8 @@ static bool isCompatibleImpl(Type type, DenseSet<Type> &compatibleTypes) {
             Float64Type,
             Float80Type,
             Float128Type,
+            Float8E4M3FNType,
+            Float8E5M2Type,
             LLVMLabelType,
             LLVMMetadataType,
             LLVMPPCFP128Type,
index 82d05db..d19f49d 100644 (file)
@@ -944,6 +944,11 @@ llvm.func @vector_splat_nonzero_scalable() -> vector<[4]xf32> {
   llvm.return %0 : vector<[4]xf32>
 }
 
+// CHECK-LABEL: @f8_ptrs(ptr {{%.*}}, ptr {{%.*}})
+llvm.func @f8_ptrs(%arg0: !llvm.ptr<f8E5M2>, %arg1: !llvm.ptr<f8E4M3FN>) {
+  llvm.return
+}
+
 // CHECK-LABEL: @ops
 llvm.func @ops(%arg0: f32, %arg1: f32, %arg2: i32, %arg3: i32) -> !llvm.struct<(f32, i32)> {
 // CHECK-NEXT: fsub float %0, %1