Article View: comp.arch
Article #693Re: Large constants in RISC
From: Anton Ertl
Date: Fri, 13 Nov 2026 16:35
Date: Fri, 13 Nov 2026 16:35
34 lines
2830 bytes
2830 bytes
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). 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. But when you think about that, you see why Alpha and RV64G did not go for such a scheme, but for a scheme based on loading the constant from a constant table (which usually takes one or two instructions). - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Nov13.173546@mips.complang.tuwien.ac.at>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11d76uq$11cdc$1@paganini.bofh.team>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: Large constants in RISC Date: Fri, 13 Nov 2026 16:35:46 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 34 Message-ID: <2026Nov13.173546@mips.complang.tuwien.ac.at> References: <11d76uq$11cdc$1@paganini.bofh.team> Injection-Date: Fri, 13 Nov 2026 17:00:23 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1285836"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Oq410fnw7UK/HNs6r/mDo"; posting-host="a4b6f5891e16eec05578d4726effa55e" Cancel-Lock: sha1:PHNyNepq/inA9ksPunSFXzih9m0= sha256:22oZiwfOQGMRkk07Ir5IhatEj4fv3RCTMvNc2kYGSZ4= sha1:4oIAnwHXhXNgwJ7vIqUqRXAW2PA= sha256:hnpZCIL4IXnuzGXp+ZbP8ICE6mzPv863VHuVG+5IYeI= X-newsreader: xrn 10.11