Skip to content

Differences of value types in immediate value instruction function signatures #1765

Answered by lmb
aibor asked this question in Q&A
Discussion options

You must be logged in to vote
func StoreImm(dst Register, offset int16, value int64, size Size) Instruction

This is probably a bug: #1767

Is there a reason why the later take int32 instead of int64?

The BPF ISA only allows 32 bit immediates / constants, except for the special case of a 64bit LoadImm into a register, which is turned into two BPF instructions. For ease of use we chose to represent Constant as 64bit so that this detail of the ISA doesn't leak into our abstraction.

The reason Imm is confusing is that it needs to be understood together with Imm32. From the top of my head, haven't validated this:

Imm: if (dst == (int64)i32_const) { ... }
Imm32: if ((int32)((uint32)dst) == i32_const) { ... }

The reason …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aibor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants