summaryrefslogtreecommitdiff
path: root/codegen.c
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2023-07-30 18:18:25 -0700
committerMatthew Sotoudeh <matthew@masot.net>2023-07-30 18:18:25 -0700
commit44662c62f444fc50fe523d987199f6a10c9a693c (patch)
treeb52a68243ef283471c53d224fd3f0ae87f8c0d0f /codegen.c
parentf2297c20b69d942fd1e8fdcdd8f4d142c71de662 (diff)
add support for passing through sizeof & alignofs
Diffstat (limited to 'codegen.c')
-rw-r--r--codegen.c8
1 files changed, 8 insertions, 0 deletions
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;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback