From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NOR01-OL1-obe.outbound.protection.outlook.com (mail-ol1nor01on2070.outbound.protection.outlook.com [40.107.224.70]) by sourceware.org (Postfix) with ESMTPS id D6CD13858408 for ; Wed, 5 Jul 2023 09:11:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6CD13858408 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=westcontrol.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=westcontrol.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QxQhVUFIEHcH3Q5uYEBiM58gAFaQ+P+bfASMapWSrr3oaw9/YnFKN9cmt6mOjfoVfROH71iyiQgoFdjTgxzJyDQ/UE6Cez+cC+h2pNfqhGtZsAA+fPv2whupJK/90MObDdbHMrdcSLScsiKyuP5IGHYmV6KaF8AW1UYubvSN+ewftiG/G9NotInaEwoWl36XdkAqAW8VsX68JyO9odcqgvgfWg/13v4oJgfao0xehXyeUB8tCARYJIRlGzXv1G3UCch9VyLW+PkrI3ZXp1E7nrvevalf3KMOqS+NQhsgugZTrTJ1ztMkcDp3zcpTPqr6Q423RCklRtz4vjwll84NVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OsYbudw8e44ybESEoRKMe+I6u7zwn3QgmKAX/z8lSE4=; b=lKSrq8RrStPUTQO82UUKYy1op4N/T+8KU35mFW0s6Qy7st0h3aL4+0oAvBrwrLFDwULJ6Myhe8jbx/hB9uPqmIA+bZv3tvMGXqPYDQmnPr3Mf6ht52B3NwK9z7ecBSID9J6+d8iJLK5ezyPxSu4arERsEuAf3nYGirekdnos72Lrof1rN1s3brDoq8SObpP0+YLa9UbAU7LHRVAJPjYJRHh4xc98+ng9pCzT+tXJpbg/fyJwMmt3HqO2mmVaKJA7/QsgrubKa2MXE2Ot3MtRHcA1VJ4WdB4kO8kqQ3tDWH/BzbtMBuYhfDIrrMmrmBuFQd7zdFquGoTVmmb65Li07A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=westcontrol.com; dmarc=pass action=none header.from=westcontrol.com; dkim=pass header.d=westcontrol.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=westcontrol.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OsYbudw8e44ybESEoRKMe+I6u7zwn3QgmKAX/z8lSE4=; b=BqzIFFJF0A0jxxq88/2cNwRQssWcmH2eX+achF7HlLOSjI3vhrnrz/ssnc9abeDvt6zkH22unybjAKgI1957xEmFoqV/b0btQ+rUxcBYCa+TiMcYksEgCU4/G5NSQySEdRqwWJc5r1rGAUsLhrh0v6tPqioN7tgjFXuzwrsVhQNHtbhtd8AFJOmYNMc0B2UgN8AaQWzQ2I25IFQqo5QX5RRe34qtxHOw0sjUwkr4H9yh/d+mc5s+IUlUw4DrQiNquI8MDoRpTaQCi3wwe63D9TfCc3sieCFsZ7qkOGbDiRA30NFiquXBRWYIr8s5pgfZ6MalnUfm/WjYSvxwNKpUjg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=westcontrol.com; Received: from SV0P279MB0233.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:b::13) by OSWP279MB0312.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:18::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 5 Jul 2023 09:11:06 +0000 Received: from SV0P279MB0233.NORP279.PROD.OUTLOOK.COM ([fe80::b999:1d1d:3eb1:b8f1]) by SV0P279MB0233.NORP279.PROD.OUTLOOK.COM ([fe80::b999:1d1d:3eb1:b8f1%7]) with mapi id 15.20.6565.016; Wed, 5 Jul 2023 09:11:06 +0000 Message-ID: <8825a11f-e462-8d97-3cdf-a5015250f3c1@westcontrol.com> Date: Wed, 5 Jul 2023 11:11:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: wishlist: support for shorter pointers Content-Language: en-GB To: =?UTF-8?Q?Rafa=c5=82_Pietrak?= , Martin Uecker , Ian Lance Taylor Cc: "Richard Earnshaw (lists)" , "gcc@gcc.gnu.org" References: <439affd4-11fe-de80-94c8-6fc64cbf76ec@ztk-rp.eu> <112e711791835d56cca38654f83a009cb46707d4.camel@gwdg.de> <940e9ae5-8649-5a28-e29f-06f0b2982892@ztk-rp.eu> <6c881d3fc76d112d52ec668d05b68394ae792f30.camel@gwdg.de> <1eeef918-80d0-12a3-e7e9-5a75b25fb769@ztk-rp.eu> From: David Brown In-Reply-To: <1eeef918-80d0-12a3-e7e9-5a75b25fb769@ztk-rp.eu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SV0P279CA0023.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:12::10) To SV0P279MB0233.NORP279.PROD.OUTLOOK.COM (2603:10a6:f10:b::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SV0P279MB0233:EE_|OSWP279MB0312:EE_ X-MS-Office365-Filtering-Correlation-Id: 62621605-fd68-4a83-1271-08db7d37c397 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: El83DiwtGpDa247WkxVy+fB7l389BCWQXhFjO3d5liAKQRMoB9cM4MehkEdRN2ku138rBeXGvoj8q1x0/FL5SmGz+taLqI63tyie6pfiPL4hZCeDeGh1jMTMEtYzPgxHOA/MefpG8G6K903Wzfhz6oYpVrxDDwhqt9Z2Js4JTVEmfCpWOAlKZHdUuB4FDDDVagrxZl6UgpQoM83AUlDTJJ7pOMOpR9MCf8O+bL3YhcpzS/HyY4HybC7aj5GygGR5SpGuwFdYTuS98botculot3VNQipYBtzmguV2b3McMSFtIwR+nUCUCuFKf2/XoJ2w7cRNa8YsEb+LpLRn0FrafTpc15QEJJhYpYzpvWtfDV5rDEMeuBJOZzyi6N6HrUi9VCXi99L9HClVOn1sqcCX+oEqHGWmVOdq+Zb7OpmtI8cGAcE28emRmg6Sv0YTdracyW5oaFUnGNss0bvuC2GK3QGM+I6Yi6LIaeeFKpjrpgSmPYDAkTLaMr3fWsrPJanqRYr60detCniRn5hfUTsZblsYGgnT4Dcj2s5uZ47SCFeKP5IKOWILB+jpbvVlVYWE1Oz9516YWLiSypcOaXTlRgOhPbKens7mNNws0gF3xRz5Halt0gnE59EjGN4j+Qqc6BQM9zVj9QLFtfLsngL44w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SV0P279MB0233.NORP279.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(366004)(376002)(346002)(39840400004)(451199021)(41300700001)(2906002)(8936002)(5660300002)(8676002)(36756003)(86362001)(31696002)(2616005)(478600001)(31686004)(26005)(6512007)(6506007)(186003)(6486002)(316002)(66556008)(4326008)(66476007)(66946007)(54906003)(38100700002)(83380400001)(53546011)(110136005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VWlXTDRtb0dNWnMzSFZ2ZVNzbGRteC9HYzBQdjRCenBRZGFmVTJNZG9VNXVL?= =?utf-8?B?WGxXa04rTi9WSW9LbUR4cjZnRTdvM1FsOW5NNEhZS0FZb2xSVlhNNlAwb0VI?= =?utf-8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lPRW1VbG15UXlVT003WHZOVmFCZ2N3ZkprYVM4NTFuUFIx?= =?utf-8?B?MHgzWTlDakxOa0QxdFE0VTNwbUVjc1BKNzRDZVJMNVp4b1JKNkEyb3NCRnpu?= =?utf-8?B?M0UrSXA2aUZSdXZqeGY4cFljUzN0OWgxaGdSSGhQemE3UUh3Y2NteENxVmxW?= =?utf-8?B?bE5iN1pTdXFReCtZQTRZYVhlbXp1SngyYkl4UlhTS0FKcE11a1ZnaDFqSmFh?= =?utf-8?Q?HB4oPiaCSMV8uERYJZGSjHUOq?= X-OriginatorOrg: westcontrol.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62621605-fd68-4a83-1271-08db7d37c397 X-MS-Exchange-CrossTenant-AuthSource: SV0P279MB0233.NORP279.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2023 09:11:06.4847 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: c75fbd3c-42ad-4db0-9cff-972faf83ae45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7nYbYsYYrF4TlhZ+YPayyOQm8lIf9CX9zu8f0swBgoZSve7TJQpn8hd0oP/UK4Yjp76FBnz2zslgI9dv6ENQlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSWP279MB0312 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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: On 05/07/2023 10:05, Rafał Pietrak via Gcc wrote: > Hi, > > W dniu 5.07.2023 o 09:29, Martin Uecker pisze: >> Am Mittwoch, dem 05.07.2023 um 07:26 +0200 schrieb Rafał Pietrak: > [-------] >>> And if it's so ... there is no mention of how does it show up for >>> "simple user" of the GCC (instead of the use of that "machinery" by >>> creators of particular GCC port). In other words: how the sources should >>> look like for the compiler to do "the thing"? >>> >> >> Not sure I understand the question.  You would add a name space >> to an object as a qualifier and then the object would be allocated >> in a special (small) region of memory.  Pointers known to point >> into that special region of memory (which is encoded into the >> type) would then be smaller.  At least, this is my understanding >> of how it could work. Note that this only applies to pointers declared to be of the address space specific type. If you have "__smalldata int x;" using a hypothetical new address space, then "&x" is of type "__smalldata int *" and you need to specify the address space specific pointer type to get the size advantages. (Since the __smalldata address space is a subset of the generic space, conversions between pointer types are required to work correctly.) > > Apparently you do understand my question. > > Then again ... apparently you are guessing the answer. Incidentally, > that would be my guess, too. And while such "syntax" is not really > desirable (since such attribution at every declaration of every "short > pointer" variable would significantly obfuscate the sources and a thing > like "#pragma" at the top of a file would do a better job), better > something then nothing. Then again, should you happen to fall onto an > actual documentation of syntax to use this feature with, I'd appreciate > you sharing it :) > I am not sure if you are clear about this, but the address space definition macros here are for use in the source code for the compiler, not in user code. There is (AFAIK) no way for user code to create address spaces - you need to check out the source code for GCC, modify it to support your new address space, and build your own compiler. This is perfectly possible (it's all free and open source, after all), but it is not a minor undertaking - especially if you don't like C++ ! In my personal opinion (which you are all free to disregard), named address spaces were an interesting idea that failed. I was enthusiastic about a number of the extensions in TR 18307 "C Extensions to support embedded processors" when the paper was first published. As I learned more, however, I saw it was a dead-end. The features are too under-specified to be useful or portable, gave very little of use to embedded programmers, and fit badly with C. It was an attempt to standardise and generalise some of the mess of different extensions that proprietary toolchain developers had for a variety of 8-bit CISC microcontrollers that could not use standard C very effectively. But it was all too little, too late - and AFAIK none of these proprietary toolchains support it. GCC supports some of the features to some extent - a few named address spaces on a few devices, for "gnuc" only (not standard C, and not C++), and has some fixed point support for some targets (with inefficient generated code - it appears to be little more than an initial "proof of concept" implementation). I do not think named address spaces have a future - in GCC or anywhere else. The only real use of them at the moment is for the AVR for accessing data in flash, and even then it is of limited success since it does not work in C++. I realise that learning at least some C++ is a significant step beyond learning C - but /using/ C++ classes or templates is no harder than C coding. And it is far easier, faster and less disruptive to make a C++ header library implementing such features than adding new named address spaces into the compiler itself. The one key feature that is missing is that named address spaces can affect the allocation details of data, which cannot be done with C++ classes. You could make a "small_data" class template, but variables would still need to be marked __attribute__((section(".smalldata"))) when used. I think this could be handled very neatly with one single additional feature in GCC - allow arbitrary GCC variable attributes to be specified for types, which would then be applied to any variables declared for that type. David