Skip to content

Commit fc97e36

Browse files
[NFC][Clang][AArch64]Refactor implementation of Neon vectors MFloat8x8 and MFloat8x16
This patch removes the builtins for MFloat8x8 and Mfloat8x16 and build these types the same way the other neon vectors are build. It uses the scalar type(mfloat8).
1 parent 91aad9b commit fc97e36

File tree

14 files changed

+68
-41
lines changed

14 files changed

+68
-41
lines changed

clang/include/clang/AST/Type.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25342534
bool isFloat32Type() const;
25352535
bool isDoubleType() const;
25362536
bool isBFloat16Type() const;
2537+
bool isMFloat8Type() const;
25372538
bool isFloat128Type() const;
25382539
bool isIbm128Type() const;
25392540
bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
@@ -8542,6 +8543,10 @@ inline bool Type::isBFloat16Type() const {
85428543
return isSpecificBuiltinType(BuiltinType::BFloat16);
85438544
}
85448545

8546+
inline bool Type::isMFloat8Type() const {
8547+
return isSpecificBuiltinType(BuiltinType::MFloat8);
8548+
}
8549+
85458550
inline bool Type::isFloat128Type() const {
85468551
return isSpecificBuiltinType(BuiltinType::Float128);
85478552
}

clang/include/clang/Basic/AArch64SVEACLETypes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
201201
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
202202

203203
AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__mfp8", MFloat8, MFloat8Ty, 1, 8, 1)
204-
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1)
205-
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1)
206204

207205
#undef SVE_VECTOR_TYPE
208206
#undef SVE_VECTOR_TYPE_BFLOAT

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ namespace clang {
200200
Float16,
201201
Float32,
202202
Float64,
203-
BFloat16
203+
BFloat16,
204+
MFloat8
204205
};
205206

206207
NeonTypeFlags(unsigned F) : Flags(F) {}
@@ -222,6 +223,7 @@ namespace clang {
222223
switch (getEltType()) {
223224
case Int8:
224225
case Poly8:
226+
case MFloat8:
225227
return 8;
226228
case Int16:
227229
case Float16:

clang/include/clang/Basic/arm_neon_incl.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def OP_UNAVAILABLE : Operation {
218218
// h: half-float
219219
// d: double
220220
// b: bfloat16
221+
// m: mfloat8
221222
//
222223
// Typespec modifiers
223224
// ------------------

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3901,6 +3901,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
39013901
return "Float64";
39023902
case BuiltinType::BFloat16:
39033903
return "Bfloat16";
3904+
case BuiltinType::MFloat8:
3905+
return "Mfloat8";
39043906
default:
39053907
llvm_unreachable("Unexpected vector element base type");
39063908
}

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6594,6 +6594,7 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
65946594
switch (TypeFlags.getEltType()) {
65956595
case NeonTypeFlags::Int8:
65966596
case NeonTypeFlags::Poly8:
6597+
case NeonTypeFlags::MFloat8:
65976598
return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
65986599
case NeonTypeFlags::Int16:
65996600
case NeonTypeFlags::Poly16:

clang/lib/CodeGen/CodeGenTypes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,11 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
647647
case Type::ExtVector:
648648
case Type::Vector: {
649649
const auto *VT = cast<VectorType>(Ty);
650+
if (VT->getElementType()->isMFloat8Type()) {
651+
ResultType = llvm::FixedVectorType::get(
652+
llvm::Type::getInt8Ty(getLLVMContext()), VT->getNumElements());
653+
break;
654+
}
650655
// An ext_vector_type of Bool is really a vector of bits.
651656
llvm::Type *IRElemTy = VT->isExtVectorBoolType()
652657
? llvm::Type::getInt1Ty(getLLVMContext())

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,6 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
375375
NSRN = std::min(NSRN + 1, 8u);
376376
else {
377377
switch (BT->getKind()) {
378-
case BuiltinType::MFloat8x8:
379-
case BuiltinType::MFloat8x16:
380-
NSRN = std::min(NSRN + 1, 8u);
381-
break;
382378
case BuiltinType::SveBool:
383379
case BuiltinType::SveCount:
384380
NPRN = std::min(NPRN + 1, 4u);
@@ -620,8 +616,7 @@ bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
620616
// but with the difference that any floating-point type is allowed,
621617
// including __fp16.
622618
if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) {
623-
if (BT->isFloatingPoint() || BT->getKind() == BuiltinType::MFloat8x16 ||
624-
BT->getKind() == BuiltinType::MFloat8x8)
619+
if (BT->isFloatingPoint())
625620
return true;
626621
} else if (const VectorType *VT = Ty->getAs<VectorType>()) {
627622
if (auto Kind = VT->getVectorKind();

clang/lib/Sema/SemaARM.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
323323
switch (Flags.getEltType()) {
324324
case NeonTypeFlags::Int8:
325325
return Flags.isUnsigned() ? Context.UnsignedCharTy : Context.SignedCharTy;
326+
case NeonTypeFlags::MFloat8:
327+
return Context.MFloat8Ty;
326328
case NeonTypeFlags::Int16:
327329
return Flags.isUnsigned() ? Context.UnsignedShortTy : Context.ShortTy;
328330
case NeonTypeFlags::Int32:

clang/lib/Sema/SemaExpr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10199,6 +10199,11 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
1019910199
return HLSL().handleVectorBinOpConversion(LHS, RHS, LHSType, RHSType,
1020010200
IsCompAssign);
1020110201

10202+
// Any operation with MFloat8 type is only possible with C intrinsics
10203+
if ((LHSVecType && LHSVecType->getElementType()->isMFloat8Type()) ||
10204+
(RHSVecType && RHSVecType->getElementType()->isMFloat8Type()))
10205+
return InvalidOperands(Loc, LHS, RHS);
10206+
1020210207
// AltiVec-style "vector bool op vector bool" combinations are allowed
1020310208
// for some operators but not others.
1020410209
if (!AllowBothBool && LHSVecType &&

0 commit comments

Comments
 (0)