[llvm] 3aa6ec6 - [ValueTypes] Add types for nxv16bf16 and nxv32bf16.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 23:06:27 PDT 2022


Author: Craig Topper
Date: 2022-06-15T23:00:53-07:00
New Revision: 3aa6ec619fb3982b9684b92f055763134f8ac3d7

URL: https://github.com/llvm/llvm-project/commit/3aa6ec619fb3982b9684b92f055763134f8ac3d7
DIFF: https://github.com/llvm/llvm-project/commit/3aa6ec619fb3982b9684b92f055763134f8ac3d7.diff

LOG: [ValueTypes] Add types for nxv16bf16 and nxv32bf16.

This is needed by our downstream and makes bf16 and f16 have the
same set of scalable vector types.

Reviewed By: rui.zhang

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

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/ValueTypes.td
    llvm/include/llvm/Support/MachineValueType.h
    llvm/lib/CodeGen/ValueTypes.cpp
    llvm/utils/TableGen/CodeGenTarget.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/ValueTypes.td b/llvm/include/llvm/CodeGen/ValueTypes.td
index f73c24f446023..2194800b7ba90 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.td
+++ b/llvm/include/llvm/CodeGen/ValueTypes.td
@@ -203,26 +203,28 @@ def nxv1bf16 : ValueType<16,  162>;  // n x  1 x bf16 vector value
 def nxv2bf16 : ValueType<32,  163>;  // n x  2 x bf16 vector value
 def nxv4bf16 : ValueType<64,  164>;  // n x  4 x bf16 vector value
 def nxv8bf16 : ValueType<128, 165>;  // n x  8 x bf16 vector value
-
-def nxv1f32  : ValueType<32,  166>;  // n x  1 x  f32 vector value
-def nxv2f32  : ValueType<64,  167>;  // n x  2 x  f32 vector value
-def nxv4f32  : ValueType<128, 168>;  // n x  4 x  f32 vector value
-def nxv8f32  : ValueType<256, 169>;  // n x  8 x  f32 vector value
-def nxv16f32 : ValueType<512, 170>;  // n x 16 x  f32 vector value
-
-def nxv1f64  : ValueType<64,  171>;  // n x  1 x  f64 vector value
-def nxv2f64  : ValueType<128, 172>;  // n x  2 x  f64 vector value
-def nxv4f64  : ValueType<256, 173>;  // n x  4 x  f64 vector value
-def nxv8f64  : ValueType<512, 174>;  // n x  8 x  f64 vector value
-
-def x86mmx    : ValueType<64,   175>;  // X86 MMX value
-def FlagVT    : ValueType<0,    176>;  // Pre-RA sched glue
-def isVoid    : ValueType<0,    177>;  // Produces no value
-def untyped   : ValueType<8,    178>;  // Produces an untyped value
-def funcref   : ValueType<0,    179>;  // WebAssembly's funcref type
-def externref : ValueType<0,    180>;  // WebAssembly's externref type
-def x86amx    : ValueType<8192, 181>;  // X86 AMX value
-def i64x8     : ValueType<512,  182>;  // 8 Consecutive GPRs (AArch64)
+def nxv16bf16 : ValueType<256, 166>;  // n x 16 x bf16 vector value
+def nxv32bf16 : ValueType<512, 167>;  // n x 32 x bf16 vector value
+
+def nxv1f32  : ValueType<32,  168>;  // n x  1 x  f32 vector value
+def nxv2f32  : ValueType<64,  169>;  // n x  2 x  f32 vector value
+def nxv4f32  : ValueType<128, 170>;  // n x  4 x  f32 vector value
+def nxv8f32  : ValueType<256, 171>;  // n x  8 x  f32 vector value
+def nxv16f32 : ValueType<512, 172>;  // n x 16 x  f32 vector value
+
+def nxv1f64  : ValueType<64,  173>;  // n x  1 x  f64 vector value
+def nxv2f64  : ValueType<128, 174>;  // n x  2 x  f64 vector value
+def nxv4f64  : ValueType<256, 175>;  // n x  4 x  f64 vector value
+def nxv8f64  : ValueType<512, 176>;  // n x  8 x  f64 vector value
+
+def x86mmx    : ValueType<64,   177>;  // X86 MMX value
+def FlagVT    : ValueType<0,    178>;  // Pre-RA sched glue
+def isVoid    : ValueType<0,    179>;  // Produces no value
+def untyped   : ValueType<8,    180>;  // Produces an untyped value
+def funcref   : ValueType<0,    181>;  // WebAssembly's funcref type
+def externref : ValueType<0,    182>;  // WebAssembly's externref type
+def x86amx    : ValueType<8192, 183>;  // X86 AMX value
+def i64x8     : ValueType<512,  184>;  // 8 Consecutive GPRs (AArch64)
 
 def token      : ValueType<0, 248>;  // TokenTy
 def MetadataVT : ValueType<0, 249>;  // Metadata

