@@ -303,6 +303,12 @@ void MetadataStreamerMsgPackV4::emitKernelArg(const Argument &Arg,
303303 unsigned &Offset,
304304 msgpack::ArrayDocNode Args,
305305 const MachineFunction &MF) {
306+ emitKernelArgCommon (Arg, Offset, Args, MF);
307+ }
308+
309+ void MetadataStreamerMsgPackV4::emitKernelArgCommon (
310+ const Argument &Arg, unsigned &Offset, msgpack::ArrayDocNode Args,
311+ const MachineFunction &MF, StringRef PreloadRegisters) {
306312 const auto *Func = Arg.getParent ();
307313 auto ArgNo = Arg.getArgNo ();
308314 const MDNode *Node;
@@ -361,7 +367,7 @@ void MetadataStreamerMsgPackV4::emitKernelArg(const Argument &Arg,
361367
362368 emitKernelArgImpl (DL, ArgTy, ArgAlign,
363369 getValueKind (ArgTy, TypeQual, BaseTypeName), Offset, Args,
364- " " /* PreloadRegisters */ , PointeeAlign, Name, TypeName,
370+ PreloadRegisters, PointeeAlign, Name, TypeName,
365371 BaseTypeName, ActAccQual, AccQual, TypeQual);
366372}
367373
@@ -768,9 +774,9 @@ void MetadataStreamerMsgPackV6::emitHiddenKernelArgWithPreload(
768774 msgpack::ArrayDocNode Args, const AMDGPUFunctionArgInfo &ArgInfo) {
769775
770776 SmallString<16 > PreloadStr;
771- auto PreloadDesc = ArgInfo.getHiddenArgPreloadDescriptor (HiddenArg);
777+ const auto * PreloadDesc = ArgInfo.getHiddenArgPreloadDescriptor (HiddenArg);
772778 if (PreloadDesc) {
773- const auto &Regs = (* PreloadDesc) ->Regs ;
779+ const auto &Regs = PreloadDesc->Regs ;
774780 for (unsigned I = 0 ; I < Regs.size (); ++I) {
775781 if (I > 0 )
776782 PreloadStr += " " ;
@@ -918,63 +924,12 @@ void MetadataStreamerMsgPackV6::emitKernelArg(const Argument &Arg,
918924 unsigned &Offset,
919925 msgpack::ArrayDocNode Args,
920926 const MachineFunction &MF) {
921- const auto *Func = Arg.getParent ();
922- auto ArgNo = Arg.getArgNo ();
923- const MDNode *Node;
924-
925- StringRef Name;
926- Node = Func->getMetadata (" kernel_arg_name" );
927- if (Node && ArgNo < Node->getNumOperands ())
928- Name = cast<MDString>(Node->getOperand (ArgNo))->getString ();
929- else if (Arg.hasName ())
930- Name = Arg.getName ();
931-
932- StringRef TypeName;
933- Node = Func->getMetadata (" kernel_arg_type" );
934- if (Node && ArgNo < Node->getNumOperands ())
935- TypeName = cast<MDString>(Node->getOperand (ArgNo))->getString ();
936-
937- StringRef BaseTypeName;
938- Node = Func->getMetadata (" kernel_arg_base_type" );
939- if (Node && ArgNo < Node->getNumOperands ())
940- BaseTypeName = cast<MDString>(Node->getOperand (ArgNo))->getString ();
941-
942- StringRef ActAccQual;
943- // Do we really need NoAlias check here?
944- if (Arg.getType ()->isPointerTy () && Arg.hasNoAliasAttr ()) {
945- if (Arg.onlyReadsMemory ())
946- ActAccQual = " read_only" ;
947- else if (Arg.hasAttribute (Attribute::WriteOnly))
948- ActAccQual = " write_only" ;
949- }
950-
951- StringRef AccQual;
952- Node = Func->getMetadata (" kernel_arg_access_qual" );
953- if (Node && ArgNo < Node->getNumOperands ())
954- AccQual = cast<MDString>(Node->getOperand (ArgNo))->getString ();
955-
956- StringRef TypeQual;
957- Node = Func->getMetadata (" kernel_arg_type_qual" );
958- if (Node && ArgNo < Node->getNumOperands ())
959- TypeQual = cast<MDString>(Node->getOperand (ArgNo))->getString ();
960-
961- const DataLayout &DL = Func->getDataLayout ();
962-
963- MaybeAlign PointeeAlign;
964- Type *Ty = Arg.hasByRefAttr () ? Arg.getParamByRefType () : Arg.getType ();
965-
966- // FIXME: Need to distinguish in memory alignment from pointer alignment.
967- if (auto *PtrTy = dyn_cast<PointerType>(Ty)) {
968- if (PtrTy->getAddressSpace () == AMDGPUAS::LOCAL_ADDRESS)
969- PointeeAlign = Arg.getParamAlign ().valueOrOne ();
970- }
971-
972927 const SIMachineFunctionInfo *MFI = MF.getInfo <SIMachineFunctionInfo>();
973928 SmallString<8 > PreloadRegisters;
974929 if (MFI->getNumKernargPreloadedSGPRs ()) {
975930 assert (MF.getSubtarget <GCNSubtarget>().hasKernargPreload ());
976931 const auto &PreloadDescs =
977- MFI->getArgInfo ().getPreloadDescriptorsForArgIdx (ArgNo );
932+ MFI->getArgInfo ().getPreloadDescriptorsForArgIdx (Arg. getArgNo () );
978933 for (auto &Desc : PreloadDescs) {
979934 if (!PreloadRegisters.empty ())
980935 PreloadRegisters += " " ;
@@ -987,15 +942,7 @@ void MetadataStreamerMsgPackV6::emitKernelArg(const Argument &Arg,
987942 }
988943 }
989944
990- // There's no distinction between byval aggregates and raw aggregates.
991- Type *ArgTy;
992- Align ArgAlign;
993- std::tie (ArgTy, ArgAlign) = getArgumentTypeAlign (Arg, DL);
994-
995- emitKernelArgImpl (DL, ArgTy, ArgAlign,
996- getValueKind (ArgTy, TypeQual, BaseTypeName), Offset, Args,
997- PreloadRegisters, PointeeAlign, Name, TypeName,
998- BaseTypeName, ActAccQual, AccQual, TypeQual);
945+ emitKernelArgCommon (Arg, Offset, Args, MF, PreloadRegisters);
999946}
1000947
1001948} // end namespace AMDGPU::HSAMD
0 commit comments