From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 0B8DE3858D1E for ; Wed, 28 Jun 2023 07:31:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B8DE3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9928abc11deso14154666b.1 for ; Wed, 28 Jun 2023 00:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687937488; x=1690529488; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=N+UxquM6feTiUoRinHEMRnjeNYE0E4kY21+3cncCyNc=; b=TOQHlqU/pX5hGF9HBrcTehptbSlKXgr5cUXNCL+wA8/M2Aih9eBSBxZ9HSBoPtxwHc vx3GoXPCUdyywJf8wm3AruhTu2xe/bdwiL+BWUXJ1MSIvtd62Fv8/W7ANqSuGYKc75yE VGDbzzbgL7WxTEERzqOFYn8+KHy7gqmnMagbh/t6/FVyePS9RZ9nx3+v7XCGrpn9/7Tw Td3TDEgQC+v5Do6pUVxBehrRMQiozSuvLH2LiExfNsI9anqrjc0ST/FyoPezhTyVhZBg ZH5ZGv0ylKAU1hMzbvENYNYxDqH7rKW7JfoACYPNm7Q376XiEoi8gUW4CaiV11ZrBvOh glXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687937488; x=1690529488; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=N+UxquM6feTiUoRinHEMRnjeNYE0E4kY21+3cncCyNc=; b=DkQRebyiapJrfGinZ3A42i8mAOkN0AKlzdnVcoBLYlzPpQbBJTjBRnOlw0EZxIN65V gosqPlGdgZxeiAxFRDMghPANXK+6H71Jve30NBmQ6uZLg7W2Yy09G8BmNVB/GurnQDc3 YpPwSMRIllDUTAaHFCmSkIGLWFkILy2Jw/dbnmvFiWbKYprSWZjATLjro13QBGuhkYdi i6JHLybzOpXNZj/qb8x/lZ2DNcgCvUcYi7WgJ8ZruAG67CJ+N0cGdhpUHcXsGUzhCXJ3 7KmpFg/sIitQGjBZZ9hjGM1MdwKvBD+PUAVGbUHhe2kYj69OfuqHv0i6o1V1F8uGvJfT XTjA== X-Gm-Message-State: AC+VfDzykH234FF2JZU4hUA2a7Xx0769kR0uqWgwKEMdz/Y/+Y+HMtVv gec6MU7o2JPUI+NG9uiGLv8F5/uU4Ko2RASxnno= X-Google-Smtp-Source: ACHHUZ7yzCuViSi63n6iVs7oBeGOpKsQAGEge6Jvvu9ujruUSvYQThmbwj1mxOxYb2O3lSexUFZ7FU7kRzTKjYc7Vf4= X-Received: by 2002:a17:906:d552:b0:98c:eef2:d0bc with SMTP id cr18-20020a170906d55200b0098ceef2d0bcmr17928498ejc.12.1687937488375; Wed, 28 Jun 2023 00:31:28 -0700 (PDT) MIME-Version: 1.0 References: <439affd4-11fe-de80-94c8-6fc64cbf76ec@ztk-rp.eu> In-Reply-To: From: Jonathan Wakely Date: Wed, 28 Jun 2023 08:31:16 +0100 Message-ID: Subject: Re: wishlist: support for shorter pointers To: =?UTF-8?Q?Rafa=C5=82_Pietrak?= Cc: waffl3x , "gcc@gcc.gnu.org" Content-Type: multipart/alternative; boundary="00000000000065d0e605ff2b928f" X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SCC_5_SHORT_WORD_LINES,SPF_HELO_NONE,SPF_PASS,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: --00000000000065d0e605ff2b928f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 28 Jun 2023, 08:14 Rafa=C5=82 Pietrak via Gcc, wr= ote: > Hi Alex! > > W dniu 28.06.2023 o 03:54, waffl3x pisze: > > I want to preface this stating that I have little to no experience in > compiler > > development, I am only merely just getting into it. With that said, I > have messed around > > with library design a fair amount, and this seems like something that > could be > > implemented in a library. It might be slightly comfier implemented on > the compiler side, > > but I question how generally it could be implemented. > > I thought of it a lot, and library implementation is something I'd > rather avoid. Before I elaborate, let me put some excerpts of the code > in question. GREP-ing the sources for "->next" (list processing) this is > how it looks like. I have a lot of code like this scattered around: > ------------------- > y->next =3D NULL; > if (our) { out->next =3D a; > for (y =3D t->HD; y && y->next; y =3D y->next) > if (y) y->next =3D a; > fit->HD =3D a->next; > fit->win =3D a->next; > b =3D a->next; > -------------------- > This is from just one source file, which otherwise is "plain C". If I > was to put it into a library that use "asm tweaked fancy pointers", a > portable fragment of code becomes "target dedicated" - this is undesired. > If you use a C++ library type for your pointers the syntax above doesn't need to change, and the fancy pointer type can be implemented portable, with customisation for targets where you could use 16 bits for the pointers. > To elaborate: even in (or may be "particularly" in) embedded world, one > prefers to have as portable code (to other targets) as possible. And I > must say, that such code fragments as quoted are scattered around my > sources practically everywhere. If I "convert" them to a library, the > entire project becomes "target locked", and in consequences > "unmaintainable". Not if you use a C++ class type. Such move practically kills it. > > Now, let me put the case into numbers: if I use stm32f030 instead of > stm32f103, I may end up with just 4kB of RAM. The struct I heavily use > here is 32bytes long, but with 16-bit "pointers" it collapses to > 16bytes. This structure pops up in many places and within a running > system it may reach 100 instances. It's a LOT of space to fight for. > > -R > PS: pls CC the response to my address (as you have done) - I'm not sure > if I get mails from the list. > --00000000000065d0e605ff2b928f--