I've noted that r.40170 defines MAX_OPTS_2 for AVR in aoptutils.pas. Should the constant max_operands in avr/cpubase.pas not also be changed to 2 to be internally consistent? If so then I can adapt avr/raavr.pas to be consistent with a maximum number of operands of 2.
I simply checked the value of maxops constant for the different CPUs:
$ grep -iw maxops */*pas
aarch64/aoptcpub.pas: MaxOps = 4;
arm/aoptcpub.pas: MaxOps = 4;
avr/aoptcpub.pas: MaxOps = 2;
i386/aoptcpub.pas: MaxOps = 3;
i8086/aoptcpub.pas: MaxOps = 3;
jvm/aoptcpub.pas: MaxOps = 2;
m68k/aoptcpub.pas: MaxOps = 3;
mips/aoptcpub.pas: MaxOps = 3;
powerpc/aoptcpub.pas: MaxOps = 5;
powerpc64/aoptcpub.pas: MaxOps = 5;
riscv32/aoptcpub.pas: MaxOps = 5;
riscv64/aoptcpub.pas: MaxOps = 5;
sparcgen/aoptcpub.pas: MaxOps = 3;
x86_64/aoptcpub.pas: MaxOps = 3;
As I found only avr and jvm having a value of 2,
I defined the macro MAX_OPTS_2 (which by the way should rather be renamed MAX_OPS_2...)
max_operands seems to be ddeclared in cpubase units:
$ grep -i "max_operands *=" */*pas
aarch64/cpubase.pas: max_operands = 6;
arm/cpubase.pas: max_operands = 6;
avr/cpubase.pas: max_operands = 4;
jvm/cpubase.pas: max_operands = 2;
llvm/llvmbase.pas: max_operands = ((-ord(cpubase.max_operands<=7)) and 7) or ((-ord(cpubase.max_operands>7)) and cpubase.max_operands);
m68k/cpubase.pas: max_operands = 4;
mips/cpubase.pas: max_operands = 4;
powerpc/cpubase.pas: max_operands = 5;
powerpc64/cpubase.pas: max_operands = 5;
riscv32/cpubase.pas: max_operands = 5;
riscv64/cpubase.pas: max_operands = 5;
sparcgen/cpubase.pas: max_operands = 3;
x86/cpubase.pas: max_operands = 4;
But you can see that the numbers are quite different...
i386 4/3 (the 4 is common to i386,x86_64 and i8086 from x86/cpubase unit)
i8086 4/3, as for i386
jvm 2/2, OK!!
powerpc 5/5, OK!!
powerpc64 5/5, OK!!
riscv32 5/5, OK!!
riscv64 5/5, OK!!
sparcgen 3/3, OK!!
x86_64 4/3, as for i386
Hopefully someone else can explain that discrepancy,
I have no idea why this exists,
it might be simply related to the CPU instructions
with most parameters that are considered for optimization!
fpc-devel maillist - firstname.lastname@example.org