[clang] [CIR] Upstream cir.call with scalar arguments (PR #136810)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 26 09:03:05 PDT 2025
================
@@ -152,3 +303,105 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
return ret;
}
+
+void CIRGenFunction::emitCallArg(CallArgList &args, const clang::Expr *e,
+ clang::QualType argType) {
+ assert(argType->isReferenceType() == e->isGLValue() &&
+ "reference binding to unmaterialized r-value!");
+
+ if (e->isGLValue()) {
+ assert(e->getObjectKind() == OK_Ordinary);
+ args.add(emitReferenceBindingToExpr(e), argType);
+ }
+
+ bool hasAggregateEvalKind = hasAggregateEvaluationKind(argType);
+
+ if (hasAggregateEvalKind) {
+ assert(!cir::MissingFeatures::opCallAggregateArgs());
+ cgm.errorNYI(e->getSourceRange(), "aggregate function call argument");
+ }
+
+ args.add(emitAnyExprToTemp(e), argType);
+}
+
+/// Similar to emitAnyExpr(), however, the result will always be accessible
+/// even if no aggregate location is provided.
+RValue CIRGenFunction::emitAnyExprToTemp(const Expr *e) {
+ assert(!cir::MissingFeatures::opCallAggregateArgs());
+
+ if (hasAggregateEvaluationKind(e->getType()))
+ cgm.errorNYI(e->getSourceRange(), "emit aggregate value to temp");
+
+ return emitAnyExpr(e);
+}
+
+void CIRGenFunction::emitCallArgs(
+ CallArgList &args, PrototypeWrapper prototype,
+ llvm::iterator_range<clang::CallExpr::const_arg_iterator> argRange,
+ AbstractCallee callee, unsigned paramsToSkip) {
+ llvm::SmallVector<QualType, 16> argTypes;
+
+ assert(!cir::MissingFeatures::opCallCallConv());
+
+ // First, if a prototype was provided, use those argument types.
+ assert(!cir::MissingFeatures::opCallVariadic());
+ if (prototype.p) {
+ assert(!cir::MissingFeatures::opCallObjCMethod());
+
+ const auto *fpt = cast<const FunctionProtoType *>(prototype.p);
+ argTypes.assign(fpt->param_type_begin() + paramsToSkip,
+ fpt->param_type_end());
+ }
+
+ // If we still have any arguments, emit them using the type of the argument.
+ for (auto *a : llvm::drop_begin(argRange, argTypes.size()))
----------------
Lancern wrote:
Is this achievable? This loop does not copy the range elements directly, it copies a transformation (i.e. `getType()`) of them.
https://github.com/llvm/llvm-project/pull/136810
More information about the cfe-commits
mailing list