retdec
retdec copied to clipboard
Detect idiom: packing bytes into (u)int16_t
NumericT<16> int16FromBytes(NumericT<8> byte0, NumericT<8> byte1){
return (byte1 << 8) | byte0;
}
Few questions regarding this:
- Is this some kind of compiler idiom?
- Do you have some input on where it occurs?
- What do we produce at the moment? (My guess, byte operations?)
- What do you suggest we should produce? (Do I guess right that you propose a function call?)
Is this some kind of compiler idiom?
IDK. May be generated (for unaligned access) and may be not. But it is surely widely used when coded manually.
Do you have some input on where it occurs?
It is a basic block for higher-level idioms. It is they that occur.
What do we produce at the moment?
Sometimes bit operations, sometimes integer arithmetics with the same effect.
What do you suggest we should produce? (Do I guess right that you propose a function call?)
Yeah. Add an (possibly inline) function and use it every time the idiom occurs.