Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2600d17

Browse files
committedOct 22, 2024·
Address review comments
1 parent a1c3e68 commit 2600d17

File tree

7 files changed

+48
-10
lines changed

7 files changed

+48
-10
lines changed
 

‎clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ namespace clang {
220220
switch (getEltType()) {
221221
case Int8:
222222
case Poly8:
223+
return 8;
223224
case Int16:
224225
case Float16:
225226
case Poly16:

‎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/include/clang/Serialization/ASTBitCodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs {
11491149
///
11501150
/// Type IDs for non-predefined types will start at
11511151
/// NUM_PREDEF_TYPE_IDs.
1152-
const unsigned NUM_PREDEF_TYPE_IDS = 509;
1152+
const unsigned NUM_PREDEF_TYPE_IDS = 511;
11531153

11541154
// Ensure we do not overrun the predefined types we reserved
11551155
// in the enum PredefinedTypeIDs above.

‎clang/lib/AST/ASTContext.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,10 +1411,19 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
14111411
#include "clang/Basic/HLSLIntangibleTypes.def"
14121412
}
14131413

1414+
if (Target.getTriple().isThumb() || Target.getTriple().isARM()) {
1415+
#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId)
1416+
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId)
1417+
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
1418+
#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
1419+
InitBuiltinType(SingletonId, BuiltinType::Id);
1420+
#include "clang/Basic/AArch64SVEACLETypes.def"
1421+
}
1422+
14141423
if (Target.hasAArch64SVETypes() ||
14151424
(AuxTarget && AuxTarget->hasAArch64SVETypes())) {
1416-
#define SVE_TYPE(Name, Id, SingletonId) \
1417-
InitBuiltinType(SingletonId, BuiltinType::Id);
1425+
#define SVE_TYPE(Name, Id, SingletonId) \
1426+
InitBuiltinType(SingletonId, BuiltinType::Id);
14181427
#include "clang/Basic/AArch64SVEACLETypes.def"
14191428
}
14201429

‎clang/lib/Sema/Sema.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,22 @@ void Sema::Initialize() {
476476
#include "clang/Basic/OpenCLExtensionTypes.def"
477477
}
478478

479+
// Thumb is targetting ARM cpu and can use neon types
480+
if (Context.getTargetInfo().getTriple().isThumb() ||
481+
Context.getTargetInfo().getTriple().isARM()) {
482+
#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId)
483+
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId)
484+
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
485+
#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
486+
addImplicitTypedef(Name, Context.SingletonId);
487+
#include "clang/Basic/AArch64SVEACLETypes.def"
488+
}
489+
479490
if (Context.getTargetInfo().hasAArch64SVETypes() ||
480491
(Context.getAuxTargetInfo() &&
481492
Context.getAuxTargetInfo()->hasAArch64SVETypes())) {
482-
#define SVE_TYPE(Name, Id, SingletonId) \
483-
addImplicitTypedef(Name, Context.SingletonId);
493+
#define SVE_TYPE(Name, Id, SingletonId) \
494+
addImplicitTypedef(Name, Context.SingletonId);
484495
#include "clang/Basic/AArch64SVEACLETypes.def"
485496
}
486497

‎clang/test/Modules/no-external-type-id.cppm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export module b;
2323
import a;
2424
export int b();
2525

26-
// CHECK: <DECL_FUNCTION {{.*}} op8=4088
26+
// CHECK: <DECL_FUNCTION {{.*}} op8=4104
2727
// CHECK: <TYPE_FUNCTION_PROTO
2828

2929
//--- a.v1.cppm

