From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sender4-pp-o90.zoho.com (sender4-pp-o90.zoho.com [136.143.188.90]) by sourceware.org (Postfix) with ESMTPS id F28503858429; Thu, 30 Nov 2023 22:11:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F28503858429 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=zoho.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zoho.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F28503858429 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=136.143.188.90 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1701382302; cv=pass; b=tHH7bL+M5ccvhPQFXZ/nHMAjRdDnm5lG5DFRJ/Z7bisL3se9dy7WNbhnkn0HB+eAgDKMLHb5Yi/ba2E6Pb+IEl+0mKwGRixmLBehZhclV/zrEyRakTQv5w9MuTk1t+7cLXoyMqHVqSCoK62OzTJRRveZxhN32qOpXWJ3yEPPe3M= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1701382302; c=relaxed/simple; bh=LPyGTLTOAnos0Q+W3kJRVWVgxJS5IgUEG+Yy/lOFyOU=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=C3S5T+f7iQzAvui9Pvbv1aCccXXyrxosMV+oBy32PocYYEQRp4kogRL8nwEcBE7N+z0y1eJuhTbxxjnYzaxqXN5YzKSNhx4+q8U29t6yRci51FXzUOtv8mvnNjMjQ463rzyiO6Rs2CGaVR1Cz4Ne5fMy0/DrtKFb8y+Fg1CMOOw= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1701382296; cv=none; d=zohomail.com; s=zohoarc; b=J0Tq8Cq/IRuhmzwtGQ1OqzUnMrqMkU4ePsuVCRbwaeT1wFVg/nCryvro1kdvFw5/GlAs3k0Yff3k9c4+vG2p7VyYyNRpTL62y0ddfrWjIUyJOaCUuBYfP7Of+Lz8hBwyX06TQzq/QaDGU7bWvxJZ5MzeQytVPpsij7490kxSIPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701382296; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=LPyGTLTOAnos0Q+W3kJRVWVgxJS5IgUEG+Yy/lOFyOU=; b=MKf0fFLT61pJBpXIwJfTZMYSuG6wQZKcNt0xOGVMFS1hl2to7aTjVrrgLgj7i5e/1nRIis1vgN/Qk10j9ikKEwOJFUzQUkzgxmKPlKu7n+wzhrRUB93FqKtnrWRmQos7A1+V4tO7G2p/k+M6e1RzzRZOxYrEHbEB7Yh0MbN2jKA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1701382296; s=zm2022; d=zoho.com; i=bouanto@zoho.com; h=Message-ID:Subject:Subject:From:From:To:To:Date:Date:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:MIME-Version:Feedback-ID:Message-Id:Reply-To:Cc; bh=LPyGTLTOAnos0Q+W3kJRVWVgxJS5IgUEG+Yy/lOFyOU=; b=JIebXG5OPyhKx1POuoseOq7kU6MayLl78sksrMwPg/PCjasXjq9AAdXmfp8zuQVN eQnvKtAwLOvQbkQGBHychsTtnnPir5o4bDRGFXbbKWzWGFfQh6kv9IX/zNgFaoTn+vv 4+gwFFYqevqJ7PVFItPXojXRXPf20Ztm4mUaiDmw= Received: from [192.168.1.172] (38.87.11.6 [38.87.11.6]) by mx.zohomail.com with SMTPS id 1701382294615977.6524779164612; Thu, 30 Nov 2023 14:11:34 -0800 (PST) Message-ID: Subject: Re: [PATCH] libgccjit: Add ability to get CPU features From: Antoni Boucher To: David Malcolm , jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Date: Thu, 30 Nov 2023 17:11:33 -0500 In-Reply-To: <6050c91ae34a2cdaeebd79ada9e2b9ffaf881e21.camel@zoho.com> References: <8b0199d9835f568b7bcde41bf9432c21f604e489.camel@zoho.com> <755705e37731c4fbc3ab7eb1a96d8df0147bb002.camel@redhat.com> <6050c91ae34a2cdaeebd79ada9e2b9ffaf881e21.camel@zoho.com> Autocrypt: addr=bouanto@zoho.com; prefer-encrypt=mutual; keydata=mQENBFOSMLQBCADO5aw6Ys8thMQUNzrwAnfJX2wbgWiz0pQ01DjYj22eeIpChkoZn6LWdt4dieq30u2rFi/yQzJ02foHwI2+aL9rU6xz/x4TwqyRJQGMOqklNc3R+pdXmH4WDQkQDWmLxvc07vu+zb8Tx5A6pMDh4J2ncCEhLEUcH39Yq/yg4eBnFwUX6N7kakvHrnScGNqhnSFCacoJeMJUAR+1G7VBSBd++jmnHLnx3mj7QkRZVECJUw2zqiv1yReCC6GU4SvqLjdqm5ZGeoWOqD/NHjBRoEeOVjzp6M/qOjjWRbkJVqmvgfcD8UytSSqqboR35YFT4L+rZt2ri3T12MJb3i5syCAXABEBAAG0IUFudG9uaSBCb3VjaGVyIDxib3VhbnRvQHpvaG8uY29tPokBVgQTAQgAQAIbIwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QM4FCRLMEZoACgkQRVeGAwR4zcFBQQf/afttJrA/puADQZhrDfkgr0MFvq6iB+GCy1b8BkXimk1TOXTPt87YLehSeijNu3JkYhl5eRc87BNfU9J87KfI/KIy6hZxqlDXk16FhW9bw/7wYEA0hpb3MUn7xLElXDT0ZHaD+KTe8Oun7qfzgx5RlL6r/WODf3CkSpO085R/rfeBqDEx9mVlhDWgq6Az3CZoD+3CqiCKVqmDuHTWz4kwrd9AM5eVcLvvLKnZIdoIp+G5Ao6BvaGlZyfenN1iOSjLy2NXNt4MnUt0lUYEP5KSIIRhHQ8xkUbj7eWUmaahkxhNb3fH3sAPwGnRZrPpb4rgYzNmSk63wWMh9M2xk+rLb7kBDQRTkjC0AQgAumZzsAV/UFWI+dpzebQfma36kKYZZFuseant5sq/HWP553XQ/U6ttJiKyN5MpCqtxvCAoRplf42YhlHuFqgf73WJxoJ6Y+sdyqoBSwlR+ gzAneAmsa8gmmY0wawH0Z2leazjKuS7mJjVEQZg0ZGsiCVRGeRnDqFGzDEzDc9ngWKSoTq0fKzlGy1X85OrtmUrvEbhSo6HP+FoeunHkIqrxu3w3vDoFEXxVQlKI6V3I4nCz5n6DB8WR3L7nsiiTnOiGirPw1ngvWFLW86kkA4FJpayc8Xl3va3SLY+2y4yuROboX2DVI4AC/Qeug/mDiBicPxkP6YfUartQRMe6obkEQARAQABiQE8BBgBCAAmAhsMFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QRsFCRLMEecACgkQRVeGAwR4zcE56ggAgTgrJInBKC+7552Dpccuo6Clh3wZfjlNLv9/6r5lKEbaNzaTrfhPiAP4WgnluIUmj8amOFLFJpj+BAVNOXpZ4D2R3o9ch8z7fot+fW4Yw+PKIxH4I2xEys8ndoEB3aiQwHjKcGIhkIU7uyMJFQr2aWjdTY0gmXw0YZueHOSLgo7uX4XKxB8fEO/yto/Tff2YBAAq+AtNwt+Gh5YS9rZw7rwUTWMi84yVOlc+zRE79E9NJkvdTwX7IJYo64VzIRNfgHsn7QNdVzuM1XIFHl+Glk6cIlI8s6BO7nEoCn3hTF104fQTAO3fEs+XXZOKXo2lk8faowEoPq5r58StrV0nyg== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.1 MIME-Version: 1.0 Feedback-ID: rr080112281a1fa6ad501f74de18fc32da0000f8ab7fcc4d5b2172ca1048cc4428d0c5fcc50566ef94e9a4494f:zu080112265bcb3064eded589dc6edad150000fe58cbc89db6a1603062d6a4db869312bbb28f0c3ea8f1a0:rf0801123188e231c46d4d823c05e99f80000053b268188d6afad5240bf12284442daefdc9c63e4eb24174f93b3c7523f412609ef45e:ZohoMail X-ZohoMailClient: External X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: See more answers below. On Thu, 2023-11-09 at 19:33 -0500, Antoni Boucher wrote: > > Hi. > > See answers below. > >=20 > > On Thu, 2023-11-09 at 18:04 -0500, David Malcolm wrote: > > > > On Thu, 2023-11-09 at 17:27 -0500, Antoni Boucher wrote: > > > > > > Hi. > > > > > > This patch adds support for getting the CPU features in > > > > > > libgccjit > > > > > > (bug > > > > > > 112466) > > > > > >=20 > > > > > > There's a TODO in the test: > > > > > > I'm not sure how to test that gcc_jit_target_info_arch > > > > > > returns > > > > > > the > > > > > > correct value since it is dependant on the CPU. > > > > > > Any idea on how to improve this? > > > > > >=20 > > > > > > Also, I created a CStringHash to be able to have a > > > > > > std::unordered_set. Is there any built-in way > > > > > > of > > > > > > doing > > > > > > this? > > > >=20 > > > > Thanks for the patch. > > > >=20 > > > > Some high-level questions: > > > >=20 > > > > Is this specifically about detecting capabilities of the host > > > > that > > > > libgccjit is currently running on? or how the target was > > > > configured > > > > when libgccjit was built? > >=20 > > I'm less sure about this part. I'll need to do more tests. This detects the capabilities of the host that libgccjit is currently running on. > >=20 > > > >=20 > > > > One of the benefits of libgccjit is that, in theory, we support > > > > all > > > > of > > > > the targets that GCC already supports.=C2=A0 Does this patch change > > > > that, > > > > or > > > > is this more about giving client code the ability to determine > > > > capabilities of the specific host being compiled for? > >=20 > > This should not change that. If it does, this is a bug. To add to this, libgccjit will just report that the feature is not detected when cross-compiling. > >=20 > > > >=20 > > > > I'm nervous about having per-target jit code.=C2=A0 Presumably > > > > there's a > > > > reason that we can't reuse existing target logic here - can you > > > > please > > > > describe what the problem is.=C2=A0 I see that the ChangeLog has: > > > >=20 > > > > > > =C2=A0* config/i386/i386-jit.cc: New file. > > > >=20 > > > > where i386-jit.cc has almost 200 lines of nontrivial code.=C2=A0 > > > > Where > > > > did > > > > this come from?=C2=A0 Did you base it on existing code in our sourc= e > > > > tree, > > > > making modifications to fit the new internal API, or did you > > > > write > > > > it > > > > from scratch?=C2=A0 In either case, how onerous would this be for > > > > other > > > > targets? > >=20 > > This was mostly copied from the same code done for the Rust and D > > frontends. > > See this commit and the following: > > https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3Db1c06fd9723453dd2b2= ec306684cb806dc2b4fbb > > The equivalent to i386-jit.cc is there: > > https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D22e3557e2d52f129f2b= bfdc98688b945dba28dc9 > >=20 > > > >=20 > > > > I'm not at expert at target hooks (or at the i386 backend), so > > > > if > > > > we > > > > do > > > > go with this approach I'd want someone else to review those > > > > parts > > > > of > > > > the patch. > > > >=20 > > > > Have you verified that GCC builds with this patch with jit > > > > *not* > > > > enabled in the enabled languages? > >=20 > > I will do. It does build. > >=20 > > > >=20 > > > > [...snip...] > > > >=20 > > > > A nitpick: > > > >=20 > > > > > > +.. function:: const char * \ > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 gcc_jit_target_info_arch > > > > > > (gcc_jit_target_info > > > > > > *info) > > > > > > + > > > > > > +=C2=A0=C2=A0 Get the architecture of the currently running CPU= . > > > >=20 > > > > What does this string look like? > > > > How long does the pointer remain valid? > >=20 > > It's the march string, like "znver2", for instance. > > It remains valid until we free the gcc_jit_target_info object. > >=20 > > > >=20 > > > > Thanks again; hope the above makes sense > > > > Dave > > > >=20 > >=20