From 44662c62f444fc50fe523d987199f6a10c9a693c Mon Sep 17 00:00:00 2001 From: Matthew Sotoudeh Date: Sun, 30 Jul 2023 18:18:25 -0700 Subject: add support for passing through sizeof & alignofs --- codegen.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'codegen.c') diff --git a/codegen.c b/codegen.c index 7acd2c9..b56a8b9 100644 --- a/codegen.c +++ b/codegen.c @@ -311,6 +311,14 @@ static void gen_addr(Node *node, int to_tmp) { // Generate code for a given node. static void gen_expr(Node *node, int to_tmp) { emit_line(node->tok); + if (opt_type_builtins && (node->is_sizeof || node->is_alignof)) { + decltmp(node->ty, to_tmp); + if (node->is_sizeof) printnoln("\tt%d = sizeof ( ", to_tmp); + else printnoln("\tt%d = alignof ( ", to_tmp); + print_type(node->is_sizeof); + println(" ) ;"); + return; + } switch (node->kind) { case ND_NULL_EXPR: return; -- cgit v1.2.3