@@ -50,7 +50,7 @@ class LLVMIntrinsicCallOp;
5050class FuncOp ;
5151// FIXME: Unsure if we need a proper function type
5252
53- namespace Intrinsic {
53+ namespace CIRIntrinsic {
5454
5555// Abstraction for the arguments of the noalias intrinsics
5656static const int NoAliasScopeDeclScopeArg = 0 ;
@@ -68,6 +68,26 @@ enum IndependentIntrinsics : unsigned {
6868#undef GET_INTRINSIC_ENUM_VALUES
6969};
7070
71+ // Simple descriptor struct that holds essential intrinsic information
72+ // In order to build CIRIntrinsicCallOp
73+ struct IntrinsicDescriptor {
74+ mlir::StringAttr name; // Mangled name attribute
75+ mlir::Type resultType; // Return type for the intrinsic
76+ ID id; // Original intrinsic ID (optional)
77+
78+ // Basic constructor
79+ IntrinsicDescriptor (mlir::StringAttr name, mlir::Type resultType,
80+ ID id = not_intrinsic)
81+ : name(name), resultType(resultType), id(id) {}
82+
83+ // Default constructor for empty/invalid descriptors
84+ IntrinsicDescriptor ()
85+ : name(nullptr ), resultType(nullptr ), id(not_intrinsic) {}
86+
87+ // Check if descriptor is valid
88+ bool isValid () const { return name && resultType; }
89+ };
90+
7191// / Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
7292// / Note, this version is for intrinsics with no overloads. Use the other
7393// / version of getName if overloads are required.
@@ -92,11 +112,15 @@ std::string getName(ID Id, llvm::ArrayRef<mlir::Type> Tys, mlir::ModuleOp M,
92112std::string getNameNoUnnamedTypes (ID Id, llvm::ArrayRef<mlir::Type> Tys);
93113
94114// / Return the function type for an intrinsic.
95- mlir::Type *getType (mlir::MLIRContext& Context, ID id,
96- llvm::ArrayRef<mlir::Type> Tys = {});
115+ // mlir::Type getType(mlir::MLIRContext &Context, ID id,
116+ // llvm::ArrayRef<mlir::Type> Tys = {});
117+
118+ // Get both return type and parameter types in one call
119+ mlir::Type getType (mlir::MLIRContext &Context, ID id,
120+ llvm::ArrayRef<mlir::Type> Tys);
97121
98122// / Returns true if the intrinsic can be overloaded.
99- bool isOverloaded (ID id);
123+ bool isOverloaded (ID id); // NYI
100124
101125ID lookupIntrinsicID (llvm::StringRef Name);
102126
@@ -117,18 +141,18 @@ ID lookupIntrinsicID(llvm::StringRef Name);
117141// / using iAny, fAny, vAny, or pAny). For a declaration of an overloaded
118142// / intrinsic, Tys must provide exactly one type for each overloaded type in
119143// / the intrinsic.
120- LLVMIntrinsicCallOp getOrInsertDeclaration (mlir::ModuleOp M, ID id,
121- llvm::ArrayRef<mlir::Type> Tys = {});
144+ IntrinsicDescriptor getOrInsertDeclaration (mlir::ModuleOp M, ID id,
145+ llvm::ArrayRef<mlir::Type> Tys = {});
122146
123147// / Look up the Function declaration of the intrinsic \p id in the Module
124148// / \p M and return it if it exists. Otherwise, return nullptr. This version
125149// / supports non-overloaded intrinsics.
126- LLVMIntrinsicCallOp getDeclarationIfExists (const mlir::ModuleOp *M, ID id);
150+ IntrinsicDescriptor getDeclarationIfExists (const mlir::ModuleOp *M, ID id);
127151
128152// / This version supports overloaded intrinsics.
129- LLVMIntrinsicCallOp getDeclarationIfExists (mlir::ModuleOp M, ID id,
130- llvm::ArrayRef<mlir::Type> Tys,
131- mlir::Type FT = nullptr );
153+ IntrinsicDescriptor getDeclarationIfExists (mlir::ModuleOp M, ID id,
154+ llvm::ArrayRef<mlir::Type> Tys,
155+ mlir::Type FT = nullptr );
132156
133157// / Map a Clang builtin name to an intrinsic ID.
134158ID getIntrinsicForClangBuiltin (llvm::StringRef TargetPrefix,
@@ -182,7 +206,7 @@ bool matchIntrinsicVarArg(
182206// /
183207// / Returns false if the given ID and function type combination is not a
184208// / valid intrinsic call.
185- bool getIntrinsicSignature (Intrinsic:: ID, mlir::Type FT,
209+ bool getIntrinsicSignature (ID, mlir::Type FT,
186210 llvm::SmallVectorImpl<mlir::Type> &ArgTys);
187211
188212// / Same as previous, but accepts a Function instead of ID and FunctionType.
@@ -194,7 +218,7 @@ bool getIntrinsicSignature(FuncOp F, llvm::SmallVectorImpl<mlir::Type> &ArgTys);
194218// or of the wrong kind will be renamed by adding ".renamed" to the name.
195219std::optional<LLVMIntrinsicCallOp> remangleIntrinsicFunction (FuncOp F);
196220
197- } // namespace Intrinsic
221+ } // namespace CIRIntrinsic
198222} // namespace cir
199223
200224#endif // LLVM_CLANG_CIR_DIALECT_INTRINSICS_H
0 commit comments