aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2010-12-28 19:32:40 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2010-12-28 19:32:40 +0900
commit0ed7ba3f5e79f407a206b387079c9fd68327064b (patch)
tree1e1ddb5103cf8a90b8cef2b7c28eef1606ac4a41 /tccgen.c
parent07fd82b4113c9f912383dff448e3dd8b71179b7b (diff)
downloadtinycc-0ed7ba3f5e79f407a206b387079c9fd68327064b.tar.gz
tinycc-0ed7ba3f5e79f407a206b387079c9fd68327064b.tar.bz2
Support struct arguments with stdarg.h
- add __builtin_va_arg_types to check how arguments were passed - move most code of stdarg into libtcc1.c - remove __builtin_malloc and __builtin_free - add a test case based on the bug report (http://www.mail-archive.com/tinycc-devel@nongnu.org/msg03036.html)
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/tccgen.c b/tccgen.c
index 82ec44f..3c6adbc 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -3542,12 +3542,28 @@ ST_FUNC void unary(void)
}
break;
#ifdef TCC_TARGET_X86_64
- case TOK_builtin_malloc:
- tok = TOK_malloc;
- goto tok_identifier;
- case TOK_builtin_free:
- tok = TOK_free;
- goto tok_identifier;
+ case TOK_builtin_va_arg_types:
+ {
+ /* This definition must be synced with stdarg.h */
+ enum __va_arg_type {
+ __va_gen_reg, __va_float_reg, __va_stack
+ };
+ CType type;
+ int bt;
+ next();
+ skip('(');
+ parse_type(&type);
+ skip(')');
+ bt = type.t & VT_BTYPE;
+ if (bt == VT_STRUCT || bt == VT_LDOUBLE) {
+ vpushi(__va_stack);
+ } else if (bt == VT_FLOAT || bt == VT_DOUBLE) {
+ vpushi(__va_float_reg);
+ } else {
+ vpushi(__va_gen_reg);
+ }
+ }
+ break;
#endif
case TOK_INC:
case TOK_DEC: