|
1 | 1 | /*========================== begin_copyright_notice ============================ |
2 | 2 |
|
3 | | -Copyright (C) 2022-2024 Intel Corporation |
| 3 | +Copyright (C) 2022-2025 Intel Corporation |
4 | 4 |
|
5 | 5 | SPDX-License-Identifier: MIT |
6 | 6 |
|
@@ -360,7 +360,7 @@ vc::OrigArgInfo::OrigArgInfo(Type *TyIn, ArgKind KindIn, int NewIdxIn) |
360 | 360 | : TransformedOrigType{TyIn}, Kind{KindIn}, NewIdx{NewIdxIn} { |
361 | 361 | IGC_ASSERT_MESSAGE(TyIn, "Bad type provided"); |
362 | 362 | IGC_ASSERT_MESSAGE(NewIdxIn == OmittedIdx || NewIdxIn >= 0, |
363 | | - "Undexpected new index"); |
| 363 | + "Unexpected new index"); |
364 | 364 | } |
365 | 365 |
|
366 | 366 | int vc::OrigArgInfo::getNewIdx() const { |
@@ -573,10 +573,21 @@ getTransformedFuncCallArgs(CallInst &OrigCall, |
573 | 573 | default: { |
574 | 574 | IGC_ASSERT_MESSAGE(Kind == ArgKind::CopyIn || Kind == ArgKind::CopyInOut, |
575 | 575 | "unexpected arg kind"); |
576 | | - LoadInst *Load = |
577 | | - new LoadInst(OrigArgData.getTransformedOrigType(), OrigArg.get(), |
578 | | - OrigArg.get()->getName() + ".val", |
579 | | - /* isVolatile */ false, &OrigCall); |
| 576 | + |
| 577 | + IRBuilder<> Builder(&OrigCall); |
| 578 | + |
| 579 | + auto *Arg = OrigArg.get(); |
| 580 | + Value *Load = nullptr; |
| 581 | + if (auto *G = dyn_cast<GlobalVariable>(Arg); |
| 582 | + G && G->hasAttribute("genx_volatile")) { |
| 583 | + auto *Fn = GenXIntrinsic::getGenXDeclaration( |
| 584 | + G->getParent(), GenXIntrinsic::genx_vload, |
| 585 | + {OrigArgData.getTransformedOrigType(), G->getType()}); |
| 586 | + Load = Builder.CreateCall(Fn, G, Arg->getName() + ".val"); |
| 587 | + } else { |
| 588 | + Load = Builder.CreateLoad(OrigArgData.getTransformedOrigType(), Arg, |
| 589 | + Arg->getName() + ".val"); |
| 590 | + } |
580 | 591 | NewCallOps.push_back(Load); |
581 | 592 | break; |
582 | 593 | } |
@@ -645,15 +656,26 @@ static void handleRetValuePortion(int RetIdx, RetToArgLink ArgInfo, |
645 | 656 | IGC_ASSERT_MESSAGE( |
646 | 657 | Kind == GlobalArgKind::ByValueInOut, |
647 | 658 | "only passed by value localized global should be copied-out"); |
648 | | - Builder.CreateStore( |
649 | | - OutVal, NewFuncInfo.getGlobalArgsInfo().getGlobalForArgNo(NewIdx)); |
| 659 | + auto *G = NewFuncInfo.getGlobalArgsInfo().getGlobalForArgNo(NewIdx); |
| 660 | + IGC_ASSERT_MESSAGE(!G->hasAttribute("genx_volatile"), |
| 661 | + "genx_volatile is not expected"); |
| 662 | + Builder.CreateStore(OutVal, G); |
650 | 663 | } else { |
651 | 664 | // Use orig index: working with orig call's argument |
652 | 665 | int OrigArgIdx = ArgInfo.getOrigIdx(); |
653 | 666 | auto Kind = NewFuncInfo.getOrigArgInfo()[OrigArgIdx].getKind(); |
654 | 667 | IGC_ASSERT_MESSAGE(Kind == ArgKind::CopyInOut || Kind == ArgKind::CopyOut, |
655 | 668 | "only copy (in-)out args are expected"); |
656 | | - Builder.CreateStore(OutVal, OrigCall.getArgOperand(OrigArgIdx)); |
| 669 | + auto *Arg = OrigCall.getArgOperand(OrigArgIdx); |
| 670 | + if (auto *G = dyn_cast<GlobalVariable>(Arg); |
| 671 | + G && G->hasAttribute("genx_volatile")) { |
| 672 | + auto *Fn = GenXIntrinsic::getGenXDeclaration( |
| 673 | + G->getParent(), GenXIntrinsic::genx_vstore, |
| 674 | + {OutVal->getType(), G->getType()}); |
| 675 | + Builder.CreateCall(Fn, {OutVal, G}); |
| 676 | + } else { |
| 677 | + Builder.CreateStore(OutVal, Arg); |
| 678 | + } |
657 | 679 | } |
658 | 680 | } |
659 | 681 |
|
@@ -782,7 +804,7 @@ static Value *passGlobalAsCallArg(GlobalArgInfo GAI, CallInst &OrigCall) { |
782 | 804 | // No additional work when addrspaces match |
783 | 805 | if (GVTy->getAddressSpace() == vc::AddrSpace::Private) |
784 | 806 | return GAI.GV; |
785 | | - // Need to add a temprorary cast inst to match types. |
| 807 | + // Need to add a temporary cast inst to match types. |
786 | 808 | // When this switch to the caller, it'll remove this cast. |
787 | 809 | return new AddrSpaceCastInst{ |
788 | 810 | GAI.GV, vc::changeAddrSpace(GVTy, vc::AddrSpace::Private), |
@@ -961,9 +983,9 @@ std::vector<Value *> vc::FuncBodyTransfer::handleTransformedFuncArgs() { |
961 | 983 | if (Replacement->getType() == OrigArg.getType()) |
962 | 984 | return Replacement; |
963 | 985 | IGC_ASSERT_MESSAGE(isa<PointerType>(Replacement->getType()), |
964 | | - "only pointers can posibly mismatch"); |
| 986 | + "only pointers can possibly mismatch"); |
965 | 987 | IGC_ASSERT_MESSAGE(isa<PointerType>(OrigArg.getType()), |
966 | | - "only pointers can posibly mismatch"); |
| 988 | + "only pointers can possibly mismatch"); |
967 | 989 | IGC_ASSERT_MESSAGE( |
968 | 990 | Replacement->getType()->getPointerAddressSpace() != |
969 | 991 | OrigArg.getType()->getPointerAddressSpace(), |
|
0 commit comments