aboutsummaryrefslogtreecommitdiff
path: root/include/cps/CodeGen.h
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 13:51:44 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 13:51:44 +0000
commit5eccd90b47b327917ad0e5858c79ca8fab27cd74 (patch)
tree56e5c4110560679047e8813ab221742a0ab739f6 /include/cps/CodeGen.h
parente3cc6c585a15fe4478dd2312bf5d390896729a31 (diff)
feat(codegen): pass C-struct records by value as variadic arguments
A variadic EXTERN call is now arranged by clang per call, from the fixed parameter count and the promoted argument types. C-struct records pass unchanged in variadic positions, as C11 6.5.2.2p6-7 and 7.16.1.1p2 allow; a record that is not a C struct names the offending field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps/CodeGen.h')
-rw-r--r--include/cps/CodeGen.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h
index 8f6a57b..b31cd3d 100644
--- a/include/cps/CodeGen.h
+++ b/include/cps/CodeGen.h
@@ -217,13 +217,17 @@ class CodeGen {
llvm::Value *emitOperatorCall(const FuncSig &Signature, ExprAST *Left, ExprAST *Right = nullptr);
llvm::Value *emitOperatorValues(const FuncSig &Signature, llvm::Value *Left,
const TypeInfo *LeftType, llvm::Value *Right);
- llvm::Value *emitVariadicArgument(ExprAST *Expr, const std::string &Callee, size_t Position);
+ llvm::Value *emitVariadicArgument(ExprAST *Expr, const std::string &Callee, size_t Position,
+ const TypeInfo *&Promoted);
+ // Variadic, if given, receives the promoted type of each variadic argument.
bool marshalCallArgs(const FuncSig &Signature,
const std::vector<std::unique_ptr<ExprAST>> &ArgExprs,
int Line,
- std::vector<llvm::Value*> &Out);
+ std::vector<llvm::Value*> &Out,
+ std::vector<const TypeInfo *> *Variadic = nullptr);
bool marshalCallArgs(const FuncSig &Signature, const std::vector<ExprAST*> &ArgExprs,
- int Line, std::vector<llvm::Value*> &Out);
+ int Line, std::vector<llvm::Value*> &Out,
+ std::vector<const TypeInfo *> *Variadic = nullptr);
llvm::Value *symbolAddress(const SymbolInfo &Info);
void emitAssignment(const LValueInfo &Target, ExprAST *Expr,
const SymbolInfo *Symbol = nullptr);