Bug 946 - insndb: investigate and possibly fix instructions missing in CSVs
Summary: insndb: investigate and possibly fix instructions missing in CSVs
Status: IN_PROGRESS
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- enhancement
Assignee: Luke Kenneth Casson Leighton
URL:
Depends on:
Blocks:
 
Reported: 2022-10-07 15:23 BST by Dmitry Selyutin
Modified: 2023-03-30 08:59 BST (History)
2 users (show)

See Also:
NLnet milestone: ---
total budget (EUR) for completion of task and all subtasks: 0
budget (EUR) for this task, excluding subtasks' budget: 0
parent task for budget allocation:
child tasks for budget allocation:
The table of payments (in EUR) for this task; TOML format:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Selyutin 2022-10-07 15:23:51 BST
Currently there are some instructions which are present in markdown but not present in CSVs. These must be added to CSVs or at least be explicitly listed as those which we should ignore.

DONE

    addex
    rfscv
    scv
    stq
    lq

misnamed (fixed, DONE)

    lfiwix should have been lfiwzx

obsolete / deprecated.  ignore.

    lmw
    lswi
    lswx
    stmw
    stswi
    stswx

ignore for now will sort out later.

ffadd
ffadd.
ffdiv
ffdiv.
ffdivs
ffdivs.
ffmul
ffmul.
ffmuls
ffmuls.
ffsub
ffsub.
ffsubs
ffsubs.
Comment 1 Dmitry Selyutin 2022-10-07 15:31:03 BST
I think these load/store variants simply need some special matching algorithm, but I'm not sure what's the stuff to rely on.
Comment 2 Luke Kenneth Casson Leighton 2022-10-08 01:35:34 BST
https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=openpower/isa/fixedarith.mdwn;hb=HEAD

addex should have been added.

the load/store ones aside from lq and stq not so much.

https://git.libre-soc.org/?p=openpower-isa.git;a=blob;f=openpower/isa/svfparith.mdwn;hb=HEAD

the FFT/DCT ones i focussed on what was needed as proof of
concept, the others will need attention as part of an RFC
some time in the next 3-8 months.
Comment 3 Luke Kenneth Casson Leighton 2022-10-08 03:00:06 BST
  21 1111100000,FPU,OP_FPOP,FRA,FRB,NONE,FRT,NONE,CR1,0,0,      ffadds

minor_59.csv

these and the ffmadds got FFT/DCT up and running.

they all need way more work.
Comment 4 Dmitry Selyutin 2022-10-08 05:21:39 BST
1. I mean adding to CSVs, not markdown. The whole point is that some instructions are present in markdown only.
2. ffadds does not automatically add ffadd, these are different names.
3. As for load/store, I'll add everything but ldq/stq into an explicit exception list.
Comment 5 Luke Kenneth Casson Leighton 2022-10-08 10:12:27 BST
(In reply to Dmitry Selyutin from comment #4)
> 1. I mean adding to CSVs, not markdown. The whole point is that some
> instructions are present in markdown only.

yes i know.

> 2. ffadds does not automatically add ffadd, these are different names.

yes. not in the demo (i used single not any double ops at all)
so i didn't add them.

> 3. As for load/store, I'll add everything but ldq/stq into an explicit
> exception list.

lmw should not have been added, they are retired instructions.

FP LD/ST they should be added: lfiwix isn't in v3.0B though...
ah! it's misnamed.  should be lfiwzx. sorted that.

i'll see what i can add today, they need unit tests to confirm.
Comment 6 Luke Kenneth Casson Leighton 2022-10-08 10:31:24 BST
https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=2abff724a5f58885576301e55e38c0e48d3850db

added addex, with "suck-it-and-see" test_pysvp64dis.py test,
throws this:

    yield from insn.disassemble(db=db, verbosity=verbosity)
  File "/home/lkcl/src/libresoc/openpower-isa/src/openpower/decoder/power_insn.py", line 1184, in disassemble
    self.dynamic_operands(db=db, verbosity=verbosity)))
  File "/home/lkcl/src/libresoc/openpower-isa/src/openpower/decoder/power_insn.py", line 1128, in dynamic_operands
    value = " ".join(dis)
  File "/home/lkcl/src/libresoc/openpower-isa/src/openpower/decoder/power_insn.py", line 546, in disassemble
    value = insn[span]
  File "/home/lkcl/src/libresoc/openpower-isa/src/openpower/decoder/power_insn.py", line 1083, in __getitem__
    return self.storage.__getitem__(key)
  File "/home/lkcl/src/libresoc/openpower-isa/src/openpower/decoder/selectable_int.py", line 390, in __getitem__
    for bit in key:
TypeError: 'NoneType' object is not iterable
Comment 7 Luke Kenneth Casson Leighton 2022-10-08 10:36:09 BST
(In reply to Luke Kenneth Casson Leighton from comment #6)

> added addex, with "suck-it-and-see" test_pysvp64dis.py test,
> throws this:

> TypeError: 'NoneType' object is not iterable

operand "CY" is missing - on it.
Comment 8 Luke Kenneth Casson Leighton 2022-10-08 11:10:43 BST
(In reply to Luke Kenneth Casson Leighton from comment #7)

> operand "CY" is missing - on it.

sorted - it was actually entirely missing from section 1.6 (fields.txt)
actually in the Power ISA v3.0B and v3.1 specification.
Comment 9 Luke Kenneth Casson Leighton 2022-10-08 13:17:38 BST
lq added, also sorted ld which was broken on ld RT, NONZERO_VALUE_OF_D(RA)

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=552ef2daede6f598afe50c7d698a3808d7f1efaa

still todo, add stq.
Comment 11 Luke Kenneth Casson Leighton 2022-10-08 13:39:15 BST
(In reply to Dmitry Selyutin from comment #0)

> lmw
> stmw

load-multiple. retired/obsolete

> lswi
> lswx
> stswi
> stswx

strings. retired/obsolete
Comment 12 Luke Kenneth Casson Leighton 2022-10-08 14:32:32 BST
rats, messed up and corrected

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=d4daf3685be056a6b45ce5365e0a8c076d009a04
https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=5db40783a86f3df57bfd409742c1de63718c2e03

sc and scv have been moved to extra.csv and consequently
have to be prioritised as a first-order search in Database.__getitem__()

        # specific hunt for all "extra.csv" matches. TODO: separate db of extras
        if isinstance(key, Instruction):
            ki = int(key)
            for k, records in self.__opcodes.items():
                for record in records:
                    if str(record.section.path).endswith("extra.csv"):
                        if record.match(key=ki):
                           return record


blegh!

it works...
Comment 13 Luke Kenneth Casson Leighton 2022-10-08 14:38:15 BST
rfscv added, unit test in test_pysvp64dis.py

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=ba99459eb3febc23a9b0e743c9e1dece2979f735
Comment 14 Jacob Lifshay 2023-03-30 08:59:00 BST
finished adding addex to the simulator as part of fixing bug #972