How to loop over instructions for backends in LLVM?

40 Views Asked by At

I'm trying to use the LLVM C++ API to loop over instructions for various backends that are supported. For example, say I'm trying to loop over some x86 instructions and generate a table similar to what you'd find on Felix Coutlier's site, i.e.: x86 ADD.

So I want to be able to loop over x86, x86-64, MIPS, ARM, AARCH64 and for each of their instructions figure out what operands it takes, and if those are registers, memory, etc.

I've tried a lot of things with the API, but there's a lot to understand. I'm not sure if I should be using the MachineCode Subtarget Interface, TableGen, or what. I'm not looking for someone to write this code, but just point me in the right direction like "Create a MAB as such":

MAB = target->createMCAsmBackend(*STI, *MRI, MCOptions);
if (!MAB) {
    std::cerr << "Failed to create the MachineCode Assembly Backend" << std::endl;
    return -1;
}
0

There are 0 best solutions below