BinaryAnalysisPlatform / bap

Binary Analysis Platform
MIT License
2.07k stars 273 forks source link

makes BIL smart constructors smart #1499

Closed ivg closed 2 years ago

ivg commented 2 years ago

Up until now there was no smartness in the BIL smart constructors so that Bil.(x + y) was just BinOp(PLUS,x,y). This PR adds some intelligence to smart constructors and teaches them a few identities, e.g., Bil.(x - x) will evaluate to 0. In addition, all constants will be immediately evaluated. The optimization are as lightweight as possible (not to be confused with the BIL simplifications routines that will optimize code recursively).

The code was mostly moved from the BIL semantics implementation that was before that in the bil plugin with a small change to allow ill-formed BIL expressions. In case of the ill-formed expression we will just keep the expression untouched.