@@ -671,10 +671,8 @@ static const ESIMDIntrinDesc &getIntrinDesc(StringRef SrcSpelling) {
671671 const auto &Table = getIntrinTable ();
672672 auto It = Table.find (SrcSpelling.str ());
673673
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);
678676 return It->second ;
679677}
680678
@@ -926,7 +924,7 @@ struct UpdateUint64MetaDataToMaxValue {
926924 : M(M), Key(Key), NewVal(NewVal) {
927925 // Pre-select nodes for update to do less work in the '()' operator.
928926 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" );
930928 for (auto Node : GenXKernelMD->operands ()) {
931929 if (Node->getNumOperands () <= (unsigned )Key) {
932930 continue ;
@@ -969,9 +967,8 @@ struct UpdateUint64MetaDataToMaxValue {
969967static void translateSLMInit (CallInst &CI) {
970968 auto F = CI.getFunction ();
971969 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" );
975972
976973 uint64_t NewVal = cast<llvm::ConstantInt>(ArgV)->getZExtValue ();
977974 assert (NewVal != 0 && " zero slm bytes being requested" );
@@ -985,10 +982,9 @@ static void translateSLMInit(CallInst &CI) {
985982static void translateNbarrierInit (CallInst &CI) {
986983 auto F = CI.getFunction ();
987984 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" );
992988
993989 auto NewVal = cast<llvm::ConstantInt>(ArgV)->getZExtValue ();
994990 assert (NewVal != 0 && " zero named barrier count being requested" );
@@ -1000,20 +996,18 @@ static void translateNbarrierInit(CallInst &CI) {
1000996static void translatePackMask (CallInst &CI) {
1001997 using Demangler = id::ManglingParser<SimpleAllocator>;
1002998 Function *F = CI.getCalledFunction ();
1003- assert (F && " function to translate is invalid" );
999+ llvm::esimd::assert_and_diag (F, " function to translate is invalid" );
10041000
10051001 StringRef MnglName = F->getName ();
10061002 Demangler Parser (MnglName.begin (), MnglName.end ());
10071003 id::Node *AST = Parser.parse ();
10081004
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+
10171011 auto *FE = static_cast <id::FunctionEncoding *>(AST);
10181012 llvm::LLVMContext &Context = CI.getContext ();
10191013 Type *TTy = nullptr ;
@@ -1042,19 +1036,17 @@ static void translatePackMask(CallInst &CI) {
10421036static void translateUnPackMask (CallInst &CI) {
10431037 using Demangler = id::ManglingParser<SimpleAllocator>;
10441038 Function *F = CI.getCalledFunction ();
1045- assert (F && " function to translate is invalid" );
1039+ llvm::esimd::assert_and_diag (F, " function to translate is invalid" );
10461040 StringRef MnglName = F->getName ();
10471041 Demangler Parser (MnglName.begin (), MnglName.end ());
10481042 id::Node *AST = Parser.parse ();
10491043
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+
10581050 auto *FE = static_cast <id::FunctionEncoding *>(AST);
10591051 llvm::LLVMContext &Context = CI.getContext ();
10601052 Type *TTy = nullptr ;
@@ -1194,8 +1186,9 @@ void translateFmuladd(CallInst *CI) {
11941186
11951187// Translates an LLVM intrinsic to a form, digestable by the BE.
11961188bool 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" );
11991192
12001193 switch (F->getIntrinsicID ()) {
12011194 case Intrinsic::assume:
@@ -1277,7 +1270,8 @@ translateSpirvGlobalUses(LoadInst *LI, StringRef SpirvGlobalName,
12771270 NewInst = generateGenXCall (EEI, " group.count" , true );
12781271 }
12791272
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" );
12811275 EEI->replaceAllUsesWith (NewInst);
12821276 InstsToErase.push_back (EEI);
12831277 }
@@ -1437,19 +1431,17 @@ static Function *createTestESIMDDeclaration(const ESIMDIntrinDesc &Desc,
14371431static void translateESIMDIntrinsicCall (CallInst &CI) {
14381432 using Demangler = id::ManglingParser<SimpleAllocator>;
14391433 Function *F = CI.getCalledFunction ();
1440- assert (F && " function to translate is invalid" );
1434+ llvm::esimd::assert_and_diag (F, " function to translate is invalid" );
14411435 StringRef MnglName = F->getName ();
14421436 Demangler Parser (MnglName.begin (), MnglName.end ());
14431437 id::Node *AST = Parser.parse ();
14441438
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+
14531445 auto *FE = static_cast <id::FunctionEncoding *>(AST);
14541446 id::StringView BaseNameV = FE->getName ()->getBaseName ();
14551447
0 commit comments