Bug 1082

Summary: fix the pseudo-code parser's operator precedence to match PowerISA v3.1B
Product: Libre-SOC's first SoC Reporter: Jacob Lifshay <programmerjake>
Component: Source CodeAssignee: Luke Kenneth Casson Leighton <lkcl>
Status: CONFIRMED ---    
Severity: major CC: libre-soc-bugs, programmerjake
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Linux   
See Also: https://bugs.libre-soc.org/show_bug.cgi?id=1055
https://bugs.libre-soc.org/show_bug.cgi?id=980
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:
Bug Depends on:    
Bug Blocks: 1035    

Description Jacob Lifshay 2023-05-12 03:58:40 BST
PowerISA v3.1B specifies the precedence of operators in Book I section 1.3.4 page 8(34) Table 1. 
these don't match the parser's current state.

Table 1:
(edited slightly for clarity)

+-----------------------------------+---------------+
| Operators                         | Associativity |
+-----------------------------------+---------------+
| subscript, function evaluation    | left to right |
+-----------------------------------+---------------+
| pre-superscript (replication),    | right to left |
| post-superscript (exponentiation) |               |
+-----------------------------------+---------------+
| unary -, ¬                        | right to left |
+-----------------------------------+---------------+
| ×, ÷                              | left to right |
+-----------------------------------+---------------+
| +, -                              | left to right |
+-----------------------------------+---------------+
| ||                                | left to right |
+-----------------------------------+---------------+
| =, ≠, <, ≤, >, ≥, <u, >u, ?       | left to right |
| (note: `?` is unordered           |               |
| comparison, not a typo)           |               |
+-----------------------------------+---------------+
| &, ⊕, ≡                           | left to right |
+-----------------------------------+---------------+
| |                                 | left to right |
+-----------------------------------+---------------+
| : (range)                         | none          |
+-----------------------------------+---------------+
| <-, <-iea                         | none          |
+-----------------------------------+---------------+
Comment 1 Jacob Lifshay 2023-05-19 07:05:54 BST
Today I ran into a bug directly caused by this, this needs to be higher priority.

copying from bfp_ROUND_TO_BFP64 at PowerISA v3.1B page 603(629):
the spec says:
if ro=0 & rmode=0b00 then r <- bfp_ROUND_NEAR_EVEN(53, x)
the spec says that condition is parsed as:
(ro=0) & (rmode=0b00)
however our parser incorrectly parses it as:
(ro=(0 & rmode))=0b00
translating it to:
eq(eq(ro, 0 & rmode), SelectableInt(value=0x0, bits=2))