🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #869

Re: Large constants in RISC

#869
From: Dan Cross
Date: Sat, 21 Nov 2026 20:20
101 lines
5213 bytes
In article <20261121221023.000078cd@yahoo.com>,
Michael S  <already5chosen@yahoo.com> wrote:
>On Sat, 21 Nov 2026 19:49:16 -0000 (UTC)
>cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>
>> In article <20261121195356.00001dd1@yahoo.com>,
>> Michael S  <already5chosen@yahoo.com> wrote:
>> >On Fri, 20 Nov 2026 15:23:23 GMT
>> >scott@slp53.sl.home (Scott Lurndal) wrote:
>> >
>> >> Michael S <already5chosen@yahoo.com> writes:
>> >> >On Thu, 19 Nov 2026 23:19:31 GMT
>> >> >scott@slp53.sl.home (Scott Lurndal) wrote:
>> >> >
>> >> >> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> >> >> >aph@littlepinkcloud.invalid [2026-11-19 09:42:51] wrote:
>> >> >> >> In a way, it does. Most large constants I see are addresses.
>> >> >> >> AArch64 (almost) always has a 48-bit user space, so except
>> >> >> >> for floating-point doubles and the very occasional large
>> >> >> >> integer, constant loads look like
>> >> >> >>
>> >> >> >>  mov x0, 42857; movk x0, 0x60b8, lsl 16; movk x0, 0xaaaa, lsl
>> >> >> >> 32
>> >> >> >
>> >> >> >Interesting.  I would have expected that most AArch64 code is
>> >> >> >position independent (e.g. for address space randomization
>> >> >> >purposes), so I wonder in which circumstances we end up with
>> >> >> >such instruction sequences to build hardcoded addresses.
>> >> >>
>> >> >> Consider the case where one is creating the 64-bit address
>> >> >> (virtual or physical) of a hardware component, or a VDSO.
>> >> >
>> >> >The vast majority of hardware addresses are not absolute
>> >> >addresses, but offsets relative to dynamically assigned PCI BARs.
>> >> >Therefore, constants larger than 30 bits are rare. Even 24 bits
>> >> >are uncommon.
>> >>
>> >> I work today with systems that support > 32-bit PCI express BARs.
>> >>
>> >> Note that from the host perspective, the base address programmed in
>> >> the PCI-Express/PCI BARs is 64-bit.   While the _offset_ to a
>> >> register may be smaller than 32-bits (I've worked with devices
>> >> that have larger BARs), the absoluate host address once the BAR
>> >> has been mapped into the physical address space is 64-bits.
>> >
>> >Of course, it's 64-bit.
>>
>> Perhaps not.  It's going to be whatever size the physical
>> address space (or IOMMU-virtual address size) of the machine in
>> question is.  E.g., this might be 52 bits or something similar.
>>
>> >But host does not know upper bits at compile time. Except for deeply
>> >embedded hosts. But in 64-bit land those are rarity.
>>
>> It depends on the device, not just the host.  On a device that
>> is known to only support 32-bit bars, for example, one _can_
>> know at compile time that the upper bits will all be 0.
>
>The point is that not all address bits are known in compile-time.

But again, this depends.  Some addresses _are_ known at compile
time.

Consider the text-mode CGA buffer on x86_64 systems; this is
known to be at a fixed physical address (0xb0000); on a system
that maps that to some fixed virtual address, it is known at
compile time.

Similarly with things like the IOAPIC or MMIO-based xAPIC
(though we do usually read those addresses from an MSR).

>So, ability to efficiently assemble arbitrary 64-bit (or 48-bit,
>or 52-bit) constants in compile time does not help this particular
>application much. Or at all.

I agree.

>OTHO, ability to efficiently assemble more narrow arbitrary constants,
>like 32-bit or 30-bit, but most importantly even smaller ones, in
>range from 17 to 24 bits, could be valuable.

I also agree.

>> >I read that back in previous century, esp. before 1990, people
>> >regenerated their OSes after every change in HW configuration. We
>> >don't do it now, do we?
>>
>> Depends on the OS, but most do dynamic hardware discovery.
>> However, most devices do not allocate physical address space to
>> e.g. PCIe devices (well, outside of a hotplug path, anyway); in
>> UEFI-based systems, that's usually at the PEI layer.
>
>For the question at hand it does not matter which entity assigns BARs.
>The only thing that matters is that absolute HW addresses are not known
>at compile time.

See above.  BARs aren't the only thing that matter, though I
do agree that this isn't a particularly _common_ operation.

	- Dan C.
Technical Details
Message-ID: <11dsue0$d22$1@reader2.panix.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
References: <11d76uq$11cdc$1@paganini.bofh.team> <20261121195356.00001dd1@yahoo.com> <11dssjs$2si$1@reader2.panix.com> <20261121221023.000078cd@yahoo.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Sat, 21 Nov 2026 20:20:16 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <11dsue0$d22$1@reader2.panix.com>
References: <11d76uq$11cdc$1@paganini.bofh.team> <20261121195356.00001dd1@yahoo.com> <11dssjs$2si$1@reader2.panix.com> <20261121221023.000078cd@yahoo.com>
Injection-Date: Sat, 21 Nov 2026 20:20:16 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="13378"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)