riscv-opcodes icon indicating copy to clipboard operation
riscv-opcodes copied to clipboard

Use ULL (unsigned long long) suffixes in generated encoding.h file

Open JanMatCodasip opened this issue 2 years ago • 2 comments

Improvement suggestion (merely a note to self):

The integer literals in the generated encoding.out.h C header file should contain ULL suffixes (unsigned long long) when the actual value exceeds 64 bits.

This improvement has been requested in OpenOCD project which utilizes this generated .h file: https://review.openocd.org/c/openocd/+/7600

JanMatCodasip avatar Apr 13 '23 07:04 JanMatCodasip

This is a reasonable request, but whoever handles it needs to do it in such a way that the constants can still be used in assembly code, where the ULL suffix will cause a parse error. See e.g. how the Linux kernel does this: https://github.com/torvalds/linux/blob/de4664485abbc0529b1eec44d0061bbfe58a28fb/include/uapi/linux/const.h#L7

aswaterman avatar Apr 13 '23 21:04 aswaterman

... whoever handles it needs to do it in such a way that the constants can still be used in assembly code, where the ULL suffix will cause a parse error ...

@aswaterman, thank you for pointing this out and for the link. I will keep that in mind when making the change.

JanMatCodasip avatar Apr 14 '23 05:04 JanMatCodasip