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 WJhLMlpGNGYHrwAA62LTzQ:P1 (envelope-from ) for ; Fri, 03 May 2024 04:05:14 +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 WJhLMlpGNGYHrwAA62LTzQ (envelope-from ) for ; Fri, 03 May 2024 04:05:14 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b="kCgF/PW+"; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Nsjk2Hoq; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1714701914; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Ot4EaWnlzFD1eQE2MF2akr8QPAFYO3awBxZXte7ZLek=; b=48QQ1lLGjQfO2FvOT+9WF/S1IQgv/MunNV3JkGUHbZ8NcuQ5dxAQxI9ZuZ+nUcCiNspLGH SENhvivCeWK3Xf+f04upzCUv8Aey9a/r7CgrC2aMCkLgZy2+21wW8er7HIwrQa4xUzfhTv S+4O7ljtKKKrNrNei1WbiJ3fr524NkQGvgpjEXbm2B41ewsGtNL/1PdyoMCzdQ+QeVcLB+ w0+sPb7L8+S4ntkhx06v/Io5d3+bnFW/UXH1YqSvkkmarzLPP160naImOT7glTbtgI4y1G MF1kN90/VlYwuD5iGcpVgRRjH+FsJpVbrZhgwYGFxXpOIqtgs689MOsHYfJ6+A== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b="kCgF/PW+"; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Nsjk2Hoq; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1") ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1714701914; a=rsa-sha256; cv=pass; b=wHbn2aWxuHGi3eM8XkZV8CJS8RYVoTH4YMJl4eWKL25OjA2dUT/1Lm4iyjamucJc/0BMeo SyTgpFpNqs3fqTeirTK90mX/24p8+y0V6R6dBaycBbJHDQG26dv0/AAW7cPST4Oxw08pdD EaT66HUnAnCv0SHYuarr0sGvfSv8cf7lNprmAU8SmJLq1+bcuxUhgdXCelTWefi5+7nqmu Y7CpFUGy+IprvtKyYnFMz+gxxQwR6YZxf3O6tDRKnOaOuIjIwLgNVEkJBqpc2n43TywMdG OKa65P/Z8WcvNo8QmrOJCLpFBmKw03tcYPXuZpKS80NAjD7la4X7EdCjml06MQ== 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 50F9B63C78 for ; Fri, 3 May 2024 04:05:11 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=Skp5u97EBZwZIs92c1G4VeNRBITU/VHvq4pDChwafIg=; c=simple/simple; d=lists.sr.ht; h=Date:Subject:From:To:References:In-Reply-To:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1714701910; v=1; b=kCgF/PW+1/V+ejEfEpFEvZBjA7fLkBxSS6VRfyPu+6wgghMA8vtZtadQWkGVvyAGC0B5ddkw CwA2Wzf6AERPHxrq0LrUqwC+CNTpAbdXftWNM0owKAn4CPiLTmkQW3pNSAsY/ZqnfdBLxO7CQHV j7+byczqDykJFkTHrEMkT4USvJHziuRWDKsgkzYyYEZqGd8mxqBSSNFbnRZLakjqqk3X7fmSSvW K3pdJUv+PZDS2y68wD5ernuxhVWGX3qaK2mGYQ9fnBC1dfkdSIfzKbj50Kf6FU+YBXK2MsBPHjk CpxqZg0nITgsqB0tSphjO+ZCKiXSwSZK3ygrnmruJK68Q== Received: from lists.sr.ht (unknown [IPv6:2a03:6000:1813:1337::154]) by mail-a.sr.ht (Postfix) with ESMTPSA id D160E2032D for ; Fri, 3 May 2024 02:05:10 +0000 (UTC) Received: from cichlid.ash.relay.mailchannels.net (cichlid.ash.relay.mailchannels.net [23.83.222.36]) by mail-a.sr.ht (Postfix) with ESMTPS id A042E20323 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 3 May 2024 02:05:09 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id C84832C0B73 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 3 May 2024 02:05:06 +0000 (UTC) Received: from nl-srv-smtpout1.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id D5A822C199B for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 3 May 2024 02:05:05 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1714701906; a=rsa-sha256; cv=none; b=KPtwHGn2o7cq428sqJhnCCPGBi9zuZ5tov1URowXYLSTcFZg5km2HEHhAg9epL0l1qpoa+ RDo3tKvwwDDKMFdahT9Dp2zMoQ9xBG1R0pgqU/DTb1/3QlG+MRuUDCD8mBB2dSsjd9FCXr V9jJbVHnWOn0AA7fX8SQHdulFkUGIcSAv/GDloseMmnkhfitKrJdHe9YRMfb/XeeJ1jnlQ bVre4dwLyN4LH2cqc6QvU+mtPIIbwV3iuf3hC3Bd8VCYt3LWYPkEqUGIqhHxoQ8KnyZmTR aivaPoyDD0pB5huqk9BqTbVdp6Pf5hHc02uV8z+9VYnAXR4dgFKbaFRsn7LqjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1714701906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ot4EaWnlzFD1eQE2MF2akr8QPAFYO3awBxZXte7ZLek=; b=sAWmPrHEdcsmKEFxvTymH9ByfZZ+4/cqknH8qLJ7oOkr8BHb9/yoAZJ1Jz4yy+9i0bg7+m 37yDKKL/Hi7+c0QSob8/XdcWDnhPJCR1d1ndHIkcTMN+hcwEJBaoSdWBazaQu4qCdsAqW5 qrLmmDxmxvLkpukv7+nCihx4DwyQ5L4bB3xBYlivnxp5iS61jvZj++7lHygUdu3QIzv7UT SgXDKqSUuvRGnTH5SJuqaLbszhm8N7HxRFT1eGQzJX34q57Y7rvQfWaK8HqGfXwd0HTA4d 4L4qs31eaOF0L5aStEYNr+dbt/lcZZLFBkCJhwEt6A++gB6Rt7vumSMbjwGCJg== ARC-Authentication-Results: i=1; rspamd-5c97bbd7c5-btrzl; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Belong-Average: 1fce7dd43bfe206c_1714701906340_3398269673 X-MC-Loop-Signature: 1714701906340:3974778578 X-MC-Ingress-Time: 1714701906340 Received: from nl-srv-smtpout1.hostinger.io (nl-srv-smtpout1.hostinger.io [145.14.150.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.71.32 (trex/6.9.2); Fri, 03 May 2024 02:05:06 +0000 Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1714701904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ot4EaWnlzFD1eQE2MF2akr8QPAFYO3awBxZXte7ZLek=; b=Nsjk2Hoq5/lFwx1ogl9T0l5gvlJfoJeaiyECQvRKZ1WuNjiczhiLRB0VjDAsMle0ckjl0i jiREOR7RYICF+eDtbRebGmZDM/URblhFAOnBf9+DlbQo79015BurY2i1iitXbZaQScubEI DMJsMvoFU3RLDiuevHP68m+CPBTaTql/uBGpCjHW4bkssEeV4QLA3T0FAEDORhAUDt/CHb dS8X8MK1KhYxeE4h54gFx7seePvjn2QWx165PbVmKamIQ3L/uqYMnF97xFb7xurdZMYNSh nf5c8vNAnzSVDG9ltvpKew4x6wYa1s7pTuVZb+CHAocicO4gtNug2IVidHlOnw== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 02 May 2024 23:04:58 -0300 Message-Id: Subject: Re: [PATCH olang v1 2/2] codegen: x86_64: implement binary operations From: "Carlos Maniero" To: "Johnny Richard" , <~johnnyrichard/olang-devel@lists.sr.ht> X-Mailer: aerc 0.15.2-211-g37d5fc691aff References: <20240427121832.203068-1-johnny@johnnyrichard.com> <20240427121832.203068-3-johnny@johnnyrichard.com> In-Reply-To: <20240427121832.203068-3-johnny@johnnyrichard.com> X-CM-Envelope: MS4xfE8cknYWvpVnSNLvG4//f79SKwWoMpbqDqWxKNsqLVHfF9B3PcUv0wmrQ881JD9q5yoalSmTD3xzS0xPWpCHBEyGboQOtNnyUKfwuwYDbbNhM4xiAAS0 4PWCF5e+eV74XyNkXqfSaVLADAr2emT2VGG/43i5+BuBFHHwjQ36CCQ+0WkjPk8ewtRm8cGr36GTWdwemlC/yIvnhfZNVm9MJ3K0CJY7Ecvkkqf/AuUnhVEb I2wihBu9+DY0EVCIRja8lw== X-CM-Analysis: v=2.4 cv=OPYh3zaB c=1 sm=1 tr=0 ts=66344650 a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=8u7EihINFSL1m4A7wwkA:9 a=QEXdDO2ut3YA:10 a=BXDaF_L80NY05PYiAFlV:22 X-AuthUser: 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-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -7.78 X-Spam-Score: -7.78 X-Migadu-Queue-Id: 50F9B63C78 X-Migadu-Scanner: mx13.migadu.com X-TUID: fyePrVZUxh0f That's a brilliant work man. I'm inspired in how simple the code is. I even took a look at our previous work on pipa, and this patch is art compared with pipa's implementation. Kudos! There is just one issue with the current implementation: > case AST_BINOP_DIVISION: { > codegen_linux_x86_64_emit_expression(out, bin_op.rhs)= ; > fprintf(out, " push %%rax\n"); >=20 > codegen_linux_x86_64_emit_expression(out, bin_op.lhs)= ; > fprintf(out, " pop %%rcx\n"); > fprintf(out, " div %%rcx\n"); >=20 > return; > } You should always ensure *rdx* is zero right before calling the *div* instruction otherwise the code bellow will return an unexpected value. fn main(): u32 { return 7 / 3 / 3 } The same is valid for the reminder operation. I also missed integration tests, the issue I described before could only be catch over an integration test. I know we don't have the best ever developer experience for integration tests, but following the *test_cli_compile_minimal_program* test structure could save us a lot of time in the future during refactors.