‎clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class Type {
149149
SInt,
150150
UInt,
151151
Poly,
152-
BFloat16
152+
BFloat16,
153+
MFloat8,
153154
};
154155
TypeKind Kind;
155156
bool Immediate, Constant, Pointer;
@@ -194,10 +195,11 @@ class Type {
194195
bool isPoly() const { return Kind == Poly; }
195196
bool isSigned() const { return Kind == SInt; }
196197
bool isImmediate() const { return Immediate; }
198+
bool isMFloat8() const { return Kind == MFloat8; }
197199
bool isFloat() const { return isFloating() && ElementBitwidth == 32; }
198200
bool isDouble() const { return isFloating() && ElementBitwidth == 64; }
199201
bool isHalf() const { return isFloating() && ElementBitwidth == 16; }
200-
bool isChar() const { return ElementBitwidth == 8; }
202+
bool isChar() const { return ElementBitwidth == 8 && !isMFloat8(); }
201203
bool isShort() const { return isInteger() && ElementBitwidth == 16; }
202204
bool isInt() const { return isInteger() && ElementBitwidth == 32; }
203205
bool isLong() const { return isInteger() && ElementBitwidth == 64; }
@@ -657,6 +659,8 @@ std::string Type::str() const {
657659
S += "float";
658660
else if (isBFloat16())
659661
S += "bfloat";
662+
else if (isMFloat8())
663+
S += "mfloat";
660664
else
661665
S += "int";
662666

@@ -699,6 +703,9 @@ std::string Type::builtin_str() const {
699703
else if (isBFloat16()) {
700704
assert(ElementBitwidth == 16 && "BFloat16 can only be 16 bits");
701705
S += "y";
706+
} else if (isMFloat8()) {
707+
assert(ElementBitwidth == 8 && "MFloat8 can only be 8 bits");
708+
S += "c";
702709
} else
703710
switch (ElementBitwidth) {
704711
case 16: S += "h"; break;
@@ -779,6 +786,8 @@ Type Type::fromTypedefName(StringRef Name) {
779786
T.Kind = Poly;
780787
} else if (Name.consume_front("bfloat")) {
781788
T.Kind = BFloat16;
789+
} else if (Name.consume_front("mfp")) {
790+
T.Kind = MFloat8;
782791
} else {
783792
assert(Name.starts_with("int"));
784793
Name = Name.drop_front(3);
@@ -879,6 +888,10 @@ void Type::applyTypespec(bool &Quad) {
879888
Kind = BFloat16;
880889
ElementBitwidth = 16;
881890
break;
891+
case 'm':
892+
Kind = MFloat8;
893+
ElementBitwidth = 8;
894+
break;
882895
default:
883896
llvm_unreachable("Unhandled type code!");
884897
}
@@ -993,6 +1006,9 @@ std::string Intrinsic::getInstTypeCode(Type T, ClassKind CK) const {
9931006
if (T.isBFloat16())
9941007
return "bf16";
9951008

1009+
if (T.isMFloat8())
1010+
return "mfp8";
1011+
9961012
if (T.isPoly())
9971013
typeCode = 'p';
9981014
else if (T.isInteger())
@@ -1030,7 +1046,7 @@ std::string Intrinsic::getBuiltinTypeStr() {
10301046

10311047
Type RetT = getReturnType();
10321048
if ((LocalCK == ClassI || LocalCK == ClassW) && RetT.isScalar() &&
1033-
!RetT.isFloating() && !RetT.isBFloat16())
1049+
!RetT.isFloating() && !RetT.isBFloat16() && !RetT.isMFloat8())
10341050
RetT.makeInteger(RetT.getElementSizeInBits(), false);
10351051

10361052
// Since the return value must be one type, return a vector type of the
@@ -2587,9 +2603,9 @@ void NeonEmitter::runVectorTypes(raw_ostream &OS) {
25872603
OS << "typedef float float32_t;\n";
25882604
OS << "typedef __fp16 float16_t;\n";
25892605

2590-
OS << "#if defined(__aarch64__) || defined(__arm64ec__)\n";
25912606
OS << "typedef __MFloat8x8_t mfloat8x8_t;\n";
25922607
OS << "typedef __MFloat8x16_t mfloat8x16_t;\n";
2608+
OS << "#if defined(__aarch64__) || defined(__arm64ec__)\n";
25932609
OS << "typedef double float64_t;\n";
25942610
OS << "#endif\n\n";
25952611

0 commit comments

Comments
 (0)
Please sign in to comment.