diff  --git a/llvm/include/llvm/Support/MachineValueType.h b/llvm/include/llvm/Support/MachineValueType.h
index 65472e6841364..5355c50bb7624 100644
--- a/llvm/include/llvm/Support/MachineValueType.h
+++ b/llvm/include/llvm/Support/MachineValueType.h
@@ -242,17 +242,19 @@ namespace llvm {
       nxv2bf16       = 163,  // n x  2 x bf16
       nxv4bf16       = 164,  // n x  4 x bf16
       nxv8bf16       = 165,  // n x  8 x bf16
+      nxv16bf16      = 166,  // n x 16 x bf16
+      nxv32bf16      = 167,  // n x 32 x bf16
 
-      nxv1f32        = 166,  // n x  1 x f32
-      nxv2f32        = 167,  // n x  2 x f32
-      nxv4f32        = 168,  // n x  4 x f32
-      nxv8f32        = 169,  // n x  8 x f32
-      nxv16f32       = 170,  // n x 16 x f32
+      nxv1f32        = 168,  // n x  1 x f32
+      nxv2f32        = 169,  // n x  2 x f32
+      nxv4f32        = 170,  // n x  4 x f32
+      nxv8f32        = 171,  // n x  8 x f32
+      nxv16f32       = 172,  // n x 16 x f32
 
-      nxv1f64        = 171,  // n x  1 x f64
-      nxv2f64        = 172,  // n x  2 x f64
-      nxv4f64        = 173,  // n x  4 x f64
-      nxv8f64        = 174,  // n x  8 x f64
+      nxv1f64        = 173,  // n x  1 x f64
+      nxv2f64        = 174,  // n x  2 x f64
+      nxv4f64        = 175,  // n x  4 x f64
+      nxv8f64        = 176,  // n x  8 x f64
 
       FIRST_FP_SCALABLE_VECTOR_VALUETYPE = nxv1f16,
       LAST_FP_SCALABLE_VECTOR_VALUETYPE = nxv8f64,
@@ -263,20 +265,20 @@ namespace llvm {
       FIRST_VECTOR_VALUETYPE = v1i1,
       LAST_VECTOR_VALUETYPE  = nxv8f64,
 
-      x86mmx         = 175,    // This is an X86 MMX value
+      x86mmx         = 177,    // This is an X86 MMX value
 
-      Glue           = 176,    // This glues nodes together during pre-RA sched
+      Glue           = 178,    // This glues nodes together during pre-RA sched
 
-      isVoid         = 177,    // This has no value
+      isVoid         = 179,    // This has no value
 
-      Untyped        = 178,    // This value takes a register, but has
+      Untyped        = 180,    // This value takes a register, but has
                                // unspecified type.  The register class
                                // will be determined by the opcode.
 
-      funcref        = 179,    // WebAssembly's funcref type
-      externref      = 180,    // WebAssembly's externref type
-      x86amx         = 181,    // This is an X86 AMX value
-      i64x8          = 182,    // 8 Consecutive GPRs (AArch64)
+      funcref        = 181,    // WebAssembly's funcref type
+      externref      = 182,    // WebAssembly's externref type
+      x86amx         = 183,    // This is an X86 AMX value
+      i64x8          = 184,    // 8 Consecutive GPRs (AArch64)
 
       FIRST_VALUETYPE =  1,    // This is always the beginning of the list.
       LAST_VALUETYPE = i64x8,  // This always remains at the end of the list.
@@ -650,7 +652,9 @@ namespace llvm {
       case nxv1bf16:
       case nxv2bf16:
       case nxv4bf16:
-      case nxv8bf16: return bf16;
+      case nxv8bf16:
+      case nxv16bf16:
+      case nxv32bf16: return bf16;
       case v1f32:
       case v2f32:
       case v3f32:
@@ -751,7 +755,8 @@ namespace llvm {
       case nxv32i16:
       case nxv32i32:
       case nxv32i64:
-      case nxv32f16: return 32;
+      case nxv32f16:
+      case nxv32bf16: return 32;
       case v16i1:
       case v16i8:
       case v16i16:
@@ -767,6 +772,7 @@ namespace llvm {
       case nxv16i32:
       case nxv16i64:
       case nxv16f16:
+      case nxv16bf16:
       case nxv16f32: return 16;
       case v8i1:
       case v8i8:
@@ -1007,6 +1013,7 @@ namespace llvm {
       case nxv8i32:
       case nxv4i64:
       case nxv16f16:
+      case nxv16bf16:
       case nxv8f32:
       case nxv4f64: return TypeSize::Scalable(256);
       case i64x8:
@@ -1024,6 +1031,7 @@ namespace llvm {
       case nxv16i32:
       case nxv8i64:
       case nxv32f16:
+      case nxv32bf16:
       case nxv16f32:
       case nxv8f64: return TypeSize::Scalable(512);
       case v1024i1:
@@ -1405,6 +1413,8 @@ namespace llvm {
           if (NumElements == 2)  return MVT::nxv2bf16;
           if (NumElements == 4)  return MVT::nxv4bf16;
           if (NumElements == 8)  return MVT::nxv8bf16;
+          if (NumElements == 16)  return MVT::nxv16bf16;
+          if (NumElements == 32)  return MVT::nxv32bf16;
           break;
         case MVT::f32:
           if (NumElements == 1)  return MVT::nxv1f32;

diff  --git a/llvm/lib/CodeGen/ValueTypes.cpp b/llvm/lib/CodeGen/ValueTypes.cpp
index 09183c786ee2c..f577aff39ea7d 100644
--- a/llvm/lib/CodeGen/ValueTypes.cpp
+++ b/llvm/lib/CodeGen/ValueTypes.cpp
@@ -508,6 +508,10 @@ Type *EVT::getTypeForEVT(LLVMContext &Context) const {
     return ScalableVectorType::get(Type::getBFloatTy(Context), 4);
   case MVT::nxv8bf16:
     return ScalableVectorType::get(Type::getBFloatTy(Context), 8);
+  case MVT::nxv16bf16:
+    return ScalableVectorType::get(Type::getBFloatTy(Context), 16);
+  case MVT::nxv32bf16:
+    return ScalableVectorType::get(Type::getBFloatTy(Context), 32);
   case MVT::nxv1f32:
     return ScalableVectorType::get(Type::getFloatTy(Context), 1);
   case MVT::nxv2f32:

diff  --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index 6c1b021a2b443..19134f13484e0 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -229,6 +229,8 @@ StringRef llvm::getEnumName(MVT::SimpleValueType T) {
   case MVT::nxv2bf16:  return "MVT::nxv2bf16";
   case MVT::nxv4bf16:  return "MVT::nxv4bf16";
   case MVT::nxv8bf16:  return "MVT::nxv8bf16";
+  case MVT::nxv16bf16: return "MVT::nxv16bf16";
+  case MVT::nxv32bf16: return "MVT::nxv32bf16";
   case MVT::nxv1f32:   return "MVT::nxv1f32";
   case MVT::nxv2f32:   return "MVT::nxv2f32";
   case MVT::nxv4f32:   return "MVT::nxv4f32";


        


More information about the llvm-commits mailing list