From patchwork Fri Jan 5 17:09:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoni Boucher X-Patchwork-Id: 185470 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6351291dyb; Fri, 5 Jan 2024 09:12:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJfJi4YpzrggXtcCfQaD6BMdZ5vidT2VaUOvsx4XnUHGpteqxTgyQL+xiivBnLRhioYQS4 X-Received: by 2002:a05:6358:9392:b0:175:78cc:4efe with SMTP id h18-20020a056358939200b0017578cc4efemr529995rwb.48.1704474757179; Fri, 05 Jan 2024 09:12:37 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1704474757; cv=pass; d=google.com; s=arc-20160816; b=P1nME+iaWcPLTMyORuWQE94LwcGtrkhc+RJ4RllSZMkkleJw0GES7lxECtP80/LmgC 3kPwvkMzkz8R5G6Qzi6skK2h3bBjCEpmrSqm4/CT+SJ3QmyIr3wmWk0vsnqxj3D8huUP yZsv49Iu8okg9xpclmSW4WyfVU0EEkKmxxKqZFbhZ7qpY8iHnp4VYBviGaZxdkusjXlp UuvjMkEedKy35tfOzOdJCnv05J4574KgOAtnQPzhk1PaHcAQxVBHQUpny92LCsFGQOTi TrEM6E2gP9y5/YuFltkepnqsVXOzM0CjSVtUySp/kI9d9hlK+BayzEAg3RuhW4WTG6Zk qNCw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id:mime-version :user-agent:autocrypt:date:cc:to:from:subject:message-id :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=aPWf26/lDtcXj3UzblJXI3YRk6ZDEDHDfBCCOvBaFuw=; fh=T+OJrpbtdAAwCS7EoTzoGzx8W2CueTuN+vhPCLC4QI4=; b=La2syRVHC3OZyxt3cxyZttAAyNMfFlqSakqPzBJCDlmJyn9SbbWafx40VGuUwV+Jar zuOOqGMgGHzodPDYvaWXyH7BVtEpjNLD6pHfxSRJ1LtBkOlMTANB18yNF/aHp8jNvwxL aRH9jbDStzB2WOLOCIwZjlYonVmP9BmffmZF5d4m2jnwC7qMELV+Ud9vWGMfeG1ieRMS +9eFEWMwl3Vl2zlZj3jvKJnIchtIpWVbXtI1zm0EDOfU5UisfpqSu9bjrFQT5zbbfNWH VvP7FkLxWzMgASkNDra036Qnf23JSsX2pk6bDsFnOmTZkQ7r/U9GRBnPQGM40o/p3iTJ 84ag== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=RLwwH2qF; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j13-20020a05622a038d00b0042826e3b674si2135179qtx.600.2024.01.05.09.12.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 09:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=RLwwH2qF; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4D563857B95 for ; Fri, 5 Jan 2024 17:12:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sender3-pp-o97.zoho.com (sender3-pp-o97.zoho.com [136.143.184.97]) by sourceware.org (Postfix) with ESMTPS id C7E183858C98; Fri, 5 Jan 2024 17:09:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7E183858C98 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 C7E183858C98 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=136.143.184.97 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1704474571; cv=pass; b=g7sGPE6y2x2wiv79EGotJvTF6gxr38gry521GRlXbRLbkVPdgNSA4xsbrQYfmpIApX7my9FNHOdGMBW/eGnAnzXAMcCeS3Ef8x6P75gljPV8+vvB3wiX5SV6ESz3cTMJDIlvUWUWAXvBQZ0rDPwjAY3IIJB+5Y4HBadAaGFj8og= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1704474571; c=relaxed/simple; bh=FsKZuMrsBBMQRoY/kwrJf7t+ykp9+GkKrBOiM5/sgO8=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=svGNQazyVpqwxgoTlKED6Lex1JX7kUgtkavFuRyxlwqcyH/siHJLu7/c053Cdx1GvtsFX3DdyyhtWbjGcAiEVgyLD0Dsd8rk3WPUsPkm6B3K4FovIpr5CvfzR6afHScxMdtZB502ifFLFCTkF4dMjdhfavtsl4d4SNvCmieMMxk= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1704474558; cv=none; d=zohomail.com; s=zohoarc; b=Fh8twVgxwtEXqIoiPdAnpZgef5CDG0/u3T4N2+MPajIWErmMM0GwfMD5UN0+sQE7pIEqCxc0528eh2Pnsl8g3hOTdyL/dz+lw4FO5HHkUZdDmf4mgnuHLaXM0PMXz0vvLQjF3J7mAHNmZZTC9pS5YnP+YPP36Y9uQtRqPmxYA98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704474558; h=Content-Type:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=aPWf26/lDtcXj3UzblJXI3YRk6ZDEDHDfBCCOvBaFuw=; b=iFRYTXaF4f3P601jtGKO0/UP+O6smEheBsF0C7jx2tY9Q7kMUgMX/4TfztaW0RC38wYrJLZPMI1TOLxS1vAXOmyPZtiBlU79VkXUy5NnMUnBBBEYnKxfJ8Dc8sCK6C7GbpM5WmO38+ygODn1tSIgfTvRA/zE2li16Dr/fQNvBnk= 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=1704474558; s=zm2022; d=zoho.com; i=bouanto@zoho.com; h=Message-ID:Subject:Subject:From:From:To:To:Cc:Cc:Date:Date:Content-Type:MIME-Version:Feedback-ID:Message-Id:Reply-To; bh=aPWf26/lDtcXj3UzblJXI3YRk6ZDEDHDfBCCOvBaFuw=; b=RLwwH2qF8CmrMdHjSw2XNIal+pnjX/uMWxdbC83gLJfOpjjKPKcIh6US1wG+ySLr MZfhp9alPzK7qCLnCxK1XUDTL1ev0K56FrkTd3vDNsB376+U85OKZTPkCo0Rht0UPeA p3nSuBmGJj4aSAOLzpghF9ngzytSw2Hwck6XMi0g= Received: from [192.168.1.172] (38.87.11.6 [38.87.11.6]) by mx.zohomail.com with SMTPS id 1704474557363577.2348191144276; Fri, 5 Jan 2024 09:09:17 -0800 (PST) Message-ID: <0c37a2a72b2e3a5f85844d27f8d59c21d10ca7f6.camel@zoho.com> Subject: [PATCH] libgccjit: Add support for setting the comment ident From: Antoni Boucher To: "jit@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" Cc: David Malcolm Date: Fri, 05 Jan 2024 12:09:15 -0500 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== User-Agent: Evolution 3.50.2 MIME-Version: 1.0 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-1.1.0/204.464.78 Feedback-ID: rr0801122843364358998965d82d5e5db300006cf3e4ff3e5abd855bc66fe87d3ee2778f86af0ea5246ae55ca7:zu080112261334d99679cf07d9fd28ad3e000036a2f4e5d13e623351cf934e56b4a32b9e02bc4e7a5f5be1:rf08011232f1fb3263caa817cfc46f709300005acc28325b9d00f000d92b4c4f4a4a47fee5982624268ceb1c9e2c8eda33e3485a5212e4:ZohoMail X-ZohoMailClient: External X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787271323032453561 X-GMAIL-MSGID: 1787271323032453561 Hi. This patch adds support for setting the comment ident (analogous to #ident "comment" in C). Thanks for the review. From 1af4e77540001cce8c30e86040c1da785e435810 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 27 Oct 2023 17:36:03 -0400 Subject: [PATCH] libgccjit: Add support for setting the comment ident gcc/jit/ChangeLog: * docs/topics/compatibility.rst (LIBGCCJIT_ABI_26): New ABI tag. * docs/topics/contexts.rst: Document gcc_jit_context_set_output_ident. * jit-playback.cc (set_output_ident): New method. * jit-playback.h (set_output_ident): New method. * jit-recording.cc (recording::context::set_output_ident, recording::output_ident::output_ident, recording::output_ident::~output_ident, recording::output_ident::replay_into, recording::output_ident::make_debug_string, recording::output_ident::write_reproducer): New methods. * jit-recording.h (class output_ident): New class. * libgccjit.cc (gcc_jit_context_set_output_ident): New function. * libgccjit.h (gcc_jit_context_set_output_ident): New function. * libgccjit.map: New function. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: New test. * jit.dg/test-output-ident.c: New test. --- gcc/jit/docs/topics/compatibility.rst | 7 +++ gcc/jit/docs/topics/contexts.rst | 22 ++++++++ gcc/jit/jit-playback.cc | 7 +++ gcc/jit/jit-playback.h | 3 ++ gcc/jit/jit-recording.cc | 53 ++++++++++++++++++++ gcc/jit/jit-recording.h | 22 ++++++++ gcc/jit/libgccjit.cc | 15 ++++++ gcc/jit/libgccjit.h | 6 +++ gcc/jit/libgccjit.map | 5 ++ gcc/testsuite/jit.dg/all-non-failing-tests.h | 3 ++ gcc/testsuite/jit.dg/test-output-ident.c | 23 +++++++++ 11 files changed, 166 insertions(+) create mode 100644 gcc/testsuite/jit.dg/test-output-ident.c diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst index ebede440ee4..c4de996506b 100644 --- a/gcc/jit/docs/topics/compatibility.rst +++ b/gcc/jit/docs/topics/compatibility.rst @@ -378,3 +378,10 @@ alignment of a variable: -------------------- ``LIBGCCJIT_ABI_25`` covers the addition of :func:`gcc_jit_type_get_restrict` + +.. _LIBGCCJIT_ABI_26: + +``LIBGCCJIT_ABI_26`` +-------------------- +``LIBGCCJIT_ABI_26`` covers the addition of +:func:`gcc_jit_context_set_output_ident` diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst index b22eb2aa983..c51cf5a82ea 100644 --- a/gcc/jit/docs/topics/contexts.rst +++ b/gcc/jit/docs/topics/contexts.rst @@ -599,3 +599,25 @@ Additional command-line options .. code-block:: c #ifdef LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option + +Output options +************** + +.. function:: void gcc_jit_context_set_output_ident (gcc_jit_context *ctxt,\ + const char* output_ident) + + Set the identifier to write in the .comment section of the output file to + ``output_ident``. Analogous to: + + .. code-block:: c + + #ident "My comment" + + in C. + + This entrypoint was added in :ref:`LIBGCCJIT_ABI_26`; you can test for + its presence using + + .. code-block:: c + + #ifdef LIBGCCJIT_HAVE_gcc_jit_context_set_output_ident diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index dddd537f3b1..243a9fdf972 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -319,6 +319,13 @@ get_type (enum gcc_jit_types type_) return new type (type_node); } +void +playback::context:: +set_output_ident (const char* ident) +{ + targetm.asm_out.output_ident (ident); +} + /* Construct a playback::type instance (wrapping a tree) for the given array type. */ diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index b0166f8f6ce..c6ed15517e9 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -66,6 +66,9 @@ public: type * get_type (enum gcc_jit_types type); + void + set_output_ident (const char* ident); + type * new_array_type (location *loc, type *element_type, diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 9b5b8005ebe..d86616f45ef 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -1346,6 +1346,13 @@ recording::context::set_str_option (enum gcc_jit_str_option opt, log_str_option (opt); } +void +recording::context::set_output_ident (const char *ident) +{ + recording::output_ident *memento = new output_ident (this, ident); + record (memento); +} + /* Set the given integer option for this context, or add an error if it's not recognized. @@ -2185,6 +2192,52 @@ recording::string::write_reproducer (reproducer &) /* Empty. */ } +/* The implementation of class gcc::jit::recording::output_ident. */ + +/* Constructor for gcc::jit::recording::output_ident, allocating a + copy of the given text using new char[]. */ + +recording::output_ident::output_ident (context *ctxt, const char *ident) +: memento (ctxt) +{ + m_ident = ident ? xstrdup (ident) : NULL; +} + +/* Destructor for gcc::jit::recording::output_ident. */ + +recording::output_ident::~output_ident () +{ + delete[] m_ident; +} + +/* Implementation of pure virtual hook recording::memento::replay_into + for recording::output_ident. */ + +void +recording::output_ident::replay_into (replayer *r) +{ + r->set_output_ident (m_ident); +} + +/* Implementation of recording::memento::make_debug_string for output_ident. */ + +recording::string * +recording::output_ident::make_debug_string () +{ + return m_ctxt->new_string (m_ident); +} + +/* Implementation of recording::memento::write_reproducer for output_ident. */ + +void +recording::output_ident::write_reproducer (reproducer &r) +{ + r.write (" gcc_jit_context_set_output_ident (%s, \"%s\");", + r.get_identifier (get_context ()), + m_ident); +} + + /* The implementation of class gcc::jit::recording::location. */ /* Implementation of recording::memento::replay_into for locations. diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 4a8082991fb..879fdda065d 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -224,6 +224,9 @@ public: set_str_option (enum gcc_jit_str_option opt, const char *value); + void + set_output_ident (const char *output_ident); + void set_int_option (enum gcc_jit_int_option opt, int value); @@ -463,6 +466,25 @@ private: bool m_escaped; }; +class output_ident : public memento +{ +public: + output_ident (context *ctxt, const char *text); + ~output_ident (); + + void replay_into (replayer *) final override; + + output_ident (const output_ident&) = delete; + output_ident& operator= (const output_ident&) = delete; + +private: + string * make_debug_string () final override; + void write_reproducer (reproducer &r) final override; + +private: + const char *m_ident; +}; + class location : public memento { public: diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 0451b4df7f9..7eb150fce70 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -3679,6 +3679,21 @@ gcc_jit_context_compile_to_file (gcc_jit_context *ctxt, ctxt->compile_to_file (output_kind, output_path); } +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is done by the + gcc::jit::recording::context::set_str_option method in + jit-recording.cc. */ + +void +gcc_jit_context_set_output_ident (gcc_jit_context *ctxt, + const char* output_ident) +{ + RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); + + ctxt->set_output_ident (output_ident); +} /* Public entrypoint. See description in libgccjit.h. diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 749f6c24177..29a057faf3c 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -1999,6 +1999,12 @@ gcc_jit_vector_type_get_element_type (gcc_jit_vector_type *vector_type); extern gcc_jit_type * gcc_jit_type_unqualified (gcc_jit_type *type); +extern void +gcc_jit_context_set_output_ident (gcc_jit_context *ctxt, + const char* output_ident); + +#define LIBGCCJIT_HAVE_gcc_jit_context_set_output_ident + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map index 8b90a0e2ff3..a40ec61856a 100644 --- a/gcc/jit/libgccjit.map +++ b/gcc/jit/libgccjit.map @@ -276,3 +276,8 @@ LIBGCCJIT_ABI_25 { global: gcc_jit_type_get_restrict; } LIBGCCJIT_ABI_24; + +LIBGCCJIT_ABI_26 { + global: + gcc_jit_context_set_output_ident; +} LIBGCCJIT_ABI_25; diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h index e762563f9bd..fd2d80f70f6 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -254,6 +254,9 @@ #undef create_code #undef verify_code +/* test-output-ident.c: This can't be in the testcases array as it + is target-specific. */ + /* test-quadratic.c */ #define create_code create_code_quadratic #define verify_code verify_code_quadratic diff --git a/gcc/testsuite/jit.dg/test-output-ident.c b/gcc/testsuite/jit.dg/test-output-ident.c new file mode 100644 index 00000000000..db60101aca3 --- /dev/null +++ b/gcc/testsuite/jit.dg/test-output-ident.c @@ -0,0 +1,23 @@ +/* { dg-do compile { target x86_64-*-* } } */ + +#include +#include + +#include "libgccjit.h" + +#define TEST_COMPILING_TO_FILE +#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER +#define OUTPUT_FILENAME "output-of-test-output-ident.c.s" +#include "harness.h" + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + /* Let's try to inject the equivalent of: + #ident "My comment" + */ + gcc_jit_context_set_output_ident (ctxt, "My comment"); +} + +/* { dg-final { jit-verify-output-file-was-created "" } } */ +/* { dg-final { jit-verify-assembler-output ".ident \"My comment\"" } } */ -- 2.43.0