Article View: comp.arch
Article #1046Re: CISC are not "unreduced"
From: EricP
Date: Thu, 03 Dec 2026 15:28
Date: Thu, 03 Dec 2026 15:28
209 lines
11394 bytes
11394 bytes
On 2026-Dec-01 21:54, Waldek Hebisch wrote:
> EricP <ThatWouldBeTelling@thevillage.com> wrote:
>> On 2026-Dec-01 13:54, MitchAlsup wrote:
>>> antispam@fricas.org (Waldek Hebisch) posted:
>>>
>>>
>>>> I estimate that for typical instructions one
>>>> needs to reserve between 3 and 8 registers, that is 2 for
>>>> arguments, one for result and additional registers to handle
>>>> addressing modes.
>>>
>>> Registers 00..08 are for arguments {R0 is return address}
>>> Registers 09..15 are temporary {unused arguments are also temp}
>>> Registers 16..31 are preserved. R30 is FP, R31 is SP
>>>
>>>> IIUC Risc-V and ARM need at least one
>>>> register to generate large constants which may be needed for
>>>> addressing.
>>>
>>> That is a typical RISC problem--but not for my ISA
>>>
>>>> Now, with 4 registers reserved on 32 bit ARM
>>>> there remain 11 general purpose registers (plus PC), that is
>>>> significantly less than 15 general purpose registers on VAX.
>>>
>>> Don't forget the free access to memory via address modes.
>>
>> Yes, VAX had a bunch of temp registers for holding intermediate
>> addressing results. IIRC the 780 had a whole 16 register file for them.
>> The instruction's operand specifiers were processed as they were
>> parsed so any opspec accesses and side effects took place serially
>> before the next opspec was fetched, parsed and executed.
>
> I did not look at all VAX addressing modes.
There are 13 address modes. Which subset is legal depends on the
opcode and which operand its is (eg an immediate value can be
syntactically specified as a destination but is semantically illegal.)
Other subsets are silly (an ADD with two immediate source values)
or redundant (ADD Rd = Rs1 + [mem], ADD Rd = [mem] + Rs1).
> But AFAICS scheme
> that I propose can handle most (if not all) VAX modes and many
> modes which I believe are not available on the VAX.
Remember that exceptions are precise so faults roll the
register(s) state back to its original values
(except for instructions like character strings and decimal).
These would mostly be page faults for memory operands
and execution faults like integer overflow or divide by zero,
or various floating point exceptions.
> To explain
> it more, with 4 reserved registers I can use all of them when
> computing address of first operand. After computing its address
> I load it to register. So I have 3 registers left that I can
> use to compute address of the second operand. After that
> I load the operand and perform the operation. After that
> I have 1 register that I need to preserve and 3 registers that
> I can use to compute address of destination. Once address
> of destination is computed, I store it.
>
> Note that Intel style SIB mode (IIUC not available on the VAX)
> can be done using 2 registers: in 1 register we generate
> constant displacement, then we add to it base. We copy
> index to the second register, then we shift (scale) it,
> then we add scaled index to previousy computed sum of
> base and constant.
VAX had scaled indexed address mode using two operand specifiers.
The scale factor is implied by the operand size,
not explicitly specified as in some ISA's.
> At any stage of this we can copy intermediate result back
> to different register, so this convers preinctement and
> predecrement. For postincrement and postdecrement we
> can simply emit separate instructions that modify register.
> And we can do this either after whole instruction or
> after a selected operand. So, if needed we can emulate
> VAX behaviour of updating registers after each operand.
Except if there is a fault exception, in which case any
updates are (usually) tossed.
> Similarly, we can easily introduce extra indirections
> by emiting extra load(s) after computing initial address.
> Note that at such time we have at most one register holding
> operand or value and the second containing address, so we
> still have to registers to do something extra (if needed).
>
> If you thing that this scheme is complex, note that we
> can put result of operation in the same register as the
> first operand. So "load to register" needs to preserve
> one register and can use 3. We could use all four
> reserved registers for computing address of the first
> operand but for simplicity we can reuse address calculation.
>
> Let me add that simple compiler is likely to use only
> some address modes. A naive toy backend that I have just
> lowers expression to 3 address form, introducing stack
> temporaries if needed. It is very simple, generated
> code is quite bad, but it only generates RISC instructions.
> Sligtly better version of this toy backend posses result
> of previous operation to the next in a register. Generated
> code is still bad, but visibly better than from the first
> one. It also only generates RISC instructions. I have
> looked at CDC6000 Pascal compiler by U. Amman. Amman
> added a bunch of special cases for frequent Pascal
> constructs. More importantly, he treats registers as
> a cache for recently computed values. CDC 6000 in
> a sense is most strict RISC, that is IIUC it does not
> allow constants as arguments to computational instructions.
> But similar compiler structure was used for CISC-s
> and AFAICS while some CISC instructions reduce number
> of instrucions in generated code, having them does not
> seem to lead to simplification.
The problem is most of the VAX functionality is unnecessary.
Compilers only use about 50 of the 304 opcodes,
and only a few of the 13 address modes.
But you pay for their design, and for each implementation.
> In different compiler, there is machine independent part
> that translates program to abstract instructions and
> performs some simlifications. This machine dependent
> part generates code for for each abstract instruction
> separately. The abstract instruction set has visible
> VAX smell, but uses only small part of VAX instruction
> set and only selected addressing modes. So it is no
> wonder that VAX code generator is the smallest one
> (1164 lines). ARM64 and Risc-V code generators are
> significantly bigger (1731 and 1767 lines respectively).
> Part of that is that VAX handles 3 sizes for loads and
> stores, that is 1, 2 and 4 bytes, while ARM64 and Risc-V
> handle 4 sizes (that is also 8 bytes) which adds
> additional cases in few places. On Risc-V 20 lines
> emulate autoindexing (due to compiler structure and
> structure of Risc-V instruction set emulated
> autoindexing gives better code than handling this
> in machine independent part). Part of difference may
> be due to different authors and differnt code styles
> (VAX backed was probably created 45 years ago and
> last change seem to be 31 years ago, ARM64 and Risc-V
> are very recent). But the biggest difference comes
> from fact that VAX backend has very simple map from
> addresing modes to VAX assembler, while other targets
> need to emulate (some) VAX addressing modes.
>
> But that is historical artifact, VAX was one of early
> targets. More importantly, VAX was first 32-bit target
> which allowed system expansion, so it is natural
> that compiler structure was made to match VAX well.
> Without such history it is likely that compier would
> have different structure, making difference smaller.
> Also, whole compiler is some tens thousend lines,
> (the compiler if part of larger system and it is not so
> easy to tell what is compiler proper and what has other
> function). Comparing to the whole compiler difference
> in backend size is modest.
>
>> VAX reserved use of some registers:
>> R15 PC
>> R14 SP
>> R13 FP
>> R12 AP Argument Pointer
>> R3,R5 Address counter in character and decimal instructions
>> R2,R4 Length counter in character and decimal instructions
>> R1 High function result value (optional), result of varous instructions
>> R0 Low function result value, result of various instructions
>>
>> The CALLS, CALLG and RET instructions and routine entry mask required
>> R12..R15 to be used this way.
>>
>> There was no separate FPU register file. Double, quad and octal precision
>> FP values took 2, 4, or 8 sets of aligned register ids.
>>
>> There was no multi threading then, otherwise they'd have needed a
>> TP thread pointer register too.
>
> In normal use modern machines need stack pointer, either as
> hardware feature or as software convention, so I do not count
> it separately. Maybe I am wrong, but my impression was that
> FP and AP are usable as temporary registers between calls, so
> this use is similar to link register on machines that use it
> and to register(s) reserved on some machines for use by dynamic
> linking stubs. From software point of view they do not differ
> much from other registers which are not preserved by calls.
>
Yes, FP and AP can be spilled. FP if the call frame is simple,
no variable stack allocations and no exception handler.
AP if you have your own arg passing method.
But as usual the standard method of subroutine call had a lot of
unnecessary overhead. Use of the AP presumes args are in memory.
Manipulating FP automatically assumes a new call frame is needed
when in fact it is rarely needed. The routine entry mask mechanism
requires the register save mask to be copied onto the stack so
RET can later know what to restore. But that puts the restore
mask in the data path instead of in the instruction path where
one wants it (as in Load Multiple and Store Multiple instructions).
VAX also had BSB/JSB Branch/Jump Subroutine which only pushed the
PC on the stack, and RSB Return Subroutine just popped it.
Later compilers would use those with some args passed in registers.
However the standard method used CALLS/CALLG/RET.
Technical Details
Message-ID:
<GUfQS.39767$eQ94.16606@fx40.iad>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!news-out.netnews.com!netnews.com!s1-4.netnews.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx40.iad.POSTED!not-for-mailReferences:
<11cpqih$acf5$1@dont-email.me> <11cti0c$1lilf$4@dont-email.me> <11cuoa4$21279$1@dont-email.me> <jwvcxscsjsa.fsf-monnier+comp.arch@gnu.org> <1794357499-5857@newsgrouper.org> <jwvik23o10u.fsf-monnier+comp.arch@gnu.org> <2026Nov12.072121@mips.complang.tuwien.ac.at> <jwvy0axmx8f.fsf-monnier+comp.arch@gnu.org> <2026Nov13.192642@mips.complang.tuwien.ac.at> <11ekc0r$2dni3$1@paganini.bofh.team> <1796151298-5857@newsgrouper.org> <OyFPS.84961$cKd4.69588@fx38.iad> <11eo18a$2vsc7$1@paganini.bofh.team>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!news-out.netnews.com!netnews.com!s1-4.netnews.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx40.iad.POSTED!not-for-mail MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: CISC are not "unreduced" Content-Language: en-CA Newsgroups: comp.arch References: <11cpqih$acf5$1@dont-email.me> <11cti0c$1lilf$4@dont-email.me> <11cuoa4$21279$1@dont-email.me> <jwvcxscsjsa.fsf-monnier+comp.arch@gnu.org> <1794357499-5857@newsgrouper.org> <jwvik23o10u.fsf-monnier+comp.arch@gnu.org> <2026Nov12.072121@mips.complang.tuwien.ac.at> <jwvy0axmx8f.fsf-monnier+comp.arch@gnu.org> <2026Nov13.192642@mips.complang.tuwien.ac.at> <11ekc0r$2dni3$1@paganini.bofh.team> <1796151298-5857@newsgrouper.org> <OyFPS.84961$cKd4.69588@fx38.iad> <11eo18a$2vsc7$1@paganini.bofh.team> From: EricP <ThatWouldBeTelling@thevillage.com> In-Reply-To: <11eo18a$2vsc7$1@paganini.bofh.team> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Lines: 209 Message-ID: <GUfQS.39767$eQ94.16606@fx40.iad> X-Complaints-To: abuse@UsenetServer.com NNTP-Posting-Date: Thu, 03 Dec 2026 15:28:38 UTC Date: Thu, 3 Dec 2026 10:28:36 -0500 X-Received-Bytes: 11085