Article View: comp.arch
Article #695Re: Large constants in RISC
From: Waldek Hebisch
Date: Fri, 13 Nov 2026 17:57
Date: Fri, 13 Nov 2026 17:57
48 lines
3226 bytes
3226 bytes
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> antispam@fricas.org (Waldek Hebisch) writes:
>>To solve problem of needing extra register I propose to have
>>extra register (call it C) dedicated to building constants,
>>different from normal architectural registers. I also propose
>>special flag signaling that this extra register is live. It
>>is important that this flag gets cleared after the C register
>>is consumed (used). It also gets cleared if after setup of C
>>the next instruction does not use it. I propose to have 2 or
>>3 constant-building instructions. One sets high k bits of C,
>>where k may be 26 (for case of 2 constant-building instructions)
>>or 18 (for case of 3 constant-building instructions). The
>>second constant-building instruction sets next k bits of C.
>
> You only need one opcode here: When C is dead, set bits 37..12; when
> it is alive, set bits 63..38. Or alternatively, the instruction might
> shift the result of the first instruction left by 26 bits and insert
> its bits always at bits 37..12. Any other instruction clears C at the
> end (not before using it).
Yes, that is one of possible variants.
> One nasty aspect of this scheme is what you do when there is an
> interrupt or exception while C is alive. The easiest solution is
> probably to wait until C is dead before you serve the interrupt. But
> then C must not be alive at page boundaries, making code
> generation/linking harder. The other alternative is to save and
> restore C.
Yes, interrupts need some solution. I was thinking rater on
restoring instruction pointer to the start of the sequence, at least
for page fauls. If hardware provides enough info complication
in page fault handler would be minimal, if any. Of course,
in such case page fault handler must make sure that both pages
are present, but there are many architectures that allow
instructions spanning page boundary and they handle it.
> But when you think about that, you see why Alpha and RV64G did not go
> for such a scheme,
RV64G allows 4 byte instruction with 2 byte alignment, so must handle
instructions spanning page boundary.
> but for a scheme based on loading the constant from
> a constant table (which usually takes one or two instructions).
--
Waldek Hebisch
Technical Details
Message-ID:
<11d7j2f$11orr$2@paganini.bofh.team>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!paganini.bofh.team!not-for-mailReferences:
<11d76uq$11cdc$1@paganini.bofh.team> <2026Nov13.173546@mips.complang.tuwien.ac.at>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Fri, 13 Nov 2026 17:57:37 -0000 (UTC)
Organization: bofh.team Usenet service
Message-ID: <11d7j2f$11orr$2@paganini.bofh.team>
References: <11d76uq$11cdc$1@paganini.bofh.team> <2026Nov13.173546@mips.complang.tuwien.ac.at>
Injection-Date: Fri, 13 Nov 2026 17:57:37 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="1106811"; mail-complaints-to="usenet@bofh.team"; posting-host="d028f9ad2fa2c51f22dbfed0d81d7daf"; posting-account="69e66f1681224ab92235b464ce7a90b6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
X-Postfilter: Postfilter-NG 2026.10.2