Article View: comp.arch
Article #558Re: interrupt handling latency and weird register use (was Re: OT: Epic RISC-V rant)
From: Paul Clayton
Date: Thu, 05 Nov 2026 04:53
Date: Thu, 05 Nov 2026 04:53
90 lines
6273 bytes
6273 bytes
On 10/31/26 3:44 AM, Terje Mathisen wrote: > Josh Vanderhoof wrote: [snip] >> Say instead it's for something called featurex and some >> processors want it in hardware and some don't. It'd be much >> easier for someone writing the software if a standard sequence >> of instructions for doing featurex was defined and new >> processors that do featurex in hardware automatically checked >> call targets and recognize when the instruction sequence >> matches featurex. Then when the routine is called later uses >> the dedicated instruction instead doing the call. > > There is simply no way to do that for individual instructions > intended to be used in a tight loop. The AES opcodes are a > typical example: > > You can write two different functions, one using AES opcodes and > one doing it with regular integer instructions, but if you try > to replace each AES opcode with a sequence that can be > back-patched into the actual instructions, then you will > probably end up with far slower results. Besides the slowness factor (though still faster than trap-and- emulate), there is the problem that one would need either to use fixed registers for the inputs and outputs or provide something like the Mill's conform operation to select the arguments and define the destination. If the number of operands was limited to the number in general instructions (say four register operands), a prefix instruction (similar to My 66000's DOUBLE) could provide the explicit operands (with implicit operands also being possible). If the function call used a table index rather than an offset from the instruction address, one index could be available for each new instruction so hardware could quickly determine the instruction. This would seem to double the size of the "instruction" — e.g., a 32-bit operand-defining prefix and a 32-bit operation- designating instruction. (One might have implicit operands defined when the prefix is not used.) It is not clear if such is a good tradeoff. Intel at least also seems to be eager to exclude functionality, so an automated handling faster than trap-and-emulate might not be attractive to Intel even if the performance was slow. (Some functionality would also be difficult to emulate in software. While x86 transactional memory required having a fallback path (so it was more hint-like), the performance benefit of the extra hardware support was the main motivation.) For AES there are probably also advantages for emulation software not using per-instruction "translation". Software might also choose to use a different operation that is good enough for its use case and have easier software implementation. There may also be I/O devices which provide acceleration for some operations, a processor core might not be able to decide between software emulation and handoff to an accelerator. > The correct way here is to have a function pointer that > initially points at a thunk which checks (CPUID) the local cpu > and then updates the pointer to go directly to the optimized > version. I feel that the _correct_ way is to use an intermediate software distribution format that is translated to the specific machine code. (This would still have code duplication issues when supporting multiple architectures within a family if the special code was required to be supported on all cores.) This even allows new intermediate format software to run on old hardware by updating the translator. (Old hardware might not cache the function addresses near the instruction cache for much later added instructions. Caching the actual functions would also have storage limitations compared to ROM microcode.) (The Stanford MIPS design used a code reorganizer to support an intermediate format that was agnostic of pipeline characteristics. If commercial MIPS had used an intermediate software distribution format, delayed branches could have been eliminated even with a very simple translation mechanism. With a more complex intermediate format, multiplication and division could have been changed to use GPRs.) Sadly, using an intermediate format can cause problems when there are bugs in the final translator or when the software has bugs that are only manifested in a later implementation. Formal methods might eliminate the former, but "it works on my system" seems a common attitude and even with good intentions bugs can be released where an intermediate layer makes debugging harder.
Technical Details
Message-ID:
<11clehg$2snva$2@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<87qzk0nejz.fsf@nightsong.com> <116d89d$27baf$1@paganini.bofh.team> <87ecfcagiw.fsf_-_@debian> <2026Sep1.225146@mips.complang.tuwien.ac.at> <11bpfm8$190ap$1@dont-email.me> <2026Oct27.171414@mips.complang.tuwien.ac.at> <1793120789-5857@newsgrouper.org> <11bsq36$36q1t$3@paganini.bofh.team> <1793202439-5857@newsgrouper.org> <ygnwlr084yt.fsf@y.z> <1793320218-5857@newsgrouper.org> <ygnjymy5uo2.fsf@y.z> <11c469p$u1at$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Paul Clayton <paaronclayton@gmail.com> Newsgroups: comp.arch Subject: Re: interrupt handling latency and weird register use (was Re: OT: Epic RISC-V rant) Date: Wed, 4 Nov 2026 23:53:49 -0500 Organization: A noiseless patient Spider Lines: 90 Message-ID: <11clehg$2snva$2@dont-email.me> References: <87qzk0nejz.fsf@nightsong.com> <116d89d$27baf$1@paganini.bofh.team> <87ecfcagiw.fsf_-_@debian> <2026Sep1.225146@mips.complang.tuwien.ac.at> <11bpfm8$190ap$1@dont-email.me> <2026Oct27.171414@mips.complang.tuwien.ac.at> <1793120789-5857@newsgrouper.org> <11bsq36$36q1t$3@paganini.bofh.team> <1793202439-5857@newsgrouper.org> <ygnwlr084yt.fsf@y.z> <1793320218-5857@newsgrouper.org> <ygnjymy5uo2.fsf@y.z> <11c469p$u1at$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 06 Nov 2026 20:49:53 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3039210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WkNnuInB15BDuSP93TEX2QH3Uym9oQnk="; posting-host="05cb568412db26d811c55d3340e2d5f4" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Thunderbird/140.0 Cancel-Lock: sha1:Ax8wRMltoNi3esp5Cn+iH76Zg3I= sha256:8oGDU3iIfy92WgEYARfrqWLAx1pFFq7cWg41qpscFAs= sha1:01iu9jebedxserSIEQ552NLJOsI= sha256:J0sjOUWAO9jr5kHD9mScKSZJ8xdGLJ9zm7XGxEUlXwc= In-Reply-To: <11c469p$u1at$1@dont-email.me>