@@ -1595,7 +1595,6 @@ void OCLToSPIRVBase::visitSubgroupAVCBuiltinCall(CallInst *CI,
1595
1595
// conterpart from 'MCE' with conversion for an argument and result (if needed).
1596
1596
void OCLToSPIRVBase::visitSubgroupAVCWrapperBuiltinCall (
1597
1597
CallInst *CI, Op WrappedOC, StringRef DemangledName) {
1598
- AttributeList Attrs = CI->getCalledFunction ()->getAttributes ();
1599
1598
std::string Prefix = kOCLSubgroupsAVCIntel ::Prefix;
1600
1599
1601
1600
// Find 'to_mce' conversion function.
@@ -1612,9 +1611,6 @@ void OCLToSPIRVBase::visitSubgroupAVCWrapperBuiltinCall(
1612
1611
OCLSPIRVSubgroupAVCIntelBuiltinMap::find (ToMCEFName, &ToMCEOC);
1613
1612
assert (ToMCEOC != OpNop && " Invalid Subgroup AVC Intel built-in call" );
1614
1613
1615
- SmallVector<Type *, 2 > ParamTys;
1616
- getParameterTypes (CI, ParamTys);
1617
-
1618
1614
if (std::strcmp (TyKind, " payload" ) == 0 ) {
1619
1615
// Wrapper built-ins which take the 'payload_t' argument return it as
1620
1616
// the result: two conversion calls required.
@@ -1624,38 +1620,31 @@ void OCLToSPIRVBase::visitSubgroupAVCWrapperBuiltinCall(
1624
1620
OCLSPIRVSubgroupAVCIntelBuiltinMap::find (FromMCEFName, &FromMCEOC);
1625
1621
assert (FromMCEOC != OpNop && " Invalid Subgroup AVC Intel built-in call" );
1626
1622
1627
- mutateCallInstSPIRV (
1628
- M, CI,
1629
- [=](CallInst *, std::vector<Value *> &Args, Type *&Ret) {
1630
- Ret = MCETy;
1631
- // Create conversion function call for the last operand
1632
- Args[Args.size () - 1 ] = addCallInstSPIRV (
1633
- M, getSPIRVFuncName (ToMCEOC), MCETy, Args[Args.size () - 1 ],
1634
- nullptr , {ParamTys[Args.size () - 1 ]}, CI, " " );
1635
-
1636
- return getSPIRVFuncName (WrappedOC);
1637
- },
1638
- [=](CallInst *NewCI) -> Instruction * {
1623
+ mutateCallInst (CI, WrappedOC)
1624
+ .mapArg (CI->arg_size () - 1 ,
1625
+ [&](Value *Arg, Type *ParamTy) {
1626
+ // Create conversion function call for the last operand
1627
+ return std::pair<Value *, Type *>(
1628
+ addCallInstSPIRV (M, getSPIRVFuncName (ToMCEOC), MCETy, Arg,
1629
+ nullptr , {ParamTy}, CI, " " ),
1630
+ MCESTy);
1631
+ })
1632
+ .changeReturnType (MCETy, [=](IRBuilder<> &, CallInst *NewCI) {
1639
1633
// Create conversion function call for the return result
1640
1634
return addCallInstSPIRV (M, getSPIRVFuncName (FromMCEOC), CI->getType (),
1641
1635
NewCI, nullptr , {MCESTy}, CI, " " );
1642
- },
1643
- &Attrs);
1636
+ });
1644
1637
} else {
1645
1638
// Wrapper built-ins which take the 'result_t' argument requires only one
1646
1639
// conversion for the argument
1647
- mutateCallInstSPIRV (
1648
- M, CI,
1649
- [=](CallInst *, std::vector<Value *> &Args) {
1650
- // Create conversion function call for the last
1651
- // operand
1652
- Args[Args.size () - 1 ] = addCallInstSPIRV (
1653
- M, getSPIRVFuncName (ToMCEOC), MCETy, Args[Args.size () - 1 ],
1654
- nullptr , {ParamTys[Args.size () - 1 ]}, CI, " " );
1655
-
1656
- return getSPIRVFuncName (WrappedOC);
1657
- },
1658
- &Attrs);
1640
+ mutateCallInst (CI, WrappedOC)
1641
+ .mapArg (CI->arg_size () - 1 , [&](Value *Arg, Type *ParamTy) {
1642
+ // Create conversion function call for the last operand
1643
+ return std::pair<Value *, Type *>(
1644
+ addCallInstSPIRV (M, getSPIRVFuncName (ToMCEOC), MCETy, Arg,
1645
+ nullptr , {ParamTy}, CI, " " ),
1646
+ MCESTy);
1647
+ });
1659
1648
}
1660
1649
}
1661
1650
@@ -1677,45 +1666,44 @@ void OCLToSPIRVBase::visitSubgroupAVCBuiltinCallWithSampler(
1677
1666
if (OC == OpNop)
1678
1667
return ; // this is not a VME built-in
1679
1668
1680
- AttributeList Attrs = CI->getCalledFunction ()->getAttributes ();
1681
- mutateCallInstSPIRV (
1682
- M, CI,
1683
- [=](CallInst *, std::vector<Value *> &Args) {
1684
- SmallVector<Type *, 4 > ParamTys;
1685
- getParameterTypes (CI, ParamTys);
1686
- auto *TyIt =
1687
- std::find_if (ParamTys.begin (), ParamTys.end (), isSamplerStructTy);
1688
- assert (TyIt != ParamTys.end () &&
1689
- " Invalid Subgroup AVC Intel built-in call" );
1690
- auto SamplerIt = Args.begin () + (TyIt - ParamTys.begin ());
1691
- auto *SamplerVal = *SamplerIt;
1692
- auto *SamplerTy = *TyIt;
1693
- Args.erase (SamplerIt);
1694
- ParamTys.erase (TyIt);
1695
-
1696
- for (unsigned I = 0 , E = Args.size (); I < E; ++I) {
1697
- if (!isOCLImageStructType (ParamTys[I]))
1698
- continue ;
1699
-
1700
- auto *ImageTy =
1701
- OCLTypeToSPIRVPtr
1702
- ->getAdaptedArgumentType (CI->getCalledFunction (), I)
1703
- .second ;
1704
- if (!ImageTy)
1705
- ImageTy = ParamTys[I];
1706
- ImageTy = adaptSPIRVImageType (M, ImageTy);
1707
- auto *SampledImgTy = getSPIRVTypeByChangeBaseTypeName (
1708
- M, ImageTy, kSPIRVTypeName ::Image, kSPIRVTypeName ::VmeImageINTEL);
1709
-
1710
- Value *SampledImgArgs[] = {Args[I], SamplerVal};
1711
- Args[I] = addCallInstSPIRV (M, getSPIRVFuncName (OpVmeImageINTEL),
1712
- SampledImgTy, SampledImgArgs, nullptr ,
1713
- {ParamTys[I], SamplerTy}, CI,
1714
- kSPIRVName ::TempSampledImage);
1715
- }
1716
- return getSPIRVFuncName (OC);
1717
- },
1718
- &Attrs);
1669
+ SmallVector<Type *, 4 > ParamTys;
1670
+ getParameterTypes (CI, ParamTys);
1671
+ auto *TyIt =
1672
+ std::find_if (ParamTys.begin (), ParamTys.end (), isSamplerStructTy);
1673
+ assert (TyIt != ParamTys.end () && " Invalid Subgroup AVC Intel built-in call" );
1674
+ unsigned SamplerIndex = TyIt - ParamTys.begin ();
1675
+ Value *SamplerVal = CI->getOperand (SamplerIndex);
1676
+ Type *SamplerTy = ParamTys[SamplerIndex];
1677
+
1678
+ SmallVector<Type *, 4 > AdaptedTys;
1679
+ for (unsigned I = 0 ; I < CI->arg_size (); I++)
1680
+ AdaptedTys.push_back (
1681
+ OCLTypeToSPIRVPtr->getAdaptedArgumentType (CI->getCalledFunction (), I)
1682
+ .second );
1683
+ auto *AdaptedIter = AdaptedTys.begin ();
1684
+
1685
+ mutateCallInst (CI, OC)
1686
+ .mapArgs ([&](Value *Arg, Type *PointerTy) {
1687
+ if (!isOCLImageStructType (PointerTy))
1688
+ return std::make_pair (Arg, PointerTy);
1689
+
1690
+ auto *ImageTy = *AdaptedIter++;
1691
+ if (!ImageTy)
1692
+ ImageTy = PointerTy;
1693
+ ImageTy = adaptSPIRVImageType (M, ImageTy);
1694
+ auto *SampledImgStructTy = getSPIRVStructTypeByChangeBaseTypeName (
1695
+ M, ImageTy, kSPIRVTypeName ::Image, kSPIRVTypeName ::VmeImageINTEL);
1696
+ auto *SampledImgTy =
1697
+ PointerType::get (SampledImgStructTy, SPIRAS_Global);
1698
+
1699
+ Value *SampledImgArgs[] = {Arg, SamplerVal};
1700
+ return std::pair<Value *, Type *>(
1701
+ addCallInstSPIRV (M, getSPIRVFuncName (OpVmeImageINTEL), SampledImgTy,
1702
+ SampledImgArgs, nullptr , {PointerTy, SamplerTy},
1703
+ CI, kSPIRVName ::TempSampledImage),
1704
+ SampledImgStructTy);
1705
+ })
1706
+ .removeArg (SamplerIndex);
1719
1707
}
1720
1708
1721
1709
void OCLToSPIRVBase::visitCallSplitBarrierINTEL (CallInst *CI,
0 commit comments