@@ -3548,40 +3548,65 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
35483548 transType (AI->getSemanticType ()),
35493549 SPIRSPIRVAddrSpaceMap::rmap (
35503550 BI->getValueType (Ops[Ptr]->getId ())->getPointerStorageClass ()));
3551- } else if (OC == spv::OpCooperativeMatrixStoreKHR ||
3552- OC == spv::internal::OpJointMatrixStoreINTEL ||
3553- OC == spv::internal::OpCooperativeMatrixStoreCheckedINTEL ||
3554- OC == spv::internal::OpJointMatrixLoadINTEL ||
3555- OC == spv::OpCompositeConstruct ||
3556- OC == spv::internal::OpCooperativeMatrixApplyFunctionINTEL) {
3557- auto *Val = transValue (Ops[Ptr], BB->getParent (), BB);
3558- Val = Val->stripPointerCasts ();
3559- if (auto *GEP = dyn_cast<GetElementPtrInst>(Val))
3560- ArgTys[Ptr] = TypedPointerType::get (
3561- GEP->getSourceElementType (),
3562- SPIRSPIRVAddrSpaceMap::rmap (
3563- BI->getValueType (Ops[Ptr]->getId ())->getPointerStorageClass ()));
3564- else if (auto *AI = dyn_cast<AllocaInst>(Val))
3565- ArgTys[Ptr] = TypedPointerType::get (
3566- AI->getAllocatedType (),
3567- SPIRSPIRVAddrSpaceMap::rmap (
3568- BI->getValueType (Ops[Ptr]->getId ())->getPointerStorageClass ()));
3569- else if (isa<Argument>(Val) && !RetTy->isVoidTy ()) {
3570- // Pointer could be a function parameter. Assume that the type of the
3571- // pointer is the same as the return type.
3572- Type *Ty = nullptr ;
3573- // it return type is array type, assign its element type to Ty
3574- if (RetTy->isArrayTy ())
3575- Ty = RetTy->getArrayElementType ();
3576- else if (RetTy->isVectorTy ())
3577- Ty = cast<VectorType>(RetTy)->getElementType ();
3578- else
3579- Ty = RetTy;
3551+ }
3552+ }
35803553
3581- ArgTys[Ptr] = TypedPointerType::get (
3582- Ty,
3583- SPIRSPIRVAddrSpaceMap::rmap (
3584- BI->getValueType (Ops[Ptr]->getId ())->getPointerStorageClass ()));
3554+ for (unsigned I = 0 ; I < ArgTys.size (); I++) {
3555+ if (isa<PointerType>(ArgTys[I])) {
3556+ SPIRVType *OpTy = BI->getValueType (Ops[I]->getId ());
3557+ // `Param` must be a pointer to an 8-bit integer type scalar.
3558+ // Avoid demangling for this argument if it's a pointer to get `Pc`
3559+ // mangling.
3560+ if (OC == OpEnqueueKernel && I == 7 ) {
3561+ if (ArgTys[I]->isPointerTy ())
3562+ continue ;
3563+ }
3564+ if (OpTy->isTypeUntypedPointerKHR ()) {
3565+ auto *Val = transValue (Ops[I], BB->getParent (), BB);
3566+ Val = Val->stripPointerCasts ();
3567+ if (isUntypedAccessChainOpCode (Ops[I]->getOpCode ())) {
3568+ SPIRVType *BaseTy =
3569+ reinterpret_cast <SPIRVAccessChainBase *>(Ops[I])->getBaseType ();
3570+
3571+ Type *Ty = nullptr ;
3572+ if (BaseTy->isTypeArray ())
3573+ Ty = transType (BaseTy->getArrayElementType ());
3574+ else if (BaseTy->isTypeVector ())
3575+ Ty = transType (BaseTy->getVectorComponentType ());
3576+ else
3577+ Ty = transType (BaseTy);
3578+ ArgTys[I] = TypedPointerType::get (
3579+ Ty, SPIRSPIRVAddrSpaceMap::rmap (OpTy->getPointerStorageClass ()));
3580+ } else if (auto *GEP = dyn_cast<GetElementPtrInst>(Val)) {
3581+ ArgTys[I] = TypedPointerType::get (
3582+ GEP->getSourceElementType (),
3583+ SPIRSPIRVAddrSpaceMap::rmap (OpTy->getPointerStorageClass ()));
3584+ } else if (Ops[I]->getOpCode () == OpUntypedVariableKHR) {
3585+ SPIRVUntypedVariableKHR *UV =
3586+ static_cast <SPIRVUntypedVariableKHR *>(Ops[I]);
3587+ Type *Ty = transType (UV->getDataType ());
3588+ ArgTys[I] = TypedPointerType::get (
3589+ Ty, SPIRSPIRVAddrSpaceMap::rmap (OpTy->getPointerStorageClass ()));
3590+ } else if (auto *AI = dyn_cast<AllocaInst>(Val)) {
3591+ ArgTys[I] = TypedPointerType::get (
3592+ AI->getAllocatedType (),
3593+ SPIRSPIRVAddrSpaceMap::rmap (OpTy->getPointerStorageClass ()));
3594+ } else if (Ops[I]->getOpCode () == OpFunctionParameter &&
3595+ !RetTy->isVoidTy ()) {
3596+ // Pointer could be a function parameter. Assume that the type of
3597+ // the pointer is the same as the return type.
3598+ Type *Ty = nullptr ;
3599+ // it return type is array type, assign its element type to Ty
3600+ if (RetTy->isArrayTy ())
3601+ Ty = RetTy->getArrayElementType ();
3602+ else if (RetTy->isVectorTy ())
3603+ Ty = cast<VectorType>(RetTy)->getElementType ();
3604+ else
3605+ Ty = RetTy;
3606+
3607+ ArgTys[I] = TypedPointerType::get (
3608+ Ty, SPIRSPIRVAddrSpaceMap::rmap (OpTy->getPointerStorageClass ()));
3609+ }
35853610 }
35863611 }
35873612 }
0 commit comments