I’m currently writing an interactive IR to IR translator. I need a way to let the user select a type in a module. I think the best way to do this is to parse a LLVM IR type expression in text format. I searched online and found llvm::parseType
in <llvm/AsmParser/Parser.h>
. However, llvm::parseType
seems failed to get the existing type pointers and always create new types for me. For example, supposing there’s a %A = type opaque
in the module M
, llvm::outs() << *llvm::parseType("%A", Err, M)
will print %A.0
.
The easiest way I can think to walk around this is get the type indirectly by the name of global variables or functions, but this will be too limited. I can write my own parser, but it will be nice if LLVM has already implemented this.