Partially expose the MCInst struct from the C Disassembler API to allow mechanized examination of opcodes and arguments.
Details
Diff Detail
Event Timeline
I would find this to be a useful addition the the API. Especially if it could be extended with a function like LLVMMCInstIsFlowControl
include/llvm-c/MCInst.h | ||
---|---|---|
54–62 | Can't this struct be kept opaque, like almost every other exposed type in the llvm-c api? Instead create accessor functions. Does the API get too clunky if you get rid of the LLVMMCOperandRef type entirely? And instead have functions like LLVMMCInstGetOperandKind, LLVMMCInstGetOperandRegVal and so on? | |
lib/MC/MCInst.cpp | ||
98–104 | This looks like copy-paste error of isReg here. | |
tools/llvm-c-test/disassemble.c | ||
46–49 | It would be nice if the tests requested an MCInst here and dumped some information from it to make the new code at least run on tests. If you could add some checks on the output even better. |
Can you give some background on motivation here? I can't see why we'd
like to do this right now.
-eric
@echristo: I'm currently working on a redesign of a framework for doing analysis of compiled code. Our new ARM support works by using LLVM's disassembly capabilities from within OCaml. OCaml cannot bind directly to C++, and must bind against C instead.
My lab is not the only group which does binary analysis, and the hope in adding bindings like this is to make it easier for people working in languages other than C++ to use LLVM to help them go from binary strings to an object they can use.
Is there anything further that I can do to try to get these features or something similar in? This patch has been sitting dead for a while, and it would be nice if my projects could depend on mainline LLVM instead of needing to direct everyone working with me to install a patched version.
Can't this struct be kept opaque, like almost every other exposed type in the llvm-c api? Instead create accessor functions.
Does the API get too clunky if you get rid of the LLVMMCOperandRef type entirely? And instead have functions like LLVMMCInstGetOperandKind, LLVMMCInstGetOperandRegVal and so on?