Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IR][Float8] Add Float8 IR intrinsics support #89902

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JinjinLi868
Copy link

@JinjinLi868 JinjinLi868 commented Apr 24, 2024

The series patches(for IR MVT intrinsic):
#89900
#89901
#89902

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 24, 2024

@llvm/pr-subscribers-llvm-ir

Author: None (JinjinLi868)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/89902.diff

3 Files Affected:

  • (modified) llvm/include/llvm/IR/Intrinsics.h (+2)
  • (modified) llvm/include/llvm/IR/Intrinsics.td (+13)
  • (modified) llvm/lib/IR/Function.cpp (+14)
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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants