From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1A42F3858D35 for ; Tue, 21 Nov 2023 14:44:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A42F3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1A42F3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700577844; cv=none; b=BqucfweTP6jTI0nvgPsm9u+Bs+4R6AFw668ueIC+WMIqiw2E7DwCSjhYQ/pXi6GhWJzwN4c06YyHk/GwgbNCi02ap/bYTNcVuJuWadrIT/mnQx2QOVsYqWqbB1HR5hA/ErxtSjPKANsq0BMqWah+23UTgb6XCB9CruoieOo0/rk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700577844; c=relaxed/simple; bh=b5LXu1VcznpvaYrnBzv94Akw9oGJKz5XgSnzxAkJi5I=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=JVbq4v37XfDalzKUd52gE06ocqzPYRaSWauqqqtYIdCd6iHJ8S+hmmRGeqH8jGDHHkTGOHHKuvOl8Z49sfKwKWgF9eVOcHIegKWOOxwd+eJbNzVqnElxlMIPqVb8ZjQnpkFqcleogHA88SyDoJJZKQTxRCj/wfN4BiHLwwrgZRk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700577842; 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=gzP6kRrsCzNeOOBBKd0CS71g9IaD75ABcz1j/6wOeSg=; b=ESade+Pc+3je5Y2mSka0AFPBVi9NVRk3RE7tG8I5Arh3OTyuZdgMW51zUPQ9nyOruVLPVd +KZzaNFHGCiiK+Boh+zzISvfikIBj8tnR+Ku3ewk5855h92KRt6ocAz2cllt5yyUD4kD8l 6kr/h7S+eFvwu0eaLM01Pl0amOZzEcE= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-Rb-9-Yd_MsW-kq2mbOmNhA-1; Tue, 21 Nov 2023 09:44:01 -0500 X-MC-Unique: Rb-9-Yd_MsW-kq2mbOmNhA-1 Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-6d64f84b8beso7492584a34.0 for ; Tue, 21 Nov 2023 06:44:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700577840; x=1701182640; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gzP6kRrsCzNeOOBBKd0CS71g9IaD75ABcz1j/6wOeSg=; b=vHXYXVFmRUBnsniC2vzxzFDXAgQ+BuI5fJu3b1rjsAR40yCoKcozwus6p0HDh5Ewd9 tvhOhhP9hq+u4zYfyvtvdML29lp6P6ESuJyec0afiYaLBJe7TLtO8xq7oYaZv5ZYAIZv kKppgJXGETB8+OeZREZQ9stUzTC4Pi5RhoGwT04jZZZUxeVPQMJ9Y3s8ClCn7l7jLSRK MistM1b8H2AsCLxsXOBZAsb0XQW25kH4wiJMr+zVnzLfuonYtQefOv7cypke8oS58rqs uzt1ScE016bWIWRJz5lNifmBqqCxWmueTJVd++vwDZUTDEXuVpLz/YuVey6xlWe2PGKf MOxw== X-Gm-Message-State: AOJu0Yy9/AW29OifBz/VMV5WFf43Q6vK3/xxvsGo5aK58aW9Ga+BQBCb kSxrIOb/pH2pN9b5gffZ8Y1aqRN70ENdPCDrtsB3KECmobS47JYa4I1hdcV0NomF4s2Is+4YJmr Eqh6oGfk= X-Received: by 2002:a05:6830:457:b0:6c4:cda6:ff31 with SMTP id d23-20020a056830045700b006c4cda6ff31mr11598475otc.15.1700577840208; Tue, 21 Nov 2023 06:44:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdPul/EzmuV4IF1g3bVsUmlApBv8GuvjURimD09Veuo7uLW8vn00m9heHo+pXSLsiVrIDSig== X-Received: by 2002:a05:6830:457:b0:6c4:cda6:ff31 with SMTP id d23-20020a056830045700b006c4cda6ff31mr11598457otc.15.1700577839937; Tue, 21 Nov 2023 06:43:59 -0800 (PST) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id f10-20020ad4558a000000b006655cc8f872sm4038538qvx.99.2023.11.21.06.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:43:59 -0800 (PST) Message-ID: <4f908fb2947d419a0260bd17107a353f4f0ab057.camel@redhat.com> Subject: Re: [PATCH 1/2] jit: Complex types and loong constants From: David Malcolm To: Petter Tomner , jit@gcc.gnu.org Date: Tue, 21 Nov 2023 09:43:58 -0500 In-Reply-To: <3c502ba4-ffc1-4faf-8e3f-f7b7367a50e5@bahnhof.se> References: <697d6d25-c8fb-452b-8997-7ea28b6eb659@bahnhof.se> <3c502ba4-ffc1-4faf-8e3f-f7b7367a50e5@bahnhof.se> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 2023-11-20 at 23:10 +0100, Petter Tomner wrote: > This patch fixes support for complex types. >=20 > It adds the entrypoints: > gcc_jit_context_new_rvalue_from_complex_double > gcc_jit_context_set_bool_enable_complex_types >=20 > Aswell as the binary operator GCC_JIT_BINARY_OP_COMPLEX, to make > complex numbers from two real number rvalues. >=20 > Note that the complex types already are in the type enum, so I > thought the > cleanest solution is to enable them, rather than to have a > "get_complex_type" > function. >=20 > When I wrote the patch originally, the complex enums were not usable > due to a > range check, but I think they accidentally were included when int8_t > etc were added. > However, casts to complex types segfaults currently and some other > issues, so I would say > an explicit enable is the least confusing, since the enums have been > there since the get go. >=20 > See attachement. > Subject: [PATCH 1/2] Complex >=20 > Fix support for complex types Thanks for the patch. >=20 > The patch adds support of complex floating point types to libgccjit. > A new binary operator 'COMPLEX' is added to create complex values > from real values. Aswell as a function to create a complex double > literal. The patch adds usage of "_Complex" to libgccjit.h. According to https://en.cppreference.com/w/c/language/arithmetic_types#Complex_floating_= types this is a C99 feature. I think libgccjit.h is currently only requiring C89 (but I'm not sure), so this declaration probably needs some kind of "C99 or later" preprocessor guard. Also, this needs to be includeable from C++; I'm not sure what the precise requirements there are. >=20 > To notify users if a binary linking to libgccjit depends on complex > types, complex type support most be enabled with a new option function > since they allready are in the types enum. I like this approach, but I see that the patch only uses it to guard gcc_jit_context_get_type. It seems to me that it should guard every entrypoint that uses an enum that's expanded by the API, so presumably it should also guard gcc_jit_context_new_binary_op with op =3D=3D GCC_JIT_BINARY_OP_COMPLEX.=20 Although you'd need a complex type from gcc_jit_context_get_type to get the result, it's probably easier for the user to understand if we document and validate the gcc_jit_context_new_binary_op with op =3D=3D GCC_JIT_BINARY_OP_COMPLEX explicitly. I looked through the rest of the patch and it seems OK, though I'm nervous about all the tests that are comparing floating point values for equality; do we always get the precise expected value, on every target? Floating point equality comparisons tend to be a nightmare in unit tests. Thanks again for the patch Dave