From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by sourceware.org (Postfix) with ESMTPS id 1F86E3858003 for ; Thu, 2 Dec 2021 21:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F86E3858003 Received: by mail-yb1-xb29.google.com with SMTP id v138so3188047ybb.8 for ; Thu, 02 Dec 2021 13:10:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yjNBxm7wmcZrAYn2KVv/11aZ9D4C3hdJm4jeiOJk2ZY=; b=6z2+ibWcHaMqSntvOmqiWyqTlsfRt5Yt1CWJnAjHoanIGtKTiFNsWAH56w0bVUQESi 7wfKIEpccyKMbq0ehNPTaHhikTXnV3XqKflcKbpSMQtkn8xjYxuImGuAbzmls/zXqnnQ VcvI6s0ed4AaMzI45zuDxaYJuGkz+0UXG/A/EF3OpSdOTSzWr2Tpra/Y3Y/IdoqWn7Zq jNM6ZQW/EsiD5sIq6NqVKpIvkpUpAUBUP03wIfjsjYhnx6TotallS1BX9iA9Yvgfu7Dk 5WvqqudMp95NY/Op9flwD2h6S1pmkqIHwQTNYsGTqXcvNJCGubNMBG60k9F93AOeB1eg /Z0w== X-Gm-Message-State: AOAM530TEEaHk/+VgQ/FMS9+Vdus1xesBiV+dHQOdfY67mozkJSH1XVD r8U9SuD357UnWQNIWEVVKmCXJHPoqwcIBf1FPKs= X-Google-Smtp-Source: ABdhPJwgF/L3gOE1kwcvY5AMnK6BT9le0FpaZqd+3r6R7RG6k1aFycIMV3fvzVZVIDrcJP7Yyq2/cFxJQC0FxjTwxhY= X-Received: by 2002:a25:660d:: with SMTP id a13mr17838087ybc.460.1638479444549; Thu, 02 Dec 2021 13:10:44 -0800 (PST) MIME-Version: 1.0 References: <1546448170.7788.10.camel@redhat.com> In-Reply-To: <1546448170.7788.10.camel@redhat.com> From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Thu, 2 Dec 2021 22:10:33 +0100 Message-ID: Subject: Re: Conversion of pointers to integers and vice versa; pointer tagging To: David Malcolm Cc: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= , jit@gcc.gnu.org X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 21:10:46 -0000 Am Mi., 2. Jan. 2019 um 17:56 Uhr schrieb David Malcolm : > On Tue, 2019-01-01 at 12:00 +0100, Marc Nieper-Wi=C3=9Fkirchen wrote: > > Implementations of languages with garbage collection and dynamic > > typing often employ the concept of tagged pointers. Unused bits of a > > pointer representation are used to distinguish between pointers to > > different types or between pointers and immediate values. > > > > Implementing such a language with libgccjit raises a couple of > > questions: > > > > 1) libgccjit has currently only a limited set of type-casting > > expressions. In particular, there is no type-casting expression > > between an integer type (e.g. uintptr_t) and a pointer type defined. > > > > Are there technical reasons for that or is that just an area where > > libgccjit still has to be complemented? > > In general, I've chosen to require the user to explicitly supply any > casting that's needed, out of a desire to catch problems early. > > gcc_jit_context_new_cast only supports a few conversions. IIRC this > was to simplify the internal implementation; perhaps more conversions > could be allowed. > > > I guess, a workaround could be to use union types =C3=A0 la > > > > union { > > uintptr_t i; > > void *p; > > } > > > > everywhere. > > That ought to work. > Please excuse resurrecting this thread, but it has occurred to me that I don't know how to create an integer type whose width is exactly the same as the one of a pointer using libgccjit. Wouldn't it make sense to add something like GCC_JIT_TYPE_UINTPTR_T or similar? Or am I supposed to use, say, Autoconf, to check the sizes of the provided types and choose one accordingly? Thanks, Marc