diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2023-07-30 18:18:25 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2023-07-30 18:18:25 -0700 |
commit | 44662c62f444fc50fe523d987199f6a10c9a693c (patch) | |
tree | b52a68243ef283471c53d224fd3f0ae87f8c0d0f /codegen.c | |
parent | f2297c20b69d942fd1e8fdcdd8f4d142c71de662 (diff) |
add support for passing through sizeof & alignofs
Diffstat (limited to 'codegen.c')
-rw-r--r-- | codegen.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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; |