I've not come across pyvex before, and I can't seem to find any examples of translating VEX to LLIR (either with llvmlite or using another implementation) - I suspect that there's no quick way to do what you want, and you'd have to produce a translator that takes VEX (or the subset that is interesting to you) and uses llvmlite to build the IR all yourself. The llvmlite IR layer is what you'd want to use:
https://llvmlite.readthedocs.io/en/latest/ir/index.html - there is a minimal example to get started with this at:
https://llvmlite.readthedocs.io/en/latest/ir/examples.htmlIf you want to execute code you build with the IR layer, you can use the binding layer:
https://llvmlite.readthedocs.io/en/latest/binding/index.htmlAs llvmlite's primary driver for development has been Numba, you might also find that it doesn't implement everything that you'd need to easily translate VEX to LLIR. If this is the case, you might have to extend llvmlite, either by adding more to the IR layer to replicate things you can do to build IR with LLVM, or to add more bindings to LLVM functions in the binding layer. There's a distinction between these two layers because the IR layer is a Python reimplementation of the LLVM IR building functions, which then generates a textual representation of the IR - this is usually then fed to the binding layer, which actually makes use of the LLVM library that it is linked to.
Best regards,
Graham.
On Tuesday, 13 June 2017 18:12:50 UTC+1, Samaneh Berenjian wrote:
Thank you for the reply. Actually, I am using pyvex and it provides VEXIr. Using llvmlite, I want to use the same functions and statements of pyvex in form of llvmlite and produce LLVMIR. However, the output should be executable (I should be able to compile the LLVM IR and do optimization on it 9for example using by lli output.ll). My other question is that, how can i for example write the following statements in llvmlite and then I will have a generated llvm IR?
for stmt in irsb.statements:
if isinstance(stmt, pyvex.IRStmt.IMark):
print "------ IMark(0x%x, %d, %d) ------" % (stmt.addr, stmt.len, stmt.delta)
?
Look forward to here from you soon