@@ -671,10 +671,8 @@ static const ESIMDIntrinDesc &getIntrinDesc(StringRef SrcSpelling) {
671
671
const auto &Table = getIntrinTable ();
672
672
auto It = Table.find (SrcSpelling.str ());
673
673
674
- if (It == Table.end ()) {
675
- Twine Msg (" unknown ESIMD intrinsic: " + SrcSpelling);
676
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
677
- }
674
+ llvm::esimd::assert_and_diag (It != Table.end (),
675
+ " unknown ESIMD intrinsic: " , SrcSpelling);
678
676
return It->second ;
679
677
}
680
678
@@ -926,7 +924,7 @@ struct UpdateUint64MetaDataToMaxValue {
926
924
: M(M), Key(Key), NewVal(NewVal) {
927
925
// Pre-select nodes for update to do less work in the '()' operator.
928
926
llvm::NamedMDNode *GenXKernelMD = M.getNamedMetadata (GENX_KERNEL_METADATA);
929
- assert (GenXKernelMD && " invalid genx.kernels metadata" );
927
+ llvm::esimd::assert_and_diag (GenXKernelMD, " invalid genx.kernels metadata" );
930
928
for (auto Node : GenXKernelMD->operands ()) {
931
929
if (Node->getNumOperands () <= (unsigned )Key) {
932
930
continue ;
@@ -969,9 +967,8 @@ struct UpdateUint64MetaDataToMaxValue {
969
967
static void translateSLMInit (CallInst &CI) {
970
968
auto F = CI.getFunction ();
971
969
auto *ArgV = CI.getArgOperand (0 );
972
- if (!isa<ConstantInt>(ArgV))
973
- llvm::report_fatal_error (llvm::Twine (__FILE__ " " ) +
974
- " integral constant is expected for slm size" );
970
+ llvm::esimd::assert_and_diag (isa<ConstantInt>(ArgV), __FILE__,
971
+ " integral constant is expected for slm size" );
975
972
976
973
uint64_t NewVal = cast<llvm::ConstantInt>(ArgV)->getZExtValue ();
977
974
assert (NewVal != 0 && " zero slm bytes being requested" );
@@ -985,10 +982,9 @@ static void translateSLMInit(CallInst &CI) {
985
982
static void translateNbarrierInit (CallInst &CI) {
986
983
auto F = CI.getFunction ();
987
984
auto *ArgV = CI.getArgOperand (0 );
988
- if (!isa<ConstantInt>(ArgV))
989
- llvm::report_fatal_error (
990
- llvm::Twine (__FILE__ " " ) +
991
- " integral constant is expected for named barrier count" );
985
+ llvm::esimd::assert_and_diag (
986
+ isa<ConstantInt>(ArgV), __FILE__,
987
+ " integral constant is expected for named barrier count" );
992
988
993
989
auto NewVal = cast<llvm::ConstantInt>(ArgV)->getZExtValue ();
994
990
assert (NewVal != 0 && " zero named barrier count being requested" );
@@ -1000,20 +996,18 @@ static void translateNbarrierInit(CallInst &CI) {
1000
996
static void translatePackMask (CallInst &CI) {
1001
997
using Demangler = id::ManglingParser<SimpleAllocator>;
1002
998
Function *F = CI.getCalledFunction ();
1003
- assert (F && " function to translate is invalid" );
999
+ llvm::esimd::assert_and_diag (F, " function to translate is invalid" );
1004
1000
1005
1001
StringRef MnglName = F->getName ();
1006
1002
Demangler Parser (MnglName.begin (), MnglName.end ());
1007
1003
id::Node *AST = Parser.parse ();
1008
1004
1009
- if (!AST || !Parser.ForwardTemplateRefs .empty ()) {
1010
- Twine Msg (" failed to demangle ESIMD intrinsic: " + MnglName);
1011
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
1012
- }
1013
- if (AST->getKind () != id::Node::KFunctionEncoding) {
1014
- Twine Msg (" bad ESIMD intrinsic: " + MnglName);
1015
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
1016
- }
1005
+ llvm::esimd::assert_and_diag (
1006
+ AST && Parser.ForwardTemplateRefs .empty (),
1007
+ " failed to demangle ESIMD intrinsic: " , MnglName);
1008
+ llvm::esimd::assert_and_diag (AST->getKind () == id::Node::KFunctionEncoding,
1009
+ " bad ESIMD intrinsic: " , MnglName);
1010
+
1017
1011
auto *FE = static_cast <id::FunctionEncoding *>(AST);
1018
1012
llvm::LLVMContext &Context = CI.getContext ();
1019
1013
Type *TTy = nullptr ;
@@ -1042,19 +1036,17 @@ static void translatePackMask(CallInst &CI) {
1042
1036
static void translateUnPackMask (CallInst &CI) {
1043
1037
using Demangler = id::ManglingParser<SimpleAllocator>;
1044
1038
Function *F = CI.getCalledFunction ();
1045
- assert (F && " function to translate is invalid" );
1039
+ llvm::esimd::assert_and_diag (F, " function to translate is invalid" );
1046
1040
StringRef MnglName = F->getName ();
1047
1041
Demangler Parser (MnglName.begin (), MnglName.end ());
1048
1042
id::Node *AST = Parser.parse ();
1049
1043
1050
- if (!AST || !Parser.ForwardTemplateRefs .empty ()) {
1051
- Twine Msg (" failed to demangle ESIMD intrinsic: " + MnglName);
1052
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
1053
- }
1054
- if (AST->getKind () != id::Node::KFunctionEncoding) {
1055
- Twine Msg (" bad ESIMD intrinsic: " + MnglName);
1056
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
1057
- }
1044
+ llvm::esimd::assert_and_diag (
1045
+ AST && Parser.ForwardTemplateRefs .empty (),
1046
+ " failed to demangle ESIMD intrinsic: " , MnglName);
1047
+ llvm::esimd::assert_and_diag (AST->getKind () == id::Node::KFunctionEncoding,
1048
+ " bad ESIMD intrinsic: " , MnglName);
1049
+
1058
1050
auto *FE = static_cast <id::FunctionEncoding *>(AST);
1059
1051
llvm::LLVMContext &Context = CI.getContext ();
1060
1052
Type *TTy = nullptr ;
@@ -1194,8 +1186,9 @@ void translateFmuladd(CallInst *CI) {
1194
1186
1195
1187
// Translates an LLVM intrinsic to a form, digestable by the BE.
1196
1188
bool translateLLVMIntrinsic (CallInst *CI) {
1197
- Function *F = CI->getCalledFunction () ? CI->getCalledFunction () : nullptr ;
1198
- assert (F && F->isIntrinsic ());
1189
+ Function *F = CI->getCalledFunction ();
1190
+ llvm::esimd::assert_and_diag (F && F->isIntrinsic (),
1191
+ " malformed llvm intrinsic call" );
1199
1192
1200
1193
switch (F->getIntrinsicID ()) {
1201
1194
case Intrinsic::assume:
@@ -1277,7 +1270,8 @@ translateSpirvGlobalUses(LoadInst *LI, StringRef SpirvGlobalName,
1277
1270
NewInst = generateGenXCall (EEI, " group.count" , true );
1278
1271
}
1279
1272
1280
- assert (NewInst && " Load from global SPIRV builtin was not translated" );
1273
+ llvm::esimd::assert_and_diag (
1274
+ NewInst, " Load from global SPIRV builtin was not translated" );
1281
1275
EEI->replaceAllUsesWith (NewInst);
1282
1276
InstsToErase.push_back (EEI);
1283
1277
}
@@ -1437,19 +1431,17 @@ static Function *createTestESIMDDeclaration(const ESIMDIntrinDesc &Desc,
1437
1431
static void translateESIMDIntrinsicCall (CallInst &CI) {
1438
1432
using Demangler = id::ManglingParser<SimpleAllocator>;
1439
1433
Function *F = CI.getCalledFunction ();
1440
- assert (F && " function to translate is invalid" );
1434
+ llvm::esimd::assert_and_diag (F, " function to translate is invalid" );
1441
1435
StringRef MnglName = F->getName ();
1442
1436
Demangler Parser (MnglName.begin (), MnglName.end ());
1443
1437
id::Node *AST = Parser.parse ();
1444
1438
1445
- if (!AST || !Parser.ForwardTemplateRefs .empty ()) {
1446
- Twine Msg (" failed to demangle ESIMD intrinsic: " + MnglName);
1447
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
1448
- }
1449
- if (AST->getKind () != id::Node::KFunctionEncoding) {
1450
- Twine Msg (" bad ESIMD intrinsic: " + MnglName);
1451
- llvm::report_fatal_error (Msg, false /* no crash diag*/ );
1452
- }
1439
+ llvm::esimd::assert_and_diag (
1440
+ AST && Parser.ForwardTemplateRefs .empty (),
1441
+ " failed to demangle ESIMD intrinsic: " , MnglName);
1442
+ llvm::esimd::assert_and_diag (AST->getKind () == id::Node::KFunctionEncoding,
1443
+ " bad ESIMD intrinsic: " , MnglName);
1444
+
1453
1445
auto *FE = static_cast <id::FunctionEncoding *>(AST);
1454
1446
id::StringView BaseNameV = FE->getName ()->getBaseName ();
1455
1447
0 commit comments