@@ -101,27 +101,23 @@ class IntrinsicFunctionImp : public llvm::Function
101101 return false ;
102102 }
103103
104- static IntrinsicFunctionImp<id>* Get (llvm::Module& module , const llvm::ArrayRef<llvm::Type*>& overloadedTypes, const llvm::ArrayRef<llvm::Type*>& overloadedPointeeTys )
104+ static IntrinsicFunctionImp<id>* Get (llvm::Module& module , const llvm::ArrayRef<llvm::Type*>& overloadedTypes)
105105 {
106- return llvm::cast<IntrinsicFunctionImp<id>>(GetDeclaration (module , overloadedTypes, overloadedPointeeTys ));
106+ return llvm::cast<IntrinsicFunctionImp<id>>(GetDeclaration (module , overloadedTypes));
107107 }
108108
109- static llvm::Function* GetDeclaration (llvm::Module& module , const llvm::ArrayRef<llvm::Type*>& overloadedTypes, const llvm::ArrayRef<llvm::Type*>& overloadedPointeeTys )
109+ static llvm::Function* GetDeclaration (llvm::Module& module , const llvm::ArrayRef<llvm::Type*>& overloadedTypes)
110110 {
111- return GetOrInsert (module , overloadedTypes, overloadedPointeeTys );
111+ return GetOrInsert (module , overloadedTypes);
112112 }
113113
114- static std::string GetName (const llvm::ArrayRef<llvm::Type*>& overloadedTypes, const llvm::ArrayRef<llvm::Type*>& overloadedPointeeTys )
114+ static std::string GetName (const llvm::ArrayRef<llvm::Type*>& overloadedTypes)
115115 {
116116 std::string result = IntrinsicDefinitionT::scFunctionRootName;
117117 for (unsigned i = 0 ; i < overloadedTypes.size (); ++i)
118118 {
119119 result += " ." + getMangledTypeStr (overloadedTypes[i]);
120120 }
121- for (unsigned i = 0 ; i < overloadedPointeeTys.size (); ++i)
122- {
123- result += " ." + getMangledTypeStr (overloadedPointeeTys[i]);
124- }
125121 return result;
126122 }
127123
@@ -143,12 +139,12 @@ class IntrinsicFunctionImp : public llvm::Function
143139
144140private:
145141
146- static llvm::Function* GetOrInsert (llvm::Module& module , const llvm::ArrayRef<llvm::Type*>& overloadedTypes, const llvm::ArrayRef<llvm::Type*>& overloadedPointeeTys )
142+ static llvm::Function* GetOrInsert (llvm::Module& module , const llvm::ArrayRef<llvm::Type*>& overloadedTypes)
147143 {
148144 llvm::LLVMContext& ctx = module .getContext ();
149- std::string funcName = GetName (overloadedTypes, overloadedPointeeTys );
145+ std::string funcName = GetName (overloadedTypes);
150146 llvm::FunctionType* pFuncType = GetType (ctx, overloadedTypes);
151- llvm::AttributeList attribs = GetAttributeList (ctx, overloadedPointeeTys );
147+ llvm::AttributeList attribs = GetAttributeList (ctx);
152148 // There can never be multiple globals with the same name of different types,
153149 // because intrinsics must be a specific type.
154150 IGCLLVM::Module& M = static_cast <IGCLLVM::Module&>(module );
@@ -205,7 +201,7 @@ class IntrinsicFunctionImp : public llvm::Function
205201 {
206202 for (uint8_t i = 0 ; i < numArguments; i++)
207203 {
208- RetrieveType (i + 1 , IntrinsicDefinitionT::scArguments [i]. m_Type );
204+ RetrieveType (i + 1 , IntrinsicDefinitionT::scArgumentTypes [i]);
209205 }
210206 }
211207 // IGC_ASSERT(overloadedTypeIndex == overloadedTypes.size());
@@ -222,60 +218,16 @@ class IntrinsicFunctionImp : public llvm::Function
222218 return llvm::FunctionType::get (resultTy, argTys, false );
223219 }
224220
225- static llvm::AttributeList GetAttributeList (llvm::LLVMContext& ctx, const llvm::ArrayRef<llvm::Type*>& overloadedPointeeTys )
221+ static llvm::AttributeList GetAttributeList (llvm::LLVMContext& ctx)
226222 {
227223 // 1. Instantiate regular attributes for the given intrinsic
228224 constexpr auto & attributeKinds = IntrinsicDefinitionT::scAttributeKinds;
229225 auto mainAttrList = llvm::AttributeList::get (
230226 ctx, llvm::AttributeList::FunctionIndex, attributeKinds);
231227 // 2. Gather the memory attribute(s) in a separate routine
232228 auto memoryAB = IntrinsicDefinitionT::scMemoryEffects.getAsAttrBuilder (ctx);
233- mainAttrList = mainAttrList.addFnAttributes (ctx, memoryAB);
234- // 3. Gather parameter attributes
235- uint8_t overloadedTypeIndex = 0 ;
236- auto RetrieveParamAttr = [&overloadedTypeIndex, &ctx, &overloadedPointeeTys, &mainAttrList](uint8_t index, const ArgumentDescription& arg)
237- {
238- if (arg.m_AttrKind == llvm::Attribute::None)
239- {
240- return ;
241- }
242- IGC_ASSERT_MESSAGE (
243- arg.m_AttrKind == llvm::Attribute::ByRef ||
244- arg.m_AttrKind == llvm::Attribute::ByVal ||
245- arg.m_AttrKind == llvm::Attribute::StructRet,
246- " Used an invalid(?) parameter attribute kind" );
247- switch (arg.m_Type .m_ID )
248- {
249- case TypeID::Pointer:
250- {
251- llvm::Type* pointeeType = nullptr ;
252- if (overloadedTypeIndex < overloadedPointeeTys.size () && arg.m_Type .IsOverloadable ())
253- {
254- pointeeType = overloadedPointeeTys[overloadedTypeIndex++];
255- }
256- else
257- {
258- pointeeType = arg.m_Type .m_Pointer .m_Type .GetType (ctx);
259- }
260- mainAttrList = mainAttrList.addParamAttribute (ctx, { index }, llvm::Attribute::get (ctx, arg.m_AttrKind , pointeeType));
261- break ;
262- }
263- default :
264- IGC_ASSERT_MESSAGE (0 , " A parameter attribute used for non-pointer function argument." );
265- break ;
266- }
267- };
268-
269- constexpr uint8_t numArguments = static_cast <uint8_t >(Argument::Count);
270- if constexpr (numArguments > 0 )
271- {
272- for (uint8_t i = 0 ; i < numArguments; i++)
273- {
274- RetrieveParamAttr (i, IntrinsicDefinitionT::scArguments[i]);
275- }
276- }
277-
278- return mainAttrList;
229+ // Return a merged collection
230+ return mainAttrList.addFnAttributes (ctx, memoryAB);
279231 }
280232};
281233
@@ -293,14 +245,14 @@ static constexpr auto GetDeclarationFuncArray()
293245 return GetDeclarationFuncArrayImp (seq);
294246}
295247
296- llvm::Function* GetDeclaration (llvm::Module* pModule, llvm::GenISAIntrinsic::ID id, llvm::ArrayRef<llvm::Type*> overloadedTys, llvm::ArrayRef<llvm::Type*> overloadedPointeeTys )
248+ llvm::Function* GetDeclaration (llvm::Module* pModule, llvm::GenISAIntrinsic::ID id, llvm::ArrayRef<llvm::Type*> overloadedTys)
297249{
298250 constexpr auto funcArray = GetDeclarationFuncArray ();
299251 llvm::Function* pResult = nullptr ;
300252 uint32_t index = static_cast <uint32_t >(id) - scBeginIntrinsicIndex;
301253 if (index < funcArray.size ())
302254 {
303- pResult = funcArray[index](*pModule, overloadedTys, overloadedPointeeTys );
255+ pResult = funcArray[index](*pModule, overloadedTys);
304256 }
305257 return pResult;
306258}
@@ -319,14 +271,14 @@ static constexpr auto GetNameFuncArray()
319271 return GetNameFuncArrayImp (seq);
320272}
321273
322- std::string GetName (llvm::GenISAIntrinsic::ID id, llvm::ArrayRef<llvm::Type*> overloadedTys, llvm::ArrayRef<llvm::Type*> overloadedPointeeTys )
274+ std::string GetName (llvm::GenISAIntrinsic::ID id, llvm::ArrayRef<llvm::Type*> overloadedTys)
323275{
324276 constexpr auto funcArray = GetNameFuncArray ();
325277 std::string result;
326278 uint32_t index = static_cast <uint32_t >(id) - scBeginIntrinsicIndex;
327279 if (index < funcArray.size ())
328280 {
329- result = funcArray[index](overloadedTys, overloadedPointeeTys );
281+ result = funcArray[index](overloadedTys);
330282 }
331283 return result;
332284}
0 commit comments