================
@@ -726,15 +727,108 @@ static RValue tryEmitFPMathIntrinsic(CIRGenFunction
&cgf, const CallExpr *e,
return RValue::getIgnored();
}
+// FIXME: Remove cgf parameter when all descriptor kinds are implemented
+static mlir::Type
+decodeFixedType(CIRGenFunction &cgf,
+ ArrayRef<llvm::Intrinsic::IITDescriptor> &infos,
+ mlir::MLIRContext *context) {
+ using namespace llvm::Intrinsic;
+
+ IITDescriptor descriptor = infos.front();
+ infos = infos.slice(1);
+
+ switch (descriptor.Kind) {
+ case IITDescriptor::Void:
+ return cir::VoidType::get(context);
+ // If the intrinsic expects unsigned integers, the signedness is corrected in
+ // correctIntegerSignedness()
+ case IITDescriptor::Integer:
+ return cir::IntType::get(context, descriptor.Integer_Width,
+ /*isSigned=*/true);
+ default:
+ cgf.cgm.errorNYI("Unimplemented intrinsic type descriptor");
+ return cir::VoidType::get(context);
+ }
+}
+
+/// Helper function to correct integer signedness for intrinsic arguments and
+/// return type. IIT always returns signed integers, but the actual intrinsic
+/// may expect unsigned integers based on the AST FunctionDecl parameter types.
+static mlir::Type correctIntegerSignedness(mlir::Type iitType, QualType
astType,
+ mlir::MLIRContext *context) {
+ auto intTy = dyn_cast<cir::IntType>(iitType);
+ if (!intTy)
+ return iitType;
+
+ if (astType->isUnsignedIntegerType())
+ return cir::IntType::get(context, intTy.getWidth(), /*isSigned=*/false);
+
+ return iitType;
+}
+
+static mlir::Value getCorrectedPtr(mlir::Value argValue, mlir::Type expectedTy,
+ CIRGenBuilderTy &builder) {
+ auto ptrType = mlir::dyn_cast<cir::PointerType>(argValue.getType());
+ assert(ptrType && "expected pointer type");
----------------
Priyanshu3820 wrote:
I have already added the check and the diagnostic before calling the function.
Look at around line 1960
https://github.com/llvm/llvm-project/pull/179098
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits