Skip to content
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

registers.py: Fix subtractions in generated C code #1099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JanMatCodasip
Copy link
Contributor

The registers.py generator outputs expressions with subtractions into the C code of debug_defines.{h,c} in this form:

((XLEN) + -6ULL)

Such code may look awkward to code readers and also triggers GCC's -Wconversion warnings in the projects that will include these generated C files.

Fix the generator to produce expressions with subtraction in a natural form:

((XLEN) - 6ULL)

The registers.py generator outputs expressions with subtractions
into the C code of debug_defines.{h,c} in this form:

```
((XLEN) + -6ULL)
```

Such code may look awkward to code readers and also triggers GCC's
-Wconversion warnings (when enabled).

Fix the generator to produce the expressions with subtraction
in a natural form:

```
((XLEN) - 6ULL)
```
@JanMatCodasip JanMatCodasip force-pushed the debug-defines-simplify-subtractions branch from 6b8b91d to 065f527 Compare January 8, 2025 20:05
@JanMatCodasip
Copy link
Contributor Author

For an easier review, attached are the generated files before and after this change:

generated_debug_defines.zip

@JanMatCodasip
Copy link
Contributor Author

@en-sc Would you please have a moment for this review? Thank you.

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.

1 participant