rizinorg / rz-rzilcompiler

C to RZIL Compiler to extend the Rizin Hexagon plugin.
4 stars 2 forks source link

Add option to inline Pures/operations #10

Closed Rot127 closed 8 months ago

Rot127 commented 2 years ago

Currently all ops are added to the ILOpHolder. Every instruction which is added there will be printed as a single statement in the resulting C code.

E.g.:

RzIlOpPure *op_ADD_0 = ADD(Rs, VARL("s"));

Especially for very short expressions this is not necessary. ADD(Rs, VARL("s") could also just be inlined.

# Like this
RzIlOpEffect *op_ASSIGN_1 = SETL("EA", ADD(Rs, VARL("s"));
# Instead of
RzIlOpEffect *op_ASSIGN_1 = SETL("EA", op_ADD_0);

To enable this we should add a flag to ILOpHolder.add_pure() to either add the pure to the "print as statement list" or don't do it. Question is: When do we inline an op?