@@ -40,26 +40,26 @@ class raw_ostream;
4040class LLT {
4141public:
4242 enum class FPVariant {
43- IEEE_FLOAT = 0x0 ,
44- BRAIN_FLOAT = 0x1 , // BRAIN_FLOAT
45- PPC128_FLOAT = 0x2 , // PPC128_FLOAT
46- EXTENDED_FP80 = 0x3 , // FP80
47- TENSOR_FLOAT32 = 0x4 , // TENSOR_FLOAT32
48- VARIANT_FLOAT_5 = 0x5 , // UNASSIGNED
49- VARIANT_FLOAT_6 = 0x6 , // UNASSIGNED
50- VARIANT_FLOAT_7 = 0x7 , // UNASSIGNED
43+ IEEE_FLOAT,
44+ BF16, // BF16
45+ TENSOR_FLOAT32 , // TENSOR_FLOAT32
46+ EXTENDED_FP80, // FP80
47+ PPC128_FLOAT, // PPC128_FLOAT
48+ VARIANT_FLOAT_5, // UNASSIGNED
49+ VARIANT_FLOAT_6, // UNASSIGNED
50+ VARIANT_FLOAT_7, // UNASSIGNED
5151 };
5252
53- enum class Kind : uint64_t {
54- INVALID = 0b0000 ,
55- ANY_SCALAR = 0b0001 ,
56- INTEGER = 0b0010 ,
57- FLOAT = 0b0011 ,
58- POINTER = 0b0100 ,
59- VECTOR_ANY = 0b0101 ,
60- VECTOR_INTEGER = 0b0110 ,
61- VECTOR_FLOAT = 0b0111 ,
62- VECTOR_POINTER = 0b1000 ,
53+ enum class Kind : uint8_t {
54+ INVALID,
55+ ANY_SCALAR,
56+ INTEGER,
57+ FLOAT,
58+ POINTER,
59+ VECTOR_ANY,
60+ VECTOR_INTEGER,
61+ VECTOR_FLOAT,
62+ VECTOR_POINTER,
6363 };
6464
6565 constexpr static Kind toVector (Kind Ty) {
@@ -136,15 +136,9 @@ class LLT {
136136 ScalarTy.isFloat () ? ScalarTy.getFPVariant ()
137137 : static_cast <FPVariant>(0 )};
138138 }
139- // Get a 8-bit brain float value.
140- static constexpr LLT bfloat8 () {
141- return floatingPoint (8 , FPVariant::BRAIN_FLOAT);
142- }
143139
144- // Get a 16-bit brain float value.
145- static constexpr LLT bfloat16 () {
146- return floatingPoint (16 , FPVariant::BRAIN_FLOAT);
147- }
140+ // Get a bfloat16 value.
141+ static constexpr LLT bfloat16 () { return floatingPoint (16 , FPVariant::BF16); }
148142
149143 // / Get a 16-bit IEEE half value.
150144 static constexpr LLT float16 () {
@@ -231,7 +225,7 @@ class LLT {
231225 constexpr bool isScalar (unsigned Size) const {
232226 return isScalar () && getScalarSizeInBits () == Size;
233227 }
234- constexpr bool isFloat () const { return isValid () && Info == Kind::FLOAT; }
228+ constexpr bool isFloat () const { return Info == Kind::FLOAT; }
235229 constexpr bool isFloat (unsigned Size) const {
236230 return isFloat () && getScalarSizeInBits () == Size;
237231 }
@@ -244,14 +238,12 @@ class LLT {
244238 constexpr bool isVariantFloat (unsigned Size, FPVariant Variant) const {
245239 return isVariantFloat (Variant) && getScalarSizeInBits () == Size;
246240 }
247- constexpr bool isFloatVector () const {
248- return isVector () && Info == Kind::VECTOR_FLOAT;
249- }
241+ constexpr bool isFloatVector () const { return Info == Kind::VECTOR_FLOAT; }
250242 constexpr bool isIEEEFloat (unsigned Size) const {
251243 return isVariantFloat (Size, FPVariant::IEEE_FLOAT);
252244 }
253245 constexpr bool isBFloat (unsigned Size) const {
254- return isVariantFloat (Size, FPVariant::BRAIN_FLOAT );
246+ return isVariantFloat (Size, FPVariant::BF16 );
255247 }
256248 constexpr bool isX86FP80 () const {
257249 return isVariantFloat (80 , FPVariant::EXTENDED_FP80);
@@ -262,31 +254,22 @@ class LLT {
262254 constexpr bool isToken () const {
263255 return Info == Kind::ANY_SCALAR && RawData == 0 ;
264256 }
265- constexpr bool isAnyScalar () const {
266- return isValid () && Info == Kind::ANY_SCALAR;
267- }
268- constexpr bool isVectorAny () const {
269- return isVector () && Info == Kind::VECTOR_ANY;
270- }
271- constexpr bool isInteger () const {
272- return isValid () && Info == Kind::INTEGER;
273- }
257+ constexpr bool isAnyScalar () const { return Info == Kind::ANY_SCALAR; }
258+ constexpr bool isVectorAny () const { return Info == Kind::VECTOR_ANY; }
259+ constexpr bool isInteger () const { return Info == Kind::INTEGER; }
274260 constexpr bool isInteger (unsigned Size) const {
275261 return isInteger () && getScalarSizeInBits () == Size;
276262 }
277263 constexpr bool isIntegerVector () const {
278- return isVector () && Info == Kind::VECTOR_INTEGER;
264+ return Info == Kind::VECTOR_INTEGER;
279265 }
280266 constexpr bool isVector () const {
281- return isValid () &&
282- (Info == Kind::VECTOR_ANY || Info == Kind::VECTOR_INTEGER ||
283- Info == Kind::VECTOR_FLOAT || Info == Kind::VECTOR_POINTER);
284- }
285- constexpr bool isPointer () const {
286- return isValid () && Info == Kind::POINTER;
267+ return Info == Kind::VECTOR_ANY || Info == Kind::VECTOR_INTEGER ||
268+ Info == Kind::VECTOR_FLOAT || Info == Kind::VECTOR_POINTER;
287269 }
270+ constexpr bool isPointer () const { return Info == Kind::POINTER; }
288271 constexpr bool isPointerVector () const {
289- return isVector () && Info == Kind::VECTOR_POINTER;
272+ return Info == Kind::VECTOR_POINTER;
290273 }
291274 constexpr bool isPointerOrPointerVector () const {
292275 return isPointer () || isPointerVector ();
@@ -469,13 +452,13 @@ class LLT {
469452#endif
470453
471454 constexpr bool operator ==(const LLT &RHS) const {
472- if (isAnyScalar () || RHS.isAnyScalar ()) {
455+ if (isAnyScalar () || RHS.isAnyScalar ())
473456 return isScalar () == RHS.isScalar () && RawData == RHS.RawData ;
474- }
475- if (isVector () && RHS.isVector ()) {
457+
458+ if (isVector () && RHS.isVector ())
476459 return getElementType () == RHS.getElementType () &&
477460 getElementCount () == RHS.getElementCount ();
478- }
461+
479462 return Info == RHS.Info && RawData == RHS.RawData ;
480463 }
481464
@@ -488,7 +471,7 @@ class LLT {
488471 // / LLT is packed into 64 bits as follows:
489472 // / Info : 4
490473 // / RawData : 60
491- // / with 61 bits of RawData remaining for Kind-specific data, packed in
474+ // / with 60 bits of RawData remaining for Kind-specific data, packed in
492475 // / bitfields as described below. As there isn't a simple portable way to pack
493476 // / bits into bitfields, here the different fields in the packed structure is
494477 // / described in static const *Field variables. Each of these variables
@@ -509,38 +492,52 @@ class LLT {
509492 ### (6)
510493 %%%% (7)
511494
512- (1) ScalarSize (2) PointerSize (3) PointerAddressSpace
513- (4) VectorElements (5) VectorScalable (6) FPVariant (7) Kind
495+ (1) ScalarSize: [63:32]
496+ (2) PointerSize: [63:48]
497+ (3) PointerAddressSpace: [47:24]
498+ (4) VectorElements: [23:8]
499+ (5) VectorScalable: [4:4]
500+ (6) FPVariant: [26:24]
501+ (7) Kind: [3:0]
514502
515503 */
516- typedef int BitFieldInfo[2 ];
517- // /
518- // / This is how the bitfields are packed per Kind:
504+
505+ // / This is how the LLT are packed per Kind:
519506 // / * Invalid:
520- // / gets encoded as RawData == 0, as that is an invalid encoding, since for
521- // / valid encodings, SizeInBits/SizeOfElement must be larger than 0.
507+ // / Info: [3:0] = 0
508+ // / RawData: [63:4] = 0;
509+ // /
522510 // / * Non-pointer scalar (isPointer == 0 && isVector == 0):
523- // / SizeInBits: 32 ;
524- // / FPInfoField: 3 ;
525- static const constexpr BitFieldInfo ScalarSizeFieldInfo{ 32 , 28 } ;
526- static const constexpr BitFieldInfo FPFieldInfo{ 3 , 20 };
511+ // / Info: [3:0] ;
512+ // / FPVariant: [26:24] ;
513+ // / SizeOfElement: [63:32] ;
514+ // /
527515 // / * Pointer (isPointer == 1 && isVector == 0):
528- // / SizeInBits: 16 ;
529- // / AddressSpace: 24 ;
530- static const constexpr BitFieldInfo PointerSizeFieldInfo{ 16 , 44 } ;
531- static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{ 24 , 20 };
516+ // / Info: [3:0] ;
517+ // / AddressSpace: [47:24] ;
518+ // / SizeInBits: [63:48] ;
519+ // /
532520 // / * Vector-of-non-pointer (isPointer == 0 && isVector == 1):
533- // / NumElements: 16;
534- // / SizeOfElement: 32 ;
535- // / FPInfoField: 3 ;
536- // / Scalable: 1 ;
537- static const constexpr BitFieldInfo VectorElementsFieldInfo{ 16 , 4 } ;
538- static const constexpr BitFieldInfo VectorScalableFieldInfo{ 1 , 0 };
521+ // / Info: [3:0]
522+ // / Scalable: [4:4] ;
523+ // / VectorElements: [23:8] ;
524+ // / FPVariant: [26:24] ;
525+ // / SizeOfElement: [63:32] ;
526+ // /
539527 // / * Vector-of-pointer (isPointer == 1 && isVector == 1):
540- // / NumElements: 16;
541- // / SizeOfElement: 16;
542- // / AddressSpace: 24;
543- // / Scalable: 1;
528+ // / Scalable: [4:4];
529+ // / VectorElements: [23:8];
530+ // / AddressSpace: [47:24];
531+ // / SizeInBits: [63:48];
532+
533+ // / BitFieldInfo: {Size, Offset}
534+ typedef int BitFieldInfo[2 ];
535+ static const constexpr BitFieldInfo VectorScalableFieldInfo{1 , 0 };
536+ static const constexpr BitFieldInfo VectorElementsFieldInfo{16 , 4 };
537+ static const constexpr BitFieldInfo FPFieldInfo{3 , 20 };
538+ static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{24 , 20 };
539+ static const constexpr BitFieldInfo ScalarSizeFieldInfo{32 , 28 };
540+ static const constexpr BitFieldInfo PointerSizeFieldInfo{16 , 44 };
544541
545542 Kind Info : 4 ;
546543 uint64_t RawData : 60 ;
0 commit comments