Bug 1123 - add set[n]bc[r] to the simulator
Summary: add set[n]bc[r] to the simulator
Status: RESOLVED FIXED
Alias: None
Product: Libre-SOC's first SoC
Classification: Unclassified
Component: Source Code (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- enhancement
Assignee: Jacob Lifshay
URL:
Depends on:
Blocks: 1120
  Show dependency treegraph
 
Reported: 2023-07-25 04:04 BST by Jacob Lifshay
Modified: 2023-08-30 17:31 BST (History)
5 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 Jacob Lifshay 2023-07-25 04:04:53 BST
* DONE: set[n]bc[r]
Comment 1 Jacob Lifshay 2023-07-25 04:12:22 BST
Added support for the C-style conditional operator since that's in the PowerISA spec.
Added set[n]bc[r] but insndb fails to assemble it, and I can't figure out why, can you try to fix that ghostmansd? backtrace at end.
I had to add the instruction form to fields.text, surprisingly it isn't listed in PowerISA v3.1B's list of instruction forms.

https://git.libre-soc.org/?p=openpower-isa.git;a=shortlog;h=b99f9bde3f9c7ce2a3172d96a6536cde011effff

commit b99f9bde3f9c7ce2a3172d96a6536cde011effff
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 19:51:46 2023 -0700

    add set[n]bc[r] -- tests broken

commit 89db91417312abd0a19c28138daca9508310f514
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 19:50:12 2023 -0700

    add missing test_caller_cr.py

commit af3624a79b0506bfcb2ec96b33f651793eb93fa3
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 19:10:37 2023 -0700

    format code

commit 721ba871a81803d3927f4bffc84a60269801a04b
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 18:54:45 2023 -0700

    restore use of ? : operator in bfp_ROUND_TO_BFP32/64 pseudocode
    
    this changes it to match the PowerISA spec. better

commit a65b3700aa3b181b5881fa55d3946dbc26be3967
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 18:42:27 2023 -0700

    add support for C conditional operator
    
    its used by setbc's pseudocode and by the bfp_* functions

<snip>
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/test/cr/cr_cases.py", line 204, in case_setbc
    prog = Program(list(SVP64Asm([mnemonic + " 3, 10"])), bigendian)
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/asm.py", line 61, in __iter__
    yield from self.trans
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/asm.py", line 114, in translate
    yield from self.translate_one(insn)
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/asm.py", line 89, in translate_one
    insn = WordInstruction.assemble(record=record, arguments=fields)
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/core.py", line 1753, in assemble
    for operand in cls.static_operands(record=record):
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/core.py", line 1692, in operands
    yield from record.operands
  File "/home/jacob/.virtualenvs/libre-soc-venv-3.7/lib/python3.7/site-packages/cached_property.py", line 36, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/core.py", line 830, in operands
    return (self.static_operands + self.dynamic_operands)
  File "/home/jacob/.virtualenvs/libre-soc-venv-3.7/lib/python3.7/site-packages/cached_property.py", line 36, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/core.py", line 840, in static_operands
    span=self.section.bitsel,
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/core.py", line 1137, in __init__
    for idx in operand.span:
  File "/home/jacob/.virtualenvs/libre-soc-venv-3.7/lib/python3.7/site-packages/cached_property.py", line 36, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/jacob/projects/libreriscv/openpower-isa/src/openpower/insndb/core.py", line 1007, in span
    return self.record.fields[self.name]
KeyError: 'BI'
Comment 2 Jacob Lifshay 2023-07-25 04:38:20 BST
Found the problem:
I forgot to add X-form to the list of formats using the BI field

all tests pass now!

https://git.libre-soc.org/?p=openpower-isa.git;a=shortlog;h=86d23dced36bf6ceb830035f3f224a4e9b266f23

commit 86d23dced36bf6ceb830035f3f224a4e9b266f23
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 20:34:22 2023 -0700

    fix set[n]bc[r]

commit dd8ad147011a17a1020442da77e6899b7d4b23e1
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Jul 24 20:33:34 2023 -0700

    don't convert CR[BI] to CR.BI
Comment 3 Jacob Lifshay 2023-08-30 15:46:01 BST
2 things: 

1. this task is intended to cover implementation in openpower-isa only, binutils is supposed to be another new subtask of #1035. ghostmansd would get paid as part of that new binutils subtask, not this one.

2. this task is less work than #1120 so should be assigned like half as much as #1120