[llvm] [IR][Float8] Add Float8 IR intrinsics support (PR #89902)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 02:39:26 PDT 2024
https://github.com/JinjinLi868 created https://github.com/llvm/llvm-project/pull/89902
None
>From 77ddd000f8f92ef9f45566e0b686c8e78a041ba7 Mon Sep 17 00:00:00 2001
From: Jinjin Li <lijinjin.868 at bytedance.com>
Date: Wed, 24 Apr 2024 14:38:59 +0800
Subject: [PATCH] [IR][Float8] Add Float8 IR intrinsics support
---
llvm/include/llvm/IR/Intrinsics.h | 2 ++
llvm/include/llvm/IR/Intrinsics.td | 13 +++++++++++++
llvm/lib/IR/Function.cpp | 14 ++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h
index 0dfe9f029f9b1a..87923356a67685 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -114,6 +114,8 @@ namespace Intrinsic {
MMX,
Token,
Metadata,
+ Float8E4M3FN,
+ FLoat8E5M2,
Half,
BFloat,
Float,
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index bdd8465883fcff..7dce3431cb1646 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -320,6 +320,8 @@ def IIT_I2 : IIT_Int<2, 57>;
def IIT_I4 : IIT_Int<4, 58>;
def IIT_AARCH64_SVCOUNT : IIT_VT<aarch64svcount, 59>;
def IIT_V6 : IIT_Vec<6, 60>;
+def IIT_F8E4M3FN : IIT_VT<f8e4m3fn, 61>;
+def IIT_F8E5M2 : IIT_VT<f8e5m2, 62>;
}
defvar IIT_all_FixedTypes = !filter(iit, IIT_all,
@@ -553,6 +555,17 @@ def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64
def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128
+def llvm_v2f8e4m3fn_ty : LLVMType<v2f8e4m3fn>; // 2 x f8e4m3 (__f8e4m3fn)
+def llvm_v4f8e4m3fn_ty : LLVMType<v4f8e4m3fn>; // 4 x f8e4m3 (__f8e4m3fn)
+def llvm_v8f8e4m3fn_ty : LLVMType<v8f8e4m3fn>; // 8 x f8e4m3 (__f8e4m3fn)
+def llvm_v16f8e4m3fn_ty : LLVMType<v16f8e4m3fn>; // 16 x f8e4m3 (__f8e4m3fn)
+def llvm_v32f8e4m3fn_ty : LLVMType<v32f8e4m3fn>; // 32 x f8e4m3 (__f8e4m3fn)
+def llvm_v2f8e5m2_ty : LLVMType<v2f8e5m2>; // 2 x f8e5m2 (__f8e5m2)
+def llvm_v4f8e5m2_ty : LLVMType<v4f8e5m2>; // 4 x f8e5m2 (__f8e5m2)
+def llvm_v8f8e5m2_ty : LLVMType<v8f8e5m2>; // 8 x f8e5m2 (__f8e5m2)
+def llvm_v16f8e5m2_ty : LLVMType<v16f8e5m2>; // 16 x f8e5m2 (__f8e5m2)
+def llvm_v32f8e5m2_ty : LLVMType<v32f8e5m2>; // 32 x f8e5m2 (__f8e5m2)
+
def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16)
def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16)
def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16)
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 96953ac49c19b4..c88e6f7eaceed7 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1111,6 +1111,12 @@ static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
case IIT_METADATA:
OutputTable.push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
return;
+ case IIT_F8E4M3FN:
+ OutputTable.push_back(IITDescriptor::get(IITDescriptor::Float8E4M3FN, 0));
+ return;
+ case IIT_F8E5M2:
+ OutputTable.push_back(IITDescriptor::get(IITDescriptor::FLoat8E5M2, 0));
+ return;
case IIT_F16:
OutputTable.push_back(IITDescriptor::get(IITDescriptor::Half, 0));
return;
@@ -1357,6 +1363,10 @@ static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
case IITDescriptor::AMX: return Type::getX86_AMXTy(Context);
case IITDescriptor::Token: return Type::getTokenTy(Context);
case IITDescriptor::Metadata: return Type::getMetadataTy(Context);
+ case IITDescriptor::Float8E4M3FN:
+ return Type::getFloat8E4M3FNTy(Context);
+ case IITDescriptor::FLoat8E5M2:
+ return Type::getFloat8E5M2Ty(Context);
case IITDescriptor::Half: return Type::getHalfTy(Context);
case IITDescriptor::BFloat: return Type::getBFloatTy(Context);
case IITDescriptor::Float: return Type::getFloatTy(Context);
@@ -1516,6 +1526,10 @@ static bool matchIntrinsicType(
case IITDescriptor::AMX: return !Ty->isX86_AMXTy();
case IITDescriptor::Token: return !Ty->isTokenTy();
case IITDescriptor::Metadata: return !Ty->isMetadataTy();
+ case IITDescriptor::Float8E4M3FN:
+ return !Ty->isFloat8E4M3FNTy();
+ case IITDescriptor::FLoat8E5M2:
+ return !Ty->isFloat8E5M2Ty();
case IITDescriptor::Half: return !Ty->isHalfTy();
case IITDescriptor::BFloat: return !Ty->isBFloatTy();
case IITDescriptor::Float: return !Ty->isFloatTy();
More information about the llvm-commits
mailing list