lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.56k stars 762 forks source link

Document correct expression of negative hexadecimal immediates in assembly guide. #12166

Open drewmacrae opened 2 years ago

drewmacrae commented 2 years ago

Expression of hexadecimal immediates in RiscV assembly is unclear. If we explain or demonstrate correct behavior here it will guide fixing issues like the one described here in the future.

drewmacrae commented 2 years ago

I'm having trouble finding documentation of how LLVM prefers negative integers be expressed for RiscV, I've searched the RiscV and the LLVM assembly guides and while the LLVM assembly guide has details on floats, and 3 assertions that "LLVM integers are two's complement" there's no indication we should expect the behavior that brought this up: that a sign extended negative integer was an incorrect or inappropriate representation of a negative integer.

drewmacrae commented 2 years ago

Sorry to be difficult on this (Thanks to everyone who asserted the correct answer without support to root cause the issue), I just like to see the spec decisively say the right thing when there's a conflict between tests and implementation.

@a-will pointed to this part of the documentation for GNU "as" which I find convincing. https://github.com/lowRISC/opentitan/issues/11968 I'm going to link to it in our documentation before going on to try to fix the compliance test.

msfschaffner commented 1 year ago

CC @GregAC @luismarques