You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[General]: Operator precedence is unspecified, so BSR and IDIV expressions have two readings #109
Neither the manual nor reading-specs.md gives a precedence or associativity for
the operators. The specification contains expressions whose value depends on them:
BSR.xml line 140: let highest_bit := operand_size - 1 - Count_Leading_Zero_Bits(src);
With operand_size = 32 and src = 1, Count_Leading_Zero_Bits(src) is 31. Grouping
to the left gives (32 - 1) - 31 = 0, the index of the highest set bit. Grouping to the
right gives 32 - (1 - 31) = 62.
With operand_size = 32: if ** binds tighter than -, this is 2**31 - 1 = 2147483647, the largest 32-bit signed value; if - binds tighter, it is 2 ** 30 = 1073741824.
Proposed fix
State the expression grammar in levels, saying which operators may be combined without
parentheses and how each level groups. For reference, the isa-tools parser
(isa_parser.mly) uses these rules:
and, or, xor, and then and or else cannot be mixed without parentheses;
comparisons do not associate;
+ and - group to the left, and ++ cannot be mixed with them;
*, / and % cannot be mixed with each other;
the operands of **, and the right operand of << and >>, are primary expressions.
AI disclosure
Assisted-by: Claude
Claude assisted with source analysis, the proposed correction and drafting this report.
Reviewed with assistance from Codex.
Activity