Skip to content

Commit 90ba58a

Browse files
committed
[SYCL-PTX] add assert for type
Signed-off-by: Victor Lomuller <[email protected]>
1 parent 414d9f2 commit 90ba58a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

clang/utils/TableGen/ClangProgModelBuiltinEmitter.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -922,17 +922,23 @@ JSONBuiltinInterfaceEmitter::TypeDesc::TypeDesc(const Record *T)
922922
IsPointer(T->getValueAsBit("IsPointer")),
923923
IsConst(T->getValueAsBit("IsConst")),
924924
IsVolatile(T->getValueAsBit("IsVolatile")) {
925+
assert((!T->getValueAsBit("IsInteger") || !T->getValueAsBit("IsFloat")) &&
926+
"A type can't be both an int and a float");
925927
if (T->getValueAsBit("IsInteger")) {
926928
if (ElementSize == 1)
927929
ElementType = BOOL;
928930
else
929931
ElementType = T->getValueAsBit("IsSigned") ? INT : UINT;
932+
} else {
933+
if (T->getValueAsBit("IsFloat"))
934+
ElementType = FLOAT;
935+
else {
936+
if (!T->isSubClassOf("FundamentalType") && !T->isSubClassOf("VectorType"))
937+
ElementType = BUILTIN;
938+
else
939+
llvm_unreachable("Invalid type");
940+
}
930941
}
931-
if (T->getValueAsBit("IsFloat"))
932-
ElementType = FLOAT;
933-
if (!T->isSubClassOf("FundamentalType") && !T->isSubClassOf("VectorType"))
934-
ElementType = BUILTIN;
935-
936942
AddrSpace = StringSwitch<const char *>(T->getValueAsString("AddrSpace"))
937943
.Case("clang::LangAS::Default", "")
938944
.Case("clang::LangAS::opencl_private", " __private")

0 commit comments

Comments
 (0)