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