[clang] [llvm] [Clang][BPF] Allow sign/zero extension for call parameters with int/uint types (PR #84874)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 17:18:32 PDT 2024


eddyz87 wrote:

Hi @efriedma-quic,

> That said, this isn't handling "unsigned int" correctly. "unsigned int" is supposed to be sign-extended on RISC-V targets. (How you resolve the conflict with PowerPC, where "unsigned int" is supposed to be zero-extended, I'm not sure.)

Could you please elaborate a bit?
My understanding is that you refer to the following part of the [specification](https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf):

> In RV64, 32-bit types, such as int, are stored in integer registers as proper sign extensions of their
> 32-bit values; that is, bits 63..31 are all equal. This restriction holds even for unsigned 32-bit types.

I assume that sign extension operations for RV64 take care of this detail.
The way I understand this pull request -- clang would now guarantee sign or zero extension for all integral function parameters. Given that extension would be done according to the platform rules, why do you think this could be an issue?

https://github.com/llvm/llvm-project/pull/84874


More information about the cfe-commits mailing list