From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id wKF2It8W72ZiLwAA62LTzQ:P1 (envelope-from ) for ; Sat, 21 Sep 2024 20:56:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id wKF2It8W72ZiLwAA62LTzQ (envelope-from ) for ; Sat, 21 Sep 2024 20:56:31 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=HMQ82KZ7; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b=rqssyj2z; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1726944991; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=FfSxscqyF9bJ63A2p4B7joxJerO8Jehu8119MojJfHY=; b=YpbjcT7/O9UkSGQDJcvayR3ohzezD/Prfab1rDHlkc/4j6u4uIjd1Flx0T1sH9q7lj3BfW x9R+qTv/yjSPpmlylqIblMyo9eSiPz79GqTL2luia6IW+lMSp4VWmiSpGTrakOGzK9bJla M0Y60Fbr1fTi5N3Pe9zQF2xPOgWwDFzg35s2x/YWAd3fwWPpCKtiYihLA1WnITGH8+Q1Qb ru5OwwaMkbYDF1vZw2KsjfSnWdRElkjJsbvxTTF6IxqqVVgs7wN8QcBB4ikhMqqE4Ft6nw 7gxxnCbXoX9+OMfiaIMULKrY3VgkDnwESpwmK4DHmHeE32tBo7e9+YTwM9CJsw== ARC-Seal: i=1; s=key1; d=johnnyrichard.com; t=1726944991; a=rsa-sha256; cv=none; b=MQZXgI/QlPsqHrYTTkjKXfpkGHeEJm05auM0f5lfoVkkPJduryt9JwnnrQFDO7rI0NL8HT mpX6lJttvuG/OraHZ3CN9t0Vef5E2spcF6b4exVP8ET5K25tAoqmlCa1cp39MhOpr7COij BHr3wW6hiGtBiPbnmbTmqtcPU/c24ltar5uDzS4uurYSdFwwUQX9Nlg1VQWBtUtsbT3TL3 hXCrQWCikNDpYhFMw+mcTXpL1+oPZt2wQTOxzCTLLsBdal90bP/G6KNgXlXlfAVC74sz0L BCWEdhwjEWSKP4HTLwitEwxL9dGWfMz50Ogll84DK1UD6aWJre9fa1QEbG4KHw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=HMQ82KZ7; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b=rqssyj2z; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4C2C66D514 for ; Sat, 21 Sep 2024 20:56:30 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=0z4kNq0r/yu6un1i4fSQEKXtywSeW38M8+m5W2x1KDM=; c=simple/simple; d=lists.sr.ht; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1726944990; v=1; b=HMQ82KZ7owspTHnoe2xRqlK9adfgPidhmlju6PV5f4p8s/tgR1dymY6JGIzAuc9FbIkGeJj+ ddB+8AUDeO0nU0p4dsrTOIpWy4OURpmFObNgscPWVUVKO60BHeOLqN6G245Kzao4yrmCbeEHyev 7dP5LJsxNvAkGPbJYRl3SnZza7pQz/g10Bz2JX9FlFOQbnAsQJIZDtYcXh/DsdlvGzpGF3fWhJz GeN5BxZYSRF8XGQ7/4H1xYLUxAJhkKuUN0mGoYLUGKUdqNzBurtBnPLNNGjKzPrNC3lanFPdVjJ QmfRPOrC/k2Q7PrviRUHPBWmOVNFQ+GJC+/+JpJyiP8sw== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 9094C2030B for ; Sat, 21 Sep 2024 18:56:30 +0000 (UTC) Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) by mail-a.sr.ht (Postfix) with ESMTPS id F1E9020125 for <~johnnyrichard/olang-devel@lists.sr.ht>; Sat, 21 Sep 2024 18:56:29 +0000 (UTC) Date: Sat, 21 Sep 2024 20:56:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1726944989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FfSxscqyF9bJ63A2p4B7joxJerO8Jehu8119MojJfHY=; b=rqssyj2zx4eSrZAqzPD377HySq6364oiEeJwUTaSuzsFK/qtWvh9t3JyQrH4wOw1Fdup3X +CunAnywm1/C+6xMX0fumTWsxef3vpbegoT0fmtOE2qIeh03/NIGUZIDo8ydf6qDlcG09L QAzsUmzSVk2LcS9FzThTbMxoQgIL0eSQjn5BmkX234PAGShXrXveUsQigOvIUkmiChGCFP fRF5Z4eoWLLX+CVLYg6ArNmbdTYCXj+Iu9d8puuoqdKvrwXGwVy8cOMlCe8qFtNc2iI2VW zbe8O+bPBHR16ioF2ybDY54wVvoUIAlwEygG1a8i404/DNzEecNmJgpu4om8pg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Johnny Richard To: Carlos Maniero Cc: ~johnnyrichard/olang-devel@lists.sr.ht Subject: Re: [PATCH olang 4/5] codegen: calculate the variable offset based on symbol type Message-ID: References: <20240921082437.396691-1-carlos@maniero.me> <20240921082437.396691-5-carlos@maniero.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240921082437.396691-5-carlos@maniero.me> List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.16 X-Spam-Score: -1.16 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Queue-Id: 4C2C66D514 X-TUID: wtBniNT6btpk On Sat, Sep 21, 2024 at 08:25:00AM GMT, Carlos Maniero wrote: > This is just an initial structure although it still only supporting u32. > > Signed-off-by: Carlos Maniero > --- > src/codegen_linux_x86_64.c | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) > > diff --git a/src/codegen_linux_x86_64.c b/src/codegen_linux_x86_64.c > index 1fa6c58..415c81b 100644 > --- a/src/codegen_linux_x86_64.c > +++ b/src/codegen_linux_x86_64.c > @@ -35,6 +35,9 @@ codegen_linux_x86_64_emit_start_entrypoint(codegen_x86_64_t *codegen); > static void > codegen_linux_x86_64_emit_function(codegen_x86_64_t *codegen, ast_fn_definition_t *fn); > > +static size_t > +type_to_bytes(type_t *type); > + If we calculate the size during the symbol creation we don't have to create this logic all over the places. Other backends would reuse the already preprocessed size in bytes. > void > codegen_linux_x86_64_init(codegen_x86_64_t *codegen, arena_t *arena, FILE *out) > { > @@ -366,7 +369,7 @@ codegen_linux_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) > codegen_linux_x86_64_emit_expression(codegen, var_def.value); > } > > - codegen->base_offset += 8; > + codegen->base_offset += type_to_bytes(&symbol->type); > size_t *offset = arena_alloc(codegen->arena, sizeof(size_t)); > *offset = codegen->base_offset; >