-
Notifications
You must be signed in to change notification settings - Fork 72
fix: add backward compatibility for new instruction schema format #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #893 |
106d324
to
aab7d0f
Compare
aab7d0f
to
ce2adef
Compare
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]>
ce2adef
to
b5f9815
Compare
if ( | ||
isinstance(field_data, dict) | ||
and "location" in field_data | ||
and isinstance(field_data["location"], str) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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:
width = max(valid_locations) + 1 | |
width = max_bit + 1 |
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:
The fix ensures generators can process the complete UDB instruction set regardless of which schema format individual instructions use.