Skip to content

Conversation

AFOliveira
Copy link
Collaborator

UDB currently allows for 2 schemas for instructions with the on-going sub-type development. Some instructions now use a 'format' field with 'opcodes' instead of the traditional 'encoding' field with 'match' and 'variables'. This caused generators to fail when processing these instructions as they couldn't extract the bit pattern matching information.

Changes:

  • Added build_match_from_format() function to convert format.opcodes to match strings compatible with existing generator logic
  • Enhanced encoding detection in load_instruction() to handle both old schema (encoding.match) and new schema (format.opcodes)
  • Maintains full backward compatibility with existing instructions
  • No functional changes to generated output format

The fix ensures generators can process the complete UDB instruction set regardless of which schema format individual instructions use.

Copy link

codecov bot commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.05%. Comparing base (a83d966) to head (1c3288c).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1051   +/-   ##
=======================================
  Coverage   46.05%   46.05%           
=======================================
  Files          11       11           
  Lines        4942     4942           
  Branches     1345     1345           
=======================================
  Hits         2276     2276           
  Misses       2666     2666           
Flag Coverage Δ
idlc 46.05% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AFOliveira
Copy link
Collaborator Author

Fixes #893

@AFOliveira AFOliveira force-pushed the AFOliveira/generatorfix branch from 106d324 to aab7d0f Compare August 30, 2025 21:06
UDB generators were failing when processing instructions using the new
schema format. Some instructions now use a 'format' field with 'opcodes'
instead of the traditional 'encoding' field with 'match' patterns.

Changes:
- Added build_match_from_format() function to convert format.opcodes to
  match strings compatible with existing generator logic
- Added support for variable instruction widths (16-bit, 32-bit, 48-bit)
  based on maximum bit position in opcode fields
- Enhanced encoding detection to handle both old and new schema formats
- Maintains full backward compatibility with existing instructions

Tested with both Go and C header generators - no changes to output format.

Signed-off-by: Afonso Oliveira <[email protected]>
@AFOliveira AFOliveira force-pushed the AFOliveira/generatorfix branch from ce2adef to b5f9815 Compare September 4, 2025 16:06
if (
isinstance(field_data, dict)
and "location" in field_data
and isinstance(field_data["location"], str)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the schema (for "possibly_split_field_location" allows strings ("31-24", "31") or integers (31). I presume we need to handle the latter case here, too?

if (
isinstance(var_data, dict)
and "location" in var_data
and isinstance(var_data["location"], str)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here?

max_bit = max(valid_locations)

# Set instruction width based on maximum bit position
width = max(valid_locations) + 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you meant to use max_bit here? (Otherwise, it is never used.) So, either remove the assignment above, or:

Suggested change
width = max(valid_locations) + 1
width = max_bit + 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants