From patchwork Mon Jul 25 09:15:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp1646962pxt; Mon, 25 Jul 2022 06:20:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sBRp4BvETm5xM83RwAD48wL1GlKRmPbaLR+mfNDmY5JEyIIJGiuDVSBp0rEt8HCqTp1UL+ X-Received: by 2002:a17:907:d28:b0:72b:5cc9:99c with SMTP id gn40-20020a1709070d2800b0072b5cc9099cmr10083204ejc.228.1658755218766; Mon, 25 Jul 2022 06:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658755218; cv=none; d=google.com; s=arc-20160816; b=T86fXCLfzen37PKawKhKu0pxq6ETTTZO67rZmwWgfAGoaPOkGHExWNsl99VS2ok2nT 6sZtlP2DZf7KwcvTwMviiLCI46trZ43wey663HSMkmqN7TN5Ro5GwfoByTaKanwMoF7H M9z0bbJPMyfBLgYgoqtD5ICLz0Cr6yYEN4jXF46zkfIAPRvZMIVS6LMOFfzG1sDBbgSM uunsOpOWR6Cich9yWAiiULcginfzDUyckWKyfkOns7SMpHtznvsfo8fQK/82icqVAhRg WEOmRlRtqGQNm6P/BhYA6BDbWM7U8qSnWs3JBwa1KW8XhDQfU0yhEwk5bH9T/vp6mYi+ ZoCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:date:from:references :in-reply-to:message-id:resent-message-id:resent-date:resent-cc :resent-to:resent-from:dkim-signature:dkim-signature:dmarc-filter :delivered-to; bh=Pu5h/hDtS8kZm6v3zZRZ7TXlVHR89euj6TO2j/rIIrY=; b=F/kJb2XjACRq9vd+hopnDLIXUo7rfQnUQc953V8E7XrPnkmtNwNIDnUOkTVGDDy8wB QBwfFGeGOfxm/q6QA3LGTaT653F3k9u/h2pLLBN9qVZQMKx0gmQmIAjD4m5GVS1mh0eO sKRgkj+9t45rfgIQi5vSdL+YibqE2jEgVY8o6Y9T2O+0IakMZ4fSHLsak/MsTZod+PIy bQgj8XTuOhjBKhqaIn845Jrow0dV2uaSbZTbJgUFcR/ejinMGeK//A0r8Hq8Tu/J6L8n cUYjV1XMO3MpqwIQg6VEEXDtHWQjy052ui23Uu0sy2SAP24YhfzDoVOzK5WSqsAsawrZ jFZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@suse.cz header.s=susede2_rsa header.b=DJlr24Kf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hq34-20020a1709073f2200b0072b9c43063csi15233161ejc.507.2022.07.25.06.20.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 06:20:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@suse.cz header.s=susede2_rsa header.b=DJlr24Kf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0CB338983BB for ; Mon, 25 Jul 2022 13:16:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id E8C8B3839C66 for ; Mon, 25 Jul 2022 13:15:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E8C8B3839C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E06DC1FD42; Mon, 25 Jul 2022 13:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1658754918; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: resent-to:resent-cc:resent-from:resent-message-id: in-reply-to:in-reply-to:references:references; bh=Pu5h/hDtS8kZm6v3zZRZ7TXlVHR89euj6TO2j/rIIrY=; b=DJlr24Kfin4j23d5yvDM5FfYgHTdOJ83v/PknjaturhsuzFfu98O9bgByLSNc07fhpFVjk 6JHSjB+Fekhfsoz34IgUs037iaaRoCQlNsBcuF7kyxKupLynhNdJ3XvVAWqOEahJaAJHGa IRKL6cYa0blPp2Bq7rz35vSjzNLlkRo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1658754918; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: resent-to:resent-cc:resent-from:resent-message-id: in-reply-to:in-reply-to:references:references; bh=Pu5h/hDtS8kZm6v3zZRZ7TXlVHR89euj6TO2j/rIIrY=; b=PtQ66VHF3s2F3L2oaQifTTYZznG3bVAR95UUmfkfDbsMzfKM//RW4zCHQwfPLeYM7P3B0f GK9A77tjGdG8DPBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CBC9413ABB; Mon, 25 Jul 2022 13:15:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0DgSL2aX3mIRdgAAMHmgww (envelope-from ); Mon, 25 Jul 2022 13:15:18 +0000 Resent-From: =?utf-8?q?Martin_Li=C5=A1ka?= Resent-To: GCC Patches Resent-Cc: David Malcolm Resent-Date: Mon, 25 Jul 2022 15:15:18 +0200 Resent-Message-ID: <56b91f71-7ae8-1945-59e1-cf700e0df6d8@suse.cz> Message-Id: <74132da05d2a26bdab25a0af7511b88c607edc50.1658754788.git.mliska@suse.cz> In-Reply-To: References: From: Martin Liska Date: Mon, 25 Jul 2022 11:15:25 +0200 Subject: [PATCH 3/7] jit,docs: various fixes To: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1739330912070172192?= X-GMAIL-MSGID: =?utf-8?q?1739330912070172192?= gcc/jit/ChangeLog: * docs/cp/intro/tutorial02.rst: Use proper reference. * docs/cp/topics/contexts.rst: Likewise. * docs/cp/topics/functions.rst: Put `class` directive before a function as it is not allowed declaring a class in a fn. * docs/cp/topics/types.rst: Add template keyword. * docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): Add removed comment used for code snippet ending detection. * docs/intro/tutorial04.rst: Fix to match the real comment. --- gcc/jit/docs/cp/intro/tutorial02.rst | 2 +- gcc/jit/docs/cp/topics/contexts.rst | 2 +- gcc/jit/docs/cp/topics/functions.rst | 46 +++++++++++------------ gcc/jit/docs/cp/topics/types.rst | 2 +- gcc/jit/docs/examples/tut04-toyvm/toyvm.c | 1 + gcc/jit/docs/intro/tutorial04.rst | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/gcc/jit/docs/cp/intro/tutorial02.rst b/gcc/jit/docs/cp/intro/tutorial02.rst index 2064f8e4dd9..55675cc7398 100644 --- a/gcc/jit/docs/cp/intro/tutorial02.rst +++ b/gcc/jit/docs/cp/intro/tutorial02.rst @@ -121,7 +121,7 @@ in this case just one: params.push_back (param_i); Now we can create the function, using -:c:func:`gccjit::context::new_function`: +:cpp:func:`gccjit::context::new_function`: .. code-block:: c++ diff --git a/gcc/jit/docs/cp/topics/contexts.rst b/gcc/jit/docs/cp/topics/contexts.rst index e5bccfb807d..f60f2102b3e 100644 --- a/gcc/jit/docs/cp/topics/contexts.rst +++ b/gcc/jit/docs/cp/topics/contexts.rst @@ -141,7 +141,7 @@ Debugging If "update_locations" is true, then also set up :class:`gccjit::location` information throughout the context, pointing at the dump file as if it were a source file. This may be of use in conjunction with - :c:macro:`GCCJIT::BOOL_OPTION_DEBUGINFO` to allow stepping through the + :c:macro:`GCC_JIT_BOOL_OPTION_DEBUGINFO` to allow stepping through the code in a debugger. .. function:: void\ diff --git a/gcc/jit/docs/cp/topics/functions.rst b/gcc/jit/docs/cp/topics/functions.rst index 0e266abc70c..4e325ac3fef 100644 --- a/gcc/jit/docs/cp/topics/functions.rst +++ b/gcc/jit/docs/cp/topics/functions.rst @@ -243,6 +243,29 @@ Statements return; +.. class:: gccjit::case_ + + A `gccjit::case_` represents a case within a switch statement, and + is created within a particular :class:`gccjit::context` using + :func:`gccjit::context::new_case`. It is a subclass of + :class:`gccjit::object`. + + Each case expresses a multivalued range of integer values. You + can express single-valued cases by passing in the same value for + both `min_value` and `max_value`. + +.. function:: gccjit::case_ *\ + gccjit::context::new_case (gccjit::rvalue min_value,\ + gccjit::rvalue max_value,\ + gccjit::block dest_block) + + Create a new gccjit::case for use in a switch statement. + `min_value` and `max_value` must be constants of an integer type, + which must match that of the expression of the switch statement. + + `dest_block` must be within the same function as the switch + statement. + .. function:: void\ gccjit::block::end_with_switch (gccjit::rvalue expr,\ gccjit::block default_block,\ @@ -292,29 +315,6 @@ Statements #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS - .. class:: gccjit::case_ - - A `gccjit::case_` represents a case within a switch statement, and - is created within a particular :class:`gccjit::context` using - :func:`gccjit::context::new_case`. It is a subclass of - :class:`gccjit::object`. - - Each case expresses a multivalued range of integer values. You - can express single-valued cases by passing in the same value for - both `min_value` and `max_value`. - - .. function:: gccjit::case_ *\ - gccjit::context::new_case (gccjit::rvalue min_value,\ - gccjit::rvalue max_value,\ - gccjit::block dest_block) - - Create a new gccjit::case for use in a switch statement. - `min_value` and `max_value` must be constants of an integer type, - which must match that of the expression of the switch statement. - - `dest_block` must be within the same function as the switch - statement. - Here's an example of creating a switch statement: .. literalinclude:: ../../../../testsuite/jit.dg/test-switch.cc diff --git a/gcc/jit/docs/cp/topics/types.rst b/gcc/jit/docs/cp/topics/types.rst index c695ceb3098..5d50a39b9d0 100644 --- a/gcc/jit/docs/cp/topics/types.rst +++ b/gcc/jit/docs/cp/topics/types.rst @@ -65,7 +65,7 @@ Standard types Access the integer type of the given size. -.. function:: gccjit::type \ +.. function:: template gccjit::type \ gccjit::context::get_int_type () Access the given integer type. For example, you could map the diff --git a/gcc/jit/docs/examples/tut04-toyvm/toyvm.c b/gcc/jit/docs/examples/tut04-toyvm/toyvm.c index 8334b975163..c2333f0de89 100644 --- a/gcc/jit/docs/examples/tut04-toyvm/toyvm.c +++ b/gcc/jit/docs/examples/tut04-toyvm/toyvm.c @@ -764,6 +764,7 @@ toyvm_function_compile (toyvm_function *fn) toyvm_result->cf_code = (toyvm_compiled_code)gcc_jit_result_get_code (jit_result, funcname); + /* (this leaks "jit_result" and "funcname") */ free (funcname); diff --git a/gcc/jit/docs/intro/tutorial04.rst b/gcc/jit/docs/intro/tutorial04.rst index e1c47a0d2d5..89098876530 100644 --- a/gcc/jit/docs/intro/tutorial04.rst +++ b/gcc/jit/docs/intro/tutorial04.rst @@ -308,7 +308,7 @@ We can now compile it, and extract machine code from the result: .. literalinclude:: ../examples/tut04-toyvm/toyvm.c :start-after: /* We've now finished populating the context. Compile it. */ - :end-before: /* (this leaks "result" and "funcname") */ + :end-before: /* (this leaks "jit_result" and "funcname") */ :language: c We can now run the result: