@@ -37,7 +37,8 @@ SPDX-License-Identifier: MIT
37
37
#include " AdaptorOCL/OCL/BuiltinResource.h"
38
38
#include " AdaptorOCL/OCL/LoadBuffer.h"
39
39
40
- #include < unordered_map>
40
+ #include < vector>
41
+ #include < utility>
41
42
42
43
using namespace llvm ;
43
44
using namespace IGC ;
@@ -500,7 +501,7 @@ bool PreCompiledFuncImport::runOnModule(Module& M)
500
501
// post-process the Int32 precompiled emulation function for div/rem
501
502
if (isI32DivRem () || isI32DivRemSP () || isSPDiv ())
502
503
{
503
- std::unordered_map< CallInst*, CallInst*> replaceInsts;
504
+ std::vector<std::pair< CallInst*,CallInst*> > replaceInsts;
504
505
for (auto FI = M.begin (), FE = M.end (); FI != FE; )
505
506
{
506
507
llvm::Function* func = &(*FI);
@@ -515,41 +516,41 @@ bool PreCompiledFuncImport::runOnModule(Module& M)
515
516
{
516
517
if (CallInst * CI = dyn_cast<CallInst>(I))
517
518
{
518
- Function* pFunc = nullptr ;
519
- GenISAIntrinsic::ID GISAIntr = GenISAIntrinsic::no_intrinsic;
520
- // ATTN: This can be made generic/cleaned up through an enum or something
521
- if (CI->getCalledFunction ()->getName ().equals (" GenISA_fma_rtz" ))
522
- {
523
- GISAIntr = GenISAIntrinsic::GenISA_fma_rtz;
524
- }
525
- else if (CI->getCalledFunction ()->getName ().equals (" GenISA_mul_rtz" ))
526
- {
527
- GISAIntr = GenISAIntrinsic::GenISA_mul_rtz;
528
- }
529
- else if (CI->getCalledFunction ()->getName ().equals (" GenISA_add_rtz" ))
530
- {
531
- GISAIntr = GenISAIntrinsic::GenISA_add_rtz;
532
- }
533
- else if (CI->getCalledFunction ()->getName ().equals (" GenISA_uitof_rtz" ))
534
- {
535
- GISAIntr = GenISAIntrinsic::GenISA_uitof_rtz;
536
- }
537
- if (GISAIntr != GenISAIntrinsic::no_intrinsic)
538
- {
539
- IRBuilder<> builder (CI);
540
- std::vector<Value*> args;
541
- std::vector<Type*> types;
542
-
543
- types.push_back (CI->getType ());
544
-
545
- for (unsigned int i = 0 ; i < CI->getNumArgOperands (); i++)
519
+ if (const llvm::Function *calledFunc = CI->getCalledFunction ()) {
520
+ GenISAIntrinsic::ID GISAIntr = GenISAIntrinsic::no_intrinsic;
521
+ if (calledFunc->getName ().equals (" GenISA_fma_rtz" ))
522
+ {
523
+ GISAIntr = GenISAIntrinsic::GenISA_fma_rtz;
524
+ }
525
+ else if (calledFunc->getName ().equals (" GenISA_mul_rtz" ))
526
+ {
527
+ GISAIntr = GenISAIntrinsic::GenISA_mul_rtz;
528
+ }
529
+ else if (calledFunc->getName ().equals (" GenISA_add_rtz" ))
530
+ {
531
+ GISAIntr = GenISAIntrinsic::GenISA_add_rtz;
532
+ }
533
+ else if (calledFunc->getName ().equals (" GenISA_uitof_rtz" ))
534
+ {
535
+ GISAIntr = GenISAIntrinsic::GenISA_uitof_rtz;
536
+ }
537
+ if (GISAIntr != GenISAIntrinsic::no_intrinsic)
546
538
{
547
- types.push_back (CI->getArgOperand (i)->getType ());
548
- args.push_back (CI->getArgOperand (i));
539
+ IRBuilder<> builder (CI);
540
+ std::vector<Value*> args;
541
+ std::vector<Type*> types;
542
+
543
+ types.push_back (CI->getType ());
544
+
545
+ for (unsigned i = 0 ; i < CI->getNumArgOperands (); i++)
546
+ {
547
+ types.push_back (CI->getArgOperand (i)->getType ());
548
+ args.push_back (CI->getArgOperand (i));
549
+ }
550
+ Function* pFunc = GenISAIntrinsic::getDeclaration (&M, GISAIntr, types);
551
+ CallInst* pCall = builder.CreateCall (pFunc, args);
552
+ replaceInsts.emplace_back (CI, pCall);
549
553
}
550
- pFunc = GenISAIntrinsic::getDeclaration (&M, GISAIntr, types);
551
- CallInst* pCall = builder.CreateCall (pFunc, args);
552
- replaceInsts.insert (std::make_pair (CI, pCall));
553
554
}
554
555
}
555
556
}
0 commit comments